diff --git a/resourceschedule/resourceschedule_standard/backgroundtaskmanager/src/main/js/default/test/BackgroundTaskMagrJs.test.js b/resourceschedule/resourceschedule_standard/backgroundtaskmanager/src/main/js/default/test/BackgroundTaskMagrJs.test.js old mode 100644 new mode 100755 index a77c187f25b9f7c3fbbfa4a190899a4e452b00a2..e7389dd8d4e1683a08e982b65de534fa7ab9e844 --- a/resourceschedule/resourceschedule_standard/backgroundtaskmanager/src/main/js/default/test/BackgroundTaskMagrJs.test.js +++ b/resourceschedule/resourceschedule_standard/backgroundtaskmanager/src/main/js/default/test/BackgroundTaskMagrJs.test.js @@ -18,7 +18,6 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from ' describe("TransientTaskJsTest", function () { beforeAll(function() { - /* * @tc.setup: setup invoked before all testcases */ @@ -26,7 +25,6 @@ describe("TransientTaskJsTest", function () { }) afterAll(function() { - /* * @tc.teardown: teardown invoked after all testcases */ @@ -34,7 +32,6 @@ describe("TransientTaskJsTest", function () { }) beforeEach(function() { - /* * @tc.setup: setup invoked before each testcases */ @@ -42,7 +39,6 @@ describe("TransientTaskJsTest", function () { }) afterEach(function() { - /* * @tc.teardown: teardown invoked after each testcases */ @@ -50,13 +46,135 @@ describe("TransientTaskJsTest", function () { }) /* - * @tc.name:TransientTaskJsTest001 - * @tc.desc:verify app info is not null + * @tc.name: TransientTaskJsTest001 + * @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.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(); + backgroundTaskManager.cancelSuspendDelay(info.requestId) + } else { + expect(false).assertTrue(); + } + done(); }) }) diff --git a/resourceschedule/resourceschedule_standard/backgroundtaskmanager/src/main/js/default/test/List.test.js b/resourceschedule/resourceschedule_standard/backgroundtaskmanager/src/main/js/default/test/List.test.js old mode 100644 new mode 100755