提交 8b63d3d9 编写于 作者: N niebenkui

短时任务测试用例何如

Signed-off-by: Nniebenkui <niebenkui5@huawei.com>
Change-Id: Ia4dbe3e98e40ef6dc3447722bb295993d8f2719c
上级 854b3de2
...@@ -18,7 +18,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' ...@@ -18,7 +18,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
describe("TransientTaskJsTest", function () { describe("TransientTaskJsTest", function () {
beforeAll(function() { beforeAll(function() {
/* /*
* @tc.setup: setup invoked before all testcases * @tc.setup: setup invoked before all testcases
*/ */
...@@ -26,7 +25,6 @@ describe("TransientTaskJsTest", function () { ...@@ -26,7 +25,6 @@ describe("TransientTaskJsTest", function () {
}) })
afterAll(function() { afterAll(function() {
/* /*
* @tc.teardown: teardown invoked after all testcases * @tc.teardown: teardown invoked after all testcases
*/ */
...@@ -34,7 +32,6 @@ describe("TransientTaskJsTest", function () { ...@@ -34,7 +32,6 @@ describe("TransientTaskJsTest", function () {
}) })
beforeEach(function() { beforeEach(function() {
/* /*
* @tc.setup: setup invoked before each testcases * @tc.setup: setup invoked before each testcases
*/ */
...@@ -42,7 +39,6 @@ describe("TransientTaskJsTest", function () { ...@@ -42,7 +39,6 @@ describe("TransientTaskJsTest", function () {
}) })
afterEach(function() { afterEach(function() {
/* /*
* @tc.teardown: teardown invoked after each testcases * @tc.teardown: teardown invoked after each testcases
*/ */
...@@ -50,13 +46,135 @@ describe("TransientTaskJsTest", function () { ...@@ -50,13 +46,135 @@ describe("TransientTaskJsTest", function () {
}) })
/* /*
* @tc.name:TransientTaskJsTest001 * @tc.name: TransientTaskJsTest001
* @tc.desc:verify app info is not null * @tc.desc: test request a suspend delay
* @tc.type: FUNC
* @tc.require: AR000GH86K AR000GH86N AR000GH86L
*/
it("TransientTaskJsTest001", 0, async function (done) {
console.info('----------------------TransientTaskJsTest001---------------------------');
function callback() {}
var info = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info.requestId != -1) {
console.info('TransientTaskJsTest001 backgroundTaskManager success, requestId:' + info.requestId);
expect(true).assertTrue();
backgroundTaskManager.cancelSuspendDelay(info.requestId)
} else {
expect(false).assertTrue();
}
done();
})
/*
* @tc.name: TransientTaskJsTest002
* @tc.desc: test transient task more than three
* @tc.type: FUNC
* @tc.require: AR000GH86K AR000GH86L AR000GH86N
*/
it("TransientTaskJsTest002", 0, async function (done) {
console.info('----------------------TransientTaskJsTest002---------------------------');
function callback() {}
var info1 = backgroundTaskManager.requestSuspendDelay("test", callback);
var info2 = backgroundTaskManager.requestSuspendDelay("test", callback);
var info3 = backgroundTaskManager.requestSuspendDelay("test", callback);
var info4 = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info4.requestId == -1) {
console.info('TransientTaskJsTest002 backgroundTaskManager more than three');
expect(true).assertTrue();
backgroundTaskManager.cancelSuspendDelay(info1.requestId);
backgroundTaskManager.cancelSuspendDelay(info2.requestId);
backgroundTaskManager.cancelSuspendDelay(info3.requestId);
} else {
expect(false).assertTrue();
}
done();
})
/*
* @tc.name: TransientTaskJsTest003
* @tc.desc: test getRemainingDelayTime Promise
* @tc.type: FUNC
* @tc.require: AR000GH86M AR000GH860 AR000GH86L
*/
it("TransientTaskJsTest003", 0, async function (done) {
function callback() {}
var info = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info.requestId != -1) {
console.info('TransientTaskJsTest003 backgroundTaskManager success, requestId:' + info.requestId);
expect(true).assertTrue();
} else {
expect(false).assertTrue();
done();
}
backgroundTaskManager.getRemainingDelayTime(info.requestId)
.then(data => {
console.info('TransientTaskJsTest003 backgroundTaskManager success, delaytime:' + data);
expect(true).assertTrue();
backgroundTaskManager.cancelSuspendDelay(info.requestId);
})
.catch(error => {
console.info('TransientTaskJsTest003 backgroundTaskManager error');
expect(false).assertTrue();
});
setTimeout(()=>{
done();
}, 500);
})
/*
* @tc.name: TransientTaskJsTest004
* @tc.desc: test getRemainingDelayTime Callback
* @tc.type: FUNC
* @tc.require: AR000GH86M AR000GH860 AR000GH86L
*/
it("TransientTaskJsTest004", 0, async function (done) {
function callback() {}
var info = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info.requestId != -1) {
console.info('TransientTaskJsTest004 backgroundTaskManager success, requestId:' + info.requestId);
expect(true).assertTrue();
} else {
expect(false).assertTrue();
done();
}
backgroundTaskManager.getRemainingDelayTime(info.requestId, (err, res) => {
if (err.data === 0) {
console.info('TransientTaskJsTest004 backgroundTaskManager success, delaytime:' + res);
expect(true).assertTrue();
} else {
console.info('TransientTaskJsTest004 backgroundTaskManager error');
expect(false).assertTrue();
}
backgroundTaskManager.cancelSuspendDelay(info.requestId)
});
setTimeout(()=>{
done();
}, 500);
})
/*
* @tc.name: TransientTaskJsTest005
* @tc.desc: test request a suspend delay
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: Issue Number * @tc.require: AR000GH86K AR000GH86N AR000GH86L
*/ */
it("TransientTaskJsTest001", 0, function () { it("TransientTaskJsTest005", 0, async function (done) {
console.info('----------------------TransientTaskJsTest005---------------------------');
function callback() {}
var info = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info.actualDealyTime != -1) {
console.info('TransientTaskJsTest001 backgroundTaskManager success, actualDealyTime:' +
info.actualDealyTime);
expect(true).assertTrue(); expect(true).assertTrue();
backgroundTaskManager.cancelSuspendDelay(info.requestId)
} else {
expect(false).assertTrue();
}
done();
}) })
}) })
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册