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 483408782165df81489fb57d215f2df01e8dfd76..8b1198adefd0baaff90306d7c64b5007c5b785d2 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 */