From 8b63d3d99bd704318ac110c6a46b6359bb8f9b24 Mon Sep 17 00:00:00 2001 From: niebenkui Date: Sat, 12 Feb 2022 16:12:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9F=AD=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B=E4=BD=95=E5=A6=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: niebenkui Change-Id: Ia4dbe3e98e40ef6dc3447722bb295993d8f2719c --- .../default/test/BackgroundTaskMagrJs.test.js | 134 ++++++++++++++++-- .../src/main/js/default/test/List.test.js | 0 2 files changed, 126 insertions(+), 8 deletions(-) mode change 100644 => 100755 resourceschedule/resourceschedule_standard/backgroundtaskmanager/src/main/js/default/test/BackgroundTaskMagrJs.test.js mode change 100644 => 100755 resourceschedule/resourceschedule_standard/backgroundtaskmanager/src/main/js/default/test/List.test.js 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 a77c187f2..e7389dd8d --- 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 -- GitLab