diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/BUILD.gn b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/BUILD.gn index 15d4b2e77dfb614049f28e46bc4e5b28c4a1baf1..d290d611a58241e3198723fa25b106805ce13c54 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/BUILD.gn +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/BUILD.gn @@ -14,7 +14,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("ActsAmsUsersExtensionSystemTest") { - hap_profile = "entry/src/main/module.json" + hap_profile = "./entry/src/main/module.json" js_build_mode = "debug" deps = [ ":actsamsusersextensionsystemtest_js_assets", @@ -23,6 +23,8 @@ ohos_js_hap_suite("ActsAmsUsersExtensionSystemTest") { ets2abc = true certificate_profile = "signature/openharmony_sx.p7b" hap_name = "ActsAmsUsersExtensionSystemTest" + subsystem_name = "ability" + part_name = "ability_runtime" } ohos_app_scope("actsamsusersextensionsystemtest_app_profile") { @@ -31,11 +33,11 @@ ohos_app_scope("actsamsusersextensionsystemtest_app_profile") { } ohos_js_assets("actsamsusersextensionsystemtest_js_assets") { - source_dir = "entry/src/main/ets" + source_dir = "./entry/src/main/ets" } ohos_resources("actsamsusersextensionsystemtest_resources") { - sources = [ "entry/src/main/resources" ] + sources = [ "./entry/src/main/resources" ] deps = [ ":actsamsusersextensionsystemtest_app_profile" ] - hap_profile = "entry/src/main/module.json" + hap_profile = "./entry/src/main/module.json" } diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/Test.json b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/Test.json index 4517a84f854cca81e865ac735997b12e3439d526..23c3021a3f7e6c9520d14f4c446efa4580c7faf3 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/Test.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.acts.actsinterfacemultiusersextensiontest", - "shell-timeout": "300000" + "bundle-name": "com.acts.actsinterfacemultiusersextensiontest", + "module-name":"phone", + "shell-timeout": "300000", + "testcase-timeout": "30000" }, "kits": [ { @@ -12,6 +14,10 @@ "run-command": [ "acm create -n user101 -t normal", "acm switch -i 101" + ], + "teardown-command": [ + "acm switch -i 100", + "acm delete -i 101" ] }, { diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts index 10dd9a1eaff7ad67843219facba7f8aea7b5a1a5..627735a9b31509b0636ac5c410c996deb725d036 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -4,7 +4,7 @@ * 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 + * 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, @@ -13,38 +13,42 @@ * limitations under the License. */ import Ability from '@ohos.application.Ability' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' export default class MainAbility extends Ability { - onCreate(want,launchParam){ - // Ability is creating, initialize resources for this ability - console.log("MainAbility onCreate") + onCreate(want, launchParam) { + console.log('MainAbility onCreate') globalThis.abilityWant = want; + globalThis.abilityContext = this.context; + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) } onDestroy() { - // Ability is destroying, release resources for this ability - console.log("MainAbility onDestroy") + console.log('MainAbility onDestroy') } onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("MainAbility onWindowStageCreate") - globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) + console.log('MainAbility onWindowStageCreate') + windowStage.setUIContent(this.context, 'MainAbility/pages/index/index', null) } onWindowStageDestroy() { - //Main window is destroyed, release UI related resources - console.log("MainAbility onWindowStageDestroy") + console.log('MainAbility onWindowStageDestroy') } onForeground() { - // Ability has brought to foreground - console.log("MainAbility onForeground") + console.log('MainAbility onForeground') } onBackground() { - // Ability has back to background - console.log("MainAbility onBackground") + console.log('MainAbility onBackground') } + }; \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility/pages/index/index.ets b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3213051cd207a81d45aa7fac27cf772e8eade194 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,31 @@ +/* + * 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. + */ +@Entry +@Component +struct Index { + @State message: string = 'ActsAmsUsersExtensionSystemTest' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility/pages/second/second.ets b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility/pages/second/second.ets @@ -0,0 +1,43 @@ +/* + * 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 '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts index 69bd30f43010522ddda8fc48abb21c69d9936d2c..3a23181f8bcee8f27646f6d5015002e5dc73480c 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -19,7 +19,7 @@ export default class MainAbility2 extends Ability { onCreate(want, launchParam) { console.log("MainAbility2 onCreate"); - globalThis.abilityContext = this.context + globalThis.abilityContext2 = this.context } onDestroy() { @@ -28,10 +28,10 @@ export default class MainAbility2 extends Ability { onWindowStageCreate(windowStage) { console.log("MainAbility2 onWindowStageCreate"); - windowStage.setUIContent(this.context, "pages/index/second", null); + windowStage.setUIContent(this.context, "MainAbility/pages/index/second", null); commonEvent.publish("ACTS_InterfaceMultiUsersExtension_CommonEvent", () => { console.log("publish Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback") - globalThis.abilityContext.terminateSelf().then(() => { + globalThis.abilityContext2.terminateSelf().then(() => { commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{ console.log('terminateSelf promise'); }); diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts index 62e5690da243ce838f4fddf69cbd10002cf4b8a3..9585ba864f16191e33e635e2e1d8336044bcd90d 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -79,6 +79,8 @@ export default class ServiceAbility extends ServiceExtensionAbility { },{ windowMode:0 },(err,data) => { + console.debug("==== err is====>"+ JSON.stringify(err)); + console.debug("==== errCode is====>"+ JSON.stringify(err.code)); console.debug("====>startAbility end====>" ); }) var myStub7 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility"); @@ -92,7 +94,9 @@ export default class ServiceAbility extends ServiceExtensionAbility { abilityName: 'com.acts.error.MainAbility2' },{ windowMode:0 - },() => { + },(err,data) => { + console.debug("==== err is====>"+ JSON.stringify(err)); + console.debug("==== errCode is====>"+ JSON.stringify(err.code)); console.debug("====>startAbility end====>" ); }) var myStub2 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility"); @@ -126,8 +130,10 @@ export default class ServiceAbility extends ServiceExtensionAbility { { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2' - },() => { - console.debug("====>startAbility end====>" ); + },(err,data) => { + console.debug("==== err is====>"+ JSON.stringify(err)); + console.debug("==== errCode is====>"+ JSON.stringify(err.code)); + console.debug("====>startAbility end====>" ); }) var myStub8 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility"); console.log('ThirdAbility onConnect before return:') @@ -138,8 +144,10 @@ export default class ServiceAbility extends ServiceExtensionAbility { { bundleName: 'com.acts.error', abilityName: 'com.acts.error.ServiceAbility2' - },() => { - console.debug("====>startAbility end====>" ); + },(err,data) => { + console.debug("==== err is====>"+ JSON.stringify(err)); + console.debug("==== errCode is====>"+ JSON.stringify(err.code)); + console.debug("====>startAbility end====>" ); }) var myStub4 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility"); console.log('ThirdAbility onConnect before return:') @@ -186,8 +194,10 @@ export default class ServiceAbility extends ServiceExtensionAbility { { bundleName: 'com.acts.error', abilityName: 'com.acts.error.ServiceAbility2' - },() => { - console.debug("====>startAbility end====>" ); + },(err,data) => { + console.debug("==== err is====>"+ JSON.stringify(err)); + console.debug("==== errCode is====>"+ JSON.stringify(err.code)); + console.debug("====>startAbility end====>" ); }) var myStub6 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility"); console.log('ThirdAbility onConnect before return:') @@ -210,8 +220,10 @@ export default class ServiceAbility extends ServiceExtensionAbility { { bundleName: 'com.example.userservicesystemapi7', abilityName: 'com.example.userservicesystemapi7.ServiceAbility' - },() => { - console.debug("====>startAbility end====>" ); + },(err,data) => { + console.debug("==== err is====>"+ JSON.stringify(err)); + console.debug("==== errCode is====>"+ JSON.stringify(err.code)); + console.debug("====>startAbility end====>" ); }) var myStub10 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility"); console.log('ThirdAbility onConnect before return:') diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..9f9cabbe3239cf9f61c388d0912f2373a2aec4f5 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/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.acts.actsinterfacemultiusersextensiontest.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/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/test/Ability.test.ets index ed891c859e2fcc76828916a5eef86fc3a8e25b69..a20fe5e8ad3860dbb227886a1f9e84f3025dabd2 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/test/Ability.test.ets @@ -12,13 +12,13 @@ * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" import commonEvent from '@ohos.commonEvent' import osaccount from '@ohos.account.osAccount' var subscriberInfo_MainAbility = { events: ["ACTS_InterfaceMultiUsersExtension_CommonEvent"] - }; +}; var subscriberInfo_MainAbility2 = { events: ["ACTS_TerminateSelf_CommonEvent"] }; @@ -29,21 +29,11 @@ var osAccountManager const START_ABILITY_TIMEOUT = 6000; globalThis.number = 0; console.debug("====>in Ability.test====>"); -export default function abilityTest(abilityContext) { +export default function abilityTest() { console.debug("====>in function abilityTest====>"); describe('ActsInterfaceMultiUsersExtensionTest', function () { - afterAll(function() { - osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - osAccountManager.activateOsAccount(100, (err)=>{ - console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err)); - osAccountManager.removeOsAccount(101, (err)=>{ - console.debug("====>remove localId: 101" + " err:" + JSON.stringify(err)); - }) - }) - }) console.debug("====>in ACTS_InterfaceMultiUsers====>"); - + /* * @tc.number : ACTS_ExtensionStartAbility_0100 * @tc.name : start new ability @@ -55,46 +45,46 @@ export default function abilityTest(abilityContext) { var startresult = false globalThis.startnum = 1 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent").assertTrue(); console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){ + if (data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent") { startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); } - commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { - console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo) => { - console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); - Subscriber = data; - commonEvent.subscribe(Subscriber, SubscribeCallBack); - console.debug("====>0100start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( - { - bundleName: 'com.acts.actsinterfacemultiusersextensiontest', - abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' - }) - console.debug("====>number is====>" + JSON.stringify(globalThis.number)); - }) + commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { + console.debug("====>Create Subscriber====>"); + data.getSubscribeInfo().then(async (SubscribeInfo) => { + console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + console.debug("====>0100start connectAbility====>"); + globalThis.number = await globalThis.abilityContext.connectAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); }) + }) function UnSubscribeCallback() { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(true); - setTimeout(()=>{ + setTimeout(() => { done() - },1000) + }, 1000) } function timeout() { console.debug('in ACTS_ExtensionStartAbility_0100 timeout'); - if(flag == true) { + if (flag == true) { expect().assertFail(); console.debug('ACTS_ExtensionStartAbility_0100 - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) @@ -115,11 +105,11 @@ export default function abilityTest(abilityContext) { var startresult = false globalThis.startnum = 2 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect().assertFail(); expect(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent").assertTrue(); console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){ + if (data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent") { startresult = true } commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); @@ -128,21 +118,21 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(false); - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); - setTimeout(()=>{ + setTimeout(() => { done(); - },1000) + }, 1000) } function onConnectCallback(element, remote) { console.log(' onConnectCallback====> element=' + JSON.stringify(element)); console.log(' onConnectCallback====> remote=' + JSON.stringify(remote)); - setTimeout(()=> { + setTimeout(() => { console.log('====>in timeout'); console.debug("====>flag is====>" + JSON.stringify(flag)); - if(flag == true) { + if (flag == true) { console.debug('ACTS_ExtensionStartAbility_0200 - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); } @@ -157,18 +147,18 @@ export default function abilityTest(abilityContext) { } commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ + data.getSubscribeInfo().then(async (SubscribeInfo) => { console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0200start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' - },{ - onConnect:onConnectCallback, - onDisconnect:onDisconnectCallback, + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, onFailed: onFailedCallback }) console.debug("====>number is====>" + JSON.stringify(globalThis.number)); @@ -185,15 +175,15 @@ export default function abilityTest(abilityContext) { let Subscriber var flag = true var startresult = false - globalThis.startnum=3 + globalThis.startnum = 3 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent").assertTrue(); console.debug("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){ + if (data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent") { startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -201,12 +191,12 @@ export default function abilityTest(abilityContext) { } commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ + data.getSubscribeInfo().then(async (SubscribeInfo) => { console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0300start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' @@ -219,14 +209,14 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(true); - setTimeout(()=>{ + setTimeout(() => { done() - },1000) + }, 1000) } function timeout() { console.debug('in ACTS_ExtensionStartAbility_0300 timeout'); - if(flag == true) { + if (flag == true) { expect().assertFail(); console.debug('ACTS_ExtensionStartAbility_0300 - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) @@ -247,11 +237,11 @@ export default function abilityTest(abilityContext) { var startresult = false globalThis.startnum = 4 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect().assertFail(); expect(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent").assertTrue(); console.debug("====>0400 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){ + if (data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent") { startresult = true } commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); @@ -260,21 +250,21 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(false); - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); - setTimeout(()=>{ + setTimeout(() => { done(); - },1000) + }, 1000) } function onConnectCallback(element, remote) { console.log(' onConnectCallback====> element=' + JSON.stringify(element)); console.log(' onConnectCallback====> remote=' + JSON.stringify(remote)); - setTimeout(()=> { + setTimeout(() => { console.log('====>in timeout'); console.debug("====>flag is====>" + JSON.stringify(flag)); - if(flag == true) { + if (flag == true) { console.debug('ACTS_ExtensionStartAbility_0400 - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); } @@ -289,18 +279,18 @@ export default function abilityTest(abilityContext) { } commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ + data.getSubscribeInfo().then(async (SubscribeInfo) => { console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0400start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' - },{ - onConnect:onConnectCallback, - onDisconnect:onDisconnectCallback, + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, onFailed: onFailedCallback }) console.debug("====>number is====>" + JSON.stringify(globalThis.number)); @@ -320,13 +310,13 @@ export default function abilityTest(abilityContext) { var startresult = false globalThis.startnum = 5 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent").assertTrue(); console.debug("====>0500 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){ + if (data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent") { startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -334,12 +324,12 @@ export default function abilityTest(abilityContext) { } commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ + data.getSubscribeInfo().then(async (SubscribeInfo) => { console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0500start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' @@ -352,14 +342,14 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(true); - setTimeout(()=>{ + setTimeout(() => { done() - },1000) + }, 1000) } function timeout() { console.debug('in ACTS_ExtensionStartAbility_0500 timeout'); - if(flag == true) { + if (flag == true) { expect().assertFail(); console.debug('ACTS_ExtensionStartAbility_0500 - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) @@ -380,11 +370,11 @@ export default function abilityTest(abilityContext) { var startresult = false globalThis.startnum = 6 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect().assertFail(); expect(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent").assertTrue(); console.debug("====>0600 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){ + if (data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent") { startresult = true } commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); @@ -393,21 +383,21 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(false); - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); - setTimeout(()=>{ + setTimeout(() => { done(); - },1000) + }, 1000) } function onConnectCallback(element, remote) { console.log(' onConnectCallback====> element=' + JSON.stringify(element)); console.log(' onConnectCallback====> remote=' + JSON.stringify(remote)); - setTimeout(()=> { + setTimeout(() => { console.log('====>in timeout'); console.debug("====>flag is====>" + JSON.stringify(flag)); - if(flag == true) { + if (flag == true) { console.debug('ACTS_ExtensionStartAbility_0600 - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); } @@ -422,18 +412,18 @@ export default function abilityTest(abilityContext) { } commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ + data.getSubscribeInfo().then(async (SubscribeInfo) => { console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0600start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' - },{ - onConnect:onConnectCallback, - onDisconnect:onDisconnectCallback, + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, onFailed: onFailedCallback }) console.debug("====>number is====>" + JSON.stringify(globalThis.number)); @@ -450,15 +440,15 @@ export default function abilityTest(abilityContext) { let Subscriber var flag = true var startresult = false - globalThis.startnum=7 + globalThis.startnum = 7 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent").assertTrue(); console.debug("====>0700 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){ + if (data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent") { startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -466,12 +456,12 @@ export default function abilityTest(abilityContext) { } commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ + data.getSubscribeInfo().then(async (SubscribeInfo) => { console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0700start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' @@ -484,14 +474,14 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(true); - setTimeout(()=>{ + setTimeout(() => { done() - },1000) + }, 1000) } function timeout() { console.debug('in ACTS_ExtensionStartAbility_0700 timeout'); - if(flag == true) { + if (flag == true) { expect().assertFail(); console.debug('ACTS_ExtensionStartAbility_0700 - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) @@ -513,11 +503,11 @@ export default function abilityTest(abilityContext) { var startresult = false globalThis.startnum = 8 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect().assertFail(); expect(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent").assertTrue(); console.debug("====>0800 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){ + if (data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent") { startresult = true } commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); @@ -526,21 +516,21 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(false); - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); - setTimeout(()=>{ + setTimeout(() => { done(); - },1000) + }, 1000) } function onConnectCallback(element, remote) { console.log(' onConnectCallback====> element=' + JSON.stringify(element)); console.log(' onConnectCallback====> remote=' + JSON.stringify(remote)); - setTimeout(()=> { + setTimeout(() => { console.log('====>in timeout'); console.debug("====>flag is====>" + JSON.stringify(flag)); - if(flag == true) { + if (flag == true) { console.debug('ACTS_ExtensionStartAbility_0800 - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); } @@ -555,18 +545,18 @@ export default function abilityTest(abilityContext) { } commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ + data.getSubscribeInfo().then(async (SubscribeInfo) => { console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0800start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' - },{ - onConnect:onConnectCallback, - onDisconnect:onDisconnectCallback, + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, onFailed: onFailedCallback }) console.debug("====>number is====>" + JSON.stringify(globalThis.number)); @@ -583,15 +573,15 @@ export default function abilityTest(abilityContext) { let Subscriber var flag = true var startresult = false - globalThis.startnum=13 + globalThis.startnum = 13 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent").assertTrue(); console.debug("====>0900 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ + if (data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent") { startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -599,12 +589,12 @@ export default function abilityTest(abilityContext) { } commonEvent.createSubscriber(subscriberInfo_MainAbility3).then(async (data) => { console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ + data.getSubscribeInfo().then(async (SubscribeInfo) => { console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0900start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' @@ -617,14 +607,14 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(true); - setTimeout(()=>{ + setTimeout(() => { done() - },1000) + }, 1000) } function timeout() { console.debug('in ACTS_ExtensionStartAbility_0900 timeout'); - if(flag == true) { + if (flag == true) { expect().assertFail(); console.debug('ACTS_ExtensionStartAbility_0900 - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) @@ -644,15 +634,15 @@ export default function abilityTest(abilityContext) { let Subscriber var flag = true var startresult = false - globalThis.startnum=14 + globalThis.startnum = 14 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent").assertTrue(); console.debug("====>1000 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ + if (data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent") { startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -660,12 +650,12 @@ export default function abilityTest(abilityContext) { } commonEvent.createSubscriber(subscriberInfo_MainAbility3).then(async (data) => { console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ + data.getSubscribeInfo().then(async (SubscribeInfo) => { console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>1000start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' @@ -678,14 +668,14 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(true); - setTimeout(()=>{ + setTimeout(() => { done() - },1000) + }, 1000) } function timeout() { console.debug('in ACTS_ExtensionStartAbility_1000 timeout'); - if(flag == true) { + if (flag == true) { expect().assertFail(); console.debug('ACTS_ExtensionStartAbility_1000 - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) @@ -707,13 +697,13 @@ export default function abilityTest(abilityContext) { var startresult = false globalThis.startnum = 9 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect(data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); - console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_TerminateSelf_CommonEvent"){ + console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ACTS_TerminateSelf_CommonEvent") { startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -730,18 +720,18 @@ export default function abilityTest(abilityContext) { } commonEvent.createSubscriber(subscriberInfo_MainAbility2).then(async (data) => { console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ + data.getSubscribeInfo().then(async (SubscribeInfo) => { console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0100start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' - },{ - onConnect:onConnectCallback, - onDisconnect:onDisconnectCallback, + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, onFailed: onFailedCallback }) console.debug("====>number is====>" + JSON.stringify(globalThis.number)); @@ -752,14 +742,14 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(true); - setTimeout(()=>{ + setTimeout(() => { done() - },1000) + }, 1000) } function timeout() { console.debug('in ACTS_ExtensionTerminateSelf_0100 timeout'); - if(flag == true) { + if (flag == true) { expect().assertFail(); console.debug('ACTS_ExtensionTerminateSelf_0100 - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) @@ -780,11 +770,11 @@ export default function abilityTest(abilityContext) { var startresult = false globalThis.startnum = 10 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect().assertFail(); expect(data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_TerminateSelf_CommonEvent"){ + if (data.event == "ACTS_TerminateSelf_CommonEvent") { startresult = true } commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); @@ -793,21 +783,21 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(false); - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); - setTimeout(()=>{ + setTimeout(() => { done(); - },1000) + }, 1000) } function onConnectCallback(element, remote) { console.log(' onConnectCallback====> element=' + JSON.stringify(element)); console.log(' onConnectCallback====> remote=' + JSON.stringify(remote)); - setTimeout(()=> { + setTimeout(() => { console.log('====>in timeout'); console.debug("====>flag is====>" + JSON.stringify(flag)); - if(flag == true) { + if (flag == true) { console.debug(' - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); } @@ -822,18 +812,18 @@ export default function abilityTest(abilityContext) { } commonEvent.createSubscriber(subscriberInfo_MainAbility2).then(async (data) => { console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ + data.getSubscribeInfo().then(async (SubscribeInfo) => { console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0200start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' - },{ - onConnect:onConnectCallback, - onDisconnect:onDisconnectCallback, + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, onFailed: onFailedCallback }) console.debug("====>number is====>" + JSON.stringify(globalThis.number)); @@ -853,13 +843,13 @@ export default function abilityTest(abilityContext) { var startresult = false globalThis.startnum = 11 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect(data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); console.debug("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_TerminateSelf_CommonEvent"){ + if (data.event == "ACTS_TerminateSelf_CommonEvent") { startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -867,12 +857,12 @@ export default function abilityTest(abilityContext) { } commonEvent.createSubscriber(subscriberInfo_MainAbility2).then(async (data) => { console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ + data.getSubscribeInfo().then(async (SubscribeInfo) => { console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0300start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' @@ -885,14 +875,14 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(true); - setTimeout(()=>{ + setTimeout(() => { done() - },1000) + }, 1000) } function timeout() { console.debug('in ACTS_ExtensionTerminateSelf_0300 timeout'); - if(flag == true) { + if (flag == true) { expect().assertFail(); console.debug('ACTS_ExtensionTerminateSelf_0300 - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) @@ -914,11 +904,11 @@ export default function abilityTest(abilityContext) { var startresult = false globalThis.startnum = 12 console.log('====>globalThis.startnum is====>' + globalThis.startnum); - function SubscribeCallBack (err, data) { + function SubscribeCallBack(err, data) { expect().assertFail(); expect(data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); console.debug("====>0400 Subscribe CallBack data:====>" + JSON.stringify(data)); - if(data.event == "ACTS_TerminateSelf_CommonEvent"){ + if (data.event == "ACTS_TerminateSelf_CommonEvent") { startresult = true } commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); @@ -927,21 +917,21 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(false); - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data) => { console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); - setTimeout(()=>{ + setTimeout(() => { done(); - },1000) + }, 1000) } function onConnectCallback(element, remote) { console.log('ACTS_ExtensionTerminateSelf_0400 onConnectCallback====> element=' + JSON.stringify(element)); console.log('ACTS_ExtensionTerminateSelf_0400 onConnectCallback====> remote=' + JSON.stringify(remote)); - setTimeout(()=> { + setTimeout(() => { console.log('====>in timeout'); console.debug("====>flag is====>" + JSON.stringify(flag)); - if(flag == true) { + if (flag == true) { console.debug('ACTS_ExtensionTerminateSelf_0400 - timeout'); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); } @@ -956,18 +946,18 @@ export default function abilityTest(abilityContext) { } commonEvent.createSubscriber(subscriberInfo_MainAbility2).then(async (data) => { console.debug("====>Create Subscriber====>"); - data.getSubscribeInfo().then(async (SubscribeInfo)=>{ + data.getSubscribeInfo().then(async (SubscribeInfo) => { console.debug("====>SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0400start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensiontest', abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' - },{ - onConnect:onConnectCallback, - onDisconnect:onDisconnectCallback, + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, onFailed: onFailedCallback }) console.debug("====>number is====>" + JSON.stringify(globalThis.number)); diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/test/List.test.ets index f4e1c2a61d343de3599bfc16768af46c3df792b0..87a37045ffc9e7898182239819b483d50d9dafac 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/test/List.test.ets +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/test/List.test.ets @@ -14,7 +14,7 @@ */ import abilityTest from './Ability.test.ets' -export default function testsuite(context) { +export default function testsuite() { console.debug("====>in list.test====>"); - abilityTest(context) + abilityTest() } \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/resources/base/profile/main_pages.json index 6898b31d2085f478ee1ed9d933a5910cbf901d92..02221db61d317863114ff0ca4dd2b33586abff12 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/resources/base/profile/main_pages.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,6 @@ { "src": [ - "pages/index/index", - "pages/second/second" + "MainAbility/pages/index/index", + "MainAbility/pages/second/second" ] } \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/signature/openharmony_sx.p7b b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/signature/openharmony_sx.p7b index cc53179a48f88f20acc379c138a001e9a15838f6..dcec6c9615032c1b48bf185e839d9720dd68aab0 100644 Binary files a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/signature/openharmony_sx.p7b and b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionSystemTest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/BUILD.gn b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/BUILD.gn index e321c5b2427ce9f4743a72b277bd5b9d8f1582ab..3fa89e6a8a0c085525898ee25c3b3c769cad75e2 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/BUILD.gn +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/BUILD.gn @@ -22,6 +22,8 @@ ohos_js_hap_suite("ActsAmsUsersExtensionThirdTest") { ets2abc = true certificate_profile = "signature/openharmony_sx.p7b" hap_name = "ActsAmsUsersExtensionThirdTest" + subsystem_name = "ability" + part_name = "ability_runtime" } ohos_app_scope("actsamsusersextensionthirdtest_app_profile") { diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/Test.json b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/Test.json index 9d52925e08a927c83f634f36354d39617b8c912f..c63a35a36676032db176e329090140cfd878418f 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/Test.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/Test.json @@ -1,12 +1,25 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.acts.actsinterfacemultiusersextensionthirdtest", - "shell-timeout": "300000" + "bundle-name": "com.acts.actsinterfacemultiusersextensionthirdtest", + "module-name":"phone", + "shell-timeout": "300000", + "testcase-timeout": "30000" }, "kits": [ + { + "type": "ShellKit", + "run-command": [ + "acm create -n user101 -t normal", + "acm switch -i 101" + ], + "teardown-command": [ + "acm switch -i 100", + "acm delete -i 101" + ] + }, { "test-file-name": [ "ActsAmsUsersExtensionThirdTest.hap" diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility/MainAbility.ts index c5b97d7a538f200cff4d39d125418200a171c155..e2707cec8cbc04da7acb6f4cb23f4060c1e6d10d 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -13,39 +13,42 @@ * limitations under the License. */ import Ability from '@ohos.application.Ability' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../test/List.test' export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log('MainAbility onCreate') + globalThis.abilityWant = want; + globalThis.abilityContext = this.context; + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } - onCreate(want, launchParam) { - // Ability is creating, initialize resources for this ability - console.log("MainAbility onCreate"); - globalThis.abilityWant = want; - globalThis.abilityContext = this.context - } + onDestroy() { + console.log('MainAbility onDestroy') + } - onDestroy() { - // Ability is destroying, release resources for this ability - console.log("MainAbility onDestroy"); - } + onWindowStageCreate(windowStage) { + console.log('MainAbility onWindowStageCreate') + windowStage.setUIContent(this.context, 'MainAbility/pages/index/index', null) + } - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("MainAbility onWindowStageCreate"); - windowStage.setUIContent(this.context, "pages/index/index", null); - } + onWindowStageDestroy() { + console.log('MainAbility onWindowStageDestroy') + } - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - console.log("MainAbility onWindowStageDestroy"); - } + onForeground() { + console.log('MainAbility onForeground') + } - onForeground() { - // Ability has brought to foreground - console.log("MainAbility onForeground"); - } - - onBackground() { - // Ability has back to background - console.log("MainAbility onBackground"); - } -}; + onBackground() { + console.log('MainAbility onBackground') + } + +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility/pages/index/index.ets b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3213051cd207a81d45aa7fac27cf772e8eade194 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,31 @@ +/* + * 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. + */ +@Entry +@Component +struct Index { + @State message: string = 'ActsAmsUsersExtensionSystemTest' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility/pages/second/second.ets b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..7d77623164cfc87c809713272776bff63fefbbd9 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility/pages/second/second.ets @@ -0,0 +1,44 @@ +/* + * 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 '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility2/MainAbility2.ts index 3a43ba7672765d2bd84848843bce0a9b47766f8e..9623986e8c1deb65c7e033e1de0449e94bddd80a 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility2/MainAbility2.ts +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -19,7 +19,7 @@ export default class MainAbility2 extends Ability { onCreate(want, launchParam) { console.log("MainAbility2 onCreate"); - globalThis.abilityContext = this.context + globalThis.abilityContext2 = this.context } onDestroy() { @@ -28,10 +28,10 @@ export default class MainAbility2 extends Ability { onWindowStageCreate(windowStage) { console.log("MainAbility2 onWindowStageCreate"); - windowStage.setUIContent(this.context, "pages/index/second", null); + windowStage.setUIContent(this.context, "MainAbility/pages/index/second", null); commonEvent.publish("ACTS_InterfaceMultiUsersExtension_CommonEvent", () => { console.log("publish Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback") - globalThis.abilityContext.terminateSelf().then(() => { + globalThis.abilityContext2.terminateSelf().then(() => { commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{ console.log('terminateSelf promise'); }); diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts index 04f85c959d20e32cb47eed8f86e6d88d66bb5eb5..f363a918d8db101f7e8ac80356b701290fc88e0d 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -76,7 +76,8 @@ export default class ServiceAbility extends ServiceExtensionAbility { abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility2' },{ windowMode:0 - },() => { + },(err,data) => { + console.debug("====>err is====>" + JSON.stringify(err)); console.debug("====>startAbility end====>" ); }) var myStub7 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility"); @@ -90,7 +91,8 @@ export default class ServiceAbility extends ServiceExtensionAbility { abilityName: 'com.acts.error.MainAbility2' },{ windowMode:0 - },() => { + },(err,data) => { + console.debug("====>err is====>" + JSON.stringify(err)); console.debug("====>startAbility end====>" ); }) var myStub2 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility"); @@ -124,9 +126,10 @@ export default class ServiceAbility extends ServiceExtensionAbility { { bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility2' - },() => { - console.debug("====>startAbility end====>" ); - }) + },(err,data) => { + console.debug("====>err is====>" + JSON.stringify(err)); + console.debug("====>startAbility end====>" ); + }) var myStub8 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility"); console.log('ThirdAbility onConnect before return:') return myStub8; @@ -136,9 +139,10 @@ export default class ServiceAbility extends ServiceExtensionAbility { { bundleName: 'com.acts.error', abilityName: 'com.acts.error.ServiceAbility2' - },() => { - console.debug("====>startAbility end====>" ); - }) + },(err,data) => { + console.debug("====>err is====>" + JSON.stringify(err)); + console.debug("====>startAbility end====>" ); + }) var myStub4 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility"); console.log('ThirdAbility onConnect before return:') return myStub4; @@ -178,9 +182,10 @@ export default class ServiceAbility extends ServiceExtensionAbility { { bundleName: 'com.acts.error', abilityName: 'com.acts.error.ServiceAbility2' - },() => { - console.debug("====>startAbility end====>" ); - }) + },(err,data) => { + console.debug("====>err is====>" + JSON.stringify(err)); + console.debug("====>startAbility end====>" ); + }) var myStub6 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility"); console.log('ThirdAbility onConnect before return:') return myStub6; diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/TestAbility/TestAbility.ts b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9f9aadff45f162df116bfe3a90661ea6ab331dc --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,51 @@ +/* + * 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/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fae969f985ff5bf7432de71e36c792364ebac1f6 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2021 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/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b106a82e3b4cc5d0d6046651a54aa9a1d7ed46d --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/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.acts.actsinterfacemultiusersextensionthirdtest.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/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/test/Ability.test.ets index 49a09a4449568803ed3de04409a5c41e4a5c87d7..044a87d3647bfd0ffc8dc13bb18a207f97e83335 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/test/Ability.test.ets @@ -12,7 +12,7 @@ * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "@ohos/hypium" import commonEvent from '@ohos.commonEvent' import osaccount from '@ohos.account.osAccount' @@ -26,20 +26,11 @@ var osAccountManager const START_ABILITY_TIMEOUT = 6000; globalThis.number = 0; console.debug("====>in Ability.test====>"); -export default function abilityTest(abilityContext) { +export default function abilityTest() { console.debug("====>in function abilityTest====>"); describe('ActsInterfaceMultiUsersExtensionThirdTest', function () { - afterAll(function() { - osAccountManager = osaccount.getAccountManager(); - console.debug("====>get AccountManager finish===="); - osAccountManager.activateOsAccount(100, (err)=>{ - console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err)); - osAccountManager.removeOsAccount(101, (err)=>{ - console.debug("====>remove localId: 101" + " err:" + JSON.stringify(err)); - }) - }) - }) console.debug("====>in ACTS_InterfaceMultiUsers====>"); + /* * @tc.number : ACTS_ThirdPartyExtensionStartAbility_0100 * @tc.name : start new ability @@ -57,7 +48,7 @@ export default function abilityTest(abilityContext) { if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){ startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{ console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -70,7 +61,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0100start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' @@ -124,7 +115,7 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(false); - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{ console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -158,7 +149,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0200start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' @@ -189,7 +180,7 @@ export default function abilityTest(abilityContext) { if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){ startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{ console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -202,7 +193,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0300start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' @@ -256,7 +247,7 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(false); - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{ console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -290,7 +281,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0400start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' @@ -322,7 +313,7 @@ export default function abilityTest(abilityContext) { if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){ startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{ console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -335,7 +326,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0500start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' @@ -389,7 +380,7 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(false); - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{ console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -423,7 +414,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0600start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' @@ -454,7 +445,7 @@ export default function abilityTest(abilityContext) { if(data.event == "ACTS_InterfaceMultiUsersExtension_CommonEvent"){ startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{ console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -467,7 +458,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0700start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' @@ -522,7 +513,7 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(false); - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{ console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -556,7 +547,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0800start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' @@ -586,7 +577,7 @@ export default function abilityTest(abilityContext) { if(data.event == "ACTS_TerminateSelf_CommonEvent"){ startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{ console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -599,7 +590,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0100start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' @@ -652,7 +643,7 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(false); - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{ console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -686,7 +677,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0200start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' @@ -717,7 +708,7 @@ export default function abilityTest(abilityContext) { if(data.event == "ACTS_TerminateSelf_CommonEvent"){ startresult = true } - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{ console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -730,7 +721,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0300start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' @@ -784,7 +775,7 @@ export default function abilityTest(abilityContext) { console.debug("====>UnSubscribeCallback====>"); flag = false expect(startresult).assertEqual(false); - abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + globalThis.abilityContext.disconnectAbility(globalThis.number).then((data)=>{ console.debug("====>data is====>" + JSON.stringify(data)); }) console.log('====>disconnectAbility finish'); @@ -820,7 +811,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>0400start connectAbility====>"); - globalThis.number = await abilityContext.connectAbility( + globalThis.number = await globalThis.abilityContext.connectAbility( { bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/test/List.test.ets index 38ad693b91e3f4b84a7d4717063a8ac61b23d9c1..3a84309ab20a5fdffbd08c23ea8f50735b79ef54 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/test/List.test.ets +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/test/List.test.ets @@ -14,7 +14,7 @@ */ import abilityTest from './Ability.test.ets' -export default function testsuite(context) { +export default function testsuite() { console.debug("====>in list.test====>"); - abilityTest(context) + abilityTest() } \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/resources/base/element/string.json index 376647878b379044fa3300dfa4662c98a4c3efbc..f03b06594a7d47bd569242c9a9871cd1e11c2d52 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/resources/base/element/string.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/resources/base/element/string.json @@ -29,4 +29,4 @@ "value": "Demo" } ] -} \ No newline at end of file +} diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/resources/base/profile/main_pages.json index 96b478210df9884592229ae2db6f6bb7f86c14f4..010134e5cdcb46ef62097816f127dac0bb93a398 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/resources/base/profile/main_pages.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,6 @@ { "src": [ - "pages/index/index", - "pages/second/second" + "MainAbility/pages/index/index", + "MainAbility/pages/second/second" ] } \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/signature/openharmony_sx.p7b b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/signature/openharmony_sx.p7b index f06e218defa7f707e22a3890903c574e1c498217..dcec6c9615032c1b48bf185e839d9720dd68aab0 100644 Binary files a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/signature/openharmony_sx.p7b and b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/Test.json b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/Test.json index 96258b2006b10e2d9bc458f66617516efbb4dd75..3e23cb1d4c53342dc9374e65e9850c3e290afa14 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/Test.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/Test.json @@ -6,7 +6,7 @@ "bundle-name": "com.acts.actsinterfacemultiuserstest", "module-name":"phone", "shell-timeout": "300000", - "testcase-timeout": 300000 + "testcase-timeout": "30000" }, "kits": [ { diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/BUILD.gn b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/BUILD.gn index da9e6e4431cb621fe8c7af6622739a2aad4bf43a..b4e59886110a0ff53f131570cd6873c7d897f2fd 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/BUILD.gn +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/BUILD.gn @@ -23,6 +23,8 @@ ohos_js_hap_suite("ActsAmsUsersThirdTest") { ets2abc = true certificate_profile = "signature/openharmony_sx_thirdparty.p7b" hap_name = "ActsAmsUsersThirdTest" + subsystem_name = "ability" + part_name = "ability_runtime" } ohos_app_scope("actsamsusersthirdtest_app_profile") { diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/Test.json b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/Test.json index 2411ca9decb89b9796652e845271699cb3218a40..c6a72336cbaf8982de5a0a86795db8275a4388f2 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/Test.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/Test.json @@ -1,10 +1,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "300000", - "package": "com.acts.actsinterfacemultiusersthirdtest", - "shell-timeout": "300000" + "bundle-name": "com.acts.actsinterfacemultiusersthirdtest", + "module-name":"phone", + "shell-timeout": "300000", + "testcase-timeout": "30000" }, "kits": [ { @@ -14,6 +16,7 @@ "acm switch -i 101" ], "teardown-command":[ + "acm switch -i 100", "acm delete -i 101" ] }, diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility/MainAbility.ts index 33a978656e9b6f51d499612afce665c16d4374d7..28be9d6cdefeae6069de5011f9546b61c54d2345 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -28,7 +28,7 @@ export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { console.log("MainAbility onWindowStageCreate") globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility/pages/index/index.ets b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a7b56cd65dee907f5d21f00139c9c4158d58d4f --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2021 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import router from '@ohos.router' + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + + } + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('MainAbility') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility/pages/second/second.ets b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility/pages/second/second.ets @@ -0,0 +1,43 @@ +/* + * 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 '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility2/MainAbility2.ts index d11ff297aef4b72d9b9a4488cfa1012722ae4968..e66016096d8bbe4076a7e40687131f6a632488f0 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility2/MainAbility2.ts +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -16,7 +16,7 @@ import Ability from '@ohos.application.Ability' import commonEvent from '@ohos.commonEvent' function PublishCallBackOne() { console.debug("====>Publish CallBack ACTS_StartAbility_0100_CommonEvent====>"); - globalThis.abilityContext.terminateSelf(); + globalThis.abilityContext2.terminateSelf(); console.debug("====>terminateSelf succese====>") commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{ console.debug("====>publish ACTS_TerminateSelf_CommonEvent====>") @@ -34,7 +34,7 @@ export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { console.log("MainAbility2 onWindowStageCreate") - globalThis.abilityContext = this.context + globalThis.abilityContext2 = this.context commonEvent.publish("ACTS_InterfaceMultiUsers_0100_Start_CommonEvent", PublishCallBackOne); } diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility3/MainAbility3.ts b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility3/MainAbility3.ts index 160c319d16027f71779d18088633c125f8ecf759..f02f2fdec86b36e804a811504343d458200fb90e 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility3/MainAbility3.ts +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility3/MainAbility3.ts @@ -26,9 +26,9 @@ export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { console.log("MainAbility3 onWindowStageCreate") - globalThis.abilityContext = this.context + globalThis.abilityContext3 = this.context windowStage.setUIContent(this.context, "pages/index/second", null) - globalThis.abilityContext.terminateSelfWithResult( + globalThis.abilityContext3.terminateSelfWithResult( { resultCode:1, want:{ @@ -46,7 +46,7 @@ export default class MainAbility extends Ability { onForeground() { console.log("MainAbility3 onForeground") - globalThis.abilityContext.terminateSelfWithResult({ + globalThis.abilityContext3.terminateSelfWithResult({ resultCode: 1 }) } diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/TestAbility/TestAbility.ts b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9f9aadff45f162df116bfe3a90661ea6ab331dc --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,51 @@ +/* + * 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/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fae969f985ff5bf7432de71e36c792364ebac1f6 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2021 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/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..96bad66c942b0118a6b5c3c33518b5fb9cf91d17 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/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.acts.actsinterfacemultiusersthirdtest.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/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/test/Ability.test.ets index 474672fb84b08b330eb4a8d216fc45d7aafd3b39..455e13eb3fd39a2d6941805ab4cac07a5d0c28b7 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/test/Ability.test.ets @@ -12,7 +12,7 @@ * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "@ohos/hypium" import commonEvent from '@ohos.commonEvent' import osaccount from '@ohos.account.osAccount' @@ -22,7 +22,7 @@ var subscriberInfo_MainAbility = { var osAccountManager const START_ABILITY_TIMEOUT = 6000; console.debug("====>in Ability.test====>"); -export default function abilityTest(abilityContext) { +export default function abilityTest() { console.debug("====>in function abilityTest====>"); describe('ActsInterfaceMultiUsersThirdTest', function () { @@ -50,7 +50,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await abilityContext.startAbility( + await globalThis.abilityContext.startAbility( { bundleName: 'com.acts.actsinterfacemultiusersthirdtest', abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2' @@ -101,7 +101,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await abilityContext.startAbility( + await globalThis.abilityContext.startAbility( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility2' @@ -151,15 +151,16 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - abilityContext.startAbility( + globalThis.abilityContext.startAbility( { bundleName: 'com.acts.actsinterfacemultiusersthirdtest', abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2' }, { windowMode:0 - },() => { + },(err,data) => { + console.debug("====>startAbility err:====>" + JSON.stringify(err)); console.debug("====>startAbility end====>" ); - }) + }) }) }) @@ -203,7 +204,7 @@ export default function abilityTest(abilityContext) { commonEvent.subscribe(Subscriber, SubscribeCallBack); }) console.debug("====>start startAbility====>"); - await abilityContext.startAbility( + await globalThis.abilityContext.startAbility( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility2' @@ -252,7 +253,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await abilityContext.startAbility( + await globalThis.abilityContext.startAbility( { bundleName: 'com.acts.actsinterfacemultiusersthirdtest', abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2' @@ -301,7 +302,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await abilityContext.startAbility( + await globalThis.abilityContext.startAbility( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility2' @@ -349,12 +350,13 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - abilityContext.startAbility( + globalThis.abilityContext.startAbility( { bundleName: 'com.acts.actsinterfacemultiusersthirdtest', abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2' - },() => { - console.debug("====>startAbility end====>" ); + },(err,data) => { + console.debug("====>startAbility err:====>" + JSON.stringify(err)); + console.debug("====>startAbility end====>" ); }) }) }) @@ -399,7 +401,7 @@ export default function abilityTest(abilityContext) { commonEvent.subscribe(Subscriber, SubscribeCallBack); }) console.debug("====>start startAbility====>"); - await abilityContext.startAbility( + await globalThis.abilityContext.startAbility( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility2' @@ -438,7 +440,7 @@ export default function abilityTest(abilityContext) { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await abilityContext.startAbilityForResult( + await globalThis.abilityContext.startAbilityForResult( { bundleName: 'com.acts.actsinterfacemultiusersthirdtest', abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3', @@ -466,7 +468,7 @@ export default function abilityTest(abilityContext) { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await abilityContext.startAbilityForResult( + await globalThis.abilityContext.startAbilityForResult( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility3', @@ -497,7 +499,7 @@ export default function abilityTest(abilityContext) { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await abilityContext.startAbilityForResult( + await globalThis.abilityContext.startAbilityForResult( { bundleName: 'com.acts.actsinterfacemultiusersthirdtest', abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3', @@ -524,7 +526,7 @@ export default function abilityTest(abilityContext) { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await abilityContext.startAbilityForResult( + await globalThis.abilityContext.startAbilityForResult( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility3', @@ -555,7 +557,7 @@ export default function abilityTest(abilityContext) { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await abilityContext.startAbilityForResult( + await globalThis.abilityContext.startAbilityForResult( { bundleName: 'com.acts.actsinterfacemultiusersthirdtest', abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3', @@ -581,7 +583,7 @@ export default function abilityTest(abilityContext) { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await abilityContext.startAbilityForResult( + await globalThis.abilityContext.startAbilityForResult( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility3', @@ -610,7 +612,7 @@ export default function abilityTest(abilityContext) { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await abilityContext.startAbilityForResult( + await globalThis.abilityContext.startAbilityForResult( { bundleName: 'com.acts.actsinterfacemultiusersthirdtest', abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3', @@ -635,7 +637,7 @@ export default function abilityTest(abilityContext) { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await abilityContext.startAbilityForResult( + await globalThis.abilityContext.startAbilityForResult( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility3', @@ -673,7 +675,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await abilityContext.startAbility( + await globalThis.abilityContext.startAbility( { bundleName: 'com.acts.actsinterfacemultiusersthirdtest', abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2' @@ -722,7 +724,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await abilityContext.startAbility( + await globalThis.abilityContext.startAbility( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility2' @@ -772,7 +774,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - abilityContext.startAbility( + globalThis.abilityContext.startAbility( { bundleName: 'com.acts.actsinterfacemultiusersthirdtest', abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2' @@ -821,7 +823,7 @@ export default function abilityTest(abilityContext) { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await abilityContext.startAbility( + await globalThis.abilityContext.startAbility( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility2' @@ -862,7 +864,7 @@ export default function abilityTest(abilityContext) { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await abilityContext.startAbilityForResult( + await globalThis.abilityContext.startAbilityForResult( { bundleName: 'com.acts.actsinterfacemultiusersthirdtest', abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3', @@ -889,7 +891,7 @@ export default function abilityTest(abilityContext) { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await abilityContext.startAbilityForResult( + await globalThis.abilityContext.startAbilityForResult( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility3', @@ -919,7 +921,7 @@ export default function abilityTest(abilityContext) { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await abilityContext.startAbilityForResult( + await globalThis.abilityContext.startAbilityForResult( { bundleName: 'com.acts.actsinterfacemultiusersthirdtest', abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3', @@ -945,7 +947,7 @@ export default function abilityTest(abilityContext) { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await abilityContext.startAbilityForResult( + await globalThis.abilityContext.startAbilityForResult( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility3', diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/test/List.test.ets index 198b3e4099bc53462227bffa2f9c2fcb31c19baa..f454ef993c3548d1046e1e069604e7bc4de4b6dd 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/test/List.test.ets +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/test/List.test.ets @@ -14,7 +14,7 @@ */ import abilityTest from './Ability.test.ets' -export default function testsuite(context) { +export default function testsuite() { console.debug("====>in list.test====>"); - abilityTest(context) + abilityTest() } \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/resources/base/profile/main_pages.json index 6898b31d2085f478ee1ed9d933a5910cbf901d92..02221db61d317863114ff0ca4dd2b33586abff12 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/resources/base/profile/main_pages.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,6 @@ { "src": [ - "pages/index/index", - "pages/second/second" + "MainAbility/pages/index/index", + "MainAbility/pages/second/second" ] } \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/BUILD.gn b/ability/ability_runtime/actsusers/BUILD.gn index 48b6afef0c6d58085b7e0f7b50022c80fea8bbe8..62fc33cc6a3a4c8331d388f27d382038d7ecd1c9 100644 --- a/ability/ability_runtime/actsusers/BUILD.gn +++ b/ability/ability_runtime/actsusers/BUILD.gn @@ -13,7 +13,7 @@ import("//build/ohos_var.gni") -group("actsusers") { +group("actsusers900") { testonly = true if (is_standard_system) { deps = [ diff --git a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/BUILD.gn b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/BUILD.gn index 28ed27d1d8283ec0a360e38d60cd3b4615b151be..9d04bcc220fd02bcdb72aecce8777f5297f88fe9 100644 --- a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/BUILD.gn +++ b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/BUILD.gn @@ -22,6 +22,8 @@ ohos_js_hap_suite("ActsConnectAbilitySystemAbilityTest") { ets2abc = true certificate_profile = "signature/openharmony_sx.p7b" hap_name = "ActsConnectAbilitySystemAbilityTest" + subsystem_name = "ability" + part_name = "ability_runtime" } ohos_app_scope("actsconnectabilitysystemabilitytest_app_profile") { diff --git a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/Test.json b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/Test.json index 5a2cbc313846373afb121ff37c0a0f41a58d4a13..59844f8e02a2864c6c39e214cd10d6dd2dbbffef 100644 --- a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/Test.json +++ b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/Test.json @@ -2,10 +2,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", - "test-timeout": "120000", - "package": "com.example.actsconnectabilitysystemabilitytest", - "shell-timeout": "60000" + "type": "OHJSUnitTest", + "test-timeout": "300000", + "bundle-name": "com.example.actsconnectabilitysystemabilitytest", + "module-name":"phone", + "shell-timeout": "300000", + "testcase-timeout": "30000" }, "kits": [ { @@ -15,6 +17,7 @@ "acm switch -i 101" ], "teardown-command":[ + "acm switch -i 101", "acm delete -i 101" ] }, diff --git a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts index 43899997172ff90613c927330340d2f1f108cb46..7f32c4093a7b1c2defff0cebb83e074cd1cf6cbc 100644 --- a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -1,55 +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. -*/ + * 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 MainAbility extends Ability { - - onCreate(want, launchParam) { + onCreate(want,launchParam){ // Ability is creating, initialize resources for this ability - console.log("AbilityMultiInstanceTest onCreate") + console.log("MainAbility onCreate") globalThis.abilityWant = want; } onDestroy() { // Ability is destroying, release resources for this ability - console.log("AbilityMultiInstanceTest onDestroy") + console.log("MainAbility onDestroy") } onWindowStageCreate(windowStage) { // Main window is created, set main page for this ability - console.log("AbilityMultiInstanceTest onWindowStageCreate") + console.log("MainAbility onWindowStageCreate") globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "pages/index/index", null) + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - console.log("AbilityMultiInstanceTest onWindowStageDestroy") + //Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") } - onForeground() { // Ability has brought to foreground - console.log("AbilityMultiInstanceTest onForeground") + console.log("MainAbility onForeground") } onBackground() { // Ability has back to background - console.log("AbilityMultiInstanceTest onBackground") + console.log("MainAbility onBackground") } - -}; +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/MainAbility/pages/index/index.ets b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a7b56cd65dee907f5d21f00139c9c4158d58d4f --- /dev/null +++ b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2021 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import router from '@ohos.router' + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + + } + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('MainAbility') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/MainAbility/pages/second/second.ets b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/MainAbility/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..caa9f1c5fbc706c60414d23f0be4cbadeb8ee346 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/MainAbility/pages/second/second.ets @@ -0,0 +1,43 @@ +/* + * 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 '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/TestAbility/TestAbility.ts b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9f9aadff45f162df116bfe3a90661ea6ab331dc --- /dev/null +++ b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,51 @@ +/* + * 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/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fae969f985ff5bf7432de71e36c792364ebac1f6 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2021 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/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..764da81c43c1e9c379697d92068c79604eb7fb7c --- /dev/null +++ b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/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.actsconnectabilitysystemabilitytest.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/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/test/List.test.ets index 548001ece0135cf64b85dbb7673fc7aa49b92eae..28df98361684afa7098165888c1e1a088d291475 100644 --- a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/test/List.test.ets +++ b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/test/List.test.ets @@ -13,6 +13,6 @@ * limitations under the License. */ import abilityTest from './manyusersabilitytest.test.ets' -export default function testsuite(context) { - abilityTest(context) +export default function testsuite() { + abilityTest() } \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/test/manyusersabilitytest.test.ets b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/test/manyusersabilitytest.test.ets index 5abbdbcbdaa8fcfccb360e79728a2c6f9904c014..16e4658887f2f8b7a740b1690a7cd4a3496cba37 100644 --- a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/test/manyusersabilitytest.test.ets +++ b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/test/manyusersabilitytest.test.ets @@ -12,7 +12,7 @@ * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" import commonEvent from '@ohos.commonEvent' @@ -66,7 +66,7 @@ var unsubscriberInfoStartAbility_0200 = { const START_ABILITY_TIMEOUT = 1000; globalThis.number = 0; -export default function abilityTest(abilityContext) { +export default function abilityTest() { describe('ActssystemabilityTest', function () { /* @@ -87,7 +87,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_0100_commonEvent"); console.debug("====>ACTS_ConnectAbility_0100 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -114,7 +114,7 @@ export default function abilityTest(abilityContext) { expect().assertFail(); console.debug('AMS_ConnectAbility_0100 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -139,7 +139,7 @@ export default function abilityTest(abilityContext) { id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ConnectAbility_0100 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsconnectabilitysystemabilitytest", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", @@ -189,7 +189,7 @@ export default function abilityTest(abilityContext) { commonEvent.unsubscribe(subscriber, unSubscribeCallback) } id = setTimeout(timeout, START_ABILITY_TIMEOUT); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsconnectabilitysystemabilitytest", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbilityone", @@ -217,7 +217,7 @@ export default function abilityTest(abilityContext) { console.debug("====>ACTS_DisconnectAbility_0100 5 CallBack data:====>" + JSON.stringify(data)); clearTimeout(id); console.debug("====>ACTS_DisconnectAbility_0100 6====>"); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -241,7 +241,7 @@ export default function abilityTest(abilityContext) { expect().assertFail(); console.debug('AMS_DonnectAbility_0300 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -249,7 +249,7 @@ export default function abilityTest(abilityContext) { } id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_DisconnectAbility_0100 3====>"); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsconnectabilitysystemabilitytest", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", @@ -283,7 +283,7 @@ export default function abilityTest(abilityContext) { console.debug("====>ACTS_DisconnectAbility_0200 1111 connectAbility2====>"); console.debug("====>ACTS_DisconnectAbility_0200 66 Subscriber====>"); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( 999, (error, data) => { console.log('ACTS_DisconnectAbility_0200 5 DisconnectAbility result errCode : ' @@ -309,7 +309,7 @@ export default function abilityTest(abilityContext) { console.debug('unsubscribe subscriberdisconnect'); commonEvent.unsubscribe(subscriber, () => { console.debug('unsubscribe subscriber') - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('ACTS_DisconnectAbility_0200 9 DisconnectAbility result errCode : ' @@ -326,7 +326,7 @@ export default function abilityTest(abilityContext) { console.debug("====>ACTS_DisconnectAbility_0200 10 Subscriber====>"); subscriber = data; await commonEvent.subscribe(subscriber, subscribeCallBack) - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsconnectabilitysystemabilitytest", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", @@ -358,7 +358,7 @@ export default function abilityTest(abilityContext) { console.debug("====>ACTS_DisconnectAbility_0300 4 CallBack data:====>" + JSON.stringify(data)); clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_0500_commonEvent"); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('ACTS_DisconnectAbility_0300 5 DisconnectAbility result errCode : ' @@ -382,7 +382,7 @@ export default function abilityTest(abilityContext) { expect().assertFail(); console.debug('AMS_ConnectAbility_0500 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('ACTS_DisconnectAbility_0300 7 DisconnectAbility result errCode : ' @@ -391,7 +391,7 @@ export default function abilityTest(abilityContext) { } id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_DisconnectAbility_0300 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsconnectabilitysystemabilitytest", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", @@ -425,7 +425,7 @@ export default function abilityTest(abilityContext) { console.debug("====>ACTS_DisconnectAbility_0400 1111 connectAbility2====>"); console.debug("====>ACTS_DisconnectAbility_0400 66 Subscriber====>"); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( 999, (error, data) => { console.log('ACTS_DisconnectAbility_0400 5 DisconnectAbility result errCode : ' @@ -451,7 +451,7 @@ export default function abilityTest(abilityContext) { console.debug('unsubscribe subscriberdisconnect'); commonEvent.unsubscribe(subscriber, () => { console.debug('unsubscribe subscriber') - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('ACTS_DisconnectAbility_0400 9 DisconnectAbility result errCode : ' @@ -468,7 +468,7 @@ export default function abilityTest(abilityContext) { console.debug("====>ACTS_DisconnectAbility_0400 10 Subscriber====>"); subscriber = data; await commonEvent.subscribe(subscriber, subscribeCallBack) - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsconnectabilitysystemabilitytest", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", @@ -501,7 +501,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_0700_commonEvent"); console.debug("====>ACTS_ExtensionConnectAbility_0100 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -525,7 +525,7 @@ export default function abilityTest(abilityContext) { expect().assertFail(); console.debug('ACTS_ExtensionConnectAbility_0100 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -533,7 +533,7 @@ export default function abilityTest(abilityContext) { } id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ExtensionConnectAbility_0100 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsconnectabilitysystemabilitytest", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", @@ -560,7 +560,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_0800_commonEvent"); console.debug("====>ACTS_ExtensionConnectAbility_0200 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -583,7 +583,7 @@ export default function abilityTest(abilityContext) { function timeout() { console.debug('ACTS_ExtensionConnectAbility_0200 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -591,7 +591,7 @@ export default function abilityTest(abilityContext) { } id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ExtensionConnectAbility_0200 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsconnectabilitysystemabilitytest", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", @@ -618,7 +618,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_0900_commonEvent"); console.debug("====>ACTS_ExtensionDisconnectAbility_0100 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -642,7 +642,7 @@ export default function abilityTest(abilityContext) { expect().assertFail(); console.debug('ACTS_ExtensionDisconnectAbility_0100 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -650,7 +650,7 @@ export default function abilityTest(abilityContext) { } id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ExtensionDisconnectAbility_0100 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsconnectabilitysystemabilitytest", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", @@ -677,7 +677,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_1000_commonEvent"); console.debug("====>ACTS_ExtensionDisconnectAbility_0200 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -701,7 +701,7 @@ export default function abilityTest(abilityContext) { expect().assertFail(); console.debug('ACTS_ExtensionDisconnectAbility_0200 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -709,7 +709,7 @@ export default function abilityTest(abilityContext) { } id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ExtensionDisconnectAbility_0200 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsconnectabilitysystemabilitytest", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", @@ -736,7 +736,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_1100_commonEvent"); console.debug("====>ACTS_ExtensionDisconnectAbility_0300 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -759,7 +759,7 @@ export default function abilityTest(abilityContext) { function timeout() { console.debug('ACTS_ExtensionDisconnectAbility_0300 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -767,7 +767,7 @@ export default function abilityTest(abilityContext) { } id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ExtensionDisconnectAbility_0300 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsconnectabilitysystemabilitytest", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", @@ -795,7 +795,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_1200_commonEvent"); console.debug("====>ACTS_ExtensionDisconnectAbility_0400 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -818,7 +818,7 @@ export default function abilityTest(abilityContext) { function timeout() { console.debug('ACTS_ExtensionDisconnectAbility_0400 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -826,7 +826,7 @@ export default function abilityTest(abilityContext) { } id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ExtensionDisconnectAbility_0400 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsconnectabilitysystemabilitytest", abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", diff --git a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/resources/base/profile/main_pages.json index 96b478210df9884592229ae2db6f6bb7f86c14f4..010134e5cdcb46ef62097816f127dac0bb93a398 100644 --- a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/resources/base/profile/main_pages.json +++ b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,6 @@ { "src": [ - "pages/index/index", - "pages/second/second" + "MainAbility/pages/index/index", + "MainAbility/pages/second/second" ] } \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/signature/openharmony_sx.p7b b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/signature/openharmony_sx.p7b index cc53179a48f88f20acc379c138a001e9a15838f6..dcec6c9615032c1b48bf185e839d9720dd68aab0 100644 Binary files a/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/signature/openharmony_sx.p7b and b/ability/ability_runtime/actsusers/actsconnectabilitysystemabilitytest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/BUILD.gn b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/BUILD.gn index 223611a0b0c17a75d7016946f0ba3c8abbfe43a1..ee2bf8f463485e77193941b45263f474a201b746 100644 --- a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/BUILD.gn +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/BUILD.gn @@ -21,8 +21,10 @@ ohos_js_hap_suite("ActsManyUsersAbilityTest") { ":actsmanyusersabilitytest_resources", ] ets2abc = true - certificate_profile = "signature/openharmony_sx_thirdparty.p7b" + certificate_profile = "signature/openharmony_sx.p7b" hap_name = "ActsManyUsersAbilityTest" + subsystem_name = "ability" + part_name = "ability_runtime" } ohos_app_scope("actsmanyusersabilitytest_app_profile") { diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/Test.json b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/Test.json index a559bc10e9cd8463fb27c41d4205b6051f93816c..28dd95c05d8b8bd240859deee2e66df52e5f8169 100644 --- a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/Test.json +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/Test.json @@ -2,10 +2,12 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", - "test-timeout": "120000", - "package": "com.example.actsmanyusersabilitytest", - "shell-timeout": "60000" + "type": "OHJSUnitTest", + "test-timeout": "300000", + "bundle-name": "com.example.actsmanyusersabilitytest", + "module-name":"phone", + "shell-timeout": "300000", + "testcase-timeout": "30000" }, "kits": [ { diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts index a1713c0c0788aa5456aaf5f5e787703f9c56a8bf..91d5813ab77fa200dde9e17845093fc4760d7245 100644 --- a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -20,7 +20,6 @@ export default class MainAbility extends Ability { // Ability is creating, initialize resources for this ability console.log("MainAbility onCreate") globalThis.abilityWant = want; - globalThis.abilityContext = this.context } onDestroy() { @@ -31,8 +30,8 @@ export default class MainAbility extends Ability { onWindowStageCreate(windowStage) { // Main window is created, set main page for this ability console.log("MainAbility onWindowStageCreate") - - windowStage.setUIContent(this.context, "pages/index/index", null) + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/MainAbility/pages/index/index.ets b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5a7b56cd65dee907f5d21f00139c9c4158d58d4f --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2021 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' +import router from '@ohos.router' + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + + } + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('MainAbility') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/MainAbility/pages/second/second.ets b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/MainAbility/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/MainAbility/pages/second/second.ets @@ -0,0 +1,43 @@ +/* +* 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 '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/TestAbility/TestAbility.ts b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..e9f9aadff45f162df116bfe3a90661ea6ab331dc --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,51 @@ +/* + * 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/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fae969f985ff5bf7432de71e36c792364ebac1f6 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2021 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/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..4eaf1e8878ddb3863695b2a6267cba3a53d2606e --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/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.actsmanyusersabilitytest.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/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/test/List.test.ets index f5923665570101769b9a6aff451f7c50cc3f6e52..71eb7f381dc583f4b34d9bdaeb23a8f68dc2d0a9 100644 --- a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/test/List.test.ets +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/test/List.test.ets @@ -13,7 +13,7 @@ * limitations under the License. */ import abilityTest from './manyusersabilitytest.test.ets' -export default function testsuite(context) { +export default function testsuite() { - abilityTest(context) + abilityTest() } \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/test/manyusersabilitytest.test.ets b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/test/manyusersabilitytest.test.ets index 1a8dc9b175ff9a334225f9dac64e7caccb337bc6..e1ebf0fc34c97ac81c040eb4c8617802c0e84ce6 100644 --- a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/test/manyusersabilitytest.test.ets +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/test/manyusersabilitytest.test.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index" +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" import commonEvent from '@ohos.commonEvent' @@ -87,7 +87,7 @@ function onFailedCallback(code) { console.log('ACTS_ConnectAbility onFailedCallback====> code=' + JSON.stringify(code)) } -export default function abilityTest(abilityContext) { +export default function abilityTest() { describe('manyuserability', function () { function onFailedCallBack(code) { @@ -111,7 +111,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_0100_commonEvent"); console.debug("====>ACTS_ThirdPartyConnectAbility_0100 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -136,7 +136,7 @@ export default function abilityTest(abilityContext) { expect().assertFail(); console.debug('ACTS_ThirdPartyConnectAbility_0100 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -145,7 +145,7 @@ export default function abilityTest(abilityContext) { id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ThirdPartyConnectAbility_0100 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsmanyusersabilitytest", abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", @@ -197,7 +197,7 @@ export default function abilityTest(abilityContext) { } id = setTimeout(timeout, START_ABILITY_TIMEOUT); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsmanyusersabilitytest", abilityName: "com.example.actsmanyusersabilitytest.ServiceAbilityone", @@ -221,7 +221,7 @@ export default function abilityTest(abilityContext) { console.debug("====>ACTS_ThirdPartyDisconnectAbility_0100 5 CallBack data:====>" + JSON.stringify(data)); clearTimeout(id); console.debug("====>ACTS_ThirdPartyDisconnectAbility_0100 6====>"); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -250,7 +250,7 @@ export default function abilityTest(abilityContext) { expect().assertFail(); console.debug('AMS_DonnectAbility_0300 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -259,7 +259,7 @@ export default function abilityTest(abilityContext) { id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ThirdPartyDisconnectAbility_0100 3====>"); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsmanyusersabilitytest", abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", @@ -292,7 +292,7 @@ export default function abilityTest(abilityContext) { console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 1111 connectAbility2====>"); console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 66 Subscriber====>"); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( 999, (error, data) => { console.log('ACTS_ThirdPartyDisconnectAbility_0200 5 DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -320,7 +320,7 @@ export default function abilityTest(abilityContext) { console.debug('unsubscribe subscriberdisconnect'); commonEvent.unsubscribe(subscriber, () => { console.debug('unsubscribe subscriber') - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('ACTS_ThirdPartyDisconnectAbility_0200 9 DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -339,7 +339,7 @@ export default function abilityTest(abilityContext) { console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 10 Subscriber====>"); subscriber = data; await commonEvent.subscribe(subscriber, subscribeCallBack) - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsmanyusersabilitytest", abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", @@ -374,7 +374,7 @@ export default function abilityTest(abilityContext) { console.debug("====>ACTS_ThirdPartyDisconnectAbility_0300 4 CallBack data:====>" + JSON.stringify(data)); clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_0500_commonEvent"); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('ACTS_ThirdPartyDisconnectAbility_0300 5 DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -402,7 +402,7 @@ export default function abilityTest(abilityContext) { expect().assertFail(); console.debug('ACTS_ThirdPartyDisconnectAbility_0300 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('ACTS_ThirdPartyDisconnectAbility_0300 7 DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -411,7 +411,7 @@ export default function abilityTest(abilityContext) { id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ThirdPartyDisconnectAbility_0300 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsmanyusersabilitytest", abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", @@ -443,7 +443,7 @@ export default function abilityTest(abilityContext) { console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 1111 connectAbility2====>"); console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 66 Subscriber====>"); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( 999, (error, data) => { console.log('ACTS_ThirdPartyDisconnectAbility_0400 5 DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -471,7 +471,7 @@ export default function abilityTest(abilityContext) { console.debug('unsubscribe subscriberdisconnect'); commonEvent.unsubscribe(subscriber, () => { console.debug('unsubscribe subscriber') - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('ACTS_ThirdPartyDisconnectAbility_0400 9 DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -490,7 +490,7 @@ export default function abilityTest(abilityContext) { console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 10 Subscriber====>"); subscriber = data; await commonEvent.subscribe(subscriber, subscribeCallBack) - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsmanyusersabilitytest", abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", @@ -525,7 +525,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_0700_commonEvent"); console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0100 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -554,7 +554,7 @@ export default function abilityTest(abilityContext) { expect().assertFail(); console.debug('ACTS_ExtensionConnectAbility_0100 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -563,7 +563,7 @@ export default function abilityTest(abilityContext) { id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0100 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsmanyusersabilitytest", abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", @@ -591,7 +591,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_0800_commonEvent"); console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0200 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -619,7 +619,7 @@ export default function abilityTest(abilityContext) { function timeout() { console.debug('ACTS_ThirdPartyExtensionConnectAbility_0200 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -628,7 +628,7 @@ export default function abilityTest(abilityContext) { id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0200 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsmanyusersabilitytest", abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", @@ -655,7 +655,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_0900_commonEvent"); console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0100 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -684,7 +684,7 @@ export default function abilityTest(abilityContext) { expect().assertFail(); console.debug('ACTS_ThirdPartyExtensionDisconnectAbility_0100 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -693,7 +693,7 @@ export default function abilityTest(abilityContext) { id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0100 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsmanyusersabilitytest", abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", @@ -721,7 +721,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_1000_commonEvent"); console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0200 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -750,7 +750,7 @@ export default function abilityTest(abilityContext) { expect().assertFail(); console.debug('ACTS_ThirdPartyExtensionDisconnectAbility_0200 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -759,7 +759,7 @@ export default function abilityTest(abilityContext) { id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0200 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsmanyusersabilitytest", abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", @@ -787,7 +787,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_1100_commonEvent"); console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0200 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -815,7 +815,7 @@ export default function abilityTest(abilityContext) { function timeout() { console.debug('ACTS_ThirdPartyExtensionDisconnectAbility_0300 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -824,7 +824,7 @@ export default function abilityTest(abilityContext) { id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0300 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsmanyusersabilitytest", abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", @@ -852,7 +852,7 @@ export default function abilityTest(abilityContext) { clearTimeout(id); expect(data.event).assertEqual("AMS_ConnectAbility_1200_commonEvent"); console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0400 5 "); - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -880,7 +880,7 @@ export default function abilityTest(abilityContext) { function timeout() { console.debug('ACTS_ThirdPartyExtensionDisconnectAbility_0400 timeout'); commonEvent.unsubscribe(subscriber, unSubscribeCallback) - abilityContext.disconnectAbility( + globalThis.abilityContext.disconnectAbility( connId, (error, data) => { console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) @@ -889,7 +889,7 @@ export default function abilityTest(abilityContext) { id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0400 3 "); - connId = await abilityContext.connectAbility( + connId = await globalThis.abilityContext.connectAbility( { bundleName: "com.example.actsmanyusersabilitytest", abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/resources/base/profile/main_pages.json index 6898b31d2085f478ee1ed9d933a5910cbf901d92..02221db61d317863114ff0ca4dd2b33586abff12 100644 --- a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/resources/base/profile/main_pages.json +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,6 @@ { "src": [ - "pages/index/index", - "pages/second/second" + "MainAbility/pages/index/index", + "MainAbility/pages/second/second" ] } \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/signature/openharmony_sx.p7b b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..dcec6c9615032c1b48bf185e839d9720dd68aab0 Binary files /dev/null and b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/signature/openharmony_sx.p7b differ