diff --git a/ability/ability_runtime/actsstartcomponenttest/BUILD.gn b/ability/ability_runtime/actsstartcomponenttest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..3a8570a2b79a5af43e6cfddf9ae30ef04ed812dc --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/BUILD.gn @@ -0,0 +1,30 @@ +# 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("//build/ohos_var.gni") + +group("actsstartcomponenttest") { + testonly = true + if (is_standard_system) { + deps = [ + "SpecifiedUserActionExtension_100:ActsSpecifiedUserActionextensionZeroTest", + "SpecifiedUserActionExtension_101:ActsSpecifiedUserActionextensiononeTest", + "SpecifiedUserAction_100:ActsSpecifiedUserActionZeroTest", + "SpecifiedUserAction_101:ActsSpecifiedUserActiononeTest", + "ThirdPartySpecifiedUserActionExtension_100:ActsThirdPartySpecifiedUserActionextensionZeroTest", + "ThirdPartySpecifiedUserActionExtension_101:ActsThirdPartySpecifiedUserActionextensiononeTest", + "ThirdPartySpecifiedUserAction_100:ActsThirdPartySpecifiedUserActionZeroTest", + "ThirdPartySpecifiedUserAction_101:ActsThirdPartySpecifiedUserActiononeTest", + ] + } +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/app.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..092fe3b37ef3530c83d2dcdbb79a22f1bedeae1c --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actsspecifieduseractionextensionzerotest", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon" : "$media:icon", + "label" : "$string:app_name", + "description" : "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 8, + "targetAPIVersion": 8, + "car": { + "apiCompatibleVersion": 8, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..be09cccde1bc7369ef47a5cd45d2b06884c88602 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/BUILD.gn b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..cf7ceec227311a4c121c2ebec6c43ac031ec2f15 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsSpecifiedUserActionextensionZeroTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":actsspecifieduseractionextensionzerotest_js_assets", + ":actsspecifieduseractionextensionzerotest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsSpecifiedUserActionextensionZeroTest" +} + +ohos_app_scope("actsspecifieduseractionextensionzerotest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsspecifieduseractionextensionzerotest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsspecifieduseractionextensionzerotest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsspecifieduseractionextensionzerotest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/Test.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..febfcbe0a8e08d09c19e7788f5f8c70ffe237b9e --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/Test.json @@ -0,0 +1,49 @@ + +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.actsspecifieduseractionextensionzerotest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsSpecifiedUserActionextensionZeroTest.hap", + "ActsSpecifiedUserActionextensiononeTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "PushKit", + "push": [ + "ActsSpecifiedUserActionextensionZeroTest.hap->/system/app/ActsSpecifiedUserActionextensionZeroTest.hap"] + }, + { + "type": "ShellKit", + "run-command": [ + "acm create -n 101 -t normal", + "acm create -n 102 -t normal", + "acm switch -i 101" + ], + "teardown-command":[ + "acm delete -i 101", + "acm delete -i 102" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsSpecifiedUserActionextensiononeTest.hap->/system/app/ActsSpecifiedUserActionextensiononeTest.hap"] + }, + { + "type": "ShellKit", + "run-command": [ + "acm switch -i 100" + ] + } + ] +} + diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..2266bb311cbed90a650faa1cfde49d72b3d314fc --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,24 @@ +/* + * 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.stageContext = this.context; + globalThis.startnum = 0; + console.log("MyAbilityStage finish") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..77038a5e923d6947c4419b4c9f0365e72b2327a7 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility/MainAbility.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 MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility onCreate"); + globalThis.abilityWant = want; + globalThis.abilityContext = this.context + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility onDestroy"); + } + + 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() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy"); + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground"); + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground"); + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..892ee1bfb3bd2e6686d3e2f2d2f617f1730f290e --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,58 @@ +/* + * 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' +import commonEvent from '@ohos.commonEvent' +function PublishCallBackOne() { + console.debug("====>Publish CallBack ACTS_STAWA_CommonEvent====>"); + console.debug("====>close this context====>") + globalThis.ability2Context.terminateSelf(); +} + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility2 onCreate") + + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility2 onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("MainAbility2 onWindowStageCreate") + globalThis.ability2Context = this.context + windowStage.setUIContent(this.context, "pages/index", null) + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent", PublishCallBackOne); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..4a1e4947d0bf77fc0af62c6df3d070dc1b95bb73 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,230 @@ +/* + * 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import rpc from '@ohos.rpc'; +import osaccount from '@ohos.account.osAccount' +globalThis.ACCOUNT_ID100; +globalThis.ACCOUNT_ID101; +globalThis.ACCOUNT_ID102; +class Stub extends rpc.RemoteObject { + constructor(des) { + super(des); + } + // process client's request + onRemoteRequest(code, data, reply, option) { + reply.writeNoException(); + reply.writeString("success"); + return true; + } +} + +function onConnectCallback(element) { + console.log('connectAbilityWithAccount onConnect element.bundleName : ' + element.bundleName) + console.log('connectAbilityWithAccount onConnect element.abilityName : ' + element.abilityName) +} + +function onDisconnectCallback(element) { + console.log('connectAbilityWithAccount onDisconnect element.bundleName : ' + element.bundleName) + console.log('connectAbilityWithAccount onDisconnect element.abilityName : ' + element.abilityName) +} + +function onFailedCallback(code) { + console.log('connectAbilityWithAccount onFailed errCode : ' + code) +} + +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility onCreate'); + } + onDestory(){ + console.log('ServiceAbility onDestory'); + } + onRequest(want,startId) { + console.log('ServiceAbility onRequest'); + } + + onConnect(want) { + console.log('ServiceAbility onConnect'); + console.log('globalThis.startnum is ' + globalThis.startnum); + + switch (globalThis.startnum) { + case 1: + console.log('ServiceAbility case 1'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.MainAbility2' + },globalThis.ACCOUNT_ID100 ,{ + windowMode: 2, + displayId: 1 + }).then(() => { + console.log("====>end ACTS_StartServiceAbilityWithAccount_0100 ====>success!") + }) + console.debug("====>case 1 end====>"); + var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 2: + console.log('ServiceAbility case 2'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.MainAbility2' + },globalThis.ACCOUNT_ID102 ,{ + windowMode: 2, + displayId: 1 + }).then(() => { + console.log("====>end ACTS_StartServiceAbilityWithAccount_0300 ====>success!") + }) + console.debug("====>case 2 end====>"); + var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 3: + console.log('ServiceAbility case 3'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensiononetest', + abilityName: 'com.example.actsspecifieduseractionextensiononetest.MainAbility2' + },globalThis.ACCOUNT_ID101,((err, data) => { + console.log("====>end ACTS_StartServiceAbilityWithAccount_0500====>fail!!!"+ JSON.stringify(err)) + console.log("====>end ACTS_StartServiceAbilityWithAccount_0500====>sunccess!"+ JSON.stringify(data)) + })) + console.debug("====>case 3 end====>"); + var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 4: + console.log('ServiceAbility case 4'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.MainAbility2' + },globalThis.ACCOUNT_ID102, { + windowMode: 2, + displayId: 1 + },((err, data) => { + console.log("====>end ACTS_StartServiceAbilityWithAccount_0600====>fail!!!"+ JSON.stringify(err)) + console.log("====>end ACTS_StartServiceAbilityWithAccount_0600====>sunccess!"+ JSON.stringify(data)) + })) + console.debug("====>case 4 end====>"); + var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 5: + console.log('ServiceAbility case 5'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2' + },globalThis.ACCOUNT_ID100).then((data) => { + console.log("====>end ACTS_StartServiceAbilityWithAccount_0700====>success!"+ JSON.stringify(data)) + }) + break; + case 6: + console.log('ServiceAbility case 6'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2' + },globalThis.ACCOUNT_ID102,((err, data) => { + console.log("====>end ACTS_StartServiceAbilityWithAccount_0900====>fail!!!") + console.log("====>end ACTS_StartServiceAbilityWithAccount_0900====>sunccess!") + })) + console.debug("====>case 6 end====>"); + var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 7: + console.log('ServiceAbility case 7'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensiononetest', + abilityName: 'com.example.actsspecifieduseractionextensiononetest.ServiceAbility2' + }, globalThis.ACCOUNT_ID101,((err, data) => { + console.log("====>end ACTS_StartServiceAbilityWithAccount_1100====>fail!!!"+ JSON.stringify(err)) + console.log("====>end ACTS_StartServiceAbilityWithAccount_1100====>sunccess!"+ JSON.stringify(data)) + })) + console.debug("====>case 7 end====>"); + var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 8: + console.log('ServiceAbility case 8'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2' + }, globalThis.ACCOUNT_ID102,((err, data) => { + console.log("====>end ACTS_StartServiceAbilityWithAccount_1200====>fail!!!"+ JSON.stringify(err)) + console.log("====>end ACTS_StartServiceAbilityWithAccount_1200====>sunccess!"+ JSON.stringify(data)) + })) + console.debug("====>case 8 end====>"); + var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 9: + console.log('ServiceAbility case 9'); + this.context.connectAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2', + action: "StartAbilityPromise" + }, globalThis.ACCOUNT_ID100, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback, + },) + break; + case 10: + console.log('ServiceAbility case 10'); + this.context.connectAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2', + action: "StartAbilityPromise" + },globalThis.ACCOUNT_ID102, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback, + },) + + console.debug("====>case 10 end====>"); + var myStub = new Stub("com.example.actsspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + default: + console.log("====> ServiceAbility end default =====>") + break; + } + } + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..91a83dbc24c50064a2031ddf77606699a059fac9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..c70f0a2d3cfda08ff3f4038d37128a08c013d16a --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -0,0 +1,60 @@ +/* + * 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import Want from '@ohos.application.Want'; +import commonEvent from "@ohos.commonEvent" +import rpc from '@ohos.rpc'; + +export default class ServiceAbility2 extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility2 onCreate'); + globalThis.abilityWant = want; + } + + onDestory(){ + console.log('ServiceAbility2 onDestory'); + } + + onRequest(want,startId) { + console.log('ServiceAbility2 onRequest'); + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => { + console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback") + this.context.terminateSelf(); + console.log("====> terminateSelf End=====>") + }); + } + + onConnect(want: Want) { + console.log('ServiceAbility2 onConnect'); + if (want.action == 'StartAbilityPromise') { + console.log('stub StartAbilityPromise OnConnect start '); + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => { + console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback") + this.context.terminateSelf(); + console.log("====> StartAbilityPromise End=====>") + }); + } + return new rpc.RemoteObject('connect'); + } + + onDisconnect(want) { + console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility2 onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/service.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..91a83dbc24c50064a2031ddf77606699a059fac9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/service.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..ae1248c48c93d453fcd7eda5a426fcb47cbe59c0 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,49 @@ +/* + * 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 file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" +import testsuite from "../../test/List.test.ets" +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + console.info("subscribeEvent run !!!!") + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + 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/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/pages/second/second.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/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/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..a3586361441e1111245eadf7c2c8da640d5b44ee --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,833 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import commonEvent from '@ohos.commonEvent' +import osaccount from '@ohos.account.osAccount' + +var ACTS_ABILITYCONTEX = { + events: ["ABILITYCONTEX_Start_CommonEvent"] +}; + +const START_ABILITY_TIMEOUT = 3000; +console.debug("====>in Ability.test====>"); + +export default function abilityTest(abilityContext) { + console.debug("====>in ACTS_InterfaceMultiUsers====>"); + describe('ACTS_StartService', function () { + beforeAll(function(done) { + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + osAccountManager.activateOsAccount(100, (err)=>{ + console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err)); + setTimeout(()=>{ + osAccountManager.queryActivatedOsAccountIds((err,data1)=>{ + console.debug("====>getOsAccountLocalIdFromProcess100" + " err:" + JSON.stringify(err)); + console.debug("====>getOsAccountLocalIdFromProcess100" + " data:" + JSON.stringify(data1)); + globalThis.ACCOUNT_ID100 = data1[0]; + osAccountManager.activateOsAccount(101, (err)=>{ + console.debug("====>activateOsAccount localId: 101 err:" + JSON.stringify(err)); + setTimeout(()=>{ + osAccountManager.queryActivatedOsAccountIds((err,data2)=>{ + console.debug("====>getOsAccountLocalIdFromProcess101" + " err:" + JSON.stringify(err)); + console.debug("====>getOsAccountLocalIdFromProcess101" + " data:" + JSON.stringify(data2)); + globalThis.ACCOUNT_ID101 = data2[0]; + osAccountManager.activateOsAccount(102, (err)=>{ + console.debug("====>activateOsAccount localId: 102 err:" + JSON.stringify(err)); + osAccountManager.queryActivatedOsAccountIds((err,data3)=>{ + console.debug("====>getOsAccountLocalIdFromProcess102" + " err:" + JSON.stringify(err)); + console.debug("====>getOsAccountLocalIdFromProcess102" + " data:" + JSON.stringify(data3)); + globalThis.ACCOUNT_ID102 = data3[0]; + osAccountManager.activateOsAccount(100, (err)=>{ + console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err)); + done(); + }) + }) + }) + }) + },3000) + }) + }) + },3000) + }) + }) + + /* + * @tc.number : ACTS_StartServiceAbilityWithAccount_0100 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : In multi-user non-concurrent mode, + * the specified user is equal to the current user and the user's task list exists (promise) + */ + it('ACTS_StartServiceAbilityWithAccount_0100', 0, async function (done) { + let Subscriber + var flag = true; + var startresult = false; + globalThis.startnum = 1; + + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function onConnectCallback(element, remote) { + console.log('ACTS_StartServiceAbilityWithAccount_0100 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_StartServiceAbilityWithAccount_0100 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_StartServiceAbilityWithAccount_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(() => { + done() + }, 1000) + } + + function timeout() { + console.debug('in ACTS_StartServiceAbilityWithAccount_0100 timeout'); + if (flag == true) { + expect().assertFail(); + console.debug('ACTS_StartServiceAbilityWithAccount_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_StartServiceAbilityWithAccount_0300 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user does not have a task list (the user does not exist), call Promise + */ + it('ACTS_StartServiceAbilityWithAccount_0300', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 2; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_StartServiceAbilityWithAccount_0300 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_StartServiceAbilityWithAccount_0300 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_StartServiceAbilityWithAccount_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0300start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_StartServiceAbilityWithAccount_0500 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * the specified user is not equal to the current user, + * and the user's task list exists, call AsyncCallback + */ + it('ACTS_StartServiceAbilityWithAccount_0500', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 3; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0500 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + // setTimeout(() => { + + // }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_StartServiceAbilityWithAccount_0500 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_StartServiceAbilityWithAccount_0500 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_StartServiceAbilityWithAccount_0500 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + done(); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0500start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_StartServiceAbilityWithAccount_0600 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user does not have a task list (the user does not exist), + * call AsyncCallback + */ + it('ACTS_StartServiceAbilityWithAccount_0600', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 4; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0600 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_StartServiceAbilityWithAccount_0600 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_StartServiceAbilityWithAccount_0600 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_StartServiceAbilityWithAccount_0600 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0600start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_StartServiceAbilityWithAccount_0700 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user is equal to the current user, + * and the user's task list exists, call Promise + */ + it('ACTS_StartServiceAbilityWithAccount_0700', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 5; + + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0700 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0700start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(() => { + done() + }, 1000) + } + + function timeout() { + console.debug('in ACTS_StartServiceAbilityWithAccount_0700 timeout'); + if (flag == true) { + expect().assertFail(); + console.debug('ACTS_StartServiceAbilityWithAccount_0700 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_StartServiceAbilityWithAccount_0900 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user does not have a task list (the user does not exist), + * call Promise + */ + it('ACTS_StartServiceAbilityWithAccount_0900', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 6; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0900 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_StartServiceAbilityWithAccount_0900 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_StartServiceAbilityWithAccount_0900 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_StartServiceAbilityWithAccount_0900 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0900start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_StartServiceAbilityWithAccount_1100 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * the specified user is not equal to the current user, + * and the user's task list exists, call AsyncCallback + */ + it('ACTS_StartServiceAbilityWithAccount_1100', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 7; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>1100 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_StartServiceAbilityWithAccount_1100 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_StartServiceAbilityWithAccount_1100 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_StartServiceAbilityWithAccount_1100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>1100start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_StartServiceAbilityWithAccount_1200 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user does not have a task list (the user does not exist), + * call AsyncCallback + */ + it('ACTS_StartServiceAbilityWithAccount_1200', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 8; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>1200 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_StartServiceAbilityWithAccount_1200 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_StartServiceAbilityWithAccount_1200 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_StartServiceAbilityWithAccount_1200 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>1200start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ConnectServiceAbilityWithAccount_0100 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user is equal to the current user and the user's task list exists + */ + it('ACTS_ConnectServiceAbilityWithAccount_0100', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 9; + + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0100 ConnectServiceAbility connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(() => { + done() + }, 1000) + } + + function timeout() { + console.debug('in ACTS_ConnectServiceAbilityWithAccount_0100 timeout'); + if (flag == true) { + expect().assertFail(); + console.debug('ACTS_ConnectServiceAbilityWithAccount_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ConnectServiceAbilityWithAccount_0300 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user does not have a task list (the user does not exist) + */ + it('ACTS_ConnectServiceAbilityWithAccount_0300', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 10; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ConnectServiceAbilityWithAccount_0300 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ConnectServiceAbilityWithAccount_0300 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ConnectServiceAbilityWithAccount_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0300 ConnectServiceAbility connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + }) +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..14db1352021eca93318bfef24eaece89517e9ba8 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,23 @@ +/* + * 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 abilityTest from './Ability.test.ets' + + +export default function testsuite(context) { + + console.debug("====>in list.test====>"); + abilityTest(context) + +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/module.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..857db4fa29e57d8e9e6d708115c8a1ebf96b6227 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/module.json @@ -0,0 +1,131 @@ +{ + "module": { + "name": "com.example.actsspecifieduseractionextensionzerotest", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.example.actsspecifieduseractionextensionzerotest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.actsspecifieduseractionextensionzerotest.MainAbility2", + "srcEntrance": "./ets/MainAbility2/MainAbility2.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "name": "com.example.actsspecifieduseractionextensionzerotest.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + }, + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ], + + "requestPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS", + "reason": "ceshi" + }, + { + "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION", + "reason": "ceshi" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.CLEAN_APPLICATION_DATA", + "reason":"need use ohos.permission.CLEAN_APPLICATION_DATA" + } + ] + } +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..d75325f3cf0a50c1dfe4dbc5162c8737276c3dd9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/signature/openharmony_sx.p7b b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_100/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/app.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..3af7577046c529ec844fd187c327d9fe488f38d9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actsspecifieduseractionextensiononetest", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon" : "$media:icon", + "label" : "$string:app_name", + "description" : "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 8, + "targetAPIVersion": 8, + "car": { + "apiCompatibleVersion": 8, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..be09cccde1bc7369ef47a5cd45d2b06884c88602 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/BUILD.gn b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..35bca596beb835dee6ad6f26c3ce5c1b7b041021 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsSpecifiedUserActionextensiononeTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":actsspecifieduseractionextensiononetest_js_assets", + ":actsspecifieduseractionextensiononetest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsSpecifiedUserActionextensiononeTest" +} + +ohos_app_scope("actsspecifieduseractionextensiononetest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsspecifieduseractionextensiononetest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsspecifieduseractionextensiononetest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsspecifieduseractionextensiononetest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/Test.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..5d1c66eefeac2d13af908ec2f887c34692d5a311 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/Test.json @@ -0,0 +1,61 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.example.actsspecifieduseractionextensiononetest", + "shell-timeout": "300000" + }, + "kits": [ + { + "type": "ShellKit", + "run-command": [ + "acm create -n 101 -t normal", + "acm create -n 102 -t normal", + "acm switch -i 101" + ], + "teardown-command":[ + "acm delete -i 101", + "acm delete -i 102" + ] + }, + { + "test-file-name": [ + "ActsSpecifiedUserActionextensiononeTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsSpecifiedUserActionextensiononeTest.hap->/system/app/ActsSpecifiedUserActionextensiononeTest.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "acm switch -i 100" + ] + }, + + { + "type": "PushKit", + "push": [ + "ActsSpecifiedUserActionextensionZeroTest.hap->/system/app/ActsSpecifiedUserActionextensionZeroTest.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "acm switch -i 101" + ] + } + ] +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..9c18cb44c374b23ff545fc0b62982cdf69024ab9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,24 @@ +/* + * 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.stageContext = this.context; + globalThis.startnum = 0; + console.log("MyAbilityStage finish") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..8be28c127eab8f0e5bf9522ea34f0817021db14c --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,51 @@ +/* + * 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 Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility onCreate"); + globalThis.abilityWant = want; + globalThis.abilityContext = this.context + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility onDestroy"); + } + + 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() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy"); + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground"); + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground"); + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..ea606f68626946be6167c55ca8a9b745b19c21f5 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,58 @@ +/* + * 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 Ability from '@ohos.application.Ability' +import commonEvent from '@ohos.commonEvent' +function PublishCallBackOne() { + console.debug("====>Publish CallBack ACTS_STAWA_CommonEvent====>"); + console.debug("====>close this context====>") + globalThis.ability2Context.terminateSelf(); +} + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility2 onCreate") + + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility2 onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("MainAbility2 onWindowStageCreate") + globalThis.ability2Context = this.context + windowStage.setUIContent(this.context, "pages/index", null) + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent", PublishCallBackOne); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..dcaee00d3aa99d05921fddbf011cad0f8ff44646 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,144 @@ +/* + * 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import rpc from '@ohos.rpc'; +class Stub extends rpc.RemoteObject { + constructor(des) { + super(des); + } + // process client's request + onRemoteRequest(code, data, reply, option) { + reply.writeNoException(); + reply.writeString("success"); + return true; + } +} + +function onConnectCallback(element) { + console.log('connectAbilityWithAccount onConnect element.bundleName : ' + element.bundleName) + console.log('connectAbilityWithAccount onConnect element.abilityName : ' + element.abilityName) +} + +function onDisconnectCallback(element) { + console.log('connectAbilityWithAccount onDisconnect element.bundleName : ' + element.bundleName) + console.log('connectAbilityWithAccount onDisconnect element.abilityName : ' + element.abilityName) +} + +function onFailedCallback(code) { + console.log('connectAbilityWithAccount onFailed errCode : ' + code) +} + +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility onCreate'); + } + onDestory(){ + console.log('ServiceAbility onDestory'); + } + onRequest(want,startId) { + console.log('ServiceAbility onRequest'); + } + + onConnect(want) { + console.log('ServiceAbility onConnect'); + console.log('globalThis.startnum is ' + globalThis.startnum); + + switch (globalThis.startnum) { + case 1: + console.log('ServiceAbility case 1'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.MainAbility2' + },100, { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_StartServiceAbilityWithAccount_0200 ====>success!") + }) + console.debug("====>case 1 end====>"); + var myStub = new Stub("com.example.actsspecifieduseractionextensiononetest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + break; + + case 2: + console.log('ServiceAbility case 2'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2' + }, globalThis.ACCOUNT_ID100).then((data) => { + console.log("====>end ACTS_StartServiceAbilityWithAccount_0800====>success!"+ JSON.stringify(data)) + }) + console.debug("====>case 3 end====>"); + var myStub = new Stub("com.example.actsspecifieduseractionextensiononetest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + + case 3: + console.log('ServiceAbility case 3'); + this.context.connectAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsspecifieduseractionextensionzerotest.ServiceAbility2' + }, globalThis.ACCOUNT_ID100, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback, + },) + console.debug("====>case 5 end====>"); + var myStub = new Stub("com.example.actsspecifieduseractionextensiononetest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 4: + console.log('ServiceAbility case 4'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensiononetest', + abilityName: 'com.example.actsspecifieduseractionextensiononetest.ServiceAbility2' + },globalThis.ACCOUNT_ID101,((err, data) => { + console.log("====>end ACTS_StartServiceAbilityWithAccount_1000====>fail!!!"+ JSON.stringify(err)) + console.log("====>end ACTS_StartServiceAbilityWithAccount_1000====>sunccess!"+ JSON.stringify(data)) + })) + break; + case 5: + console.log('ServiceAbility case 5'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionextensiononetest', + abilityName: 'com.example.actsspecifieduseractionextensiononetest.ServiceAbility2' + }, globalThis.ACCOUNT_ID101,((err, data) => { + console.log("====>end ACTS_StartServiceAbilityWithAccount_0400====>fail!!!"+ JSON.stringify(err)) + console.log("====>end ACTS_StartServiceAbilityWithAccount_0400====>sunccess!"+ JSON.stringify(data)) + })) + break; + default: + console.log("====> ServiceAbility end default =====>") + break; + } + } + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..383f9f0ebefc00d5761c83f88fcd1ba6c9500cd1 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,11 @@ +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..bedb302158f3ca7dc5fcda757bbca056c27a63e3 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -0,0 +1,52 @@ +/* + * 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import Want from '@ohos.application.Want'; +import commonEvent from "@ohos.commonEvent" +import rpc from '@ohos.rpc'; + +export default class ServiceAbility2 extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility2 onCreate'); + globalThis.abilityWant = want; + } + + onDestory(){ + console.log('ServiceAbility2 onDestory'); + } + + onRequest(want,startId) { + console.log('ServiceAbility2 onRequest'); + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => { + console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback") + this.context.terminateSelf(); + console.log("====> terminateSelf End=====>") + }); + } + + onConnect(want: Want) { + console.log('ServiceAbility2 onConnect'); + return new rpc.RemoteObject('connect'); + } + + onDisconnect(want) { + console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility2 onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/service.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..383f9f0ebefc00d5761c83f88fcd1ba6c9500cd1 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/service.ts @@ -0,0 +1,11 @@ +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..43f30ae365e727a0006bc0bba273e6efff796f19 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,49 @@ +/* + * 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 file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" +import testsuite from "../../test/List.test.ets" +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + console.info("subscribeEvent run !!!!") + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + 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/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/pages/second/second.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/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/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..d3d0aa53ec04ecc53f00d466ce0faef386270730 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,461 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import commonEvent from '@ohos.commonEvent' +import osaccount from '@ohos.account.osAccount' + + +var ACTS_ABILITYCONTEX = { + events: ["ABILITYCONTEX_Start_CommonEvent"] +}; + +const START_ABILITY_TIMEOUT = 3000; +console.debug("====>in Ability.test====>"); + +export default function abilityTest(abilityContext) { + console.debug("====>in ACTS_InterfaceMultiUsers====>"); + describe('ACTS_StartService', function () { + beforeAll(function(done) { + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + osAccountManager.activateOsAccount(100, (err)=>{ + console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err)); + setTimeout(()=>{ + osAccountManager.queryActivatedOsAccountIds((err,data1)=>{ + console.debug("====>getOsAccountLocalIdFromProcess100" + " err:" + JSON.stringify(err)); + console.debug("====>getOsAccountLocalIdFromProcess100" + " data:" + JSON.stringify(data1)); + globalThis.ACCOUNT_ID100 = data1[0]; + osAccountManager.activateOsAccount(101, (err)=>{ + console.debug("====>activateOsAccount localId: 101 err:" + JSON.stringify(err)); + setTimeout(()=>{ + osAccountManager.queryActivatedOsAccountIds((err,data2)=>{ + console.debug("====>getOsAccountLocalIdFromProcess101" + " err:" + JSON.stringify(err)); + console.debug("====>getOsAccountLocalIdFromProcess101" + " data:" + JSON.stringify(data2)); + globalThis.ACCOUNT_ID101 = data2[0]; + osAccountManager.activateOsAccount(102, (err)=>{ + console.debug("====>activateOsAccount localId: 102 err:" + JSON.stringify(err)); + osAccountManager.queryActivatedOsAccountIds((err,data3)=>{ + console.debug("====>getOsAccountLocalIdFromProcess102" + " err:" + JSON.stringify(err)); + console.debug("====>getOsAccountLocalIdFromProcess102" + " data:" + JSON.stringify(data3)); + globalThis.ACCOUNT_ID102 = data3[0]; + osAccountManager.activateOsAccount(101, (err)=>{ + console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err)); + done(); + }) + }) + }) + }) + },3000) + }) + }) + },3000) + }) + }) + + /* + * @tc.number : ACTS_StartServiceAbilityWithAccount_0200 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * the specified user is not equal to the current user, + * and the user's task list exists, call Promise + */ + it('ACTS_StartServiceAbilityWithAccount_0200', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 1; + console.info('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.info("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.info("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.info("====>err is====>" + JSON.stringify(err)); + }) + console.info('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 3000) + } + + function onConnectCallback(element, remote) { + console.info('ACTS_StartServiceAbilityWithAccount_0200 onConnectCallback====> element=' + JSON.stringify(element)); + console.info('ACTS_StartServiceAbilityWithAccount_0200 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.info('====>in timeout'); + console.log("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.log('ACTS_StartServiceAbilityWithAccount_0200 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('ACTS_StartServiceAbilityWithAccount_0200 onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('ACTS_StartServiceAbilityWithAccount_0200 onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.log("====>ACTS_StartServiceAbilityWithAccount_0200 Create Subscriber====>"); + // data.getSubscribeInfo().then(async (SubscribeInfo) => { + // console.log("====>ACTS_StartServiceAbilityWithAccount_0200 SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); + Subscriber = data; + console.log("====>ACTS_StartServiceAbilityWithAccount_0200 0200start subscribe====>"); + commonEvent.subscribe(Subscriber, SubscribeCallBack); + console.log("====>ACTS_StartServiceAbilityWithAccount_0200 0200start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensiononetest', + abilityName: 'com.example.actsspecifieduseractionextensiononetest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback, + }) + console.log("====>number is====>" + JSON.stringify(globalThis.number)); + // }) + }) + }) + + /* + * @tc.number : ACTS_StartServiceAbilityWithAccount_0800 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * the specified user is not equal to the current user, + * and the user's task list exists, call Promise + */ + it('ACTS_StartServiceAbilityWithAccount_0800', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 2; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0800 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 3000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_StartServiceAbilityWithAccount_0800 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_StartServiceAbilityWithAccount_0800 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_StartServiceAbilityWithAccount_0800 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0800start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensiononetest', + abilityName: 'com.example.actsspecifieduseractionextensiononetest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ConnectServiceAbilityWithAccount_0200 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * the specified user is not equal to the current user, + * and the user's task list exists + */ + it('ACTS_ConnectServiceAbilityWithAccount_0200', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 3; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>ACTS_ConnectServiceAbilityWithAccount_0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>ACTS_ConnectServiceAbilityWithAccount_0200 UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>ACTS_ConnectServiceAbilityWithAccount_0200 disconnectAbility finish'); + setTimeout(() => { + done(); + }, 3000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ConnectServiceAbilityWithAccount_0200 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ConnectServiceAbilityWithAccount_0200 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>ACTS_ConnectServiceAbilityWithAccount_0200 in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ConnectServiceAbilityWithAccount_0200 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('ACTS_ConnectServiceAbilityWithAccount_0200 onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('ACTS_ConnectServiceAbilityWithAccount_0200 onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("====>ACTS_ConnectServiceAbilityWithAccount_0200 Create Subscriber====>"); + data.getSubscribeInfo().then(async (SubscribeInfo) => { + console.debug("====>ACTS_ConnectServiceAbilityWithAccount_0200 SubscribeInfo is====>" + JSON.stringify(SubscribeInfo)); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + console.debug("====>ACTS_ConnectServiceAbilityWithAccount_0200 0200start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensiononetest', + abilityName: 'com.example.actsspecifieduseractionextensiononetest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>ACTS_ConnectServiceAbilityWithAccount_0200 number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_StartServiceAbilityWithAccount_1000 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user is equal to the current user, + * and the user's task list exists, call AsyncCallback + */ + it('ACTS_StartServiceAbilityWithAccount_1000', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 4; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>1000 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 3000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_StartServiceAbilityWithAccount_1000 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_StartServiceAbilityWithAccount_1000 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_StartServiceAbilityWithAccount_1000 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>1000start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensiononetest', + abilityName: 'com.example.actsspecifieduseractionextensiononetest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_StartServiceAbilityWithAccount_0400 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user is equal to the current user, + * and the user's task list exists, call AsyncCallback + */ + it('ACTS_StartServiceAbilityWithAccount_0400', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 5; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0400 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_StartServiceAbilityWithAccount_0400 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_StartServiceAbilityWithAccount_0400 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_StartServiceAbilityWithAccount_0400 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0400start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsspecifieduseractionextensiononetest', + abilityName: 'com.example.actsspecifieduseractionextensiononetest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..4436395534f304976110ce8ce85ca2e7ac9984f4 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,23 @@ +/* + * 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 abilityTest from './Ability.test.ets' + + +export default function testsuite(context) { + + console.debug("====>in list.test====>"); + abilityTest(context) + +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/module.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..3b963d0c7cc3048040d7dd89c4c50d2b534ef801 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/module.json @@ -0,0 +1,131 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.example.actsspecifieduseractionextensiononetest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.actsspecifieduseractionextensiononetest.MainAbility2", + "srcEntrance": "./ets/MainAbility2/MainAbility2.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "name": "com.example.actsspecifieduseractionextensiononetest.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + }, + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.example.actsspecifieduseractionextensiononetest.ServiceAbility2", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ], + + "requestPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS", + "reason": "ceshi" + }, + { + "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION", + "reason": "ceshi" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.CLEAN_APPLICATION_DATA", + "reason":"need use ohos.permission.CLEAN_APPLICATION_DATA" + } + ] + } +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..d75325f3cf0a50c1dfe4dbc5162c8737276c3dd9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/signature/openharmony_sx.p7b b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserActionExtension_101/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/app.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..51a7178ef9945ef296bbb58c0ec19f2f3ccaae7a --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actsspecifieduseractionzerotest", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon" : "$media:icon", + "label" : "$string:app_name", + "description" : "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 8, + "targetAPIVersion": 8, + "car": { + "apiCompatibleVersion": 8, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..be09cccde1bc7369ef47a5cd45d2b06884c88602 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/BUILD.gn b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..2f4eac94fd97eec421a600dc27cd69c2eea21f1e --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsSpecifiedUserActionZeroTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":actsspecifieduseractionzerotest_js_assets", + ":actsspecifieduseractionzerotest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsSpecifiedUserActionZeroTest" +} + +ohos_app_scope("actsspecifieduseractionzerotest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsspecifieduseractionzerotest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsspecifieduseractionzerotest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsspecifieduseractionzerotest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/Test.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..50653b9cfccaae4dfeadb0669ca6c3d6a07ab271 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/Test.json @@ -0,0 +1,50 @@ + +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.example.actsspecifieduseractionzerotest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsSpecifiedUserActionZeroTest.hap", + "ActsSpecifiedUserActiononeTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "PushKit", + "push": [ + "ActsSpecifiedUserActionZeroTest.hap->/system/app/ActsSpecifiedUserActionZeroTest.hap"] + }, + { + "type": "ShellKit", + "run-command": [ + "acm create -n 101 -t normal", + "acm create -n 102 -t normal", + "acm switch -i 101" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsSpecifiedUserActiononeTest.hap->/system/app/ActsSpecifiedUserActiononeTest.hap"] + }, + { + "type": "ShellKit", + "run-command": [ + "acm switch -i 100" + ], + "teardown-command":[ + "acm delete -i 101", + "acm delete -i 102" + ] + } + +] +} + diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..08dee12306de669ae4e52f53c5234d98461148f4 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,23 @@ +/* + * 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..69a9a4bac10f41ef5d60cbc5bb1aa90f85d7dc50 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/MainAbility/MainAbility.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 MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + 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) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..209189314ea2c328102dbee3a923d99b898447a8 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,57 @@ +/* + * 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' +import commonEvent from '@ohos.commonEvent' +function PublishCallBackOne() { + console.debug("====>Publish CallBack ACTS_STAWA_CommonEvent====>"); + console.debug("====>close this context====>") + globalThis.ability2Context.terminateSelf(); +} +export default class MainAbility2 extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility2 onCreate") + + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility2 onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("MainAbility2 onWindowStageCreate") + globalThis.ability2Context = this.context + windowStage.setUIContent(this.context, "pages/index", null) + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent", PublishCallBackOne); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..8941ea468ec094392a23a0ea114f227fcddf128d --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -0,0 +1,66 @@ +/* + * 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import commonEvent from "@ohos.commonEvent" +import rpc from '@ohos.rpc'; +class Stub extends rpc.RemoteObject { + constructor(des) { + super(des); + } + // process client's request + onRemoteRequest(code, data, reply, option) { + reply.writeNoException(); + reply.writeString("success"); + return true; + } +} +export default class ServiceAbility2 extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility2 onCreate'); + globalThis.abilityWant = want; + } + + onDestory(){ + console.log('ServiceAbility2 onDestory'); + } + + onRequest(want,startId) { + console.log('ServiceAbility2 onRequest'); + } + + onConnect(want) { + console.log('ServiceAbility2 onConnect'); + if (want.action == 'StartAbilityPromise') { + console.log('stub StartAbilityPromise OnConnect start '); + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => { + console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback") + console.log("====> StartAbilityPromise End=====>") + }); + + var myStub = new Stub("com.example.actsspecifieduseractionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + } + } + + onDisconnect(want) { + console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility2 onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/service.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..b4e93f63e685c503c43c7e9ba6a88c3ba155fcfa --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/service.ts @@ -0,0 +1,26 @@ +/* + * 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. + */ + +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..ae1248c48c93d453fcd7eda5a426fcb47cbe59c0 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,49 @@ +/* + * 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 file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" +import testsuite from "../../test/List.test.ets" +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + console.info("subscribeEvent run !!!!") + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + 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/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/pages/second/second.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/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/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..72baf47de53d1392864356c566692a78e02d9ff6 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,22 @@ +/* + * 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 abilityTest from './abilityTest.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/test/abilityTest.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/test/abilityTest.ets new file mode 100755 index 0000000000000000000000000000000000000000..7951c6ae3b79bac98003419005f88ba92e796fb9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/test/abilityTest.ets @@ -0,0 +1,935 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import commonEvent from '@ohos.commonEvent'; +import osaccount from '@ohos.account.osAccount' + +var ACTS_ABILITYCONTEX = { + events: ["ABILITYCONTEX_Start_CommonEvent"] +}; +var ACCOUNT_ID100; +var ACCOUNT_ID101; +var ACCOUNT_ID102; + +const START_ABILITY_TIMEOUT = 3000; +export default function abilityTest(abilityContext) { + describe('ACTS_AbilityContext', function () { + beforeAll(function(done) { + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + osAccountManager.activateOsAccount(100, (err)=>{ + console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err)); + setTimeout(()=>{ + osAccountManager.queryActivatedOsAccountIds((err,data1)=>{ + console.debug("====>getOsAccountLocalIdFromProcess100" + " err:" + JSON.stringify(err)); + console.debug("====>getOsAccountLocalIdFromProcess100" + " data:" + JSON.stringify(data1)); + ACCOUNT_ID100 = data1[0]; + osAccountManager.activateOsAccount(101, (err)=>{ + console.debug("====>activateOsAccount localId: 101 err:" + JSON.stringify(err)); + setTimeout(()=>{ + osAccountManager.queryActivatedOsAccountIds((err,data2)=>{ + console.debug("====>getOsAccountLocalIdFromProcess101" + " err:" + JSON.stringify(err)); + console.debug("====>getOsAccountLocalIdFromProcess101" + " data:" + JSON.stringify(data2)); + ACCOUNT_ID101 = data2[0]; + osAccountManager.activateOsAccount(102, (err)=>{ + console.debug("====>activateOsAccount localId: 102 err:" + JSON.stringify(err)); + osAccountManager.queryActivatedOsAccountIds((err,data3)=>{ + console.debug("====>getOsAccountLocalIdFromProcess102" + " err:" + JSON.stringify(err)); + console.debug("====>getOsAccountLocalIdFromProcess102" + " data:" + JSON.stringify(data3)); + ACCOUNT_ID102 = data3[0]; + osAccountManager.activateOsAccount(100, (err)=>{ + console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err)); + done(); + }) + }) + }) + }) + },3000) + }) + }) + },3000) + }) + }) + + + /* + * @tc.number: ACTS_StartStandardAbilityWithAccount_0100 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, + * call the AbilityContext::startAbilityWithAccount interface of + * Promise (with the StartOptions parameter) to start Ability. + */ + it('ACTS_StartStandardAbilityWithAccount_0100', 0, async function (done) { + console.log("ACTS_StartStandardAbilityWithAccount_0100====>start") + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityWithAccount_0100====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>ACTS_StartStandardAbilityWithAccount_0100 UnSubscribeCallback====>"); + setTimeout(function(){ + done(); + },2000) + } + + function timeout() { + if(flag == false) { + expect().assertFail(); + console.debug('ACTS_StartStandardAbilityWithAccount_0100 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility2' + },ACCOUNT_ID100, + { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_StartStandardAbilityWithAccount_0100====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityWithAccount_0300 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), + * call the AbilityContext::startAbilityWithAccount interface of + * Promise (with the StartOptions parameter) to start Ability. + */ + it('ACTS_StartStandardAbilityWithAccount_0300', 0, async function (done) { + console.log("ACTS_StartStandardAbilityWithAccount_0300 ====> start") + + function timeout() { + console.debug('ACTS_StartStandardAbilityWithAccount_0300 ====> timeout'); + done(); + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility12' + },ACCOUNT_ID102, + { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_StartStandardAbilityWithAccount_0300====>success!"+ JSON.stringify(data)) + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityWithAccount_0500 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the AbilityContext::startAbilityWithAccount interface + * of AsyncCallback (with the StartOptions parameter) to start Ability. + */ + it('ACTS_StartStandardAbilityWithAccount_0500', 0, async function (done) { + console.log("ACTS_StartStandardAbilityWithAccount_0500 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0500 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityWithAccount_0500====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_StartStandardAbilityWithAccount_0500 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractiononetest', + abilityName: 'com.example.actsspecifieduseractiononetest.MainAbility2' + },ACCOUNT_ID101, { + windowMode: 2, + displayId: 1 + }, ((err, data) => { + console.log("====>end ACTS_StartStandardAbilityWithAccount_0500====>success!!!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityWithAccount_0600 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), call the + * AbilityContext::startAbilityWithAccount interface of + * AsyncCallback (with the StartOptions parameter) to start the Ability. + */ + it('ACTS_StartStandardAbilityWithAccount_0600', 0, async function (done) { + console.log("ACTS_StartStandardAbilityWithAccount_0600 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0600 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityWithAccount_0600====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_StartStandardAbilityWithAccount_0600 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility2' + },ACCOUNT_ID102, { + windowMode: 2, + displayId: 1 + }, ((err, data) => { + console.log("====>end ACTS_StartStandardAbilityWithAccount_0600====>success!!!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityWithAccount_0700 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, call the + * AbilityCont. + * ext::startAbilityWithAccount interface of Promise (without the StartOptions parameter) + * to start Ability. + */ + it('ACTS_StartStandardAbilityWithAccount_0700', 0, async function (done) { + console.log("ACTS_StartStandardAbilityWithAccount_0700 ====> start") + + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>0700 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityWithAccount_0700====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>ACTS_StartStandardAbilityWithAccount_0700 UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false) { + expect().assertFail(); + console.debug('ACTS_StartStandardAbilityWithAccount_0700 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility2' + },ACCOUNT_ID100).then((data) => { + console.log("====>end ACTS_StartStandardAbilityWithAccount_0700====>success!"+ JSON.stringify(data)) + }) + }) + + + /** + * @tc.number: ACTS_StartStandardAbilityWithAccount_0900 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), call + * the AbilityContext::startAbilityWithAccount interface of + * Promise (without the StartOptions parameter) to start the Ability. + */ + it('ACTS_StartStandardAbilityWithAccount_0900', 0, async function (done) { + console.log("ACTS_StartStandardAbilityWithAccount_0900 ====> start") + + var Subscriber; + + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0900 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityWithAccount_0900====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_StartStandardAbilityWithAccount_0900 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility2' + },ACCOUNT_ID102).then((data) => { + console.log("====>end ACTS_StartStandardAbilityWithAccount_0900====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityWithAccount_1100 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, call the + * AbilityContext::startAbilityWithAccount interface of + * AsyncCallback (without the StartOptions parameter) to start the Ability. + */ + it('ACTS_StartStandardAbilityWithAccount_1100', 0, async function (done) { + console.log("ACTS_StartStandardAbilityWithAccount_1100 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>1100 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityWithAccount_1100====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_StartStandardAbilityWithAccount_1100 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractiononetest', + abilityName: 'com.example.actsspecifieduseractiononetest.MainAbility2' + },ACCOUNT_ID101, ((err, data) => { + console.log("====>end ACTS_StartStandardAbilityWithAccount_1100====>success!!!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityWithAccount_1200 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), call the + * AbilityContext::startAbilityWithAccount interface of + * AsyncCallback (without the StartOptions parameter) to start the Ability. + */ + it('ACTS_StartStandardAbilityWithAccount_1200', 0, async function (done) { + console.log("ACTS_StartStandardAbilityWithAccount_1200 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>1200 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityWithAccount_1200====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_StartStandardAbilityWithAccount_1200 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility2' + },ACCOUNT_ID102,((err, data) => { + console.log("====>end ACTS_StartStandardAbilityWithAccount_1200====>success!!!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityForResultWithAccount_0100 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, + * call the Promise's AbilityContext::startAbilityForResultWithAccount + * (with the StartOptions parameter) interface to start Ability. + */ + it('ACTS_StartStandardAbilityForResultWithAccount_0100', 0, async function (done) { + console.log("ACTS_StartStandardAbilityForResultWithAccount_0100 ====> start") + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityForResultWithAccount_0100====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>ACTS_StartStandardAbilityForResultWithAccount_0100 UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false){ + expect().assertFail(); + console.debug('ACTS_StartStandardAbilityForResultWithAccount_0100 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsspecifieduseractiononetest', + abilityName: 'com.example.actsspecifieduseractiononetest.MainAbility2' + }, ACCOUNT_ID100, + { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_StartStandardAbilityForResultWithAccount_0100====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityForResultWithAccount_0300 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), + * call the AbilityContext::startAbilityForResultWithAccount (with the StartOptions parameter) + * interface of Promise to start Ability. + */ + it('ACTS_StartStandardAbilityForResultWithAccount_0300', 0, async function (done) { + console.log("ACTS_StartStandardAbilityForResultWithAccount_0300 ====> start") + + function timeout() { + console.debug('ACTS_StartStandardAbilityForResultWithAccount_0300 ====> timeout'); + done(); + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility2' + },ACCOUNT_ID102, + { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_StartStandardAbilityForResultWithAccount_0300====>success!"+ JSON.stringify(data)) + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityForResultWithAccount_0500 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, call the + * AsyncCallback's AbilityContext::startAbilityForResultWithAccount (with the StartOptions parameter) + * interface to start Ability. + */ + it('ACTS_StartStandardAbilityForResultWithAccount_0500', 0, async function (done) { + console.log("ACTS_StartStandardAbilityForResultWithAccount_0500 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0500 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityForResultWithAccount_0500====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_StartStandardAbilityForResultWithAccount_0500 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsspecifieduseractiononetest', + abilityName: 'com.example.actsspecifieduseractiononetest.MainAbility2' + }, ACCOUNT_ID101, + { + windowMode: 2, + displayId: 1 + }, ((err, data) => { + console.log("ACTS_StartStandardAbilityForResultWithAccount_0500 === success!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityForResultWithAccount_0600 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), call the + * AbilityContext::startAbilityForResultWithAccount (with the StartOptions parameter) interface of + * AsyncCallback to start the Ability. + */ + it('ACTS_StartStandardAbilityForResultWithAccount_0600', 0, async function (done) { + console.log("ACTS_StartStandardAbilityForResultWithAccount_0600 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0600 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityForResultWithAccount_0600====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + + console.debug('ACTS_StartStandardAbilityForResultWithAccount_0600 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility2' + }, ACCOUNT_ID102, + { + windowMode: 2, + displayId: 1 + }, ((err, data) => { + console.log("ACTS_StartStandardAbilityForResultWithAccount_0600 === success!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityForResultWithAccount_0700 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, + * call the Promise's AbilityContext::startAbilityForResultWithAccount + * (without the StartOptions parameter) interface to start the Ability. + */ + it('ACTS_StartStandardAbilityForResultWithAccount_0700', 0, async function (done) { + console.log("ACTS_StartStandardAbilityForResultWithAccount_0700 ====> start") + + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>0700 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityForResultWithAccount_0700====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false) + { + expect().assertFail(); + console.debug('ACTS_StartStandardAbilityForResultWithAccount_0700 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsspecifieduseractiononetest', + abilityName: 'com.example.actsspecifieduseractiononetest.MainAbility2' + }, ACCOUNT_ID100).then((data) => { + console.log("====>end ACTS_StartStandardAbilityForResultWithAccount_0700====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityForResultWithAccount_0900 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), call the + * AbilityContext::startAbilityForResultWithAccount (no StartOptions parameter) interface of + * Promise to start Ability. + */ + it('ACTS_StartStandardAbilityForResultWithAccount_0900', 0, async function (done) { + console.log("ACTS_StartStandardAbilityForResultWithAccount_0900 ====> start") + + function timeout() { + console.debug('ACTS_StartStandardAbilityForResultWithAccount_0900 ====> timeout'); + done(); + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility2' + },ACCOUNT_ID102).then((data) => { + console.log("====>end ACTS_StartStandardAbilityForResultWithAccount_0900====>success!"+ JSON.stringify(data)) + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityForResultWithAccount_1100 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the AsyncCallback's + * AbilityContext::startAbilityForResultWithAccount (without the StartOptions parameter) interface + * to start the Ability. + */ + it('ACTS_StartStandardAbilityForResultWithAccount_1100', 0, async function (done) { + console.log("ACTS_StartStandardAbilityForResultWithAccount_1100 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>1100 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityForResultWithAccount_1100====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_StartStandardAbilityForResultWithAccount_1100 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsspecifieduseractiononetest', + abilityName: 'com.example.actsspecifieduseractiononetest.MainAbility2' + }, ACCOUNT_ID101, ((err, data) => { + console.log("ACTS_StartStandardAbilityForResultWithAccount_1100 === success!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityForResultWithAccount_1200 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), + * call the AbilityContext::startAbilityForResultWithAccount (no StartOptions parameter) + * interface of AsyncCallback to start Ability. + */ + it('ACTS_StartStandardAbilityForResultWithAccount_1200', 0, async function (done) { + console.log("ACTS_StartStandardAbilityForResultWithAccount_1200 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>1200 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityForResultWithAccount_1200====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility2' + }, ACCOUNT_ID102, ((err, data) => { + console.log("ACTS_StartStandardAbilityForResultWithAccount_1200 === success!" + JSON.stringify(data)) + })) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_StartStandardAbilityForResultWithAccount_1200 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /** + * @tc.number: ACTS_ConnectStandardAbilityWithAccount_0100 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is equal to the current user and the user's task list exists, + * call the AbilityContext::connectAbilityWithAccount interface to connect to Ability. + */ + it('ACTS_ConnectStandardAbilityWithAccount_0100', 0, async function (done) { + console.log("ACTS_ConnectStandardAbilityWithAccount_0100====>start") + var Subscriber; + var flag = true; + var number = 0; + + function onConnectCallback(element, remote) { + console.log('ACTS_ConnectStandardAbilityWithAccount_0100 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ConnectStandardAbilityWithAccount_0100 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(()=> { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if(flag == true) { + console.debug('ACTS_ConnectStandardAbilityWithAccount_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>WithAccount 0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + abilityContext.disconnectAbility(number).then((err)=>{ + console.debug("====>err is====>" + JSON.stringify(err)); + }) + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ConnectStandardAbilityWithAccount_0100====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>ACTS_ConnectStandardAbilityWithAccount_0100 UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false) { + expect().assertFail(); + console.debug('ACTS_ConnectStandardAbilityWithAccount_0100 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start connectAbilityWithAccount====>"); + number = await abilityContext.connectAbilityWithAccount({ + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.ServiceAbility2', + action: "StartAbilityPromise" + }, ACCOUNT_ID100,{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + }) + + /** + * @tc.number: ACTS_ConnectStandardAbilityWithAccount_0300 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), + * call the AbilityContext::connectAbilityWithAccount interface to connect the Ability. + */ + it('ACTS_ConnectStandardAbilityWithAccount_0300', 0, async function (done) { + console.log("ACTS_ConnectStandardAbilityWithAccount_0300 ====> start") + var Subscriber; + var flag = true; + var number = 0; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>WithAccount 0300 Subscribe CallBack data:====>" + JSON.stringify(data)); + abilityContext.disconnectAbility(number).then((err)=>{ + console.debug("====>err is====>" + JSON.stringify(err)); + }) + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + function onConnectCallback(element, remote) { + console.log('ACTS_ConnectStandardAbilityWithAccount_0300 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ConnectStandardAbilityWithAccount_0300 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(()=> { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if(flag == true) { + console.debug('ACTS_ConnectStandardAbilityWithAccount_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ConnectStandardAbilityWithAccount_0300====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + console.debug("====>start connectAbilityWithAccount====>"); + number = await abilityContext.connectAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.ServiceAbility2', + action: "StartAbilityPromise" + },ACCOUNT_ID102 ,{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ConnectStandardAbilityWithAccount_0300 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/module.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..c353cc06d91ebac5b8cb4ca3e44cafb450d8b42a --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/module.json @@ -0,0 +1,122 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.example.actsspecifieduseractionzerotest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.actsspecifieduseractionzerotest.MainAbility2", + "srcEntrance": "./ets/MainAbility2/MainAbility2.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.example.actsspecifieduseractionzerotest.ServiceAbility2", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ], + + "requestPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS", + "reason": "ceshi" + }, + { + "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION", + "reason": "ceshi" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.CLEAN_APPLICATION_DATA", + "reason":"need use ohos.permission.CLEAN_APPLICATION_DATA" + } + ] + } +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..d75325f3cf0a50c1dfe4dbc5162c8737276c3dd9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/signature/openharmony_sx.p7b b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_100/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/app.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..9b04e81d77e7570aff3a3af7a9c792358af952ea --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actsspecifieduseractiononetest", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon" : "$media:icon", + "label" : "$string:app_name", + "description" : "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 8, + "targetAPIVersion": 8, + "car": { + "apiCompatibleVersion": 8, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..be09cccde1bc7369ef47a5cd45d2b06884c88602 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/BUILD.gn b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..7ce5fd5bbdd4d24a7d8ab95696ce7b25c68b1ca0 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsSpecifiedUserActiononeTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":actsspecifieduseractiononetest_js_assets", + ":actsspecifieduseractiononetest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsSpecifiedUserActiononeTest" +} + +ohos_app_scope("actsspecifieduseractiononetest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsspecifieduseractiononetest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsspecifieduseractiononetest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsspecifieduseractiononetest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/Test.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..a8c171bda36735c5943541d63d88791a045ab5ea --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/Test.json @@ -0,0 +1,63 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.example.actsspecifieduseractiononetest", + "shell-timeout": "300000" + }, + "kits": [ + { + "type": "ShellKit", + "run-command": [ + "acm create -n 101 -t normal", + "acm create -n 102 -t normal", + "acm switch -i 101" + ] + }, + { + "test-file-name": [ + "ActsSpecifiedUserActiononeTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsSpecifiedUserActiononeTest.hap->/system/app/ActsSpecifiedUserActiononeTest.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "acm switch -i 100" + ] + }, + + { + "type": "PushKit", + "push": [ + "ActsSpecifiedUserActionZeroTest.hap->/system/app/ActsSpecifiedUserActionZeroTest.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "acm switch -i 101" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/*.hap" + ] + } + ] +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..8375d549288c1fc101c0ab596545af9d626118da --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,23 @@ +/* + * 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..69a9a4bac10f41ef5d60cbc5bb1aa90f85d7dc50 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/MainAbility/MainAbility.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 MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + 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) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..6176b8ae0398e0573d77f1d005f1011fa6f323a0 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,57 @@ +/* + * 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' +import commonEvent from '@ohos.commonEvent' +function PublishCallBackOne() { + console.debug("====>Publish CallBack ACTS_STAWA_CommonEvent====>"); + console.debug("====>close this context====>") + globalThis.ability2Context.terminateSelf(); +} + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility2 onCreate") + + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility2 onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("MainAbility2 onWindowStageCreate") + globalThis.ability2Context = this.context + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent", PublishCallBackOne); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..c45bdac905c73438b73d0b7959bd38895327124f --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -0,0 +1,68 @@ +/* + * 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 ServiceExtension from '@ohos.application.ServiceExtensionAbility' +import commonEvent from "@ohos.commonEvent" +import rpc from '@ohos.rpc'; +class Stub extends rpc.RemoteObject { + constructor(des) { + super(des); + } + // process client's request + onRemoteRequest(code, data, reply, option) { + reply.writeNoException(); + reply.writeString("success"); + return true; + } +} +export default class ServiceAbility2 extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility2 onCreate'); + globalThis.abilityWant = want; + } + + onDestory(){ + console.log('ServiceAbility2 onDestory'); + } + + onRequest(want,startId) { + console.log('ServiceAbility2 onRequest'); + } + + onConnect(want) { + let extensionContext = this.context + console.log('ServiceAbility2 onConnect'); + if (want.action == 'StartAbilityPromise') { + console.log('stub StartAbilityPromise OnConnect start '); + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => { + console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback") + extensionContext.terminateSelf(); + console.log("====> StartAbilityPromise End=====>") + }); + + var myStub = new Stub("com.example.actsspecifieduseractiononetest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + } + } + + onDisconnect(want) { + console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility2 onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/service.ts b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..91a83dbc24c50064a2031ddf77606699a059fac9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/service.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..ae1248c48c93d453fcd7eda5a426fcb47cbe59c0 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,49 @@ +/* + * 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 file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" +import testsuite from "../../test/List.test.ets" +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + console.info("subscribeEvent run !!!!") + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + 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/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/pages/second/second.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/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/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..5635f2840894a3a90336344a0d439a5e2942b166 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,22 @@ +/* + * 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 abilityTest from './abilityTest.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/test/abilityTest.ets b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/test/abilityTest.ets new file mode 100755 index 0000000000000000000000000000000000000000..470e2e0f645240b347bea3b4d4f11b653370d7a9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/test/abilityTest.ets @@ -0,0 +1,540 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import commonEvent from '@ohos.commonEvent'; +import osaccount from '@ohos.account.osAccount' + +var ACTS_ABILITYCONTEX = { + events: ["ABILITYCONTEX_Start_CommonEvent"] +}; +var ACCOUNT_ID100; +var ACCOUNT_ID101; +var ACCOUNT_ID102; + +const START_ABILITY_TIMEOUT = 3000; +export default function abilityTest(abilityContext) { + describe('ACTS_AbilityContext', function () { + beforeAll(function(done) { + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + osAccountManager.activateOsAccount(100, (err)=>{ + console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err)); + setTimeout(()=>{ + osAccountManager.queryActivatedOsAccountIds((err,data1)=>{ + console.debug("====>getOsAccountLocalIdFromProcess100" + " err:" + JSON.stringify(err)); + console.debug("====>getOsAccountLocalIdFromProcess100" + " data:" + JSON.stringify(data1)); + ACCOUNT_ID100 = data1[0]; + osAccountManager.activateOsAccount(101, (err)=>{ + console.debug("====>activateOsAccount localId: 101 err:" + JSON.stringify(err)); + setTimeout(()=>{ + osAccountManager.queryActivatedOsAccountIds((err,data2)=>{ + console.debug("====>getOsAccountLocalIdFromProcess101" + " err:" + JSON.stringify(err)); + console.debug("====>getOsAccountLocalIdFromProcess101" + " data:" + JSON.stringify(data2)); + ACCOUNT_ID101 = data2[0]; + osAccountManager.activateOsAccount(102, (err)=>{ + console.debug("====>activateOsAccount localId: 102 err:" + JSON.stringify(err)); + osAccountManager.queryActivatedOsAccountIds((err,data3)=>{ + console.debug("====>getOsAccountLocalIdFromProcess102" + " err:" + JSON.stringify(err)); + console.debug("====>getOsAccountLocalIdFromProcess102" + " data:" + JSON.stringify(data3)); + ACCOUNT_ID102 = data3[0]; + osAccountManager.activateOsAccount(101, (err)=>{ + console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err)); + done(); + }) + }) + }) + }) + },3000) + }) + }) + },3000) + }) + }) + + + /** + * @tc.number: ACTS_StartStandardAbilityWithAccount_0200 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the Promise's AbilityContext::startAbilityWithAccount + * interface (with the StartOptions parameter) to start Ability. + */ + it('ACTS_StartStandardAbilityWithAccount_0200', 0, async function (done) { + console.log("ACTS_StartStandardAbilityWithAccount_0200====>start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityWithAccount_0200====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_StartStandardAbilityWithAccount_0200 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility2' + },ACCOUNT_ID100, + { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_StartStandardAbilityWithAccount_0200====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityWithAccount_0400 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, + * call the AbilityContext::startAbilityWithAccount interface of + * AsyncCallback (with the StartOptions parameter) to start Ability. + */ + it('ACTS_StartStandardAbilityWithAccount_0400', 0, async function (done) { + console.log("ACTS_StartStandardAbilityWithAccount_0400 ====> start") + + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>0400 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityWithAccount_0400====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false){ + expect().assertFail(); + console.debug('ACTS_StartStandardAbilityWithAccount_0400 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + done(); + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractiononetest', + abilityName: 'com.example.actsspecifieduseractiononetest.MainAbility2' + },ACCOUNT_ID101, + { + windowMode: 2, + displayId: 1 + }, ((err, data) => { + console.log("====>end ACTS_StartStandardAbilityWithAccount_0400====>success!!!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityWithAccount_0800 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the Promise's AbilityContext::startAbilityWithAccount + * interface (without the StartOptions parameter) to start the Ability. + */ + it('ACTS_StartStandardAbilityWithAccount_0800', 0, async function (done) { + console.log("ACTS_StartStandardAbilityWithAccount_0800 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0800 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityWithAccount_0800====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_StartStandardAbilityWithAccount_0800 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility2' + },ACCOUNT_ID100).then((data) => { + console.log("====>end ACTS_StartStandardAbilityWithAccount_0800====>success!"+ JSON.stringify(data)) + }) + }) + + + /** + * @tc.number: ACTS_StartStandardAbilityWithAccount_1000 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, call the + * AbilityContext::startAbilityWithAccount interface of + * AsyncCallback (without the StartOptions parameter) to start the Ability. + */ + it('ACTS_StartStandardAbilityWithAccount_1000', 0, async function (done) { + console.log("ACTS_StartStandardAbilityWithAccount_1000 ====> start") + + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>1000 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityWithAccount_1000====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false){ + expect().assertFail(); + console.debug('ACTS_StartStandardAbilityWithAccount_1000 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractiononetest', + abilityName: 'com.example.actsspecifieduseractiononetest.MainAbility2' + },ACCOUNT_ID101, ((err, data) => { + console.log("====>end ACTS_StartStandardAbilityWithAccount_1000====>success!!!" + JSON.stringify(data)) + })) + }) + + + /** + * @tc.number: ACTS_StartStandardAbilityForResultWithAccount_0200 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, call the + * Promise's AbilityContext::startAbilityForResultWithAccount (with the StartOptions parameter) + * interface to start Ability. + */ + it('ACTS_StartStandardAbilityForResultWithAccount_0200', 0, async function (done) { + console.log("ACTS_StartStandardAbilityForResultWithAccount_0200 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityForResultWithAccount_0200====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_StartStandardAbilityForResultWithAccount_0200 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility2' + }, ACCOUNT_ID100, + { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_StartStandardAbilityForResultWithAccount_0200====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityForResultWithAccount_0400 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, call the + * AsyncCallback's AbilityContext::startAbilityForResultWithAccount (with the StartOptions parameter) + * interface to start the Ability. + */ + it('ACTS_StartStandardAbilityForResultWithAccount_0400', 0, async function (done) { + console.log("ACTS_StartStandardAbilityForResultWithAccount_0400 ====> start") + + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>0400 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityForResultWithAccount_0400====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false){ + expect().assertFail(); + console.debug('ACTS_StartStandardAbilityForResultWithAccount_0400 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsspecifieduseractiononetest', + abilityName: 'com.example.actsspecifieduseractiononetest.MainAbility2' + }, ACCOUNT_ID101, + { + windowMode: 2, + displayId: 1 + }, ((err, data) => { + console.log("StartStandardAbilityForResultWithAccount_0400 === success!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityForResultWithAccount_0800 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the Promise's + * AbilityContext::startAbilityForResultWithAccount (without the StartOptions parameter) interface + * to start Ability. + */ + it('ACTS_StartStandardAbilityForResultWithAccount_0800', 0, async function (done) { + console.log("ACTS_StartStandardAbilityForResultWithAccount_0800 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0800 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityForResultWithAccount_0800====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_StartStandardAbilityForResultWithAccount_0800 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.MainAbility2' + }, ACCOUNT_ID100).then((data) => { + console.log("====>end ACTS_StartStandardAbilityForResultWithAccount_0800====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_StartStandardAbilityForResultWithAccount_1000 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the AsyncCallback's + * AbilityContext::startAbilityForResultWithAccount (without the StartOptions parameter) + * interface to start the Ability. + */ + it('ACTS_StartStandardAbilityForResultWithAccount_1000', 0, async function (done) { + console.log("ACTS_StartStandardAbilityForResultWithAccount_1000 ====> start") + var flag = false; + var Subscriber; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>1000 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_StartStandardAbilityForResultWithAccount_1000====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false){ + expect().assertFail(); + console.debug('ACTS_StartStandardAbilityForResultWithAccount_1000 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + + } + } + + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsspecifieduseractiononetest', + abilityName: 'com.example.actsspecifieduseractiononetest.MainAbility2' + }, ACCOUNT_ID101, ((err, data) => { + console.log("ACTS_StartStandardAbilityForResultWithAccount_1000 === success!" + JSON.stringify(data)) + })) + }) + + + /** + * @tc.number: ACTS_ConnectStandardAbilityWithAccount_0200 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the AbilityContext::connectAbilityWithAccount interface to connect the Ability. + */ + it('ACTS_ConnectStandardAbilityWithAccount_0200', 0, async function (done) { + console.log("ACTS_ConnectStandardAbilityWithAccount_0200 ====> start") + var Subscriber; + var flag = true; + var number = 0; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>WithAccount 0300 Subscribe CallBack data:====>" + JSON.stringify(data)); + abilityContext.disconnectAbility(number).then((err)=>{ + console.debug("====>err is====>" + JSON.stringify(err)); + }) + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + function onConnectCallback(element, remote) { + console.log('ACTS_ConnectStandardAbilityWithAccount_0200 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ConnectStandardAbilityWithAccount_0200 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(()=> { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if(flag == true) { + console.debug('ACTS_ConnectStandardAbilityWithAccount_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ConnectStandardAbilityWithAccount_0200====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + console.debug("====>start connectAbilityWithAccount====>"); + number = await abilityContext.connectAbilityWithAccount( + { + bundleName: 'com.example.actsspecifieduseractionzerotest', + abilityName: 'com.example.actsspecifieduseractionzerotest.ServiceAbility2', + action: "StartAbilityPromise" + },ACCOUNT_ID102 ,{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ConnectStandardAbilityWithAccount_0200 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/module.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..d1014c0d76671e6ac62a405d793da2ae7d26cfcb --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/module.json @@ -0,0 +1,110 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.example.actsspecifieduseractiononetest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.actsspecifieduseractiononetest.MainAbility2", + "srcEntrance": "./ets/MainAbility2/MainAbility2.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.example.actsspecifieduseractiononetest.ServiceAbility2", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ], + + "requestPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name":"ohos.permission.REMOVE_CACHE_FILES", + "reason":"need use ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name":"ohos.permission.LISTEN_BUNDLE_CHANGE", + "reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE" + }, + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name":"ohos.permission.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.CLEAN_APPLICATION_DATA", + "reason":"need use ohos.permission.CLEAN_APPLICATION_DATA" + } + ] + } +} diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..d75325f3cf0a50c1dfe4dbc5162c8737276c3dd9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/signature/openharmony_sx.p7b b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/SpecifiedUserAction_101/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/AppScope/app.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..f16afaf4c0d00ded259b49d627075259898d492f --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actsthirdpartyspecifieduseractionextensionzerotest", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon" : "$media:icon", + "label" : "$string:app_name", + "description" : "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 8, + "targetAPIVersion": 8, + "car": { + "apiCompatibleVersion": 8, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..be09cccde1bc7369ef47a5cd45d2b06884c88602 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/BUILD.gn b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..8e7176241cf038ce918dfa022e655f4cfd1118e8 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsThirdPartySpecifiedUserActionextensionZeroTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":thirdpartyspecifieduseractionextension_100_js_assets", + ":thirdpartyspecifieduseractionextension_100_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx_thirdparty.p7b" + hap_name = "ActsThirdPartySpecifiedUserActionextensionZeroTest" +} + +ohos_app_scope("thirdpartyspecifieduseractionextension_100_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("thirdpartyspecifieduseractionextension_100_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("thirdpartyspecifieduseractionextension_100_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":thirdpartyspecifieduseractionextension_100_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/Test.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..0b2c7ac59fce609adeb49e667240969f9028e115 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/Test.json @@ -0,0 +1,49 @@ + +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.actsthirdpartyspecifieduseractionextensionzerotest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsThirdPartySpecifiedUserActionextensionZeroTest.hap", + "ActsThirdPartySpecifiedUserActionextensiononeTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "PushKit", + "push": [ + "ActsThirdPartySpecifiedUserActionextensionZeroTest.hap->/data/ActsThirdPartySpecifiedUserActionextensionZeroTest.hap"] + }, + { + "type": "ShellKit", + "run-command": [ + "acm create -n 101 -t normal", + "acm create -n 102 -t normal", + "acm switch -i 101" + ], + "teardown-command":[ + "acm delete -i 101", + "acm delete -i 102" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsThirdPartySpecifiedUserActionextensiononeTest.hap->/data/ActsThirdPartySpecifiedUserActionextensiononeTest.hap"] + }, + { + "type": "ShellKit", + "run-command": [ + "acm switch -i 100" + ] + } + ] +} + diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..2266bb311cbed90a650faa1cfde49d72b3d314fc --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,24 @@ +/* + * 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.stageContext = this.context; + globalThis.startnum = 0; + console.log("MyAbilityStage finish") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..77038a5e923d6947c4419b4c9f0365e72b2327a7 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility/MainAbility.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 MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility onCreate"); + globalThis.abilityWant = want; + globalThis.abilityContext = this.context + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility onDestroy"); + } + + 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() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy"); + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground"); + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground"); + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..892ee1bfb3bd2e6686d3e2f2d2f617f1730f290e --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,58 @@ +/* + * 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' +import commonEvent from '@ohos.commonEvent' +function PublishCallBackOne() { + console.debug("====>Publish CallBack ACTS_STAWA_CommonEvent====>"); + console.debug("====>close this context====>") + globalThis.ability2Context.terminateSelf(); +} + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility2 onCreate") + + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility2 onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("MainAbility2 onWindowStageCreate") + globalThis.ability2Context = this.context + windowStage.setUIContent(this.context, "pages/index", null) + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent", PublishCallBackOne); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..67c80395b012010c2b45f90feb81296c772703fe --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,202 @@ +/* + * 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import rpc from '@ohos.rpc'; +class Stub extends rpc.RemoteObject { + constructor(des) { + super(des); + } + // process client's request + onRemoteRequest(code, data, reply, option) { + reply.writeNoException(); + reply.writeString("success"); + return true; + } +} +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility onCreate'); + } + onDestory(){ + console.log('ServiceAbility onDestory'); + } + onRequest(want,startId) { + console.log('ServiceAbility onRequest'); + } + + onConnect(want) { + console.log('ServiceAbility onConnect'); + console.log('globalThis.startnum is ' + globalThis.startnum); + + switch (globalThis.startnum) { + case 1: + console.log('ServiceAbility case 1'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility2' + },100 ,{ + windowMode: 2, + displayId: 1 + }).then(() => { + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_0100 ====>success!") + }) + console.debug("====>case 1 end====>"); + var myStub = new Stub("com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 2: + console.log('ServiceAbility case 2'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility2' + },102 ,{ + windowMode: 2, + displayId: 1 + }).then(() => { + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_0300 ====>success!") + }) + console.debug("====>case 2 end====>"); + var myStub = new Stub("com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 3: + console.log('ServiceAbility case 3'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest.MainAbility2' + },101,((err, data) => { + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_0500====>fail!!!"+ JSON.stringify(err)) + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_0500====>sunccess!"+ JSON.stringify(data)) + })) + console.debug("====>case 3 end====>"); + var myStub = new Stub("com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 4: + console.log('ServiceAbility case 4'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility2' + },102, { + windowMode: 2, + displayId: 1 + },((err, data) => { + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_0600====>fail!!!"+ JSON.stringify(err)) + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_0600====>sunccess!"+ JSON.stringify(data)) + })) + console.debug("====>case 4 end====>"); + var myStub = new Stub("com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 5: + console.log('ServiceAbility case 5'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility2' + },100).then((data) => { + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_0700====>success!"+ JSON.stringify(data)) + }) + break; + case 6: + console.log('ServiceAbility case 6'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility2' + },102,((err, data) => { + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_0900====>fail!!!") + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_0900====>sunccess!") + })) + console.debug("====>case 6 end====>"); + var myStub = new Stub("com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 7: + console.log('ServiceAbility case 7'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest.ServiceAbility2' + }, 101,((err, data) => { + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_1100====>fail!!!"+ JSON.stringify(err)) + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_1100====>sunccess!"+ JSON.stringify(data)) + })) + console.debug("====>case 7 end====>"); + var myStub = new Stub("com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 8: + console.log('ServiceAbility case 8'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility2' + }, 102,((err, data) => { + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_1200====>fail!!!"+ JSON.stringify(err)) + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_1200====>sunccess!"+ JSON.stringify(data)) + })) + console.debug("====>case 8 end====>"); + var myStub = new Stub("com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 9: + console.log('ServiceAbility case 9'); + this.context.connectAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility2', + action: "StartAbilityPromise" + }, 100) + break; + case 10: + console.log('ServiceAbility case 10'); + this.context.connectAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility2', + action: "StartAbilityPromise" + },102) + + console.debug("====>case 10 end====>"); + var myStub = new Stub("com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + default: + console.log("====> ServiceAbility end default =====>") + break; + } + } + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..91a83dbc24c50064a2031ddf77606699a059fac9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..c70f0a2d3cfda08ff3f4038d37128a08c013d16a --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -0,0 +1,60 @@ +/* + * 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import Want from '@ohos.application.Want'; +import commonEvent from "@ohos.commonEvent" +import rpc from '@ohos.rpc'; + +export default class ServiceAbility2 extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility2 onCreate'); + globalThis.abilityWant = want; + } + + onDestory(){ + console.log('ServiceAbility2 onDestory'); + } + + onRequest(want,startId) { + console.log('ServiceAbility2 onRequest'); + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => { + console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback") + this.context.terminateSelf(); + console.log("====> terminateSelf End=====>") + }); + } + + onConnect(want: Want) { + console.log('ServiceAbility2 onConnect'); + if (want.action == 'StartAbilityPromise') { + console.log('stub StartAbilityPromise OnConnect start '); + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => { + console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback") + this.context.terminateSelf(); + console.log("====> StartAbilityPromise End=====>") + }); + } + return new rpc.RemoteObject('connect'); + } + + onDisconnect(want) { + console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility2 onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/service.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..91a83dbc24c50064a2031ddf77606699a059fac9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/service.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..ae1248c48c93d453fcd7eda5a426fcb47cbe59c0 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,49 @@ +/* + * 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 file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" +import testsuite from "../../test/List.test.ets" +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + console.info("subscribeEvent run !!!!") + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + 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/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/pages/second/second.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/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/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..59eef0caab38491bb54faeba38a87747871c3e94 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,796 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import commonEvent from '@ohos.commonEvent' + +var ACTS_ABILITYCONTEX = { + events: ["ABILITYCONTEX_Start_CommonEvent"] +}; + +const START_ABILITY_TIMEOUT = 3000; +console.debug("====>in Ability.test====>"); + +export default function abilityTest(abilityContext) { + console.debug("====>in ACTS_ThirdPartyInterfaceMultiUsers====>"); + describe('ACTS_ThirdPartyStartService', function () { + + /* + * @tc.number : ACTS_ThirdPartyStartServiceAbilityWithAccount_0100 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : In multi-user non-concurrent mode, + * the specified user is equal to the current user and the user's task list exists (promise) + */ + it('ACTS_ThirdPartyStartServiceAbilityWithAccount_0100', 0, async function (done) { + let Subscriber + var flag = true; + var startresult = false; + globalThis.startnum = 1; + + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0100 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0100 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ThirdPartyStartServiceAbilityWithAccount_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(() => { + done() + }, 1000) + } + + function timeout() { + console.debug('in ACTS_ThirdPartyStartServiceAbilityWithAccount_0100 timeout'); + if (flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartServiceAbilityWithAccount_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ThirdPartyStartServiceAbilityWithAccount_0300 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user does not have a task list (the user does not exist), call Promise + */ + it('ACTS_ThirdPartyStartServiceAbilityWithAccount_0300', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 2; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0300 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0300 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ThirdPartyStartServiceAbilityWithAccount_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0300start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartServiceAbilityWithAccount_0500 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * the specified user is not equal to the current user, + * and the user's task list exists, call AsyncCallback + */ + it('ACTS_ThirdPartyStartServiceAbilityWithAccount_0500', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 3; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0500 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0500 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0500 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ThirdPartyStartServiceAbilityWithAccount_0500 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0500start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartServiceAbilityWithAccount_0600 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user does not have a task list (the user does not exist), + * call AsyncCallback + */ + it('ACTS_ThirdPartyStartServiceAbilityWithAccount_0600', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 4; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0600 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0600 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0600 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ThirdPartyStartServiceAbilityWithAccount_0600 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0600start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartServiceAbilityWithAccount_0700 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user is equal to the current user, + * and the user's task list exists, call Promise + */ + it('ACTS_ThirdPartyStartServiceAbilityWithAccount_0700', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 5; + + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0700 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0700start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(() => { + done() + }, 1000) + } + + function timeout() { + console.debug('in ACTS_ThirdPartyStartServiceAbilityWithAccount_0700 timeout'); + if (flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartServiceAbilityWithAccount_0700 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ThirdPartyStartServiceAbilityWithAccount_0900 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user does not have a task list (the user does not exist), + * call Promise + */ + it('ACTS_ThirdPartyStartServiceAbilityWithAccount_0900', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 6; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0900 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0900 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0900 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ThirdPartyStartServiceAbilityWithAccount_0900 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0900start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartServiceAbilityWithAccount_1100 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * the specified user is not equal to the current user, + * and the user's task list exists, call AsyncCallback + */ + it('ACTS_ThirdPartyStartServiceAbilityWithAccount_1100', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 7; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>1100 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_1100 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_1100 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ThirdPartyStartServiceAbilityWithAccount_1100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>1100start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartServiceAbilityWithAccount_1200 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user does not have a task list (the user does not exist), + * call AsyncCallback + */ + it('ACTS_ThirdPartyStartServiceAbilityWithAccount_1200', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 8; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>1200 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_1200 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_1200 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ThirdPartyStartServiceAbilityWithAccount_1200 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>1200start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyConnectServiceAbilityWithAccount_0100 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user is equal to the current user and the user's task list exists + */ + it('ACTS_ThirdPartyConnectServiceAbilityWithAccount_0100', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 9; + + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0100 ConnectServiceAbility connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(() => { + done() + }, 1000) + } + + function timeout() { + console.debug('in ACTS_ThirdPartyConnectServiceAbilityWithAccount_0100 timeout'); + if (flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyConnectServiceAbilityWithAccount_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ThirdPartyConnectServiceAbilityWithAccount_0300 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user does not have a task list (the user does not exist) + */ + it('ACTS_ThirdPartyConnectServiceAbilityWithAccount_0300', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 10; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyConnectServiceAbilityWithAccount_0300 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyConnectServiceAbilityWithAccount_0300 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ThirdPartyConnectServiceAbilityWithAccount_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0300 ConnectServiceAbility connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + }) +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..14db1352021eca93318bfef24eaece89517e9ba8 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,23 @@ +/* + * 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 abilityTest from './Ability.test.ets' + + +export default function testsuite(context) { + + console.debug("====>in list.test====>"); + abilityTest(context) + +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/module.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..f64feec0d44b1bbb774746884d7169371eaf4f6a --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/module.json @@ -0,0 +1,76 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility2", + "srcEntrance": "./ets/MainAbility2/MainAbility2.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "name": "com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + }, + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility2", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ] + } +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..d75325f3cf0a50c1dfe4dbc5162c8737276c3dd9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/signature/openharmony_sx_thirdparty.p7b b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/signature/openharmony_sx_thirdparty.p7b new file mode 100755 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_100/signature/openharmony_sx_thirdparty.p7b differ diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/AppScope/app.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..35996253955cb5f742b621ae0f5cef466da66e4e --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actsthirdpartyspecifieduseractionextensiononetest", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon" : "$media:icon", + "label" : "$string:app_name", + "description" : "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 8, + "targetAPIVersion": 8, + "car": { + "apiCompatibleVersion": 8, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..be09cccde1bc7369ef47a5cd45d2b06884c88602 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/BUILD.gn b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..1b2ba86bbd02e8a7255f748dafde04698e4bd027 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsThirdPartySpecifiedUserActionextensiononeTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":thirdpartyspecifieduseractionextension_101_js_assets", + ":thirdpartyspecifieduseractionextension_101_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx_thirdparty.p7b" + hap_name = "ActsThirdPartySpecifiedUserActionextensiononeTest" +} + +ohos_app_scope("thirdpartyspecifieduseractionextension_101_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("thirdpartyspecifieduseractionextension_101_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("thirdpartyspecifieduseractionextension_101_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":thirdpartyspecifieduseractionextension_101_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/Test.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..860ff970b5800d9ce7fb746bc3ee37d070fc76f5 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/Test.json @@ -0,0 +1,62 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.example.actsthirdpartyspecifieduseractionextensiononetest", + "shell-timeout": "300000" + }, + "kits": [ + { + "type": "ShellKit", + "run-command": [ + "acm create -n 101 -t normal", + "acm create -n 102 -t normal", + "acm switch -i 101" + ], + "teardown-command":[ + "acm delete -i 101", + "acm delete -i 102" + ] + }, + { + "test-file-name": [ + "ActsThirdPartySpecifiedUserActionextensiononeTest.hap", + "ActsThirdPartySpecifiedUserActionextensionZeroTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsThirdPartySpecifiedUserActionextensiononeTest.hap->/data/ActsThirdPartySpecifiedUserActionextensiononeTest.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "acm switch -i 100" + ] + }, + + { + "type": "PushKit", + "push": [ + "ActsThirdPartySpecifiedUserActionextensionZeroTest.hap->/data/ActsThirdPartySpecifiedUserActionextensionZeroTest.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "acm switch -i 101" + ] + } + ] +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..9c18cb44c374b23ff545fc0b62982cdf69024ab9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,24 @@ +/* + * 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.stageContext = this.context; + globalThis.startnum = 0; + console.log("MyAbilityStage finish") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..8be28c127eab8f0e5bf9522ea34f0817021db14c --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,51 @@ +/* + * 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 Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility onCreate"); + globalThis.abilityWant = want; + globalThis.abilityContext = this.context + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility onDestroy"); + } + + 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() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy"); + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground"); + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground"); + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..ea606f68626946be6167c55ca8a9b745b19c21f5 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,58 @@ +/* + * 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 Ability from '@ohos.application.Ability' +import commonEvent from '@ohos.commonEvent' +function PublishCallBackOne() { + console.debug("====>Publish CallBack ACTS_STAWA_CommonEvent====>"); + console.debug("====>close this context====>") + globalThis.ability2Context.terminateSelf(); +} + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility2 onCreate") + + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility2 onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("MainAbility2 onWindowStageCreate") + globalThis.ability2Context = this.context + windowStage.setUIContent(this.context, "pages/index", null) + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent", PublishCallBackOne); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..ee262d37bf81cbc5b72dddd5d6865658913d30f8 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,125 @@ +/* + * 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import rpc from '@ohos.rpc'; +class Stub extends rpc.RemoteObject { + constructor(des) { + super(des); + } + // process client's request + onRemoteRequest(code, data, reply, option) { + reply.writeNoException(); + reply.writeString("success"); + return true; + } +} +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility onCreate'); + } + onDestory(){ + console.log('ServiceAbility onDestory'); + } + onRequest(want,startId) { + console.log('ServiceAbility onRequest'); + } + + onConnect(want) { + console.log('ServiceAbility onConnect'); + console.log('globalThis.startnum is ' + globalThis.startnum); + + switch (globalThis.startnum) { + case 1: + console.log('ServiceAbility case 1'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.MainAbility2' + },100, { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_0200 ====>success!") + }) + console.debug("====>case 1 end====>"); + var myStub = new Stub("com.example.actsthirdpartyspecifieduseractionextensiononetest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + break; + + case 2: + console.log('ServiceAbility case 2'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility2' + },100).then((data) => { + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_0800====>success!"+ JSON.stringify(data)) + }) + console.debug("====>case 3 end====>"); + var myStub = new Stub("com.example.actsthirdpartyspecifieduseractionextensiononetest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + + case 3: + console.log('ServiceAbility case 3'); + this.context.connectAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensionzerotest.ServiceAbility2' + },100) + console.debug("====>case 5 end====>"); + var myStub = new Stub("com.example.actsthirdpartyspecifieduseractionextensiononetest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + break; + case 4: + console.log('ServiceAbility case 4'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest.ServiceAbility2' + },101,((err, data) => { + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_1000====>fail!!!"+ JSON.stringify(err)) + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_1000====>sunccess!"+ JSON.stringify(data)) + })) + break; + case 5: + console.log('ServiceAbility case 5'); + this.context.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest.ServiceAbility2' + },101,((err, data) => { + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_0400====>fail!!!"+ JSON.stringify(err)) + console.log("====>end ACTS_ThirdPartyStartServiceAbilityWithAccount_0400====>sunccess!"+ JSON.stringify(data)) + })) + break; + default: + console.log("====> ServiceAbility end default =====>") + break; + } + } + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..383f9f0ebefc00d5761c83f88fcd1ba6c9500cd1 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,11 @@ +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..bedb302158f3ca7dc5fcda757bbca056c27a63e3 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -0,0 +1,52 @@ +/* + * 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import Want from '@ohos.application.Want'; +import commonEvent from "@ohos.commonEvent" +import rpc from '@ohos.rpc'; + +export default class ServiceAbility2 extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility2 onCreate'); + globalThis.abilityWant = want; + } + + onDestory(){ + console.log('ServiceAbility2 onDestory'); + } + + onRequest(want,startId) { + console.log('ServiceAbility2 onRequest'); + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => { + console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback") + this.context.terminateSelf(); + console.log("====> terminateSelf End=====>") + }); + } + + onConnect(want: Want) { + console.log('ServiceAbility2 onConnect'); + return new rpc.RemoteObject('connect'); + } + + onDisconnect(want) { + console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility2 onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/service.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..383f9f0ebefc00d5761c83f88fcd1ba6c9500cd1 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/service.ts @@ -0,0 +1,11 @@ +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..43f30ae365e727a0006bc0bba273e6efff796f19 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,49 @@ +/* + * 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 file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" +import testsuite from "../../test/List.test.ets" +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + console.info("subscribeEvent run !!!!") + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + 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/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/pages/second/second.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/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/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..db58a83983f385ea00fa16df232e07c34ed43c2b --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,402 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import commonEvent from '@ohos.commonEvent' + +var ACTS_ABILITYCONTEX = { + events: ["ABILITYCONTEX_Start_CommonEvent"] +}; + +const START_ABILITY_TIMEOUT = 3000; +console.debug("====>in Ability.test====>"); + +export default function abilityTest(abilityContext) { + console.debug("====>in ACTS_ThirdPartyInterfaceMultiUsers====>"); + describe('ACTS_ThirdPartyStartService', function () { + + /* + * @tc.number : ACTS_ThirdPartyStartServiceAbilityWithAccount_0200 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * the specified user is not equal to the current user, + * and the user's task list exists, call Promise + */ + it('ACTS_ThirdPartyStartServiceAbilityWithAccount_0200', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 1; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0200 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0200 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ThirdPartyStartServiceAbilityWithAccount_0200 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0200start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartServiceAbilityWithAccount_0800 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * the specified user is not equal to the current user, + * and the user's task list exists, call Promise + */ + it('ACTS_ThirdPartyStartServiceAbilityWithAccount_0800', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 2; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0800 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0800 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0800 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ThirdPartyStartServiceAbilityWithAccount_0800 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0800start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyConnectServiceAbilityWithAccount_0200 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * the specified user is not equal to the current user, + * and the user's task list exists + */ + it('ACTS_ThirdPartyConnectServiceAbilityWithAccount_0200', 0, async function (done) { + let Subscriber + var startresult = false + globalThis.startnum = 3; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0200start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done() + } + + function timeout() { + console.debug('in ACTS_ThirdPartyConnectServiceAbilityWithAccount_0200 timeout'); + if(startresult == false){ + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ThirdPartyStartServiceAbilityWithAccount_1000 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user is equal to the current user, + * and the user's task list exists, call AsyncCallback + */ + it('ACTS_ThirdPartyStartServiceAbilityWithAccount_1000', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 4; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>1000 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_1000 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_1000 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ThirdPartyStartServiceAbilityWithAccount_1000 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>1000start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartServiceAbilityWithAccount_0400 + * @tc.name : In multi-user non-concurrent mode + * @tc.desc : System application, in multi-user non-concurrent mode, + * when the specified user is equal to the current user, + * and the user's task list exists, call AsyncCallback + */ + it('ACTS_ThirdPartyStartServiceAbilityWithAccount_0400', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 5; + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + + function SubscribeCallBack(err, data) { + expect().assertFail(); + expect(data.event == "ABILITYCONTEX_Start_CommonEvent").assertTrue(); + console.debug("====>0400 Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ABILITYCONTEX_Start_CommonEvent") { + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((err) => { + console.debug("====>err is====>" + JSON.stringify(err)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(() => { + done(); + }, 1000) + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0400 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyStartServiceAbilityWithAccount_0400 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_ThirdPartyStartServiceAbilityWithAccount_0400 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).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("====>0400start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionextensiononetest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..4436395534f304976110ce8ce85ca2e7ac9984f4 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,23 @@ +/* + * 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 abilityTest from './Ability.test.ets' + + +export default function testsuite(context) { + + console.debug("====>in list.test====>"); + abilityTest(context) + +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/module.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..d2c0998ded53a8b2ab2c05e48ae2b0bc8d74007a --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/module.json @@ -0,0 +1,76 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.example.actsthirdpartyspecifieduseractionextensiononetest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.actsthirdpartyspecifieduseractionextensiononetest.MainAbility2", + "srcEntrance": "./ets/MainAbility2/MainAbility2.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "name": "com.example.actsthirdpartyspecifieduseractionextensiononetest.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + }, + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.example.actsthirdpartyspecifieduseractionextensiononetest.ServiceAbility2", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ] + } +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..d75325f3cf0a50c1dfe4dbc5162c8737276c3dd9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/signature/openharmony_sx_thirdparty.p7b b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/signature/openharmony_sx_thirdparty.p7b new file mode 100755 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserActionExtension_101/signature/openharmony_sx_thirdparty.p7b differ diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/AppScope/app.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..a03655e21a138a5ecc5be9f38539f960973797ed --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actsthirdpartyspecifieduseractionzerotest", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon" : "$media:icon", + "label" : "$string:app_name", + "description" : "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 8, + "targetAPIVersion": 8, + "car": { + "apiCompatibleVersion": 8, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..be09cccde1bc7369ef47a5cd45d2b06884c88602 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/BUILD.gn b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..2a8f8e6d56190f29d1e8851b0125aa39e2a3c923 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsThirdPartySpecifiedUserActionZeroTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":thirdpartyspecifieduseraction_100_js_assets", + ":thirdpartyspecifieduseraction_100_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx_thirdparty.p7b" + hap_name = "ActsThirdPartySpecifiedUserActionZeroTest" +} + +ohos_app_scope("thirdpartyspecifieduseraction_100_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("thirdpartyspecifieduseraction_100_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("thirdpartyspecifieduseraction_100_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":thirdpartyspecifieduseraction_100_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/Test.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..17cb41c62233cd47cfd073f4f5aa995af8df0010 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/Test.json @@ -0,0 +1,50 @@ + +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.example.actsthirdpartyspecifieduseractionzerotest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsThirdPartySpecifiedUserActionZeroTest.hap", + "ActsThirdPartySpecifiedUserActiononeTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "PushKit", + "push": [ + "ActsThirdPartySpecifiedUserActionZeroTest.hap->/data/ActsThirdPartySpecifiedUserActionZeroTest.hap"] + }, + { + "type": "ShellKit", + "run-command": [ + "acm create -n 101 -t normal", + "acm create -n 102 -t normal", + "acm switch -i 101" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsThirdPartySpecifiedUserActiononeTest.hap->/data/ActsThirdPartySpecifiedUserActiononeTest.hap"] + }, + { + "type": "ShellKit", + "run-command": [ + "acm switch -i 100" + ], + "teardown-command":[ + "acm delete -i 101", + "acm delete -i 102" + ] + } + +] +} + diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..08dee12306de669ae4e52f53c5234d98461148f4 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,23 @@ +/* + * 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..69a9a4bac10f41ef5d60cbc5bb1aa90f85d7dc50 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/MainAbility/MainAbility.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 MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + 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) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..209189314ea2c328102dbee3a923d99b898447a8 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,57 @@ +/* + * 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' +import commonEvent from '@ohos.commonEvent' +function PublishCallBackOne() { + console.debug("====>Publish CallBack ACTS_STAWA_CommonEvent====>"); + console.debug("====>close this context====>") + globalThis.ability2Context.terminateSelf(); +} +export default class MainAbility2 extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility2 onCreate") + + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility2 onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("MainAbility2 onWindowStageCreate") + globalThis.ability2Context = this.context + windowStage.setUIContent(this.context, "pages/index", null) + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent", PublishCallBackOne); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..8941ea468ec094392a23a0ea114f227fcddf128d --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -0,0 +1,66 @@ +/* + * 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import commonEvent from "@ohos.commonEvent" +import rpc from '@ohos.rpc'; +class Stub extends rpc.RemoteObject { + constructor(des) { + super(des); + } + // process client's request + onRemoteRequest(code, data, reply, option) { + reply.writeNoException(); + reply.writeString("success"); + return true; + } +} +export default class ServiceAbility2 extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility2 onCreate'); + globalThis.abilityWant = want; + } + + onDestory(){ + console.log('ServiceAbility2 onDestory'); + } + + onRequest(want,startId) { + console.log('ServiceAbility2 onRequest'); + } + + onConnect(want) { + console.log('ServiceAbility2 onConnect'); + if (want.action == 'StartAbilityPromise') { + console.log('stub StartAbilityPromise OnConnect start '); + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => { + console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback") + console.log("====> StartAbilityPromise End=====>") + }); + + var myStub = new Stub("com.example.actsspecifieduseractionzerotest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + } + } + + onDisconnect(want) { + console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility2 onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/service.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..b4e93f63e685c503c43c7e9ba6a88c3ba155fcfa --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/service.ts @@ -0,0 +1,26 @@ +/* + * 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. + */ + +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..ae1248c48c93d453fcd7eda5a426fcb47cbe59c0 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,49 @@ +/* + * 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 file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" +import testsuite from "../../test/List.test.ets" +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + console.info("subscribeEvent run !!!!") + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + 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/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/pages/second/second.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/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/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..72baf47de53d1392864356c566692a78e02d9ff6 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,22 @@ +/* + * 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 abilityTest from './abilityTest.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/test/abilityTest.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/test/abilityTest.ets new file mode 100755 index 0000000000000000000000000000000000000000..bd44ba644d5e631f6cf1ceb2bdc77638dec91828 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/ets/test/abilityTest.ets @@ -0,0 +1,892 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import commonEvent from '@ohos.commonEvent'; + +var ACTS_ABILITYCONTEX = { + events: ["ABILITYCONTEX_Start_CommonEvent"] +}; + +const START_ABILITY_TIMEOUT = 3000; +export default function abilityTest(abilityContext) { + describe('ACTS_AbilityContext', function () { + + /* + * @tc.number: ACTS_ThirdPartyStartStandardAbilityWithAccount_0100 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, + * call the AbilityContext::startAbilityWithAccount interface of + * Promise (with the StartOptions parameter) to start Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityWithAccount_0100', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityWithAccount_0100====>start") + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityWithAccount_0100====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>ACTS_ThirdPartyStartStandardAbilityWithAccount_0100 UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartStandardAbilityWithAccount_0100 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + },100, + { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityWithAccount_0100====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityWithAccount_0300 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), + * call the AbilityContext::startAbilityWithAccount interface of + * Promise (with the StartOptions parameter) to start Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityWithAccount_0300', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityWithAccount_0300 ====> start") + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityWithAccount_0300 ====> timeout'); + done(); + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + },102, + { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityWithAccount_0300====>success!"+ JSON.stringify(data)) + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityWithAccount_0500 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the AbilityContext::startAbilityWithAccount interface + * of AsyncCallback (with the StartOptions parameter) to start Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityWithAccount_0500', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityWithAccount_0500 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0500 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityWithAccount_0500====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityWithAccount_0500 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractiononetest.MainAbility2' + },101, { + windowMode: 2, + displayId: 1 + }, ((err, data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityWithAccount_0500====>success!!!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityWithAccount_0600 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), call the + * AbilityContext::startAbilityWithAccount interface of + * AsyncCallback (with the StartOptions parameter) to start the Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityWithAccount_0600', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityWithAccount_0600 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0600 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityWithAccount_0600====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityWithAccount_0600 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + },102, { + windowMode: 2, + displayId: 1 + }, ((err, data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityWithAccount_0600====>success!!!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityWithAccount_0700 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, call the + * AbilityContext::startAbilityWithAccount interface of Promise (without the StartOptions parameter) + * to start Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityWithAccount_0700', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityWithAccount_0700 ====> start") + + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>0700 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityWithAccount_0700====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>ACTS_ThirdPartyStartStandardAbilityWithAccount_0700 UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartStandardAbilityWithAccount_0700 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + },100).then((data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityWithAccount_0700====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityWithAccount_0900 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), call + * the AbilityContext::startAbilityWithAccount interface of + * Promise (without the StartOptions parameter) to start the Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityWithAccount_0900', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityWithAccount_0900 ====> start") + + var Subscriber; + + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0900 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityWithAccount_0900====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityWithAccount_0900 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + },102).then((data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityWithAccount_0900====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityWithAccount_1100 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, call the + * AbilityContext::startAbilityWithAccount interface of + * AsyncCallback (without the StartOptions parameter) to start the Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityWithAccount_1100', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityWithAccount_1100 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>1100 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityWithAccount_1100====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityWithAccount_1100 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractiononetest.MainAbility2' + },101, ((err, data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityWithAccount_1100====>success!!!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityWithAccount_1200 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), call the + * AbilityContext::startAbilityWithAccount interface of + * AsyncCallback (without the StartOptions parameter) to start the Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityWithAccount_1200', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityWithAccount_1200 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>1200 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityWithAccount_1200====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityWithAccount_1200 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + },102,((err, data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityWithAccount_1200====>success!!!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0100 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, + * call the Promise's AbilityContext::startAbilityForResultWithAccount + * (with the StartOptions parameter) interface to start Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0100', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0100 ====> start") + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0100====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0100 UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false){ + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0100 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + }, 100, + { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0100====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0300 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), + * call the AbilityContext::startAbilityForResultWithAccount (with the StartOptions parameter) + * interface of Promise to start Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0300', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0300 ====> start") + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0300 ====> timeout'); + done(); + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + },102, + { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0300====>success!"+ JSON.stringify(data)) + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0500 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, call the + * AsyncCallback's AbilityContext::startAbilityForResultWithAccount (with the StartOptions parameter) + * interface to start Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0500', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0500 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0500 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0500====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0500 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractiononetest.MainAbility2' + }, 101, + { + windowMode: 2, + displayId: 1 + }, ((err, data) => { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0500 === success!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0600 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), call the + * AbilityContext::startAbilityForResultWithAccount (with the StartOptions parameter) interface of + * AsyncCallback to start the Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0600', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0600 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0600 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0600====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + + console.debug('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0600 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + }, 102, + { + windowMode: 2, + displayId: 1 + }, ((err, data) => { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0600 === success!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0700 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, + * call the Promise's AbilityContext::startAbilityForResultWithAccount + * (without the StartOptions parameter) interface to start the Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0700', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0700 ====> start") + + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>0700 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0700====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false) + { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0700 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + }, 100).then((data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0700====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0900 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), call the + * AbilityContext::startAbilityForResultWithAccount (no StartOptions parameter) interface of + * Promise to start Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0900', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0900 ====> start") + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0900 ====> timeout'); + done(); + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + },102).then((data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0900====>success!"+ JSON.stringify(data)) + expect().assertFail(); + done(); + }) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1100 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the AsyncCallback's + * AbilityContext::startAbilityForResultWithAccount (without the StartOptions parameter) interface + * to start the Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1100', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1100 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>1100 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1100====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1100 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractiononetest.MainAbility2' + }, 101, ((err, data) => { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1100 === success!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1200 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), + * call the AbilityContext::startAbilityForResultWithAccount (no StartOptions parameter) + * interface of AsyncCallback to start Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1200', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1200 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>1200 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1200====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + }, 102, ((err, data) => { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1200 === success!" + JSON.stringify(data)) + })) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1200 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /** + * @tc.number: ACTS_ThirdPartyConnectStandardAbilityWithAccount_0100 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is equal to the current user and the user's task list exists, + * call the AbilityContext::connectAbilityWithAccount interface to connect to Ability. + */ + it('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0100', 0, async function (done) { + console.log("ACTS_ThirdPartyConnectStandardAbilityWithAccount_0100====>start") + var Subscriber; + var flag = true; + var number = 0; + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0100 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0100 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(()=> { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if(flag == true) { + console.debug('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>WithAccount 0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + abilityContext.disconnectAbility(number).then((err)=>{ + console.debug("====>err is====>" + JSON.stringify(err)); + }) + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyConnectStandardAbilityWithAccount_0100====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>ACTS_ThirdPartyConnectStandardAbilityWithAccount_0100 UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0100 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start connectAbilityWithAccount====>"); + number = await abilityContext.connectAbilityWithAccount({ + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.ServiceAbility2', + action: "StartAbilityPromise" + }, 100,{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + }) + + /** + * @tc.number: ACTS_ThirdPartyConnectStandardAbilityWithAccount_0300 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user does not have a task list (the user does not exist), + * call the AbilityContext::connectAbilityWithAccount interface to connect the Ability. + */ + it('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0300', 0, async function (done) { + console.log("ACTS_ThirdPartyConnectStandardAbilityWithAccount_0300 ====> start") + + var Subscriber; + var flag = true; + var number = 0; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>WithAccount 0300 Subscribe CallBack data:====>" + JSON.stringify(data)); + abilityContext.disconnectAbility(number).then((err)=>{ + console.debug("====>err is====>" + JSON.stringify(err)); + }) + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0300 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0300 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(()=> { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if(flag == true) { + console.debug('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyConnectStandardAbilityWithAccount_0300====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + console.debug("====>start connectAbilityWithAccount====>"); + number = await abilityContext.connectAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.ServiceAbility2', + action: "StartAbilityPromise" + },102 ,{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0300 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/module.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..a745ea0dc9b24f9b1b5da0c92b182f419f4c83e2 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/module.json @@ -0,0 +1,67 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2", + "srcEntrance": "./ets/MainAbility2/MainAbility2.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.example.actsthirdpartyspecifieduseractionzerotest.ServiceAbility2", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ] + } +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..d75325f3cf0a50c1dfe4dbc5162c8737276c3dd9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/signature/openharmony_sx_thirdparty.p7b b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/signature/openharmony_sx_thirdparty.p7b new file mode 100755 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_100/signature/openharmony_sx_thirdparty.p7b differ diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/AppScope/app.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..b7aec8c605f59aa35ca086f00e8dcad468a3a9dc --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actsthirdpartyspecifieduseractiononetest", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon" : "$media:icon", + "label" : "$string:app_name", + "description" : "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 8, + "targetAPIVersion": 8, + "car": { + "apiCompatibleVersion": 8, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..be09cccde1bc7369ef47a5cd45d2b06884c88602 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/BUILD.gn b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..62377964866e779cd46887b5974f4c77748bd16f --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsThirdPartySpecifiedUserActiononeTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":thirdpartyspecifieduseraction_101_js_assets", + ":thirdpartyspecifieduseraction_101_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx_thirdparty.p7b" + hap_name = "ActsThirdPartySpecifiedUserActiononeTest" +} + +ohos_app_scope("thirdpartyspecifieduseraction_101_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("thirdpartyspecifieduseraction_101_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("thirdpartyspecifieduseraction_101_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":thirdpartyspecifieduseraction_101_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/Test.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..b15f68dc9eb7398bb636e22f6b0dbf022613e9cf --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/Test.json @@ -0,0 +1,63 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.example.actsthirdpartyspecifieduseractiononetest", + "shell-timeout": "300000" + }, + "kits": [ + { + "type": "ShellKit", + "run-command": [ + "acm create -n 101 -t normal", + "acm create -n 102 -t normal", + "acm switch -i 101" + ] + }, + { + "test-file-name": [ + "ActsThirdPartySpecifiedUserActiononeTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsThirdPartySpecifiedUserActiononeTest.hap->/data/ActsThirdPartySpecifiedUserActiononeTest.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "acm switch -i 100" + ] + }, + + { + "type": "PushKit", + "push": [ + "ActsThirdPartySpecifiedUserActionZeroTest.hap->/data/ActsThirdPartySpecifiedUserActionZeroTest.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "acm switch -i 101" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/*.hap" + ] + } + ] +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..8375d549288c1fc101c0ab596545af9d626118da --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,23 @@ +/* + * 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..69a9a4bac10f41ef5d60cbc5bb1aa90f85d7dc50 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/MainAbility/MainAbility.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 MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + 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) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..6176b8ae0398e0573d77f1d005f1011fa6f323a0 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,57 @@ +/* + * 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' +import commonEvent from '@ohos.commonEvent' +function PublishCallBackOne() { + console.debug("====>Publish CallBack ACTS_STAWA_CommonEvent====>"); + console.debug("====>close this context====>") + globalThis.ability2Context.terminateSelf(); +} + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility2 onCreate") + + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility2 onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("MainAbility2 onWindowStageCreate") + globalThis.ability2Context = this.context + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent", PublishCallBackOne); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..c45bdac905c73438b73d0b7959bd38895327124f --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -0,0 +1,68 @@ +/* + * 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 ServiceExtension from '@ohos.application.ServiceExtensionAbility' +import commonEvent from "@ohos.commonEvent" +import rpc from '@ohos.rpc'; +class Stub extends rpc.RemoteObject { + constructor(des) { + super(des); + } + // process client's request + onRemoteRequest(code, data, reply, option) { + reply.writeNoException(); + reply.writeString("success"); + return true; + } +} +export default class ServiceAbility2 extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility2 onCreate'); + globalThis.abilityWant = want; + } + + onDestory(){ + console.log('ServiceAbility2 onDestory'); + } + + onRequest(want,startId) { + console.log('ServiceAbility2 onRequest'); + } + + onConnect(want) { + let extensionContext = this.context + console.log('ServiceAbility2 onConnect'); + if (want.action == 'StartAbilityPromise') { + console.log('stub StartAbilityPromise OnConnect start '); + commonEvent.publish("ABILITYCONTEX_Start_CommonEvent",() => { + console.log("publish Publish ABILITYCONTEX_Start_CommonEvent callback") + extensionContext.terminateSelf(); + console.log("====> StartAbilityPromise End=====>") + }); + + var myStub = new Stub("com.example.actsspecifieduseractiononetest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + } + } + + onDisconnect(want) { + console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility2 onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/service.ts b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..91a83dbc24c50064a2031ddf77606699a059fac9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/service.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..ae1248c48c93d453fcd7eda5a426fcb47cbe59c0 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,49 @@ +/* + * 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 file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" +import testsuite from "../../test/List.test.ets" +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + console.info("subscribeEvent run !!!!") + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + 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/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/pages/second/second.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/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/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..5635f2840894a3a90336344a0d439a5e2942b166 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,22 @@ +/* + * 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 abilityTest from './abilityTest.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/test/abilityTest.ets b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/test/abilityTest.ets new file mode 100755 index 0000000000000000000000000000000000000000..7fc3fe1c15650ed126339c2c603a2ef45de9245f --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/ets/test/abilityTest.ets @@ -0,0 +1,501 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import commonEvent from '@ohos.commonEvent'; + +var ACTS_ABILITYCONTEX = { + events: ["ABILITYCONTEX_Start_CommonEvent"] +}; + +const START_ABILITY_TIMEOUT = 3000; +export default function abilityTest(abilityContext) { + describe('ACTS_AbilityContext', function () { + + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityWithAccount_0200 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the Promise's AbilityContext::startAbilityWithAccount + * interface (with the StartOptions parameter) to start Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityWithAccount_0200', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityWithAccount_0200====>start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityWithAccount_0200====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityWithAccount_0200 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + done(); + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + },100, + { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityWithAccount_0200====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityWithAccount_0400 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, + * call the AbilityContext::startAbilityWithAccount interface of + * AsyncCallback (with the StartOptions parameter) to start Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityWithAccount_0400', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityWithAccount_0400 ====> start") + + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>0400 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityWithAccount_0400====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false){ + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartStandardAbilityWithAccount_0400 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + done(); + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractiononetest.MainAbility2' + },101, + { + windowMode: 2, + displayId: 1 + }, ((err, data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityWithAccount_0400====>success!!!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityWithAccount_0800 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the Promise's AbilityContext::startAbilityWithAccount + * interface (without the StartOptions parameter) to start the Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityWithAccount_0800', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityWithAccount_0800 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0800 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityWithAccount_0800====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityWithAccount_0800 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + done(); + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + },100).then((data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityWithAccount_0800====>success!"+ JSON.stringify(data)) + }) + }) + + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityWithAccount_1000 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, call the + * AbilityContext::startAbilityWithAccount interface of + * AsyncCallback (without the StartOptions parameter) to start the Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityWithAccount_1000', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityWithAccount_1000 ====> start") + + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>1000 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityWithAccount_1000====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false){ + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartStandardAbilityWithAccount_1000 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + done(); + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbility====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractiononetest.MainAbility2' + },101, ((err, data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityWithAccount_1000====>success!!!" + JSON.stringify(data)) + })) + }) + + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0200 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, call the + * Promise's AbilityContext::startAbilityForResultWithAccount (with the StartOptions parameter) + * interface to start Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0200', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0200 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0200====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0200 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + done(); + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + }, 100, + { + windowMode: 2, + displayId: 1 + }).then((data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0200====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0400 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: When the specified user is equal to the current user and the user's task list exists, call the + * AsyncCallback's AbilityContext::startAbilityForResultWithAccount (with the StartOptions parameter) + * interface to start the Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0400', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0400 ====> start") + + var Subscriber; + var flag = false; + + function SubscribeCallBack(err, data) { + flag = true; + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>0400 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0400====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + if(flag == false){ + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0400 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + done(); + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractiononetest.MainAbility2' + }, 101, + { + windowMode: 2, + displayId: 1 + }, ((err, data) => { + console.log("StartStandardAbilityForResultWithAccount_0400 === success!" + JSON.stringify(data)) + })) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0800 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the Promise's + * AbilityContext::startAbilityForResultWithAccount (without the StartOptions parameter) interface + * to start Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0800', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0800 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0800 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0800====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0800 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + done(); + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.MainAbility2' + }, 100).then((data) => { + console.log("====>end ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_0800====>success!"+ JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1000 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the AsyncCallback's + * AbilityContext::startAbilityForResultWithAccount (without the StartOptions parameter) + * interface to start the Ability. + */ + it('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1000', 0, async function (done) { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1000 ====> start") + + var Subscriber; + + function SubscribeCallBack(err, data) { + expect(data.event).assertEqual("ABILITYCONTEX_Start_CommonEvent"); + console.debug("====>1000 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1000====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1000 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + done(); + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResultWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractiononetest', + abilityName: 'com.example.actsthirdpartyspecifieduseractiononetest.MainAbility2' + }, 101, ((err, data) => { + console.log("ACTS_ThirdPartyStartStandardAbilityForResultWithAccount_1000 === success!" + JSON.stringify(data)) + })) + }) + + + /** + * @tc.number: ACTS_ThirdPartyConnectStandardAbilityWithAccount_0200 + * @tc.name: Provides a system interface to specify user startup components (standard page). + * @tc.desc: If the specified user is not equal to the current user and the user's task list exists, + * call the AbilityContext::connectAbilityWithAccount interface to connect the Ability. + */ + it('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0200', 0, async function (done) { + console.log("ACTS_ThirdPartyConnectStandardAbilityWithAccount_0200 ====> start") + + var Subscriber; + var flag = true + + function SubscribeCallBack(err, data) { + expect().assertFail(); + console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0200 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0200 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(()=> { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if(flag == true) { + console.debug('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0200 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + done(); + } + + commonEvent.createSubscriber(ACTS_ABILITYCONTEX).then(async (data) => { + console.debug("ACTS_ThirdPartyConnectStandardAbilityWithAccount_0200====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + console.debug("====>start connectAbility====>"); + await abilityContext.connectAbilityWithAccount( + { + bundleName: 'com.example.actsthirdpartyspecifieduseractionzerotest', + abilityName: 'com.example.actsthirdpartyspecifieduseractionzerotest.ServiceAbility2', + action: "StartAbilityPromise" + },100 ,{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + }) + function UnSubscribeCallback() { + console.debug("====>connectAbility UnSubscribeCallback====>"); + done(); + } + function timeout() { + console.debug('ACTS_ThirdPartyConnectStandardAbilityWithAccount_0200 ====> timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + done(); + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/module.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..11d9405c89c5647770227e5c54dc0835fe17491d --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/module.json @@ -0,0 +1,67 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.example.actsthirdpartyspecifieduseractiononetest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.actsthirdpartyspecifieduseractiononetest.MainAbility2", + "srcEntrance": "./ets/MainAbility2/MainAbility2.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.example.actsthirdpartyspecifieduseractiononetest.ServiceAbility2", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ] + } +} diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..d75325f3cf0a50c1dfe4dbc5162c8737276c3dd9 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/signature/openharmony_sx_thirdparty.p7b b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/signature/openharmony_sx_thirdparty.p7b new file mode 100755 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/ability/ability_runtime/actsstartcomponenttest/ThirdPartySpecifiedUserAction_101/signature/openharmony_sx_thirdparty.p7b differ diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersApi7AppA/BUILD.gn b/ability/ability_runtime/actsusers/ActsAmsUsersApi7AppA/BUILD.gn index c8d412b5e2cce1ee67da2276b443273b10d6d22d..e6c31b21c318005c0a5981f7068f6fb50a5369a2 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersApi7AppA/BUILD.gn +++ b/ability/ability_runtime/actsusers/ActsAmsUsersApi7AppA/BUILD.gn @@ -13,19 +13,19 @@ import("//test/xts/tools/build/suite.gni") -ohos_hap_assist_suite("ActsAmsUsersApi7AppA") { +ohos_hap("ActsAmsUsersApi7AppA") { hap_name = "ActsAmsUsersApi7AppA" js_build_mode = "debug" hap_profile = "entry/src/main/config.json" - + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" testonly = true deps = [ ":actsamsusersapi7appa_resources", ":actsamsusersapi7appa_ts_assets", ] certificate_profile = "signature/openharmony_sx.p7b" - subsystem_name = "ability" - part_name = "ability_runtime" } ohos_js_assets("actsamsusersapi7appa_ts_assets") { diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/AppScope/app.json b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..2dccd99e896b2eaf5691f18ec780f1f5509dbddf --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.acts.actsinterfacemultiusersextensionthirdtest", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon" : "$media:icon", + "label" : "$string:app_name", + "description" : "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 8, + "targetAPIVersion": 8, + "car": { + "apiCompatibleVersion": 8, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/BUILD.gn b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e321c5b2427ce9f4743a72b277bd5b9d8f1582ab --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/BUILD.gn @@ -0,0 +1,40 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAmsUsersExtensionThirdTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsusersextensionthirdtest_js_assets", + ":actsamsusersextensionthirdtest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsUsersExtensionThirdTest" +} + +ohos_app_scope("actsamsusersextensionthirdtest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsusersextensionthirdtest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsusersextensionthirdtest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsusersextensionthirdtest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/Test.json b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..9d52925e08a927c83f634f36354d39617b8c912f --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.acts.actsinterfacemultiusersextensionthirdtest", + "shell-timeout": "300000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsUsersExtensionThirdTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,23 @@ +/* +* 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..c5b97d7a538f200cff4d39d125418200a171c155 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility/MainAbility.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 MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility onCreate"); + globalThis.abilityWant = want; + globalThis.abilityContext = this.context + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility onDestroy"); + } + + 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() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy"); + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground"); + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground"); + } +}; 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 new file mode 100644 index 0000000000000000000000000000000000000000..3a43ba7672765d2bd84848843bce0a9b47766f8e --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,53 @@ +/* + * 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' +import commonEvent from "@ohos.commonEvent" + +export default class MainAbility2 extends Ability { + + onCreate(want, launchParam) { + console.log("MainAbility2 onCreate"); + globalThis.abilityContext = this.context + } + + onDestroy() { + console.log("MainAbility2 onDestroy"); + } + + onWindowStageCreate(windowStage) { + console.log("MainAbility2 onWindowStageCreate"); + windowStage.setUIContent(this.context, "pages/index/second", null); + commonEvent.publish("ACTS_InterfaceMultiUsersExtension_CommonEvent", () => { + console.log("publish Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback") + globalThis.abilityContext.terminateSelf().then(() => { + commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{ + console.log('terminateSelf promise'); + }); + }); + }) + } + + onWindowStageDestroy() { + console.log("MainAbility2 onWindowStageDestroy"); + } + + onForeground() { + console.log("MainAbility2 onForeground"); + } + + onBackground() { + console.log("MainAbility2 onBackground"); + } +}; 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 new file mode 100644 index 0000000000000000000000000000000000000000..aaf94c7b7d0cec6c8c4dc8089f259ae9ec329c31 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,199 @@ +/* + * 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import rpc from '@ohos.rpc'; +class Stub extends rpc.RemoteObject { + constructor(des) { + super(des); + } + onRemoteRequest(code, data, reply, option) { + reply.writeNoException(); + reply.writeString("success"); + return true; + } +} +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility onCreate'); + } + onDestory(){ + console.log('ServiceAbility onDestory'); + } + onRequest(want,startId) { + console.log('ServiceAbility onRequest'); + } + + onConnect(want) { + console.log('ServiceAbility onConnect'); + console.log('globalThis.startnum is' + globalThis.startnum); + switch (globalThis.startnum) { + case 1: + this.context.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility2' + },{ + windowMode:0 + } + ).then((data) => { + console.debug("====>startAbility end====>"); + console.debug("====>data is====>" + JSON.stringify(data)); + }) + break; + case 2: + this.context.startAbility( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility2' + },{ + windowMode:0 + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + console.debug("====>case 2 end====>"); + var myStub1 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub1; + break; + case 3: + this.context.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility2' + },{ + windowMode:0 + },() => { + console.debug("====>startAbility end====>" ); + }) + var myStub7 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub7; + break; + case 4: + this.context.startAbility( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility2' + },{ + windowMode:0 + },() => { + console.debug("====>startAbility end====>" ); + }) + var myStub2 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub2; + break; + case 5: + this.context.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility2' + }).then((data)=>{ + console.debug("====>startAbility end====>"); + console.debug("====>data is====>" + JSON.stringify(data)); + }) + break; + case 6: + this.context.startAbility( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.ServiceAbility2' + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + var myStub3 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub3; + break; + case 7: + this.context.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility2' + },() => { + console.debug("====>startAbility end====>" ); + }) + var myStub8 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub8; + break; + case 8: + this.context.startAbility( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.ServiceAbility2' + },() => { + console.debug("====>startAbility end====>" ); + }) + var myStub4 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub4; + break; + case 9: + this.context.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility2' + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + break; + case 10: + this.context.startAbility( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.ServiceAbility2' + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + var myStub5 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub5; + break; + case 11: + this.context.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility2' + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + break; + case 12: + this.context.startAbility( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.ServiceAbility2' + },() => { + console.debug("====>startAbility end====>" ); + }) + var myStub6 = new Stub("com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub6; + break; + default: + break; + } + } + + onDisconnect(want) { + console.log('ServiceAbility onDisconnect'); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100644 index 0000000000000000000000000000000000000000..80fb5c18abaf725ab8ab58b24d04e1a7b519929f --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import commonEvent from "@ohos.commonEvent" + +export default class ServiceAbility2 extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility2 onCreate'); + } + + onDestory(){ + console.log('ServiceAbility2 onDestory'); + } + + onRequest(want,startId) { + console.log('ServiceAbility2 onRequest'); + commonEvent.publish("ACTS_InterfaceMultiUsersExtension_CommonEvent", () => { + console.log("publish Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback") + this.context.terminateSelf().then(() => { + commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{ + console.log('terminateSelf promise'); + }); + }); + }) + } + + onConnect(want) { + console.log('ServiceAbility2 onConnect'); + } + + onDisconnect(want) { + console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility2 onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5377765fe755ef5ac64fc909de70c4a3eca01e2a --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" +import testsuite from "../../test/List.test.ets" +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + console.info("subscribeEvent run !!!!") + const configService = core.getDefaultService('config') + globalThis.abilityWant.parameters['timeout'] = 10000 + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + 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/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/pages/second/second.ets b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..7d77623164cfc87c809713272776bff63fefbbd9 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/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/test/Ability.test.ets b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..49a09a4449568803ed3de04409a5c41e4a5c87d7 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,837 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +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"] +}; +var osAccountManager +const START_ABILITY_TIMEOUT = 6000; +globalThis.number = 0; +console.debug("====>in Ability.test====>"); +export default function abilityTest(abilityContext) { + 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 + * @tc.desc : Start an ability with the parameter startability with options succeeded.(promise) + */ + it('ACTS_ThirdPartyExtensionStartAbility_0100', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 1 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + 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"){ + startresult = true + } + 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.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(()=>{ + done() + },1000) + } + + function timeout() { + console.debug('in ACTS_ThirdPartyExtensionStartAbility_0100 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyExtensionStartAbility_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ThirdPartyExtensionStartAbility_0200 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options failed.(promise) + */ + it('ACTS_ThirdPartyExtensionStartAbility_0200', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 2 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + 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"){ + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + console.debug("====>data is====>" + JSON.stringify(data)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(()=>{ + done(); + },1000) + } + function onConnectCallback(element, remote) { + console.log(' onConnectCallback====> element=' + JSON.stringify(element)); + console.log(' onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(()=> { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if(flag == true) { + console.debug('ACTS_ThirdPartyExtensionStartAbility_0200 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + 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("====>0200start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' + },{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyExtensionStartAbility_0300 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options succeeded.(callback) + */ + it('ACTS_ThirdPartyExtensionStartAbility_0300', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum=3 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + 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"){ + startresult = true + } + 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("====>0300start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(()=>{ + done() + },1000) + } + + function timeout() { + console.debug('in ACTS_ThirdPartyExtensionStartAbility_0300 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyExtensionStartAbility_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ThirdPartyExtensionStartAbility_0400 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options failed.(callback) + */ + it('ACTS_ThirdPartyExtensionStartAbility_0400', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 4 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + 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"){ + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + console.debug("====>data is====>" + JSON.stringify(data)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(()=>{ + done(); + },1000) + } + function onConnectCallback(element, remote) { + console.log(' onConnectCallback====> element=' + JSON.stringify(element)); + console.log(' onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(()=> { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if(flag == true) { + console.debug('ACTS_ThirdPartyExtensionStartAbility_0400 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + 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("====>0400start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' + },{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + }) + + /* + * @tc.number : ACTS_ThirdPartyExtensionStartAbility_0500 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability succeeded.(promise) + */ + it('ACTS_ThirdPartyExtensionStartAbility_0500', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 5 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + 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"){ + startresult = true + } + 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("====>0500start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(()=>{ + done() + },1000) + } + + function timeout() { + console.debug('in ACTS_ThirdPartyExtensionStartAbility_0500 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyExtensionStartAbility_0500 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ThirdPartyExtensionStartAbility_0600 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability failed.(promise) + */ + it('ACTS_ThirdPartyExtensionStartAbility_0600', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 6 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + 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"){ + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + console.debug("====>data is====>" + JSON.stringify(data)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(()=>{ + done(); + },1000) + } + function onConnectCallback(element, remote) { + console.log(' onConnectCallback====> element=' + JSON.stringify(element)); + console.log(' onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(()=> { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if(flag == true) { + console.debug('ACTS_ThirdPartyExtensionStartAbility_0600 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + 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("====>0600start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' + },{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyExtensionStartAbility_0700 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability succeeded.(callback) + */ + it('ACTS_ThirdPartyExtensionStartAbility_0700', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum=7 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + 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"){ + startresult = true + } + 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("====>0700start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(()=>{ + done() + },1000) + } + + function timeout() { + console.debug('in ACTS_ThirdPartyExtensionStartAbility_0700 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyExtensionStartAbility_0700 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_ThirdPartyExtensionStartAbility_0800 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability failed.(callback) + */ + it('ACTS_ThirdPartyExtensionStartAbility_0800', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 8 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + 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"){ + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + console.debug("====>data is====>" + JSON.stringify(data)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(()=>{ + done(); + },1000) + } + function onConnectCallback(element, remote) { + console.log(' onConnectCallback====> element=' + JSON.stringify(element)); + console.log(' onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(()=> { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if(flag == true) { + console.debug('ACTS_ThirdPartyExtensionStartAbility_0800 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + 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("====>0800start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' + },{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + /* + * @tc.number : ACTS_ThirdPartyExtensionTerminateSelf_0100 + * @tc.name : Use terminateself to terminate ability + * @tc.desc : Starting mainability2 with startAbility then terminateself ability succeeded.(promise) + */ + it('ACTS_ThirdPartyExtensionTerminateSelf_0100', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 9 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + 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"){ + startresult = true + } + abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + console.debug("====>data is====>" + JSON.stringify(data)); + }) + console.log('====>disconnectAbility finish'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + commonEvent.createSubscriber(subscriberInfo_MainAbility2).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.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(()=>{ + done() + },1000) + } + + function timeout() { + console.debug('in ACTS_ThirdPartyExtensionTerminateSelf_0100 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyExtensionTerminateSelf_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + /* + * @tc.number : ACTS_ThirdPartyExtensionTerminateSelf_0200 + * @tc.name : Use terminateself to terminate ability + * @tc.desc : Starting mainability2 with startAbility then terminateself ability failed.(promise) + */ + it('ACTS_ThirdPartyExtensionTerminateSelf_0200', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 10 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + 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"){ + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + console.debug("====>data is====>" + JSON.stringify(data)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(()=>{ + done(); + },1000) + } + function onConnectCallback(element, remote) { + console.log(' onConnectCallback====> element=' + JSON.stringify(element)); + console.log(' onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(()=> { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if(flag == true) { + console.debug(' - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + commonEvent.createSubscriber(subscriberInfo_MainAbility2).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("====>0200start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' + },{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + }) + /* + * @tc.number : ACTS_ThirdPartyExtensionTerminateSelf_0300 + * @tc.name : Use terminateself to terminate ability + * @tc.desc : Starting mainability2 with startAbility then terminateself ability succeeded.(callback) + */ + it('ACTS_ThirdPartyExtensionTerminateSelf_0300', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 11 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + 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"){ + startresult = true + } + abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + console.debug("====>data is====>" + JSON.stringify(data)); + }) + console.log('====>disconnectAbility finish'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + commonEvent.createSubscriber(subscriberInfo_MainAbility2).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("====>0300start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(()=>{ + done() + },1000) + } + + function timeout() { + console.debug('in ACTS_ThirdPartyExtensionTerminateSelf_0300 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyExtensionTerminateSelf_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + /* + * @tc.number : ACTS_ThirdPartyExtensionTerminateSelf_0400 + * @tc.name : Use terminateself to terminate ability + * @tc.desc : Starting mainability2 with startAbility then terminateself ability failed.(callback) + */ + it('ACTS_ThirdPartyExtensionTerminateSelf_0400', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum = 12 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + 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"){ + startresult = true + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(false); + abilityContext.disconnectAbility(globalThis.number).then((data)=>{ + console.debug("====>data is====>" + JSON.stringify(data)); + }) + console.log('====>disconnectAbility finish'); + setTimeout(()=>{ + done(); + },1000) + } + function onConnectCallback(element, remote) { + console.log('ACTS_ThirdPartyExtensionTerminateSelf_0400 onConnectCallback====> element=' + + JSON.stringify(element)); + console.log('ACTS_ThirdPartyExtensionTerminateSelf_0400 onConnectCallback====> remote=' + + JSON.stringify(remote)); + setTimeout(()=> { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if(flag == true) { + console.debug('ACTS_ThirdPartyExtensionTerminateSelf_0400 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, 1000); + } + function onDisconnectCallback(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + + function onFailedCallback(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + commonEvent.createSubscriber(subscriberInfo_MainAbility2).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("====>0400start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensionthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility' + },{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + }) +} \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..38ad693b91e3f4b84a7d4717063a8ac61b23d9c1 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * 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 abilityTest from './Ability.test.ets' + +export default function testsuite(context) { + console.debug("====>in list.test====>"); + abilityTest(context) +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/module.json b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..188aba9605ab4b513f7ede8a61352b027b0f44cc --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/module.json @@ -0,0 +1,66 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.acts.actsinterfacemultiusersextensionthirdtest.MainAbility2", + "srcEntrance": "./ets/MainAbility2/MainAbility2.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait" + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "name": "com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + }, + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.acts.actsinterfacemultiusersextensionthirdtest.ServiceAbility2", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ] + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/resources/base/media/icon.png differ 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 new file mode 100644 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "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 new file mode 100644 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/ability/ability_runtime/actsusers/ActsAmsUsersExtensionThirdTest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppA/BUILD.gn b/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppA/BUILD.gn index 9d5042ea8a43709721f61e4538a2284b3f25e8d0..e98b3f4c8d186585f10eee36257e3260d0d64c44 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppA/BUILD.gn +++ b/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppA/BUILD.gn @@ -13,11 +13,13 @@ import("//test/xts/tools/build/suite.gni") -ohos_hap_assist_suite("ActsAmsUsersKillProcessAppA") { +ohos_hap("ActsAmsUsersKillProcessAppA") { hap_profile = "entry/src/main/module.json" js_build_mode = "debug" hap_name = "ActsAmsUsersKillProcessAppA" - + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" testonly = true deps = [ ":actsamsuserskillprocessappa_js_assets", @@ -25,8 +27,6 @@ ohos_hap_assist_suite("ActsAmsUsersKillProcessAppA") { ] ets2abc = true certificate_profile = "signature/openharmony_sx.p7b" - subsystem_name = "ability" - part_name = "ability_runtime" } ohos_app_scope("actsamsuserskillprocessappa_app_profile") { diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppB/BUILD.gn b/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppB/BUILD.gn index 6454481d618652d654d198b402d684afa7156249..36056d57a323abf8d3b571c8ca45ed5b88c2c4b5 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppB/BUILD.gn +++ b/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppB/BUILD.gn @@ -13,11 +13,13 @@ import("//test/xts/tools/build/suite.gni") -ohos_hap_assist_suite("ActsAmsUsersKillProcessAppB") { +ohos_hap("ActsAmsUsersKillProcessAppB") { hap_profile = "entry/src/main/module.json" js_build_mode = "debug" hap_name = "ActsAmsUsersKillProcessAppB" - + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" testonly = true deps = [ ":actsamsuserskillprocessappb_js_assets", @@ -25,8 +27,6 @@ ohos_hap_assist_suite("ActsAmsUsersKillProcessAppB") { ] ets2abc = true certificate_profile = "signature/openharmony_sx.p7b" - subsystem_name = "ability" - part_name = "ability_runtime" } ohos_app_scope("actsamsuserskillprocessappb_app_profile") { diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppC/BUILD.gn b/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppC/BUILD.gn index e7807fa427239404ec9655a81f6e9b65f7774208..125e54b0ed991b8cd0f09f1a1d80119de3235b43 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppC/BUILD.gn +++ b/ability/ability_runtime/actsusers/ActsAmsUsersKillProcessAppC/BUILD.gn @@ -13,11 +13,13 @@ import("//test/xts/tools/build/suite.gni") -ohos_hap_assist_suite("ActsAmsUsersKillProcessAppC") { +ohos_hap("ActsAmsUsersKillProcessAppC") { hap_profile = "entry/src/main/module.json" js_build_mode = "debug" hap_name = "ActsAmsUsersKillProcessAppC" - + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" testonly = true deps = [ ":actsamsuserskillprocessappc_js_assets", @@ -25,8 +27,6 @@ ohos_hap_assist_suite("ActsAmsUsersKillProcessAppC") { ] ets2abc = true certificate_profile = "signature/openharmony_sx.p7b" - subsystem_name = "ability" - part_name = "ability_runtime" } ohos_app_scope("actsamsuserskillprocessappc_app_profile") { diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/BUILD.gn b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/BUILD.gn index b4ebea688778e6a33a0283f03dcecf22452b1b71..89ebbb136f336061efb377f11561b515d03748e4 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/BUILD.gn +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/BUILD.gn @@ -14,7 +14,7 @@ import("//test/xts/tools/build/suite.gni") ohos_js_hap_suite("ActsAmsUsersSystemTest") { - hap_profile = "./entry/src/main/module.json" + hap_profile = "entry/src/main/module.json" js_build_mode = "debug" deps = [ ":actsamsuserssystemtest_js_assets", @@ -23,8 +23,6 @@ ohos_js_hap_suite("ActsAmsUsersSystemTest") { ets2abc = true certificate_profile = "signature/openharmony_sx.p7b" hap_name = "ActsAmsUsersSystemTest" - subsystem_name = "ability" - part_name = "ability_runtime" } ohos_app_scope("actsamsuserssystemtest_app_profile") { @@ -33,11 +31,11 @@ ohos_app_scope("actsamsuserssystemtest_app_profile") { } ohos_js_assets("actsamsuserssystemtest_js_assets") { - source_dir = "./entry/src/main/ets" + source_dir = "entry/src/main/ets" } ohos_resources("actsamsuserssystemtest_resources") { - sources = [ "./entry/src/main/resources" ] + sources = [ "entry/src/main/resources" ] deps = [ ":actsamsuserssystemtest_app_profile" ] - hap_profile = "./entry/src/main/module.json" + hap_profile = "entry/src/main/module.json" } diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/Test.json b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/Test.json index 96258b2006b10e2d9bc458f66617516efbb4dd75..c602f1fd444422e74fb75da810e38ca999bc9b42 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/Test.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/Test.json @@ -1,12 +1,10 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "OHJSUnitTest", + "type": "JSUnitTest", "test-timeout": "300000", - "bundle-name": "com.acts.actsinterfacemultiuserstest", - "module-name":"phone", - "shell-timeout": "300000", - "testcase-timeout": 300000 + "package": "com.acts.actsinterfacemultiuserstest", + "shell-timeout": "300000" }, "kits": [ { diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts index 5d9cb94eb1b16f32da7f1ba0b9896c87323bca11..10dd9a1eaff7ad67843219facba7f8aea7b5a1a5 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -30,7 +30,7 @@ export default class MainAbility extends Ability { // Main window is created, set main page for this ability console.log("MainAbility onWindowStageCreate") globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) + windowStage.setUIContent(this.context, "pages/index/index", null) } onWindowStageDestroy() { diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts index 18a480f20d7c4dbac48ace298cc2713946da095c..ed230be695002ffeec4497d77fc7ce923bc13954 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -41,7 +41,7 @@ export default class MainAbility2 extends Ability { // Main window is created, set main page for this ability console.log("MainAbility2 onWindowStageCreate") globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "MainAbility/pages/index/second", null) + windowStage.setUIContent(this.context, "pages/index/second", null) commonEvent.publish("ACTS_InterfaceMultiUsers_0100_Start_CommonEvent", PublishCallBackOne); } diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility3/MainAbility3.ts b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility3/MainAbility3.ts index 901087341aa196125ecf69cd1b61963ec6d09489..b2f395fb4ec2675fc400f6e92441f514fa910972 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility3/MainAbility3.ts +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility3/MainAbility3.ts @@ -29,7 +29,7 @@ export default class MainAbility3 extends Ability { // Main window is created, set main page for this ability console.log("MainAbility3 onWindowStageCreate") globalThis.abilityContext = this.context - windowStage.setUIContent(this.context, "MainAbility/pages/index/second", null) + windowStage.setUIContent(this.context, "pages/index/second", null) globalThis.abilityContext.terminateSelfWithResult( { resultCode:1, diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..984b76dc28d0ae1a82dfc54b06dfed500280a187 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,50 @@ +/* + * 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 file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" +import testsuite from "../../test/List.test.ets" +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + console.info("subscribeEvent run !!!!") + const configService = core.getDefaultService('config') + globalThis.abilityWant.parameters['timeout'] = 20000 + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + 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/ActsAmsUsersSystemTest/entry/src/main/ets/pages/second/second.ets b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/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/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets index 75df93e18d8024f2eb686df2670bf3d9c06ed2db..25a4a28a84a1d79c93ba463daa3b8a7c34f95f69 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/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 "@ohos/hypium" +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" import commonEvent from '@ohos.commonEvent' import appManager from '@ohos.application.appManager' import osaccount from '@ohos.account.osAccount' @@ -26,7 +26,7 @@ var subscriberInfo_killprocess ={ var osAccountManager const START_ABILITY_TIMEOUT = 10000; console.debug("====>in Ability.test====>"); -export default function abilityTest() { +export default function abilityTest(abilityContext) { console.debug("====>in function abilityTest====>"); describe('ActsInterfaceMultiUsersTest', function () { // afterAll(function() { @@ -64,7 +64,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.acts.actsinterfacemultiuserstest', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2' @@ -115,7 +115,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility2' @@ -165,7 +165,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - globalThis.abilityContext.startAbility( + abilityContext.startAbility( { bundleName: 'com.acts.actsinterfacemultiuserstest', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2' @@ -217,7 +217,7 @@ export default function abilityTest() { commonEvent.subscribe(Subscriber, SubscribeCallBack); }) console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility2' @@ -266,7 +266,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.acts.actsinterfacemultiuserstest', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2' @@ -315,7 +315,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility2' @@ -363,7 +363,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - globalThis.abilityContext.startAbility( + abilityContext.startAbility( { bundleName: 'com.acts.actsinterfacemultiuserstest', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2' @@ -413,7 +413,7 @@ export default function abilityTest() { commonEvent.subscribe(Subscriber, SubscribeCallBack); }) console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility2' @@ -461,7 +461,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.example.userservicesystemapi7', abilityName: 'com.example.userservicesystemapi7.ServiceAbility' @@ -512,7 +512,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.example.userservicesystemapi7', abilityName: 'com.example.userservicesystemapi7.ServiceAbility' @@ -556,7 +556,7 @@ export default function abilityTest() { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await globalThis.abilityContext.startAbilityForResult( + await abilityContext.startAbilityForResult( { bundleName: 'com.acts.actsinterfacemultiuserstest', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3', @@ -584,7 +584,7 @@ export default function abilityTest() { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await globalThis.abilityContext.startAbilityForResult( + await abilityContext.startAbilityForResult( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility3', @@ -615,7 +615,7 @@ export default function abilityTest() { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await globalThis.abilityContext.startAbilityForResult( + await abilityContext.startAbilityForResult( { bundleName: 'com.acts.actsinterfacemultiuserstest', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3', @@ -642,7 +642,7 @@ export default function abilityTest() { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await globalThis.abilityContext.startAbilityForResult( + await abilityContext.startAbilityForResult( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility3', @@ -673,7 +673,7 @@ export default function abilityTest() { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await globalThis.abilityContext.startAbilityForResult( + await abilityContext.startAbilityForResult( { bundleName: 'com.acts.actsinterfacemultiuserstest', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3', @@ -699,7 +699,7 @@ export default function abilityTest() { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await globalThis.abilityContext.startAbilityForResult( + await abilityContext.startAbilityForResult( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility3', @@ -728,7 +728,7 @@ export default function abilityTest() { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await globalThis.abilityContext.startAbilityForResult( + await abilityContext.startAbilityForResult( { bundleName: 'com.acts.actsinterfacemultiuserstest', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3', @@ -753,7 +753,7 @@ export default function abilityTest() { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await globalThis.abilityContext.startAbilityForResult( + await abilityContext.startAbilityForResult( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility3', @@ -792,7 +792,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.acts.actsinterfacemultiuserstest', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2' @@ -841,7 +841,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility2' @@ -892,7 +892,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - globalThis.abilityContext.startAbility( + abilityContext.startAbility( { bundleName: 'com.acts.actsinterfacemultiuserstest', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility2' @@ -941,7 +941,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility2' @@ -982,7 +982,7 @@ export default function abilityTest() { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await globalThis.abilityContext.startAbilityForResult( + await abilityContext.startAbilityForResult( { bundleName: 'com.acts.actsinterfacemultiuserstest', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3', @@ -1008,7 +1008,7 @@ export default function abilityTest() { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await globalThis.abilityContext.startAbilityForResult( + await abilityContext.startAbilityForResult( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility3', @@ -1037,7 +1037,7 @@ export default function abilityTest() { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await globalThis.abilityContext.startAbilityForResult( + await abilityContext.startAbilityForResult( { bundleName: 'com.acts.actsinterfacemultiuserstest', abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3', @@ -1062,7 +1062,7 @@ export default function abilityTest() { } setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug("====>start startAbilityForResult====>"); - await globalThis.abilityContext.startAbilityForResult( + await abilityContext.startAbilityForResult( { bundleName: 'com.acts.error', abilityName: 'com.acts.error.MainAbility3', @@ -1123,7 +1123,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.acts.killprocesshap', abilityName: 'com.acts.killprocesshap.MainAbility' @@ -1198,7 +1198,7 @@ export default function abilityTest() { Subscriber = data; commonEvent.subscribe(Subscriber, SubscribeCallBack); console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.acts.killprocesshap', abilityName: 'com.acts.killprocesshap.MainAbility' @@ -1232,7 +1232,7 @@ export default function abilityTest() { */ it('ACTS_ThirdPartyKillProcess_0100', 0, async function (done) { console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.acts.killprocessthirdhap', abilityName: 'com.acts.killprocessthirdhap.MainAbility' @@ -1278,7 +1278,7 @@ export default function abilityTest() { */ it('ACTS_ThirdPartyKillProcess_0200', 0, async function (done) { console.debug("====>start startAbility====>"); - await globalThis.abilityContext.startAbility( + await abilityContext.startAbility( { bundleName: 'com.acts.killprocessthirdhap2', abilityName: 'com.acts.killprocessthirdhap2.MainAbility' diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/List.test.ets index 87a37045ffc9e7898182239819b483d50d9dafac..f4e1c2a61d343de3599bfc16768af46c3df792b0 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/List.test.ets +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/List.test.ets @@ -14,7 +14,7 @@ */ import abilityTest from './Ability.test.ets' -export default function testsuite() { +export default function testsuite(context) { console.debug("====>in list.test====>"); - abilityTest() + abilityTest(context) } \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/resources/base/profile/main_pages.json index 02221db61d317863114ff0ca4dd2b33586abff12..6898b31d2085f478ee1ed9d933a5910cbf901d92 100644 --- a/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/resources/base/profile/main_pages.json +++ b/ability/ability_runtime/actsusers/ActsAmsUsersSystemTest/entry/src/main/resources/base/profile/main_pages.json @@ -1,6 +1,6 @@ { "src": [ - "MainAbility/pages/index/index", - "MainAbility/pages/second/second" + "pages/index/index", + "pages/second/second" ] } \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/AppScope/app.json b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..654d873993702f76353e10e654856d5766a07a7a --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.acts.actsinterfacemultiusersthirdtest", + "vendor":"huawei", + "versionCode":1000000, + "versionName":"1.0.0", + "debug":false, + "icon":"$media:icon", + "label":"$string:app_name", + "description":"$string:description_application", + "distributedNotificationEnabled":true, + "keepAlive":true, + "singleUser":true, + "minAPIVersion":8, + "targetAPIVersion":8, + "car":{ + "apiCompatibleVersion":8, + "singleUser":false + } + } +} diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/AppScope/resources/base/profile/main_pages.json b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/AppScope/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/AppScope/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/BUILD.gn b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..da9e6e4431cb621fe8c7af6622739a2aad4bf43a --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAmsUsersThirdTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":actsamsusersthirdtest_js_assets", + ":actsamsusersthirdtest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx_thirdparty.p7b" + hap_name = "ActsAmsUsersThirdTest" +} + +ohos_app_scope("actsamsusersthirdtest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsusersthirdtest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsusersthirdtest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsusersthirdtest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/Test.json b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..32d68200f663626a9b14457f87106e6097a80342 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/Test.json @@ -0,0 +1,25 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.acts.actsinterfacemultiusersthirdtest", + "shell-timeout": "300000" + }, + "kits": [ + { + "type": "ShellKit", + "run-command": [ + "acm create -n user101 -t normal", + "acm switch -i 101" + ] + }, + { + "test-file-name": [ + "ActsAmsUsersThirdTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..5e2915fe4fc033cd5c9bd579dc08fe7369e51016 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,23 @@ +/* + * 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..33a978656e9b6f51d499612afce665c16d4374d7 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,45 @@ +/* + * 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 Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + console.log("MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + console.log("MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + console.log("MainAbility onForeground") + } + + onBackground() { + console.log("MainAbility onBackground") + } +}; 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 new file mode 100644 index 0000000000000000000000000000000000000000..d11ff297aef4b72d9b9a4488cfa1012722ae4968 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,52 @@ +/* + * 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 Ability from '@ohos.application.Ability' +import commonEvent from '@ohos.commonEvent' +function PublishCallBackOne() { + console.debug("====>Publish CallBack ACTS_StartAbility_0100_CommonEvent====>"); + globalThis.abilityContext.terminateSelf(); + console.debug("====>terminateSelf succese====>") + commonEvent.publish("ACTS_TerminateSelf_CommonEvent", ()=>{ + console.debug("====>publish ACTS_TerminateSelf_CommonEvent====>") + }); +} +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + console.log("MainAbility2 onCreate") + } + + onDestroy() { + console.log("MainAbility2 onDestroy") + } + + onWindowStageCreate(windowStage) { + console.log("MainAbility2 onWindowStageCreate") + globalThis.abilityContext = this.context + commonEvent.publish("ACTS_InterfaceMultiUsers_0100_Start_CommonEvent", PublishCallBackOne); + } + + onWindowStageDestroy() { + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + console.log("MainAbility onForeground") + } + + onBackground() { + console.log("MainAbility onBackground") + } +}; 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 new file mode 100644 index 0000000000000000000000000000000000000000..160c319d16027f71779d18088633c125f8ecf759 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/MainAbility3/MainAbility3.ts @@ -0,0 +1,57 @@ +/* + * 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 Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + console.log("MainAbility3 onCreate") + } + + onDestroy() { + console.log("MainAbility3 onDestroy") + } + + onWindowStageCreate(windowStage) { + console.log("MainAbility3 onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/second", null) + globalThis.abilityContext.terminateSelfWithResult( + { + resultCode:1, + want:{ + action:'ACTION' + } + },()=>{ + console.debug("====>terminateSelfWithResult succese====>") + }); + console.debug("====>terminateSelf end====>") + } + + onWindowStageDestroy() { + console.log("MainAbility3 onWindowStageDestroy") + } + + onForeground() { + console.log("MainAbility3 onForeground") + globalThis.abilityContext.terminateSelfWithResult({ + resultCode: 1 + }) + } + + onBackground() { + console.log("MainAbility3 onBackground") + } +}; diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8b2238543638218c823f2414c955176da3af7818 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,50 @@ +/* + * 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 file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" +import testsuite from "../../test/List.test.ets" +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + console.info("subscribeEvent run !!!!") + const configService = core.getDefaultService('config') + globalThis.abilityWant.parameters['timeout'] = 10000 + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + 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/pages/second/second.ets b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/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/test/Ability.test.ets b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..474672fb84b08b330eb4a8d216fc45d7aafd3b39 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,961 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import commonEvent from '@ohos.commonEvent' +import osaccount from '@ohos.account.osAccount' + +var subscriberInfo_MainAbility = { + events: ["ACTS_InterfaceMultiUsers_0100_Start_CommonEvent","ACTS_TerminateSelf_CommonEvent"] +}; +var osAccountManager +const START_ABILITY_TIMEOUT = 6000; +console.debug("====>in Ability.test====>"); +export default function abilityTest(abilityContext) { + console.debug("====>in function abilityTest====>"); + describe('ActsInterfaceMultiUsersThirdTest', function () { + + /* + * @tc.number : ACTS_ThirdPartyStartAbility_0100 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options succeeded.(promise) + */ + it('ACTS_ThirdPartyStartAbility_0100', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + function SubscribeCallBack (err, data) { + expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); + console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ + startresult = true + } + 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("====>start startAbility====>"); + await abilityContext.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2' + }, { + windowMode:0 + }).then((data)=>{ + console.debug("====>startAbility end====>"); + console.debug("====>data is====>" + JSON.stringify(data)); + }) + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + done(); + } + + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartAbility_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbility_0200 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options failed.(promise) + */ + it('ACTS_ThirdPartyStartAbility_0200', 0, async function (done) { + let Subscriber + function SubscribeCallBack (err, data) { + expect().assertFail(); + console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(subscriberInfo_MainAbility).then((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("====>start startAbility====>"); + await abilityContext.startAbility( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility2' + }, { + windowMode:0 + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartAbility_0200 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbility_0300 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options succeeded.(callback) + */ + it('ACTS_ThirdPartyStartAbility_0300', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + function SubscribeCallBack (err, data) { + expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); + console.debug("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data)); + if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ + startresult = true + } + 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("====>start startAbility====>"); + abilityContext.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2' + }, { + windowMode:0 + },() => { + console.debug("====>startAbility end====>" ); + }) + }) + }) + + function UnSubscribeCallback() { + flag = false + console.debug("====>UnSubscribeCallback====>"); + expect(startresult).assertEqual(true); + done(); + } + + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartAbility_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbility_0400 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options failed.(callback) + */ + it('ACTS_ThirdPartyStartAbility_0400', 0, async function (done) { + let Subscriber + function SubscribeCallBack (err, data) { + expect().assertFail(); + console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + 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("====>start startAbility====>"); + await abilityContext.startAbility( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility2' + }, { + windowMode:0 + },() => { + console.debug("====>startAbility end====>" ); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartAbility_0400 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbility_0500 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability succeeded.(promise) + */ + it('ACTS_ThirdPartyStartAbility_0500', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + function SubscribeCallBack (err, data) { + expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); + console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ + startresult = true + } + 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("====>start startAbility====>"); + await abilityContext.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2' + }).then((data)=>{ + console.debug("====>startAbility end====>"); + console.debug("====>data is====>" + JSON.stringify(data)); + }) + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + done(); + } + + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartAbility_0500 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbility_0600 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability failed.(promise) + */ + it('ACTS_ThirdPartyStartAbility_0600', 0, async function (done) { + let Subscriber + function SubscribeCallBack (err, data) { + expect().assertFail(); + console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(subscriberInfo_MainAbility).then((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("====>start startAbility====>"); + await abilityContext.startAbility( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility2' + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartAbility_0600 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbility_0700 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability succeeded.(callback) + */ + it('ACTS_ThirdPartyStartAbility_0700', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + function SubscribeCallBack (err, data) { + expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); + console.debug("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data)); + if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ + startresult = true + } + 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("====>start startAbility====>"); + abilityContext.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2' + },() => { + console.debug("====>startAbility end====>" ); + }) + }) + }) + + function UnSubscribeCallback() { + flag = false + console.debug("====>UnSubscribeCallback====>"); + expect(startresult).assertEqual(true); + done(); + } + + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartAbility_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbility_0800 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability failed.(callback) + */ + it('ACTS_ThirdPartyStartAbility_0800', 0, async function (done) { + let Subscriber + function SubscribeCallBack (err, data) { + expect().assertFail(); + console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + 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("====>start startAbility====>"); + await abilityContext.startAbility( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility2' + },() => { + console.debug("====>startAbility end====>" ); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyStartAbility_0800 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbilityForResult_0100 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(promise) + */ + it('ACTS_ThirdPartyStartAbilityForResult_0100', 0, async function (done) { + var flag = true + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartAbilityForResult_0100 - timeout'); + done(); + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.actsinterfacemultiusersthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3', + }, { + windowMode:0 + }).then((data)=>{ + console.debug("====>startAbilityForResult end====>"); + flag = false + console.debug("====>data.resultCode is====>"+JSON); + expect(data.resultCode).assertEqual(1) + expect(data.want.action).assertEqual('ACTION') + done(); + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbilityForResult_0200 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult failed.(promise) + */ + it('ACTS_ThirdPartyStartAbilityForResult_0200', 0, async function (done) { + function timeout() { + console.debug('ACTS_ThirdPartyStartAbilityForResult_0200 - timeout'); + done(); + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility3', + }, { + windowMode:0 + }).then((data)=>{ + console.debug("====>startAbilityForResult end====>"); + expect().assertFail(); + expect(data.resultCode).assertEqual(1) + expect(data.want.action).assertEqual('ACTION') + done(); + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbilityForResult_0300 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(callback) + */ + it('ACTS_ThirdPartyStartAbilityForResult_0300', 0, async function (done) { + var flag = true + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartAbilityForResult_0300 - timeout'); + done(); + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.actsinterfacemultiusersthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3', + },{ + windowMode : 0 + },(err,data)=>{ + console.debug("====>startAbilityForResult end====>"); + flag = false + expect(data.resultCode).assertEqual(1) + expect(data.want.action).assertEqual('ACTION') + done(); + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbilityForResult_0400 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult failed.(callback) + */ + it('ACTS_ThirdPartyStartAbilityForResult_0400', 0, async function (done) { + function timeout() { + console.debug('ACTS_ThirdPartyStartAbilityForResult_0400 - timeout'); + done(); + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility3', + }, { + windowMode:0 + },(err,data)=>{ + expect().assertFail(); + console.debug("====>startAbilityForResult end====>"); + expect(data.resultCode).assertEqual(1) + expect(data.want.action).assertEqual('ACTION') + done(); + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbilityForResult_0500 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(promise) + */ + it('ACTS_ThirdPartyStartAbilityForResult_0500', 0, async function (done) { + var flag = true + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartAbilityForResult_0500 - timeout'); + done(); + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.actsinterfacemultiusersthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3', + }).then((data)=>{ + console.debug("====>startAbilityForResult end====>"); + flag = false + console.debug("====>data.resultCode is====>"+JSON); + expect(data.resultCode).assertEqual(1) + expect(data.want.action).assertEqual('ACTION') + done(); + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbilityForResult_0600 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult failed.(promise) + */ + it('ACTS_ThirdPartyStartAbilityForResult_0600', 0, async function (done) { + function timeout() { + console.debug('ACTS_ThirdPartyStartAbilityForResult_0600 - timeout'); + done(); + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility3', + }).then((data)=>{ + console.debug("====>startAbilityForResult end====>"); + expect().assertFail(); + expect(data.resultCode).assertEqual(1) + expect(data.want.action).assertEqual('ACTION') + done(); + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbilityForResult_0700 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(callback) + */ + it('ACTS_ThirdPartyStartAbilityForResult_0700', 0, async function (done) { + var flag = true + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ThirdPartyStartAbilityForResult_0700 - timeout'); + done(); + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.actsinterfacemultiusersthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3', + },(err,data)=>{ + console.debug("====>startAbilityForResult end====>"); + flag = false + expect(data.resultCode).assertEqual(1) + expect(data.want.action).assertEqual('ACTION') + done(); + }) + }) + + /* + * @tc.number : ACTS_ThirdPartyStartAbilityForResult_0800 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult failed.(callback) + */ + it('ACTS_ThirdPartyStartAbilityForResult_0800', 0, async function (done) { + function timeout() { + console.debug('ACTS_ThirdPartyStartAbilityForResult_0800 - timeout'); + done(); + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility3', + },(err,data)=>{ + expect().assertFail(); + console.debug("====>startAbilityForResult end====>"); + expect(data.resultCode).assertEqual(1) + expect(data.want.action).assertEqual('ACTION') + done(); + }) + }) + + /* + * @tc.number : ACTS_TerminateSelf_0100 + * @tc.name : Use terminateself to terminate ability + * @tc.desc : Starting mainability2 with startAbility then terminateself ability succeeded.(promise) + */ + it('ACTS_TerminateSelf_0100', 0, async function (done) { + let Subscriber + var flag = true + var terminateresult = false + function SubscribeCallBack (err, data) { + expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); + console.debug("====>0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + if(data.event == "ACTS_TerminateSelf_CommonEvent"){ + terminateresult = true + 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("====>start startAbility====>"); + await abilityContext.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2' + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(terminateresult).assertEqual(true); + done(); + } + + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_TerminateSelf_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_TerminateSelf_0200 + * @tc.name : Use terminateself to terminate ability + * @tc.desc : Starting mainability2 with startAbility then terminateself ability failed.(promise) + */ + it('ACTS_TerminateSelf_0200', 0, async function (done) { + let Subscriber + function SubscribeCallBack (err, data) { + expect().assertFail(); + console.debug("====>0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + 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("====>start startAbility====>"); + await abilityContext.startAbility( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility2' + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_TerminateSelf_0200 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_TerminateSelf_0300 + * @tc.name : Use terminateself to terminate ability + * @tc.desc : Starting mainability2 with startAbility then terminateself ability succeeded.(callback) + */ + it('ACTS_TerminateSelf_0300', 0, async function (done) { + let Subscriber + var flag = true + var terminateresult = false + function SubscribeCallBack (err, data) { + expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent" || data.event == "ACTS_TerminateSelf_CommonEvent").assertTrue(); + console.debug("====>0300 Subscribe CallBack data:====>" + JSON.stringify(data)); + if(data.event == "ACTS_TerminateSelf_CommonEvent"){ + terminateresult = true + 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("====>start startAbility====>"); + abilityContext.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility2' + },() => { + console.debug("====>startAbility end====>" ); + }) + }) + }) + + function UnSubscribeCallback() { + flag = false + console.debug("====>UnSubscribeCallback====>"); + expect(terminateresult).assertEqual(true); + done(); + } + + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_TerminateSelf_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_TerminateSelf_0400 + * @tc.name : Use terminateself to terminate ability + * @tc.desc : Starting mainability2 with startAbility then terminateself ability failed.(callback) + */ + it('ACTS_TerminateSelf_0400', 0, async function (done) { + let Subscriber + function SubscribeCallBack (err, data) { + expect().assertFail(); + console.debug("====>0400 Subscribe CallBack data:====>" + JSON.stringify(data)); + 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("====>start startAbility====>"); + await abilityContext.startAbility( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility2' + },() => { + console.debug("====>startAbility end====>" ); + }) + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + done(); + } + + function timeout() { + console.debug('ACTS_TerminateSelf_0400 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_TerminateSelfWithResult_0100 + * @tc.name : Use terminateselfwithresult to terminate ability and return result + * @tc.desc : Starting mainability3 with startAbilityforresult + * then terminateself ability and return result succeeded.(promise) + */ + it('ACTS_TerminateSelfWithResult_0100', 0, async function (done) { + var flag = true + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_TerminateSelfWithResult_0100 - timeout'); + done(); + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.actsinterfacemultiusersthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3', + }).then((data)=>{ + console.debug("====>startAbilityForResult end====>"); + flag = false + console.debug("====>data.resultCode is====>"+JSON); + expect(data.resultCode).assertEqual(1) + expect(data.want.action).assertEqual('ACTION') + done(); + }) + }) + + /* + * @tc.number : ACTS_TerminateSelfWithResult_0200 + * @tc.name : Use terminateselfwithresult to terminate ability and return result + * @tc.desc : Starting mainability3 with startAbilityforresult + * then terminateself ability and return result failed.(promise) + */ + it('ACTS_TerminateSelfWithResult_0200', 0, async function (done) { + function timeout() { + console.debug('ACTS_TerminateSelfWithResult_0200 - timeout'); + done(); + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility3', + }).then((data)=>{ + console.debug("====>startAbilityForResult end====>"); + expect().assertFail(); + expect(data.resultCode).assertEqual(1) + expect(data.want.action).assertEqual('ACTION') + done(); + }) + }) + + /* + * @tc.number : ACTS_TerminateSelfWithResult_0300 + * @tc.name : Use terminateselfwithresult to terminate ability and return result + * @tc.desc : Starting mainability3 with startAbilityforresult + * then terminateself ability and return result succeeded.(callback) + */ + it('ACTS_TerminateSelfWithResult_0300', 0, async function (done) { + var flag = true + function timeout() { + if (flag == true) { + expect().assertFail(); + console.debug('ACTS_TerminateSelfWithResult_0300 - timeout'); + done(); + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.actsinterfacemultiusersthirdtest', + abilityName: 'com.acts.actsinterfacemultiusersthirdtest.MainAbility3', + },(err,data)=>{ + flag = false + console.debug("====>startAbilityForResult end====>"); + expect(data.resultCode).assertEqual(1) + expect(data.want.action).assertEqual('ACTION') + done(); + }) + }) + + /* + * @tc.number : ACTS_TerminateSelfWithResult_0400 + * @tc.name : Use terminateselfwithresult to terminate ability and return result + * @tc.desc : Starting mainability3 with startAbilityforresult + * then terminateself ability and return result failed.(callback) + */ + it('ACTS_TerminateSelfWithResult_0400', 0, async function (done) { + function timeout() { + console.debug('ACTS_TerminateSelfWithResult_0400 - timeout'); + done(); + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.error', + abilityName: 'com.acts.error.MainAbility3', + },(err,data)=>{ + expect().assertFail(); + console.debug("====>startAbilityForResult end====>"); + expect(data.resultCode).assertEqual(1) + expect(data.want.action).assertEqual('ACTION') + done(); + }) + }) + }) +} \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..198b3e4099bc53462227bffa2f9c2fcb31c19baa --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * 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 abilityTest from './Ability.test.ets' + +export default function testsuite(context) { + console.debug("====>in list.test====>"); + abilityTest(context) +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/module.json b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..c4fab1c1ec4aa0ad8e37219d1bba692d788d9111 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/module.json @@ -0,0 +1,55 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.acts.actsinterfacemultiusersthirdtest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.acts.actsinterfacemultiusersthirdtest.MainAbility2", + "srcEntrance": "./ets/MainAbility2/MainAbility2.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait" + }, + { + "name": "com.acts.actsinterfacemultiusersthirdtest.MainAbility3", + "srcEntrance": "./ets/MainAbility3/MainAbility3.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait" + } + ] + } +} diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/resources/base/media/icon.png differ 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 new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/signature/openharmony_sx_thirdparty.p7b b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/signature/openharmony_sx_thirdparty.p7b new file mode 100644 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/ability/ability_runtime/actsusers/ActsAmsUsersThirdTest/signature/openharmony_sx_thirdparty.p7b differ diff --git a/ability/ability_runtime/actsusers/BUILD.gn b/ability/ability_runtime/actsusers/BUILD.gn index 51a0a8c8babe307638de8a8359921986ccf5a917..f9a82288b2e3bcecb91a95188de4cdbcb5436717 100644 --- a/ability/ability_runtime/actsusers/BUILD.gn +++ b/ability/ability_runtime/actsusers/BUILD.gn @@ -18,10 +18,13 @@ group("actsusers") { if (is_standard_system) { deps = [ "ActsAmsUsersApi7AppA:ActsAmsUsersApi7AppA", + "ActsAmsUsersExtensionThirdTest:ActsAmsUsersExtensionThirdTest", "ActsAmsUsersKillProcessAppA:ActsAmsUsersKillProcessAppA", "ActsAmsUsersKillProcessAppB:ActsAmsUsersKillProcessAppB", "ActsAmsUsersKillProcessAppC:ActsAmsUsersKillProcessAppC", "ActsAmsUsersSystemTest:ActsAmsUsersSystemTest", + "ActsAmsUsersThirdTest:ActsAmsUsersThirdTest", + "actsmanyuserthirdabilitytest:ActsManyUsersAbilityTest", ] } } diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/AppScope/app.json b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..b1b238029879b38f307ef03222eaf46089585039 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actsmanyusersabilitytest", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon" : "$media:icon", + "label" : "$string:app_name", + "description" : "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive" : true, + "singleUser": true, + "minAPIVersion": 8, + "targetAPIVersion": 8, + "car": { + "apiCompatibleVersion": 8, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..be09cccde1bc7369ef47a5cd45d2b06884c88602 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/BUILD.gn b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..223611a0b0c17a75d7016946f0ba3c8abbfe43a1 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/BUILD.gn @@ -0,0 +1,41 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsManyUsersAbilityTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":actsmanyusersabilitytest_js_assets", + ":actsmanyusersabilitytest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx_thirdparty.p7b" + hap_name = "ActsManyUsersAbilityTest" +} + +ohos_app_scope("actsmanyusersabilitytest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsmanyusersabilitytest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsmanyusersabilitytest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsmanyusersabilitytest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/Test.json b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..a559bc10e9cd8463fb27c41d4205b6051f93816c --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/Test.json @@ -0,0 +1,31 @@ + +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.actsmanyusersabilitytest", + "shell-timeout": "60000" + }, + "kits": [ + { + "type": "ShellKit", + "run-command": [ + "acm create -n 101 -t normal", + "acm switch -i 101" + ], + "teardown-command":[ + "acm delete -i 101" + ] + }, + { + "test-file-name": [ + "ActsManyUsersAbilityTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + + ] +} + diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..98eb012db14b28a1f92522e305b9d4538e496dd3 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,23 @@ +/* +* 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..97457d2797e717c9f43db5f1557a78ebf2fa929d --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/MainAbility/MainAbility.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 MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + 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) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb01aca86ebcdf13084905ed44790846ae613def --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,166 @@ +/* +* 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 ServiceExtension from '@ohos.application.ServiceExtension' +import commonEvent from '@ohos.commonEvent' +var conn = -1; +function publishCallBackOne () { + console.log("========Publish CallBack AMS_ConnectAbility_0100_commonEvent========"); +} +function publishCallBackTwo () { + console.log("========Publish CallBack AMS_ConnectAbility_0200_commonEvent========"); +} +function publishCallBackThree () { + console.log("========Publish CallBack AMS_ConnectAbility_0300_commonEvent========"); +} +function publishCallBackFour () { + console.log("========Publish CallBack AMS_ConnectAbility_0400_commonEvent========"); +} +function publishCallBackFive () { + console.log("========Publish CallBack AMS_ConnectAbility_0500_commonEvent========"); +} +function publishCallBackSix () { + console.log("========Publish CallBack AMS_ConnectAbility_0600_commonEvent========"); +} +function publishCallBackzero () { + console.log("========Publish CallBack AMSc_disonnectAbility_0100_commonEvent========"); +} +function publishCallBackttwo () { + console.log("========Publish CallBack AMSc_disonnectAbility_0200_commonEvent========"); +} + +export default class ServiceAbility extends ServiceExtension { + onCreate(want) { + console.log('ServiceAbility onCreate, want: ' + want.abilityName); + } + + onRequest(want, startId) { + console.log('ServiceAbility onRequest, want: ' + want.abilityName + ', startId: ' + startId); + + console.log('ServiceAbility registerApplicationStateObserver begin'); + console.log('ServiceAbility registerApplicationStateObserver end, conn: ' + conn); + } + + onConnect(want) { + console.log('ServiceAbility onConnect, want:' + want.abilityName); + let extensionContext = this.context + if (want.action == "one") { + commonEvent.publish("AMS_ConnectAbility_0100_commonEvent", publishCallBackOne); + } + ; + if (want.action == "two") { + commonEvent.publish("AMS_ConnectAbility_0200_commonEvent", publishCallBackTwo); + } + ; + if (want.action == "Three") { + commonEvent.publish("AMS_ConnectAbility_0300_commonEvent", publishCallBackThree); + } + ; + if (want.action == "Four") { + commonEvent.publish("AMS_ConnectAbility_0400_commonEvent", publishCallBackFour); + } + ; + if (want.action == "Five") { + commonEvent.publish("AMS_ConnectAbility_0500_commonEvent", publishCallBackFive); + } + ; + if (want.action == "Six") { + commonEvent.publish("AMS_ConnectAbility_0600_commonEvent", publishCallBackSix); + } + ; + if (want.action == "Seven") { + extensionContext.connectAbility( + { + bundleName: "com.example.manyusersabilitytest", + abilityName: "com.example.manyusersabilitytest.ServiceAbility2", + } + ); + }; + if (want.action == "Eight") { + extensionContext.connectAbility( + { + bundleName: "com.example.manyusersabilitytesta", + abilityName: "com.example.manyusersabilitytest.ServiceAbility3", + } + ); + }; + if (want.action == "Nine") { + console.log('connectAbility 111'); + let num = this.context.connectAbility( + { + bundleName: 'com.example.manyusersabilitytest', + abilityName: 'com.example.manyusersabilitytest.ServiceAbility2' + }) + setTimeout(()=>{ + this.context.disconnectAbility(num).then(()=>{ + console.log('in disconnectAbility'); + }) + },1000) + + }; + if (want.action == "Ten") { + console.log('connectAbility 222'); + let num = this.context.connectAbility( + { + bundleName: 'com.example.manyusersabilitytest', + abilityName: 'com.example.manyusersabilitytest.ServiceAbility2' + }) + setTimeout(()=>{ + this.context.disconnectAbility(num).then(()=>{ + console.log('in disconnectAbility2'); + }) + },1000) + + }; + if (want.action == "Ten one") { + console.log('connectAbility 333'); + let num = this.context.connectAbility( + { + bundleName: 'com.example.manyusersabilitytest', + abilityName: 'com.example.manyusersabilitytest.ServiceAbility2' + }) + setTimeout(()=>{ + this.context.disconnectAbility(2222).then(()=>{ + console.log('in disconnectAbility3'); + }) + },1000) + + }; + if (want.action == "Ten two") { + console.log('connectAbility 444'); + let num = this.context.connectAbility( + { + bundleName: 'com.example.manyusersabilitytest', + abilityName: 'com.example.manyusersabilitytest.ServiceAbility2' + }) + setTimeout(()=>{ + this.context.disconnectAbility(2222).then(()=>{ + console.log('in disconnectAbility4'); + }) + },1000) + + }; + } + + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + commonEvent.publish("AMSc_disonnectAbility_0100_commonEvent",publishCallBackzero); + commonEvent.publish("AMSc_disonnectAbility_0200_commonEvent",publishCallBackttwo); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} + diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..b49731a414958a281c2f0c4eab0e7fb408eb2c2f --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,25 @@ +/* +* 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. +*/ +export default { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100644 index 0000000000000000000000000000000000000000..b719b73ab85d76d471b61a82dd0b49db55d4e76c --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -0,0 +1,60 @@ +/* + * 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 ServiceExtension from '@ohos.application.ServiceExtension' +import commonEvent from "@ohos.commonEvent" + +export default class ServiceAbility2 extends ServiceExtension { + onCreate(want) { + console.log('ServiceAbility2 onCreate'); + globalThis.abilityWant = want; + } + + onDestory(){ + console.log('ServiceAbility2 onDestory'); + } + + onRequest(want,startId) { + console.log('ServiceAbility2 onRequest'); + } + + onConnect(want) { + console.log('ServiceAbility2 onConnect'); + commonEvent.publish("AMS_ConnectAbility_0700_commonEvent", () => { + console.log("publish Publish AMS_ConnectAbility_0700_commonEvent callback"); + }) + commonEvent.publish("AMS_ConnectAbility_0900_commonEvent", () => { + console.log("publish Publish AMS_ConnectAbility_0900_commonEvent callback"); + }) + commonEvent.publish("AMS_ConnectAbility_1000_commonEvent", () => { + console.log("publish Publish AMS_ConnectAbility_1000_commonEvent callback"); + }) + commonEvent.publish("AMS_ConnectAbility_1100_commonEvent", () => { + console.log("publish Publish AMS_ConnectAbility_1100_commonEvent callback"); + }) + commonEvent.publish("AMS_ConnectAbility_1200_commonEvent", () => { + console.log("publish Publish AMS_ConnectAbility_1200_commonEvent callback"); + }) + } + + + onDisconnect(want) { + console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility2 onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/ServiceAbility2/service.ts b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..340a610cb718c70c98add0b5d052bb4589185174 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/ServiceAbility2/service.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ +export default { + onStart() { + console.info('ServiceAbility2 onStart'); + }, + onStop() { + console.info('ServiceAbility2 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility2 onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/pages/index/index.ets b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd39208788d8fdb66d3c7fbff8afefb2763dda90 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,50 @@ +/* + * 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 file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index" +import testsuite from "../../test/List.test.ets" +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + console.info("subscribeEvent run !!!!") + const configService = core.getDefaultService('config') + globalThis.abilityWant.parameters['timeout'] = 10000 + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + 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/pages/second/second.ets b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/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/test/List.test.ets b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f5923665570101769b9a6aff451f7c50cc3f6e52 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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 abilityTest from './manyusersabilitytest.test.ets' +export default function testsuite(context) { + + abilityTest(context) +} \ 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 new file mode 100644 index 0000000000000000000000000000000000000000..2ad577c57b2da1a773fd1e5735e76f3c3539cbd4 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/ets/test/manyusersabilitytest.test.ets @@ -0,0 +1,844 @@ +/* + * 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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import commonEvent from '@ohos.commonEvent' + + +var subscriberInfoStartAbility_0100 = { + events: ["AMS_ConnectAbility_0100_commonEvent"], +}; +var subscriberInfoStartAbility_0200 = { + events: ["AMS_ConnectAbility_0200_commonEvent"], +}; +var subscriberInfoStartAbility_0300 = { + events: ["AMS_ConnectAbility_0300_commonEvent"], +}; +var subscriberInfoStartAbility_0400 = { + events: ["AMS_ConnectAbility_0400_commonEvent"], +}; +var subscriberInfoStartAbility_0500 = { + events: ["AMS_ConnectAbility_0500_commonEvent"], +}; +var subscriberInfoStartAbility_0600 = { + events: ["AMS_ConnectAbility_0600_commonEvent"], +}; +var subscriberInfoStartAbility_0700 = { + events: ["AMS_ConnectAbility_0700_commonEvent"], +}; +var subscriberInfoStartAbility_0800 = { + events: ["AMS_ConnectAbility_0800_commonEvent"], +}; +var subscriberInfoStartAbility_0900 = { + events: ["AMS_ConnectAbility_0900_commonEvent"], +}; + +var subscriberInfoStartAbility_1000 = { + events: ["AMS_ConnectAbility_1000_commonEvent"], +}; + +var subscriberInfoStartAbility_1100 = { + events: ["AMS_ConnectAbility_1100_commonEvent"], +}; + +var subscriberInfoStartAbility_1200 = { + events: ["AMS_ConnectAbility_1200_commonEvent"], +}; +var unsubscriberInfoStartAbility_0100 = { + events: ["AMSc_disonnectAbility_0100_commonEvent"], +}; +var unsubscriberInfoStartAbility_0200 = { + events: ["AMSc_disonnectAbility_0200_commonEvent"], +}; + + +const START_ABILITY_TIMEOUT = 1000; +globalThis.number = 0; + +export default function abilityTest(abilityContext) { + describe('manyuserability', function () { + + function onFailedCallBack(code) { + console.log('ACTS_ConnectAbility_0200 Connectability errcode:' + code); + } + + it('ACTS_ThirdPartyConnectAbility_0100', 0, async function (done) { + console.log('ACTS_ThirdPartyConnectAbility_0100====ACTS_ThirdPartyConnectAbility_0100 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0100_commonEvent"); + console.debug("====>ACTS_ThirdPartyConnectAbility_0100 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ThirdPartyConnectAbility_0100 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_0100).then(async (data) => { + console.debug("====>ACTS_ThirdPartyConnectAbility_0100 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + done(); + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ThirdPartyConnectAbility_0100 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>ACTS_ThirdPartyConnectAbility_0100 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsmanyusersabilitytest", + abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", + action: "one", + }, + ); + console.debug("====>ACTS_ThirdPartyConnectAbility_0100 4 "); + + }) + it('ACTS_ThirdPartyConnectAbility_0200', 0, async function (done) { + console.log('ACTS_ThirdPartyConnectAbility_0200====Subscribe CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0200_commonEvent"); + + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } + + commonEvent.createSubscriber(subscriberInfoStartAbility_0200).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + done(); + } + + function timeout() { + console.debug('ACTS_ThirdPartyConnectAbility_0200 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + done(); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsmanyusersabilitytest", + abilityName: "com.example.actsmanyusersabilitytest.ServiceAbilityone", + action: "two", + }, + { + onFailed: onFailedCallBack, + }, + + + ); + }) + + it('ACTS_ThirdPartyDisconnectAbility_0100', 0, async function (done) { + console.log('ACTS_ThirdPartyDisconnectAbility_0100====ACTS_ThirdPartyDisconnectAbility_0100 5 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0100 6====>"); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0100 6====>"); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_0300).then(async (data) => { + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0100 2 Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(()=> + { + done() + }, 1000)}; + + function timeout() { + expect().assertFail(); + console.debug('AMS_DonnectAbility_0300 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0100 3====>"); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsmanyusersabilitytest", + abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", + action: "Three", + }, + ); + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0100 4====>"); + }) + + it('ACTS_ThirdPartyDisconnectAbility_0200', 0, async function (done) { + console.log('ACTS_ThirdPartyDisconnectAbility_0200 1====ACTS_ThirdPartyDisconnectAbility_0200 3 CallBack1 data:====>" + JSON.stringify(data)); + commonEvent.createSubscriber(unsubscriberInfoStartAbility_0100).then(async (data) => { + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 6 Subscriber====>"); + subscriberdisconnect = data; + await commonEvent.subscribe(subscriberdisconnect, subscribedisconnectback); + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 1111 connectAbility1====>"); + + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 1111 connectAbility2====>"); + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 66 Subscriber====>"); + abilityContext.disconnectAbility( + 999, + (error, data) => { + console.log('ACTS_ThirdPartyDisconnectAbility_0200 5 DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + }) + } + + function subscribedisconnectback(err, data) { + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 7 CallBack2 data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(subscriberdisconnect, () => { + console.debug('unsubscribe subscriberdisconnect'); + + commonEvent.unsubscribe(subscriber, () => { + console.debug('unsubscribe subscriber') + clearTimeout(id); + expect().assertFail(); + done(); + }) + }) + } + + function timeout() { + console.debug('ACTS_ThirdPartyDisconnectAbility_0200 8 timeout'); + commonEvent.unsubscribe(subscriberdisconnect, () => { + console.debug('unsubscribe subscriberdisconnect'); + commonEvent.unsubscribe(subscriber, () => { + console.debug('unsubscribe subscriber') + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('ACTS_ThirdPartyDisconnectAbility_0200 9 DisconnectAbility result errCode : ' + error.code + " data: " + data) + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 99 Subscriber====>"); + setTimeout(() => { + done(); + }, 1000) + }); + }) + }) + + + } + + commonEvent.createSubscriber(subscriberInfoStartAbility_0400).then(async (data) => { + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 10 Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack) + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsmanyusersabilitytest", + abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", + action: "Four", + }, + ); + console.debug("====>connId is:====>" + JSON.stringify(connId)); + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0200 1010 Subscriber====>"); + }) + + + function unSubscribeCallback() { + console.debug("====>ACTS_DisconnectAbility_0200 1111 UnSubscribe CallBack====>"); + done(); + } + + }) + + it('ACTS_ThirdPartyDisconnectAbility_0300', 0, async function (done) { + console.log('ACTS_ThirdPartyDisconnectAbility_0300====ACTS_ThirdPartyDisconnectAbility_0300 4 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0500_commonEvent"); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('ACTS_ThirdPartyDisconnectAbility_0300 5 DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_0500).then(async (data) => { + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0300 1 Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0300 6 CallBack====>"); + setTimeout(() => { + done(); + }, 1000) + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ThirdPartyDisconnectAbility_0300 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('ACTS_ThirdPartyDisconnectAbility_0300 7 DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0300 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsmanyusersabilitytest", + abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", + action: "Five", + }, + ); + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0300 4 "); + }) + it('ACTS_ThirdPartyDisconnectAbility_0400', 0, async function (done) { + console.log('ACTS_ThirdPartyDisconnectAbility_0400 1====ACTS_ThirdPartyDisconnectAbility_0400 3 CallBack1 data:====>" + JSON.stringify(data)); + commonEvent.createSubscriber(unsubscriberInfoStartAbility_0200).then(async (data) => { + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 6 Subscriber====>"); + subscriberdisconnect = data; + await commonEvent.subscribe(subscriberdisconnect, subscribedisconnectback); + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 1111 connectAbility1====>"); + + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 1111 connectAbility2====>"); + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 66 Subscriber====>"); + abilityContext.disconnectAbility( + 999, + (error, data) => { + console.log('ACTS_ThirdPartyDisconnectAbility_0400 5 DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + }) + } + + function subscribedisconnectback(err, data) { + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 7 CallBack2 data:====>" + JSON.stringify(data)); + commonEvent.unsubscribe(subscriberdisconnect, () => { + console.debug('unsubscribe subscriberdisconnect'); + + commonEvent.unsubscribe(subscriber, () => { + console.debug('unsubscribe subscriber') + clearTimeout(id); + expect().assertFail(); + done(); + }) + }) + } + + function timeout() { + console.debug('ACTS_ThirdPartyDisconnectAbility_0400 8 timeout'); + commonEvent.unsubscribe(subscriberdisconnect, () => { + console.debug('unsubscribe subscriberdisconnect'); + commonEvent.unsubscribe(subscriber, () => { + console.debug('unsubscribe subscriber') + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('ACTS_ThirdPartyDisconnectAbility_0400 9 DisconnectAbility result errCode : ' + error.code + " data: " + data) + console.debug("====>ACTS_DisconnectAbility_0200 99 Subscriber====>"); + setTimeout(() => { + done(); + }, 1000) + }); + }) + }) + + + } + + commonEvent.createSubscriber(subscriberInfoStartAbility_0600).then(async (data) => { + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 10 Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack) + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsmanyusersabilitytest", + abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", + action: "Six", + }, + ); + console.debug("====>connId is:====>" + JSON.stringify(connId)); + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 1010 Subscriber====>"); + }) + + + function unSubscribeCallback() { + console.debug("====>ACTS_ThirdPartyDisconnectAbility_0400 1111 UnSubscribe CallBack====>"); + done(); + } + + }) + it('ACTS_ThirdPartyExtensionConnectAbility_0100', 0, async function (done) { + console.log('ACTS_ThirdPartyExtensionConnectAbility_0100====ACTS_ThirdPartyExtensionConnectAbility_0100 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0700_commonEvent"); + console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0100 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0100 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_0700).then(async (data) => { + console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0100 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + setTimeout(() => { + done(); + }, 1000) + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ExtensionConnectAbility_0100 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0100 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsmanyusersabilitytest", + abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", + action: "Seven", + }, + ); + console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0100 4 "); + + }) + + it('ACTS_ThirdPartyExtensionConnectAbility_0200', 0, async function (done) { + console.log('ACTS_ThirdPartyExtensionConnectAbility_0200====ACTS_ThirdPartyExtensionConnectAbility_0200 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0800_commonEvent"); + console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0200 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0200 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_0800).then(async (data) => { + console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0200 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + setTimeout(() => { + done(); + }, 1000) + } + + function timeout() { + console.debug('ACTS_ThirdPartyExtensionConnectAbility_0200 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0200 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsmanyusersabilitytest", + abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", + action: "Eight", + }, + ); + console.debug("====>ACTS_ThirdPartyExtensionConnectAbility_0200 4 "); + + }) + it('ACTS_ThirdPartyExtensionDisconnectAbility_0100', 0, async function (done) { + console.log('ACTS_ThirdPartyExtensionDisconnectAbility_0100====ACTS_ThirdPartyExtensionDisconnectAbility_0100 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0900_commonEvent"); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0100 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0100 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_0900).then(async (data) => { + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0100 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + setTimeout(() => { + done(); + }, 1000) + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ThirdPartyExtensionDisconnectAbility_0100 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0100 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsmanyusersabilitytest", + abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", + action: "Nine", + }, + ); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0100 4 "); + + }) + + it('ACTS_ThirdPartyExtensionDisconnectAbility_0200', 0, async function (done) { + console.log('ACTS_ThirdPartyExtensionDisconnectAbility_0200====ACTS_ThirdPartyExtensionDisconnectAbility_0200 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_1000_commonEvent"); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0200 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0200 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_1000).then(async (data) => { + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0200 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + setTimeout(() => { + done(); + }, 1000) + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ThirdPartyExtensionDisconnectAbility_0200 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0200 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsmanyusersabilitytest", + abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", + action: "Ten", + }, + ); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0200 4 "); + + }) + + it('ACTS_ThirdPartyExtensionDisconnectAbility_0300', 0, async function (done) { + console.log('ACTS_ThirdPartyExtensionDisconnectAbility_0300====ACTS_ThirdPartyExtensionDisconnectAbility_0300 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_1100_commonEvent"); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0200 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0300 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_1100).then(async (data) => { + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0300 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + setTimeout(() => { + done(); + }, 1000) + } + + function timeout() { + console.debug('ACTS_ThirdPartyExtensionDisconnectAbility_0300 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0300 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsmanyusersabilitytest", + abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", + action: "Ten one", + }, + ); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0300 4 "); + + }) + + it('ACTS_ThirdPartyExtensionDisconnectAbility_0400', 0, async function (done) { + console.log('ACTS_ThirdPartyExtensionDisconnectAbility_0400====ACTS_ThirdPartyExtensionDisconnectAbility_0400 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_1200_commonEvent"); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0400 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0400 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_1200).then(async (data) => { + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0400 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + setTimeout(() => { + done(); + }, 1000) + } + + function timeout() { + console.debug('ACTS_ThirdPartyExtensionDisconnectAbility_0400 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0400 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsmanyusersabilitytest", + abilityName: "com.example.actsmanyusersabilitytest.ServiceAbility", + action: "Ten two", + }, + ); + console.debug("====>ACTS_ThirdPartyExtensionDisconnectAbility_0400 4 "); + + }) + + + + }) +} + + diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/module.json b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..3deb3e5d7010bab334ca863ca848ad8604654f49 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/module.json @@ -0,0 +1,57 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "com.example.actsmanyusersabilitytest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "name": "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + }, + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.example.actsconnectabilitysystemabilitytest.ServiceAbility2", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ] + } +} diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d75325f3cf0a50c1dfe4dbc5162c8737276c3dd9 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/resources/base/media/icon.png differ 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 new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/signature/openharmony_sx_thirdparty.p7b b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/signature/openharmony_sx_thirdparty.p7b new file mode 100644 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/ability/ability_runtime/actsusers/actsmanyuserthirdabilitytest/signature/openharmony_sx_thirdparty.p7b differ