diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/Test.json b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/Test.json index 1bcba1ee8929e00767324b2928b81fc6fa00f89f..c2317968519b6101afe93b9b4bd6ef92abe80f76 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/Test.json +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "180000", - "package": "com.example.lifecycletest", - "shell-timeout": "600000" + "bundle-name": "com.example.lifecycletest", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 }, "kits": [ { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/MainAbility.ts index 3bb8dbb83028eb925400a4885612266092c0c89e..047c5575a74fdca6b2a5e9a019ace65b8638a607 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -28,7 +28,7 @@ export default class MainAbility extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility onWindowStageCreate") globalThis.abilityContext = this.context; - windowStage.setUIContent(this.context, "pages/MainAbility_pages", null) + windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility_pages", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility1_pages.ets b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility1_pages.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility1_pages.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility1_pages.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility2_pages.ets b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility2_pages.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility2_pages.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility2_pages.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility3_pages.ets b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility3_pages.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility3_pages.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility3_pages.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility4_pages.ets b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility4_pages.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility4_pages.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility4_pages.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility5_pages.ets b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility5_pages.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility5_pages.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility5_pages.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility6_pages.ets b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility6_pages.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility6_pages.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility6_pages.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility7_pages.ets b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility7_pages.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility7_pages.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility7_pages.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility_pages.ets b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets similarity index 55% rename from ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility_pages.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets index 8f859c1002634a98b1cf405373a9388ddd2f30ff..b2da5c11fb27b5480310670e0077ee3c9375e067 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/pages/MainAbility_pages.ets +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility/pages/MainAbility_pages.ets @@ -13,9 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import file from '@system.file'; -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" -import list from '../test/ListTest' +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../test/List.test' @Entry @Component @@ -24,23 +25,12 @@ struct Index { aboutToAppear() { console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - globalThis.abilityWant.parameters.timeout = 20000; - - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - configService.setConfig(globalThis.abilityWant.parameters) - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - list(globalThis.abilityContext) - core.execute() + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } build() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility1/MainAbility1.ts b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility1/MainAbility1.ts index 9faab23c7b637934eb8d7f9c01a7d6d8b6b19c91..5c87a1b50bb61daf07f5740345b4677975db3fd8 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility1/MainAbility1.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility1/MainAbility1.ts @@ -101,7 +101,7 @@ export default class MainAbility1 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility1 onWindowStageCreate") globalThis.ability2Context = this.context; - windowStage.setUIContent(this.context, "pages/MainAbility1_pages", null) + windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility1_pages", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility2/MainAbility2.ts index f0dff13d6dbdf52fb083095df3c089a2fd634121..5f018c44268889f55c9b6e01f9ff2deacf1806d3 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility2/MainAbility2.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -87,7 +87,7 @@ export default class MainAbility2 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility2 onWindowStageCreate") globalThis.ability3Context = this.context; - windowStage.setUIContent(this.context, "pages/MainAbility2_pages", null) + windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility2_pages", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility3/MainAbility3.ts b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility3/MainAbility3.ts index dbb3f64a38f2c51dd17629e57e667055d0ba0a1f..518d6118ff07ff28ea00e93f297cd359c0478e93 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility3/MainAbility3.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility3/MainAbility3.ts @@ -115,7 +115,7 @@ export default class MainAbility3 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility3 onWindowStageCreate") - windowStage.setUIContent(this.context, "pages/MainAbility3_pages", null) + windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility3_pages", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility4/MainAbility4.ts b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility4/MainAbility4.ts index cff72bfe2be686c8aa92a326af4e8cc89188f1f2..29ef4b7916fec0722d356876bb4c5ee0cdfb530b 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility4/MainAbility4.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility4/MainAbility4.ts @@ -87,7 +87,7 @@ export default class MainAbility4 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility4 onWindowStageCreate") globalThis.ability4context = this.context; - windowStage.setUIContent(this.context, "pages/MainAbility4_pages", null) + windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility4_pages", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility5/MainAbility5.ts b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility5/MainAbility5.ts index b38c7663494f1a1291ba074968d01a0a4f0f2e32..365e3faa100f28488fd6ae666547b6f9a9e40b98 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility5/MainAbility5.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility5/MainAbility5.ts @@ -93,7 +93,7 @@ export default class MainAbility5 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility5 onWindowStageCreate") - windowStage.setUIContent(this.context, "pages/MainAbility5_pages", null) + windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility5_pages", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility6/MainAbility6.ts b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility6/MainAbility6.ts index 93281b4179bc059628177b8a9cd61afab200b934..11d0f86075ff5ffe333fa116d3eeef3c4a303739 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility6/MainAbility6.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility6/MainAbility6.ts @@ -87,7 +87,7 @@ export default class MainAbility6 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility6 onWindowStageCreate") - windowStage.setUIContent(this.context, "pages/MainAbility6_pages", null) + windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility6_pages", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility7/MainAbility7.ts b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility7/MainAbility7.ts index b6092d69d1e945c7d63bac3f4eb0d4ba22f01bfa..82ff894743b72566f522ea7c28e404c162932c4f 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility7/MainAbility7.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/MainAbility7/MainAbility7.ts @@ -14,7 +14,7 @@ export default class MainAbility7 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility7 onWindowStageCreate") globalThis.ability7context = this.context; - windowStage.setUIContent(this.context, "pages/MainAbility7_pages", null) + windowStage.setUIContent(this.context, "MainAbility/pages/MainAbility7_pages", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/TestAbility/TestAbility.ts b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..89a84730505783ba229175ab4b55d37f91a16266 --- /dev/null +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..36d0cf531209dc98342568e93183a68dfed21795 --- /dev/null +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.lifecycletest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/LifecycleTest.ets b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/LifecycleTest.ets index 2b3b3328ac1cebea0d6bdd32e121318914c48af8..e11d1fccb80bb3c2b15517a50424c80e1e818c82 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/LifecycleTest.ets +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/LifecycleTest.ets @@ -13,9 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index" - -export default function abilityTest(abilityContext) { +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" +export default function abilityTest() { describe('AbilityTest', function () { @@ -68,7 +67,7 @@ export default function abilityTest(abilityContext) { TAG = "Multihap_WindowStageLifecycleTest_001"; listKeyTemp = []; - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "MainAbility4" }, (error, data) => { @@ -78,7 +77,7 @@ export default function abilityTest(abilityContext) { await sleep(1000); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility3" }, (error, data) => { @@ -120,7 +119,7 @@ export default function abilityTest(abilityContext) { TAG = "Multihap_WindowStageLifecycleTest_002"; listKeyTemp = []; - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "MainAbility4" }, (error, data) => { @@ -130,7 +129,7 @@ export default function abilityTest(abilityContext) { await sleep(1000); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility4" }, (error, data) => { @@ -140,7 +139,7 @@ export default function abilityTest(abilityContext) { await sleep(1000); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility4" }, (error, data) => { @@ -182,7 +181,7 @@ export default function abilityTest(abilityContext) { TAG = "Multihap_WindowStageLifecycleTest_003"; listKeyTemp = []; - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "MainAbility4" }, (error, data) => { @@ -192,7 +191,7 @@ export default function abilityTest(abilityContext) { await sleep(1000); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility5" }, (error, data) => { @@ -202,7 +201,7 @@ export default function abilityTest(abilityContext) { await sleep(1000); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility5" }, (error, data) => { @@ -249,7 +248,7 @@ export default function abilityTest(abilityContext) { listKeyTemp = []; listKeyTemp1 = []; - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "MainAbility4" }, (error, data) => { @@ -259,7 +258,7 @@ export default function abilityTest(abilityContext) { await sleep(1000); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility6" }, (error, data) => { @@ -269,7 +268,7 @@ export default function abilityTest(abilityContext) { await sleep(1000); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap3MainAbility2" }, (error, data) => { @@ -320,7 +319,7 @@ export default function abilityTest(abilityContext) { listKeyTemp = []; listKeyTemp1 = []; - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "MainAbility4" }, (error, data) => { @@ -330,7 +329,7 @@ export default function abilityTest(abilityContext) { await sleep(500); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility6" }, (error, data) => { @@ -340,7 +339,7 @@ export default function abilityTest(abilityContext) { await sleep(500); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility7" }, (error, data) => { @@ -394,7 +393,7 @@ export default function abilityTest(abilityContext) { var firstCallbackId; var secondCallbackId; - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "MainAbility7" }, (error, data) => { @@ -404,7 +403,7 @@ export default function abilityTest(abilityContext) { await sleep(500); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility8" }, (error, data) => { @@ -419,7 +418,7 @@ export default function abilityTest(abilityContext) { await sleep(500); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "MainAbility7" }, (error, data) => { @@ -429,7 +428,7 @@ export default function abilityTest(abilityContext) { await sleep(1000); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility8" }, (error, data) => { @@ -476,7 +475,7 @@ export default function abilityTest(abilityContext) { var callBackId2; var flag; - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "MainAbility6" }, (error, data) => { @@ -485,7 +484,7 @@ export default function abilityTest(abilityContext) { }); setTimeout(function () { - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility9" }, (error, data) => { @@ -523,7 +522,7 @@ export default function abilityTest(abilityContext) { setTimeout(function () { if (flag == 0) { - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "MainAbility6" }, (error, data) => { @@ -532,7 +531,7 @@ export default function abilityTest(abilityContext) { }); setTimeout(function () { - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility9" }, (error, data) => { @@ -584,7 +583,7 @@ export default function abilityTest(abilityContext) { TAG = "Multihap_WindowStageLifecycleTest_008"; listKeyTemp = []; - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "MainAbility4" }, (error, data) => { @@ -594,7 +593,7 @@ export default function abilityTest(abilityContext) { await sleep(500); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility6" }, (error, data) => { @@ -644,7 +643,7 @@ export default function abilityTest(abilityContext) { listKeyTemp = []; listKeyTemp1 = []; - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "MainAbility4", }, (error, data) => { @@ -653,7 +652,7 @@ export default function abilityTest(abilityContext) { }) await sleep(1000) - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility10", }, (error, data) => { @@ -662,7 +661,7 @@ export default function abilityTest(abilityContext) { }) await sleep(1000) - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap3MainAbility3", }, (error, data) => { @@ -671,7 +670,7 @@ export default function abilityTest(abilityContext) { }) await sleep(1000) - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility10", }, (error, data) => { @@ -680,7 +679,7 @@ export default function abilityTest(abilityContext) { }) await sleep(1000) - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap3MainAbility3", }, (error, data) => { @@ -690,7 +689,7 @@ export default function abilityTest(abilityContext) { await sleep(1000) - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap2MainAbility10", }, (error, data) => { @@ -699,7 +698,7 @@ export default function abilityTest(abilityContext) { }) await sleep(1000) - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap3MainAbility3", }, (error, data) => { @@ -758,7 +757,7 @@ export default function abilityTest(abilityContext) { TAG = "Multihap_WindowStageLifecycleTest_010"; listKeyTemp = []; - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "MainAbility2", }, (error, data) => { @@ -768,7 +767,7 @@ export default function abilityTest(abilityContext) { await sleep(500); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.lifecycletest", abilityName: "Hap4MainAbility1", }, (error, data) => { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/ListTest.ets b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/List.test.ets similarity index 90% rename from ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/ListTest.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/List.test.ets index 0e786ad93d6fed5d13090f1f1d55b8183678ad24..a6c270f17f636afa7c066a393c03b92331d8fd3a 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/ListTest.ets +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/ets/test/List.test.ets @@ -14,6 +14,6 @@ */ import lifecycleTest from './LifecycleTest' -export default function List(context) { - lifecycleTest(context) +export default function List() { + lifecycleTest() } \ No newline at end of file diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/resources/base/profile/main_pages.json index dfc704c52405631e5fce73caf849106d9cbb128d..55149e4425ee07d45312d138754715076ff8de87 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/resources/base/profile/main_pages.json +++ b/ability/ability_runtime/stage/actswindowstagelifecyclemultihaptest/entry/src/main/resources/base/profile/main_pages.json @@ -1,11 +1,11 @@ { "src": [ - "pages/MainAbility_pages", - "pages/MainAbility1_pages", - "pages/MainAbility2_pages", - "pages/MainAbility3_pages", - "pages/MainAbility4_pages", - "pages/MainAbility5_pages", - "pages/MainAbility6_pages" + "MainAbility/pages/MainAbility_pages", + "MainAbility/pages/MainAbility1_pages", + "MainAbility/pages/MainAbility2_pages", + "MainAbility/pages/MainAbility3_pages", + "MainAbility/pages/MainAbility4_pages", + "MainAbility/pages/MainAbility5_pages", + "MainAbility/pages/MainAbility6_pages" ] } \ No newline at end of file diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/Test.json b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/Test.json index dc82a31e4865f43615f87ee1476afb66293e137e..471f3f3764d9473798dec35a4161562b5bbbbd37 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/Test.json +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "180000", - "package": "com.example.windowstagelifecycle_xts", - "shell-timeout": "600000" + "bundle-name": "com.example.windowstagelifecycle_xts", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 }, "kits": [ { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/Hap1MainAbility1/Hap1MainAbility1.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/Hap1MainAbility1/Hap1MainAbility1.ts index ded1affab04861ec4b1f6bfac452dfc89cf127ac..0bd8bae9cf466315bddb9dcd0cd2bb977db55340 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/Hap1MainAbility1/Hap1MainAbility1.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/Hap1MainAbility1/Hap1MainAbility1.ts @@ -35,7 +35,7 @@ export default class Hap1MainAbility1 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] Hap1MainAbility1 onWindowStageCreate") - windowStage.setUIContent(this.context, "pages/indexh1a1", null) + windowStage.setUIContent(this.context, "MainAbility/pages/indexh1a1", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/Hap1MainAbility2/Hap1MainAbility2.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/Hap1MainAbility2/Hap1MainAbility2.ts index f8552bfa873dda74f3ee4f1e8de20655996c7cd1..0827cc9ac6130e94f9b41009d09d439b9062898e 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/Hap1MainAbility2/Hap1MainAbility2.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/Hap1MainAbility2/Hap1MainAbility2.ts @@ -36,7 +36,7 @@ export default class Hap1MainAbility2 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] Hap1MainAbility2 onWindowStageCreate") - windowStage.setUIContent(this.context, "pages/indexh1a2", null) + windowStage.setUIContent(this.context, "MainAbility/pages/indexh1a2", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/MainAbility.ts index 245fde7135b60e4843ac8f1d20ee9021e886f2e3..2f474d0bc3ef5bb5dbc351e345e2c690dfb26bd7 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -28,7 +28,7 @@ export default class MainAbility extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility onWindowStageCreate") globalThis.abilityContext = this.context; - windowStage.setUIContent(this.context, "pages/index", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index.ets similarity index 61% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index.ets index e279086a082c8f5d1a57617e1ca4b32723468651..c73003d9e31befc78365c0af34d46a5538b8281c 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index.ets +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index.ets @@ -13,29 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import file from '@system.file'; -import { Core, ExpectExtend, InstrumentLog, ReportExtend } from "deccjsunit/index" -import List from '../test/ListTest' +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../test/List.test' @Entry @Component struct Index { aboutToAppear() { console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - core.addService('report', reportExtend) - core.init() - globalThis.abilityWant.parameters.timeout = 10000; - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - configService.setConfig(globalThis.abilityWant.parameters); - List(globalThis.abilityContext) - core.execute() + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } build() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index1.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index1.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index1.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index1.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index10.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index10.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index10.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index10.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index11.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index11.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index11.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index11.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index12.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index12.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index12.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index12.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index2.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index2.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index2.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index2.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index3.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index3.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index3.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index3.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index4.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index4.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index4.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index4.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index5.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index5.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index5.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index5.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index6.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index6.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index6.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index6.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index7.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index7.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index7.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index7.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index8.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index8.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index8.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index8.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index9.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index9.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/index9.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/index9.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/indexh1a1.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/indexh1a1.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/indexh1a1.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/indexh1a1.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/indexh1a2.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/indexh1a2.ets similarity index 100% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/pages/indexh1a2.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility/pages/indexh1a2.ets diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility1/MainAbility1.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility1/MainAbility1.ts index 8a1e354d410c8f8688a6ce6a3357182c887ef097..3ed184640b5978af114d8ec247946a7573eede16 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility1/MainAbility1.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility1/MainAbility1.ts @@ -100,7 +100,7 @@ export default class MainAbility1 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility1 onWindowStageCreate") globalThis.ability1context = this.context; - windowStage.setUIContent(this.context, "pages/index1", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index1", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility10/MainAbility10.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility10/MainAbility10.ts index 800eb3a87e9301437837b851068ff53c505651ea..113eddac3edf088de89be1288003a7ff3394313e 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility10/MainAbility10.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility10/MainAbility10.ts @@ -99,7 +99,7 @@ export default class MainAbility10 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility10 onWindowStageCreate") globalThis.ability10 = this.context; - windowStage.setUIContent(this.context, "pages/index10", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index10", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility11/MainAbility11.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility11/MainAbility11.ts index db47fea5949a944e62983fe6cea070a10c7b752e..52724343dfca0cb100d6c7c7b7fe87c3eb407270 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility11/MainAbility11.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility11/MainAbility11.ts @@ -100,7 +100,7 @@ export default class MainAbility11 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility11 onWindowStageCreate") - windowStage.setUIContent(this.context, "pages/index11", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index11", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility12/MainAbility12.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility12/MainAbility12.ts index d80c9036534264c566844a7def4bcac9fdfe1000..7b8c66d51ab046445efa3123907cc83f3dedca9c 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility12/MainAbility12.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility12/MainAbility12.ts @@ -99,7 +99,7 @@ export default class MainAbility12 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility12 onWindowStageCreate") globalThis.ability12 = this.context; - windowStage.setUIContent(this.context, "pages/index12", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index12", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility2/MainAbility2.ts index bd6a71c86aae9a16fa940e4ed0443e01faf42cf7..075694f3511d0e2b3f863dff8c8fb8f6955d9fbc 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility2/MainAbility2.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -28,7 +28,7 @@ export default class MainAbility2 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility2 onWindowStageCreate") globalThis.ability2 = this.context; - windowStage.setUIContent(this.context, "pages/index2", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index2", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility3/MainAbility3.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility3/MainAbility3.ts index 54bfce950fe4039d6b5f06e4d832dd16c6cd0855..5bebcb984502bf4f1aed85635ec8f09a83d53ba5 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility3/MainAbility3.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility3/MainAbility3.ts @@ -101,7 +101,7 @@ export default class MainAbility3 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility3 onWindowStageCreate") globalThis.ability3 = this.context - windowStage.setUIContent(this.context, "pages/index3", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index3", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility4/MainAbility4.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility4/MainAbility4.ts index dda86814dfc84459a01a535966b8410421d5eaa1..654590c7d003f3bacebfe56cd5e0c867fbdc65e5 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility4/MainAbility4.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility4/MainAbility4.ts @@ -101,7 +101,7 @@ export default class MainAbility4 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility4 onWindowStageCreate") globalThis.ability4 = this.context; - windowStage.setUIContent(this.context, "pages/index4", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index4", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility5/MainAbility5.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility5/MainAbility5.ts index a37e29a1855d4c7bb890260bd4745ec27364e5e1..490df759094f2aa85623e8ce8dd9fb4277c5440c 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility5/MainAbility5.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility5/MainAbility5.ts @@ -28,7 +28,7 @@ export default class MainAbility5 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility5 onWindowStageCreate") globalThis.ability5 = this.context; - windowStage.setUIContent(this.context, "pages/index5", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index5", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility6/MainAbility6.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility6/MainAbility6.ts index a7e34a3a5b56b8c1a926de02a830f9d2be2e0996..e3a1b85db4e8f29c848d6b02f958d8c6cf58102f 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility6/MainAbility6.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility6/MainAbility6.ts @@ -28,7 +28,7 @@ export default class MainAbility6 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility6 onWindowStageCreate") globalThis.ability6 = this.context; - windowStage.setUIContent(this.context, "pages/index6", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index6", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility7/MainAbility7.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility7/MainAbility7.ts index 545bf9807b66589745c45b4ac610d4ccf4912791..8405125c1b0aba9980616d356739ba4d969dccf6 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility7/MainAbility7.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility7/MainAbility7.ts @@ -28,7 +28,7 @@ export default class MainAbility7 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility7 onWindowStageCreate") globalThis.ability7 = this.context; - windowStage.setUIContent(this.context, "pages/index7", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index7", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility8/MainAbility8.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility8/MainAbility8.ts index af51bb5a3cf82e8ad8aa387dabb2dd47f303b018..ede5afac6e966d0ff806304d10889af4bcfe05f8 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility8/MainAbility8.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility8/MainAbility8.ts @@ -28,7 +28,7 @@ export default class MainAbility8 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility8 onWindowStageCreate") globalThis.ability8 = this.context; - windowStage.setUIContent(this.context, "pages/index8", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index8", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility9/MainAbility9.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility9/MainAbility9.ts index 41754e62b503fbbed1af8dd16dacbff064d2d087..c191164700f84747ffcffafc677ecbb05a6f185b 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility9/MainAbility9.ts +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/MainAbility9/MainAbility9.ts @@ -28,7 +28,7 @@ export default class MainAbility9 extends Ability { // Main window is created, set main page for this ability console.log("[Demo] MainAbility9 onWindowStageCreate") - windowStage.setUIContent(this.context, "pages/index9", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index9", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/TestAbility/TestAbility.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..89a84730505783ba229175ab4b55d37f91a16266 --- /dev/null +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..2ca088bb32b236e901540bbd505fe2aa7d6ba599 --- /dev/null +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.windowstagelifecycle_xts.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets index b554352b99b30e29281314b94c5e2cb8e61cd31a..5676654b5911ae3bdfcec0f427d1713e6bd89d64 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/LifeCycleTest.ets @@ -13,9 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index" - -export default function lifecycleTest(abilityContext) { +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" +export default function lifecycleTest() { describe('LifeCycleTest', function () { beforeEach(async function (done) { @@ -84,7 +83,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -137,7 +136,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility1", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -148,7 +147,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -206,7 +205,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility1", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -217,7 +216,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -286,7 +285,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility3", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start3 successful. Data: ' + data); }).catch((error) => { @@ -297,7 +296,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start2 successful. Data: ' + data); }).catch((error) => { @@ -370,7 +369,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility1", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start1 successful. Data: ' + data); }).catch((error) => { @@ -381,7 +380,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility5", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start5 successful. Data: ' + data); }).catch((error) => { @@ -393,7 +392,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str2) + globalThis.globalThis.abilityContext.startAbility(str2) .then((data) => { console.info(TAG + ' start2 successful. Data: ' + data); }).catch((error) => { @@ -445,7 +444,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility1", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -456,7 +455,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -468,7 +467,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -481,7 +480,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -547,7 +546,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility1", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -558,7 +557,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -570,7 +569,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -633,7 +632,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility6", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -648,7 +647,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -681,7 +680,7 @@ export default function lifecycleTest(abilityContext) { console.log("------------Singlehap_WindowStageLifeCycleTest_0900 start-------------"); TAG = "Singlehap_WindowStageLifeCycleTest_0900"; listKeyTemp = []; - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.windowstagelifecycle_xts", abilityName: "MainAbility9" }, (error, data) => { @@ -689,7 +688,7 @@ export default function lifecycleTest(abilityContext) { ",data: " + JSON.stringify(data)); }); await sleep(500); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.windowstagelifecycle_xts", abilityName: "Hap1MainAbility1" }, (error, data) => { @@ -697,7 +696,7 @@ export default function lifecycleTest(abilityContext) { ",data: " + JSON.stringify(data)); }); await sleep(500); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.windowstagelifecycle_xts", abilityName: "Hap1MainAbility1" }, (error, data) => { @@ -737,7 +736,7 @@ export default function lifecycleTest(abilityContext) { console.log("------------Singlehap_WindowStageLifeCycleTest_1000 start-------------"); TAG = "Singlehap_WindowStageLifeCycleTest_1000"; listKeyTemp = []; - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.windowstagelifecycle_xts", abilityName: "MainAbility9" }, (error, data) => { @@ -745,7 +744,7 @@ export default function lifecycleTest(abilityContext) { ",data: " + JSON.stringify(data)); }); await sleep(500); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.windowstagelifecycle_xts", abilityName: "Hap1MainAbility2" }, (error, data) => { @@ -753,7 +752,7 @@ export default function lifecycleTest(abilityContext) { ",data: " + JSON.stringify(data)); }); await sleep(500); - abilityContext.startAbility({ + globalThis.abilityContext.startAbility({ bundleName: "com.example.windowstagelifecycle_xts", abilityName: "Hap1MainAbility2" }, (error, data) => { @@ -801,7 +800,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility11", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -812,7 +811,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -828,7 +827,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility11", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -839,7 +838,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -892,7 +891,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility12", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -903,7 +902,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -935,7 +934,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility12", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -946,7 +945,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -1002,7 +1001,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility1", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -1013,7 +1012,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility12", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -1024,7 +1023,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str2) + globalThis.globalThis.abilityContext.startAbility(str2) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -1077,7 +1076,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility1", } - globalThis.abilityContext.startAbility(str) + globalThis.globalThis.abilityContext.startAbility(str) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -1088,7 +1087,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility12", } - globalThis.abilityContext.startAbility(str1) + globalThis.globalThis.abilityContext.startAbility(str1) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { @@ -1099,7 +1098,7 @@ export default function lifecycleTest(abilityContext) { "bundleName": "com.example.windowstagelifecycle_xts", "abilityName": "MainAbility2", } - globalThis.abilityContext.startAbility(str2) + globalThis.globalThis.abilityContext.startAbility(str2) .then((data) => { console.info(TAG + ' start successful. Data: ' + data); }).catch((error) => { diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/ListTest.ets b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/List.test.ets similarity index 90% rename from ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/ListTest.ets rename to ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/List.test.ets index becdd6d36bab6b61d759ca29560397d72aca99e2..990093a063a3f339484284e0167c86a94ab1aa87 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/ListTest.ets +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/ets/test/List.test.ets @@ -14,6 +14,6 @@ */ import LifeCycleTest from './LifeCycleTest' -export default function List(context) { - LifeCycleTest(context) +export default function List() { + LifeCycleTest() } \ No newline at end of file diff --git a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/resources/base/profile/main_pages.json index cb0b24346e7ce5917da687182a8574c14f1d6900..8f499d32407fe2498b34f2a71237818e3c73f61a 100755 --- a/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/resources/base/profile/main_pages.json +++ b/ability/ability_runtime/stage/actswindowstagelifecyclesinglehaptest/entry/src/main/resources/base/profile/main_pages.json @@ -1,19 +1,19 @@ { "src": [ - "pages/index", - "pages/index1", - "pages/index2", - "pages/index3", - "pages/index4", - "pages/index5", - "pages/index6", - "pages/index7", - "pages/index8", - "pages/index9", - "pages/index10", - "pages/index11", - "pages/index12", - "pages/indexh1a1", - "pages/indexh1a2" + "MainAbility/pages/index", + "MainAbility/pages/index1", + "MainAbility/pages/index2", + "MainAbility/pages/index3", + "MainAbility/pages/index4", + "MainAbility/pages/index5", + "MainAbility/pages/index6", + "MainAbility/pages/index7", + "MainAbility/pages/index8", + "MainAbility/pages/index9", + "MainAbility/pages/index10", + "MainAbility/pages/index11", + "MainAbility/pages/index12", + "MainAbility/pages/indexh1a1", + "MainAbility/pages/indexh1a2" ] } diff --git a/ability/ability_runtime/workercontextcover/workercontexttest/BUILD.gn b/ability/ability_runtime/workercontextcover/workercontexttest/BUILD.gn index 15936ed1edbcb5c1d822701b0b246a48c4351418..8c82d06e28cf666c6dfaea35252e7bf6bf84501b 100644 --- a/ability/ability_runtime/workercontextcover/workercontexttest/BUILD.gn +++ b/ability/ability_runtime/workercontextcover/workercontexttest/BUILD.gn @@ -22,7 +22,7 @@ ohos_js_hap_suite("WorkerContextTest") { ] ets2abc = true certificate_profile = "signature/openharmony_sx.p7b" - hap_name = "WorkerContextTest" + hap_name = "ActsWorkerContextTest" } ohos_app_scope("workercontexttest_app_profile") { diff --git a/ability/ability_runtime/workercontextcover/workercontexttest/Test.json b/ability/ability_runtime/workercontextcover/workercontexttest/Test.json index c69407eb0d6690601adfe45be4518142933e8ad5..fc7115a25f6bf4fb942332f3b8f617fdc1afec13 100644 --- a/ability/ability_runtime/workercontextcover/workercontexttest/Test.json +++ b/ability/ability_runtime/workercontextcover/workercontexttest/Test.json @@ -1,15 +1,17 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "180000", - "package": "com.example.workercontexttest", - "shell-timeout": "600000" + "bundle-name": "com.example.workercontexttest", + "module-name": "entry", + "shell-timeout": "600000", + "testcase-timeout": 70000 }, "kits": [ { "test-file-name": [ - "WorkerContextTest.hap" + "ActsWorkerContextTest.hap" ], "type": "AppInstallKit", "cleanup-apps": true diff --git a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/MainAbility/MainAbility.ts index ccf0d32c50c8e1beecbbf74c545b3fb385ab0541..a6d9684bfb05d18fdaf65b3a97989d7f63f88378 100644 --- a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -32,7 +32,7 @@ export default class MainAbility extends Ability { // Main window is created, set main page for this ability console.info(printLog1 + 'onWindowStageCreate') - windowStage.loadContent("pages/index", (err, data) => { + windowStage.loadContent("MainAbility/pages/index", (err, data) => { if (err.code) { console.error('Failed to load the content. Cause:' + JSON.stringify(err)); return; diff --git a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/MainAbility/pages/index.ets similarity index 54% rename from ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/pages/index.ets rename to ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/MainAbility/pages/index.ets index 885fe8b9ba3212bab45778b41e6f299621d556fa..f0c389008f9c1144b39d07e103d2a9933c7e53dd 100644 --- a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/pages/index.ets +++ b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/MainAbility/pages/index.ets @@ -12,9 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import file from '@system.file'; -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" -import list from '../test/ListTest' +import router from '@ohos.router'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../test/List.test' @Entry @Component @@ -23,23 +24,12 @@ struct Index { aboutToAppear() { console.info("start run testcase!!!!") - const core = Core.getInstance() - const expectExtend = new ExpectExtend({ - 'id': 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - globalThis.abilityWant.parameters.timeout = 20000; - - core.subscribeEvent('task', reportExtend) - const configService = core.getDefaultService('config') - configService.setConfig(globalThis.abilityWant.parameters) - console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) - list(globalThis.abilityContext) - core.execute() + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } build() { diff --git a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/TestAbility/TestAbility.ts b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..89a84730505783ba229175ab4b55d37f91a16266 --- /dev/null +++ b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.loadContent("TestAbility/pages/index", (err, data) => { + if (err.code) { + console.error('Failed to load the content. Cause:' + JSON.stringify(err)); + return; + } + console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..cc3fd3b2bc9528807ec8e2db66f9d8dd9dce29ca --- /dev/null +++ b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.workercontexttest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/test/ListTest.ets b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/test/List.test.ets similarity index 94% rename from ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/test/ListTest.ets rename to ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/test/List.test.ets index b421c3658bc304f87bd0b7d4e5750c4e887cae70..4f1c67b62218dd2e6ea27a974903273ac55f005f 100644 --- a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/test/ListTest.ets +++ b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/test/List.test.ets @@ -15,7 +15,7 @@ import workerTransmitTest from './WorkerTransmitTest.test' -export default function List(context) { +export default function List() { workerTransmitTest() } \ No newline at end of file diff --git a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/test/WorkerTransmitTest.test.ets b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/test/WorkerTransmitTest.test.ets index 932d05415f79ec1537749f31304fdb658a645d04..cce37c69d99466dbde5b6934fddad0686455ad76 100644 --- a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/test/WorkerTransmitTest.test.ets +++ b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/ets/test/WorkerTransmitTest.test.ets @@ -12,9 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" -import worker from '@ohos.worker' +import worker from '@ohos.worker' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" var TAG = '' export default function WorkerTransmitTest() { describe('WorkerTransmitTest', function () { diff --git a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/resources/base/profile/main_pages.json index feec276e105eeb8d621c20aaf838f318b0a94150..c1858c216308ad312862a877139a8ba6908ec3c6 100644 --- a/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/resources/base/profile/main_pages.json +++ b/ability/ability_runtime/workercontextcover/workercontexttest/entry/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,5 @@ { "src": [ - "pages/index" + "MainAbility/pages/index" ] }