From 51df5338842947b731edbf6821d1d5aa9fb3905c Mon Sep 17 00:00:00 2001 From: qigongming Date: Wed, 21 Sep 2022 16:40:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=B6=E8=BF=9F=E4=BB=BB=E5=8A=A1=E8=B0=83?= =?UTF-8?q?=E5=BA=A6=E5=9B=9E=E8=B0=83=E6=8E=A5=E5=8F=A3API=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: qigongming Change-Id: I6f48435a1c3b238787129f339df6ead0db56f1a0 --- .../src/main/js/test/WorkScheduler.test.js | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/resourceschedule/resourceschedule_standard/workscheduler/src/main/js/test/WorkScheduler.test.js b/resourceschedule/resourceschedule_standard/workscheduler/src/main/js/test/WorkScheduler.test.js index 483408782..8b1198ade 100644 --- a/resourceschedule/resourceschedule_standard/workscheduler/src/main/js/test/WorkScheduler.test.js +++ b/resourceschedule/resourceschedule_standard/workscheduler/src/main/js/test/WorkScheduler.test.js @@ -13,13 +13,44 @@ * limitations under the License. */ import workScheduler from '@ohos.workScheduler' +import WorkSchedulerExtensionAbility from '@ohos.WorkSchedulerExtensionAbility' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' export default function WorkSchedulerJsTest() { describe("WorkSchedulerJsTest", function () { + let workInfo = { + workId: 0, + bundleName: "ohos.acts.resourceschedule.workscheduler.js.function", + abilityName: "com.mytest.abilityName" + } + + function workStart(workInfo, callback) { + let result = null + try{ + WorkSchedulerExtensionAbility.onWorkStart(workInfo) + result = true + } catch(err) { + result = err + } + callback(result) + } + + function workStop(workInfo, callback) { + let result = null + try{ + WorkSchedulerExtensionAbility.onWorkStop(workInfo) + result = true + } catch(err) { + result = err + } + callback(result) + } beforeAll(function() { - + + workStart(workInfo,function(data) { + console.info("onWorkStart finish,result: " + data) + }) /* * @tc.setup: setup invoked before all testcases */ @@ -28,6 +59,9 @@ describe("WorkSchedulerJsTest", function () { afterAll(function() { + workStop(workInfo, function(data) { + console.info("onWorkStop finish,result: " + data) + }) /* * @tc.teardown: teardown invoked after all testcases */ -- GitLab