diff --git a/aafwk/aafwk_standard/BUILD.gn b/aafwk/aafwk_standard/BUILD.gn old mode 100644 new mode 100755 index 598989db8be285d10b46b82f298556a9639a5e24..88c173e8cbb329b5bdd5f18f826ba41e84924e04 --- a/aafwk/aafwk_standard/BUILD.gn +++ b/aafwk/aafwk_standard/BUILD.gn @@ -18,17 +18,28 @@ group("aafwk_standard") { if (is_standard_system) { deps = [ "abilitymanager:actsabilitymanagertest", + "abilitymultiinstance:abilitymultiinstance", "actsabilitydelegatorcase:ActsAbilityDelegatorCaseTest", "actsabilitylifecyclestatenew:ActsAbilityLifecycleStateNewTest", "actsabilitymanageretstest:ActsAbilityManagerEtsTest", + "actscalltest:actscalltest", + "actsstartcomponenttest:actsstartcomponenttest", "actsstserviceabilityclientcase:ActsStServiceAbilityClientCaseTest", + "actsusers:actsusers", + "amscontextualinforquery:amscontextualinforquery", "amsdatauriutils:ActsAmsDataUriUtilsTest", + "amsdisplayIdtest:amsdisplayIdtest", "amsgetabilityprocessinfo:amsgetabilityprocessinfo", "context:context", "featureability:featureability", "formmanager:formmanager", + "killprocesswithaccountstage:killprocesswithaccountstage", + "newwant:newwant", + "non_concurrent:non_concurrent", + "processmultiinstance:processmultiinstance", "stage:stage", "want:want", + "zidltest:zidltest", ] } } diff --git a/aafwk/aafwk_standard/abilitymultiinstance/BUILD.gn b/aafwk/aafwk_standard/abilitymultiinstance/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..245da91f243bb3f0e4ace8839a681ec89617a64a --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/BUILD.gn @@ -0,0 +1,28 @@ +# 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("//test/xts/tools/build/suite.gni") + +group("abilitymultiinstance") { + testonly = true + if (is_standard_system) { + deps = [ + "amsabilitymultiinstanceappa:ActsAmsAbilityMultiinstanceHapARelyHap", + "amsabilitymultiinstanceappb:ActsAmsAbilityMultiinstanceHapBRelyHap", + "amsabilitymultiinstanceappc:ActsAmsAbilityMultiinstanceHapCRelyHap", + "amsabilitymultiinstanceappd:ActsAmsAbilityMultiinstanceHapDRelyHap", + "amsabilitymultiinstanceappe:ActsAmsAbilityMultiinstanceHapERelyHap", + "amsabilitymultiinstancetest:ActsAmsAbilityMultiinstanceTest", + ] + } +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/AppScope/app.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..d67e483bd8ea4508e24f2157b4ee6d92f6f44f9e --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.amsabilitymultiinstanceappa", + "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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/BUILD.gn b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..c83c15325cd203899974104a4d98f48148bdbdae --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/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("ActsAmsAbilityMultiinstanceHapARelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsabilitymultiinstancehapa_js_assets", + ":actsamsabilitymultiinstancehapa_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsAbilityMultiinstanceHapARelyHap" +} + +ohos_app_scope("actsamsabilitymultiinstancehapa_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsabilitymultiinstancehapa_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsabilitymultiinstancehapa_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsabilitymultiinstancehapa_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/Test.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..3e374f11969c3fdeeddb1b3ab50e70f68cae2ab2 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/Application/AbilityStage.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 AbilityStage from "@ohos.application.AbilityStage" + +const ONACCEPTWANT_KEY_NOTSET_ID = -1; +const ONACCEPTWANT_KEY_UNDEFINED_ID = -2; +var onAcceptWantCalledSeq; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("AbilityMultiInstanceAppA MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } + + onAcceptWant(want) { + console.log("AbilityMultiInstanceAppA onAcceptWant called want:" + JSON.stringify(want)); + if ((want.parameters == undefined) || (want.parameters.startId == undefined)) { + console.log("AbilityMultiInstanceAppA specified param err"); + return; + } + + var abilityId = want.parameters.startId.toString(); + onAcceptWantCalledSeq = "onAcceptWantCalled"; + onAcceptWantCalledSeq += "Id"; + onAcceptWantCalledSeq += abilityId; + globalThis.onAcceptWantCalledSeq = onAcceptWantCalledSeq; + + if (want.parameters.startId == ONACCEPTWANT_KEY_NOTSET_ID) { + return; + } else if (want.parameters.startId == ONACCEPTWANT_KEY_UNDEFINED_ID) { + return undefined; + } + + globalThis.abilityWant = want; + console.log("AbilityMultiInstanceAppA set globalThis result :" + globalThis.onAcceptWantCalledSeq); + return abilityId; + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..00de6e6240e7b3c247134960a739b7e1deaba2d1 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,141 @@ +/* + * 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' + +var callBackSeq = ""; + +function publishCallBack() { + console.debug("====>Publish CallBack ====>"); +} + +async function startAbilityProcess(abilityContext, parameters) { + let bundleName = "com.example.amsabilitymultiinstanceappa"; + let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + + let idx = parameters.nextStep; + switch (parameters.step[idx]) { + case "StartA1": + parameters.startId = 1; + break; + case "StartA2": + parameters.startId = 2; + break; + case "StartB": + bundleName = "com.example.amsabilitymultiinstanceappb"; + abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + break; + case "StartC": + bundleName = "com.example.amsabilitymultiinstanceappc"; + abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + break; + case "StartDMain1": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 1; + break; + case "StartDMain2": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 2; + break; + case "StartDSec": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + break; + case "StartDThd": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + break; + case "StartE": + bundleName = "com.example.amsabilitymultiinstanceappe"; + abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + break; + + default: + break; + } + parameters.nextStep = ++idx; + abilityContext.startAbility({ + bundleName: bundleName, + abilityName: abilityName, + parameters: parameters + }, (error, data) => { + console.log('AppA startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) +} + +async function onShowProcess() { + var abilityWant = globalThis.abilityWant; + var callBackData = "AppA:" + callBackSeq += globalThis.onAcceptWantCalledSeq; + callBackData += callBackSeq; + + var commonEventPublishData = { + data: callBackData, + parameters: abilityWant.parameters + }; + + console.log("AbilityMultiInstanceAppA abilityWant = " + JSON.stringify(abilityWant)); + if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) { + commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack); + callBackSeq = ""; + globalThis.onAcceptWantCalledSeq = ""; + } else { + commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => { + callBackSeq = ""; + globalThis.onAcceptWantCalledSeq = ""; + startAbilityProcess(globalThis.abilityContext, abilityWant.parameters); + }); + } +} + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("AbilityMultiInstanceAppA onCreate") + callBackSeq += "onCreate"; + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("AbilityMultiInstanceAppA onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("AbilityMultiInstanceAppA onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("AbilityMultiInstanceAppA onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("AbilityMultiInstanceAppA onForeground") + callBackSeq += "onForeground"; + onShowProcess(); + } + + onBackground() { + // Ability has back to background + console.log("AbilityMultiInstanceAppA onBackground") + } +}; diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..550eda6bbe598f162df4ee4204b2c2f26edd5c6c --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,52 @@ +/* + * 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'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Ability MultiInstance AppA') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/module.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..1295ce09e65bf8a693bbf550e26b6410572c0c0e --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/module.json @@ -0,0 +1,80 @@ +{ + "module": { + "name": "com.example.amsabilitymultiinstanceappa", + "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.amsabilitymultiinstanceappa.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "specified", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappa/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/AppScope/app.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..3a8cafbace72ac1e99151ff1e395f5c6aac4c39e --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.amsabilitymultiinstanceappb", + "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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/BUILD.gn b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..bba12ccef8acba66db45593ea16fd8bd81e6e1b9 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/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("ActsAmsAbilityMultiinstanceHapBRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsabilitymultiinstancehapb_js_assets", + ":actsamsabilitymultiinstancehapb_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsAbilityMultiinstanceHapBRelyHap" +} + +ohos_app_scope("actsamsabilitymultiinstancehapb_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsabilitymultiinstancehapb_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsabilitymultiinstancehapb_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsabilitymultiinstancehapb_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/Test.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..f85fcf92b35787bd01eb2edb753cdd6b49f1dfdd --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..c8faf7deda610bb81a9d94659a53ef3d66dc1fc6 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,137 @@ +/* + * 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' + +var callBackSeq = ""; + +function publishCallBack() { + console.debug("====>AbilityMultiInstanceAppB Publish CallBack ====>"); +} + +async function startAbilityProcess(abilityContext, parameters) { + let bundleName = "com.example.amsabilitymultiinstanceappa"; + let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + + let idx = parameters.nextStep; + switch (parameters.step[idx]) { + case "StartA1": + parameters.startId = 1; + break; + case "StartA2": + parameters.startId = 2; + break; + case "StartB": + bundleName = "com.example.amsabilitymultiinstanceappb"; + abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + break; + case "StartC": + bundleName = "com.example.amsabilitymultiinstanceappc"; + abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + break; + case "StartDMain1": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 1; + break; + case "StartDMain2": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 2; + break; + case "StartDSec": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + break; + case "StartDThd": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + break; + case "StartE": + bundleName = "com.example.amsabilitymultiinstanceappe"; + abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + break; + + default: + break; + } + parameters.nextStep = ++idx; + abilityContext.startAbility({ + bundleName: bundleName, + abilityName: abilityName, + parameters: parameters + }, (error, data) => { + console.log('AppB startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) +} + +async function onShowProcess() { + var abilityWant = globalThis.abilityWant; + var callBackData = "AppB:" + callBackData += callBackSeq; + + var commonEventPublishData = { + data: callBackData, + parameters: abilityWant.parameters + }; + console.log("AbilityMultiInstanceAppB onShowProcess") + if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) { + commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack); + callBackSeq = ""; + } else { + commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => { + callBackSeq = ""; + startAbilityProcess(globalThis.abilityContext, abilityWant.parameters); + }); + } +} + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("AbilityMultiInstanceAppB MainAbility onCreate") + callBackSeq += "onCreate"; + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("AbilityMultiInstanceAppB MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("AbilityMultiInstanceAppB 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("AbilityMultiInstanceAppB MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("AbilityMultiInstanceAppB MainAbility onForeground") + callBackSeq += "onForeground"; + onShowProcess(); + } + + onBackground() { + // Ability has back to background + console.log("AbilityMultiInstanceAppB MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..f18188a6e7f80b21a200f1ff9314290e955434e4 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,52 @@ +/* + * 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'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Ability MultiInstance AppB') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/module.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..75e3babd5c72d3676c2316809129459391ab8ad5 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/module.json @@ -0,0 +1,80 @@ +{ + "module": { + "name": "com.example.amsabilitymultiinstanceappb", + "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.amsabilitymultiinstanceappb.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "standard", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappb/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/AppScope/app.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..9aba063149e11de782e342d6dfbee9c7e76bc7f8 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.amsabilitymultiinstanceappc", + "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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/BUILD.gn b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..cc9a0e6c0774110acccc51707a1a9542aa8cbdfc --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/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("ActsAmsAbilityMultiinstanceHapCRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsabilitymultiinstancehapc_js_assets", + ":actsamsabilitymultiinstancehapc_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsAbilityMultiinstanceHapCRelyHap" +} + +ohos_app_scope("actsamsabilitymultiinstancehapc_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsabilitymultiinstancehapc_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsabilitymultiinstancehapc_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsabilitymultiinstancehapc_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/Test.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..f85fcf92b35787bd01eb2edb753cdd6b49f1dfdd --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..26535b66d990408edcb618dd1e85a769e0fa0b8c --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,135 @@ +/* + * 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' + +var callBackSeq = ""; + +function publishCallBack() { + console.debug("====>AbilityMultiInstanceAppC Publish CallBack ====>"); +} + +async function onShowProcess() { + var abilityWant = globalThis.abilityWant; + var callBackData = "AppC:"; + callBackData += callBackSeq; + var commonEventPublishData = { + data: callBackData, + parameters: abilityWant.parameters + }; + console.log("AbilityMultiInstanceAppC onShowProcess") + if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) { + commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack); + } else { + commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => { + startAbilityProcess(globalThis.abilityContext, abilityWant.parameters); + }); + } + callBackSeq = ""; +} + +async function startAbilityProcess(abilityContext, parameters) { + let bundleName = "com.example.amsabilitymultiinstanceappa"; + let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + + let idx = parameters.nextStep; + switch (parameters.step[idx]) { + case "StartA1": + parameters.startId = 1; + break; + case "StartA2": + parameters.startId = 2; + break; + case "StartB": + bundleName = "com.example.amsabilitymultiinstanceappb"; + abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + break; + case "StartC": + bundleName = "com.example.amsabilitymultiinstanceappc"; + abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + break; + case "StartDMain1": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 1; + break; + case "StartDMain2": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 2; + break; + case "StartDSec": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + break; + case "StartDThd": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + break; + case "StartE": + bundleName = "com.example.amsabilitymultiinstanceappe"; + abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + break; + + default: + break; + } + parameters.nextStep = ++idx; + abilityContext.startAbility({ + bundleName: bundleName, + abilityName: abilityName, + parameters: parameters + }, (error, data) => { + console.log('AppC startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) +} + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility onCreate") + callBackSeq += "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") + callBackSeq += "onForeground"; + onShowProcess(); + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..d96f00914aa686b33b6813c46619dad488a45bbc --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,52 @@ +/* + * 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'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Ability MultiInstance AppC') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/module.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..e057d556016f87d67feeb1d75387d9e662e7cfae --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/module.json @@ -0,0 +1,80 @@ +{ + "module": { + "name": "com.example.amsabilitymultiinstanceappc", + "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.amsabilitymultiinstanceappc.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappc/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/AppScope/app.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..8392e22811fde0f13b8db0baa00eabbb9a86b371 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.amsabilitymultiinstanceappd", + "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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/BUILD.gn b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..4377072dbbc08ad9e916b06769f8daf5fb98fa72 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/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("ActsAmsAbilityMultiinstanceHapDRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsabilitymultiinstancehapd_js_assets", + ":actsamsabilitymultiinstancehapd_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsAbilityMultiinstanceHapDRelyHap" +} + +ohos_app_scope("actsamsabilitymultiinstancehapd_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsabilitymultiinstancehapd_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsabilitymultiinstancehapd_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsabilitymultiinstancehapd_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/Test.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..89ebbd7d62a810f034fc4bea4517987e8af21e7e --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,37 @@ +/* + * 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" + +var onAcceptWantCalledSeq; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("AbilityMultiInstanceAppD MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } + + onAcceptWant(want) { + console.log("AbilityMultiInstanceAppD onAcceptWant called want:" + JSON.stringify(want)); + var abilityId = want.parameters.startId.toString(); + onAcceptWantCalledSeq = "onAcceptWantCalled"; + onAcceptWantCalledSeq += "Id"; + onAcceptWantCalledSeq += abilityId; + globalThis.onAcceptWantCalledSeq = onAcceptWantCalledSeq; + globalThis.abilityWant = want; + console.log("AbilityMultiInstanceAppD set globalThis result :" + globalThis.onAcceptWantCalledSeq); + return abilityId; + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..0678c9cad347dec79a2fe04081e25be159d09192 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,137 @@ +/* + * 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' + +var callBackSeq = ""; +function publishCallBack() { + console.debug("====>AbilityMultiInstanceAppD Publish CallBack ====>"); +} +async function onShowProcess() { + var abilityWant = globalThis.abilityWant; + var callBackData = "AppD:"; + callBackSeq += globalThis.onAcceptWantCalledSeq; + callBackData += callBackSeq; + var commonEventPublishData = { + data: callBackData, + parameters: abilityWant.parameters + }; + + console.log("AbilityMultiInstanceAppD abilityWant = " + JSON.stringify(abilityWant)); + if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) { + commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack); + } else { + commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => { + startAbilityProcess(globalThis.abilityContext, abilityWant.parameters); + }); + } + globalThis.onAcceptWantCalledSeq = ""; + callBackSeq = ""; +} + +async function startAbilityProcess(abilityContext, parameters) { + let bundleName = "com.example.amsabilitymultiinstanceappa"; + let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + + let idx = parameters.nextStep; + switch (parameters.step[idx]) { + case "StartA1": + parameters.startId = 1; + break; + case "StartA2": + parameters.startId = 2; + break; + case "StartB": + bundleName = "com.example.amsabilitymultiinstanceappb"; + abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + break; + case "StartC": + bundleName = "com.example.amsabilitymultiinstanceappc"; + abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + break; + case "StartDMain1": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 1; + break; + case "StartDMain2": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 2; + break; + case "StartDSec": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + break; + case "StartDThd": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + break; + case "StartE": + bundleName = "com.example.amsabilitymultiinstanceappe"; + abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + break; + + default: + break; + } + parameters.nextStep = ++idx; + abilityContext.startAbility({ + bundleName: bundleName, + abilityName: abilityName, + parameters: parameters + }, (error, data) => { + console.log('AppD startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) +} + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("AbilityMultiInstanceAppD onCreate") + callBackSeq += "onCreate"; + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("AbilityMultiInstanceAppD onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("AbilityMultiInstanceAppD onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("AbilityMultiInstanceAppD onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("AbilityMultiInstanceAppD onForeground") + callBackSeq += "onForeground"; + onShowProcess(); + } + + onBackground() { + // Ability has back to background + console.log("AbilityMultiInstanceAppD onBackground") + } +}; diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/SecondAbility/SecondAbility.ts b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/SecondAbility/SecondAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..9ee4d4a6045daeedfaaac580011b9bd50086a330 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/SecondAbility/SecondAbility.ts @@ -0,0 +1,137 @@ +/* + * 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' + +var callBackSeq = ""; +function publishCallBack() { + console.debug("====>AbilityMultiInstanceAppD Sec Publish CallBack ====>"); +} +async function onShowProcess() { + var abilityWant = globalThis.abilityWant; + var callBackData = "AppD:"; + callBackSeq += globalThis.onAcceptWantCalledSeq; + callBackData += callBackSeq; + var commonEventPublishData = { + data: callBackData, + parameters: abilityWant.parameters + }; + + console.log("AbilityMultiInstanceAppD Sec abilityWant = " + JSON.stringify(abilityWant)); + if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) { + commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack); + } else { + commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => { + startAbilityProcess(globalThis.abilityContext, abilityWant.parameters); + }); + } + globalThis.onAcceptWantCalledSeq = ""; + callBackSeq = ""; +} + +async function startAbilityProcess(abilityContext, parameters) { + let bundleName = "com.example.amsabilitymultiinstanceappa"; + let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + + let idx = parameters.nextStep; + switch (parameters.step[idx]) { + case "StartA1": + parameters.startId = 1; + break; + case "StartA2": + parameters.startId = 2; + break; + case "StartB": + bundleName = "com.example.amsabilitymultiinstanceappb"; + abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + break; + case "StartC": + bundleName = "com.example.amsabilitymultiinstanceappc"; + abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + break; + case "StartDMain1": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 1; + break; + case "StartDMain2": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 2; + break; + case "StartDSec": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + break; + case "StartDThd": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + break; + case "StartE": + bundleName = "com.example.amsabilitymultiinstanceappe"; + abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + break; + + default: + break; + } + parameters.nextStep = ++idx; + abilityContext.startAbility({ + bundleName: bundleName, + abilityName: abilityName, + parameters: parameters + }, (error, data) => { + console.log('AppD startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) +} + +export default class SecondAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("AbilityMultiInstanceAppD Sec onCreate") + callBackSeq += "onCreate"; + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("AbilityMultiInstanceAppD Sec onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("AbilityMultiInstanceAppD Sec onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("AbilityMultiInstanceAppD Sec onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("AbilityMultiInstanceAppD Sec onForeground") + callBackSeq += "onForeground"; + onShowProcess(); + } + + onBackground() { + // Ability has back to background + console.log("AbilityMultiInstanceAppD Sec onBackground") + } +}; diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/ThirdAbility/ThirdAbility.ts b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/ThirdAbility/ThirdAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..9f6ca48b77417dad5d64b9c2d68a3bb43eae95c3 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/ThirdAbility/ThirdAbility.ts @@ -0,0 +1,133 @@ +/* + * 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' + +var callBackSeq = ""; +function publishCallBack() { + console.debug("====>AbilityMultiInstanceAppD Third Publish CallBack ====>"); +} +async function onShowProcess() { + var abilityWant = globalThis.abilityWant; + var callBackData = "AppD:"; + callBackSeq += globalThis.onAcceptWantCalledSeq; + callBackData += callBackSeq; + var commonEventPublishData = { + data: callBackData, + parameters: abilityWant.parameters + }; + + console.log("AbilityMultiInstanceAppD Third abilityWant = " + JSON.stringify(abilityWant)); + if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) { + commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack); + } else { + commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => { + startAbilityProcess(globalThis.abilityContext, abilityWant.parameters); + }); + } + globalThis.onAcceptWantCalledSeq = ""; + callBackSeq = ""; +} + +async function startAbilityProcess(abilityContext, parameters) { + let bundleName = "com.example.amsabilitymultiinstanceappa"; + let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + + let idx = parameters.nextStep; + switch (parameters.step[idx]) { + case "StartA1": + parameters.startId = 1; + break; + case "StartA2": + parameters.startId = 2; + break; + case "StartB": + bundleName = "com.example.amsabilitymultiinstanceappb"; + abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + break; + case "StartC": + bundleName = "com.example.amsabilitymultiinstanceappc"; + abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + break; + case "StartDMain1": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 1; + break; + case "StartDMain2": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 2; + break; + case "StartDSec": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + break; + case "StartDThd": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + break; + + default: + break; + } + parameters.nextStep = ++idx; + abilityContext.startAbility({ + bundleName: bundleName, + abilityName: abilityName, + parameters: parameters + }, (error, data) => { + console.log('AppD startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) +} + +export default class ThirdAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("AbilityMultiInstanceAppD Third onCreate") + callBackSeq += "onCreate"; + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("AbilityMultiInstanceAppD Third onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("AbilityMultiInstanceAppD Third onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("AbilityMultiInstanceAppD Third onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("AbilityMultiInstanceAppD Third onForeground") + callBackSeq += "onForeground"; + onShowProcess(); + } + + onBackground() { + // Ability has back to background + console.log("AbilityMultiInstanceAppD Third onBackground") + } +}; diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..d96f00914aa686b33b6813c46619dad488a45bbc --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,52 @@ +/* + * 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'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Ability MultiInstance AppC') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/module.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..87d984d906258e6f231e0818890387a07bd840a3 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/module.json @@ -0,0 +1,120 @@ +{ + "module": { + "name": "com.example.amsabilitymultiinstanceappd", + "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.amsabilitymultiinstanceappd.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "specified", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.amsabilitymultiinstanceappd.SecondAbility", + "srcEntrance": "./ets/SecondAbility/SecondAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "standard", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.amsabilitymultiinstanceappd.ThirdAbility", + "srcEntrance": "./ets/ThirdAbility/ThirdAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ], + "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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappd/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/BUILD.gn b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..3c1b34960ad6655fef73d3242e59ec1903d3e1de --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/BUILD.gn @@ -0,0 +1,34 @@ +# 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_hap("ActsAmsAbilityMultiinstanceHapERelyHap") { + hap_name = "ActsAmsAbilityMultiinstanceHapERelyHap" + hap_profile = "./src/main/config.json" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/js/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/config.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..7aefa80545212cec61c3b43e96ccae313ecaab5b --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/config.json @@ -0,0 +1,95 @@ +{ + "app": { + "bundleName": "com.example.amsabilitymultiinstanceappe", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": { + "default": { + "process": "com.example.amsabilitymultiinstanceappe" + } + }, + "module": { + "package": "com.example.amsabilitymultiinstanceappe", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.amsabilitymultiinstanceappe.MainAbility", + "visible": true, + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.INSTALL_BUNDLE", + "reason": "need use ohos.permission.INSTALL_BUNDLE" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.MANAGE_MISSIONS", + "reason": "need use ohos.permission.MANAGE_MISSIONS" + }, + { + "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" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/app.js b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..d47cf0cd38b846701aa9a2fe7a4e9596f79b9b0c --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/app.js @@ -0,0 +1,28 @@ +/* + * 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 { + onCreate() { + console.info('ProcessManageSystemAppA onCreate'); + }, + onDestroy() { + console.info('ProcessManageSystemAppA onDestroy'); + }, + onShow() { + console.info('ProcessManageSystemAppA onShow'); + }, + onHide() { + console.info('ProcessManageSystemAppA onHide'); + } +}; diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..26001a6c5cb812093b2b8322ce83c94d97f85910 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/default/pages/index/index.js @@ -0,0 +1,120 @@ +/* + * 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 featureAbility from '@ohos.ability.featureability' +import commonEvent from '@ohos.commonevent' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') +var callBackSeq = ""; + +function publishCallBack() { + console.debug("====>AbilityMultiInstanceAppB Publish CallBack ====>"); +} + +async function startAbilityProcess(parameters) { + let bundleName = "com.example.amsabilitymultiinstanceappa"; + let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + + let idx = parameters.nextStep; + switch (parameters.step[idx]) { + case "StartA1": + parameters.startId = 1; + break; + case "StartA2": + parameters.startId = 2; + break; + case "StartB": + bundleName = "com.example.amsabilitymultiinstanceappb"; + abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + break; + case "StartC": + bundleName = "com.example.amsabilitymultiinstanceappc"; + abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + break; + case "StartDMain1": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 1; + break; + case "StartDMain2": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 2; + break; + case "StartDSec": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + break; + case "StartDThd": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + break; + case "StartE": + bundleName = "com.example.amsabilitymultiinstanceappe"; + abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + break; + + default: + break; + } + parameters.nextStep = ++idx; + await featureAbility.startAbility({ + want: + { + bundleName: bundleName, + abilityName: abilityName, + parameters: parameters + } + }); +} + +async function onShowProcess() { + var abilityWant = await featureAbility.getWant(); + var callBackData = "AppE:"; + callBackData += callBackSeq; + var commonEventPublishData = { + data: callBackData, + parameters: abilityWant.parameters + }; + if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) { + commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack); + } else { + commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => { + startAbilityProcess(abilityWant.parameters); + }); + } + callBackSeq = ""; +} + +export default { + data: { + title: "AbilityMultiInstanceAppE" + }, + onInit() { + this.title = "AbilityMultiInstanceAppE"; + callBackSeq += "onInit"; + }, + onShow() { + console.log('AbilityMultiInstanceAppE onShow start'); + callBackSeq += "onShow"; + onShowProcess(); + }, + onStart() { + console.log('AbilityMultiInstanceAppE onStart'); + }, + onStop() { + console.log('AbilityMultiInstanceAppE onStop'); + }, +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/resources/base/element/string.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..fd60cdefa929070f1798c6e36f0502f1e1e219a4 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "particlestartability" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/resources/base/media/icon.png b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstanceappe/src/main/js/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/AppScope/app.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..48003b8c5bb034b2abb40d1769b24b6f5b09eb8e --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.abilitymultiinstance", + "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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/BUILD.gn b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..829e668b197aa722c4356111fa9ed817c92e16c8 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/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("ActsAmsAbilityMultiinstanceTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsabilitymultiinstance_js_assets", + ":actsamsabilitymultiinstance_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsAbilityMultiinstanceTest" +} + +ohos_app_scope("actsamsabilitymultiinstance_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsabilitymultiinstance_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsabilitymultiinstance_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsabilitymultiinstance_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/Test.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..f3c05f6cac44b4e1392bd7de9359f572e107fef2 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/Test.json @@ -0,0 +1,35 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "1000000", + "package": "com.example.abilitymultiinstance", + "shell-timeout": "300000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsAbilityMultiinstanceTest.hap", + "ActsAmsAbilityMultiinstanceHapARelyHap.hap", + "ActsAmsAbilityMultiinstanceHapBRelyHap.hap", + "ActsAmsAbilityMultiinstanceHapCRelyHap.hap", + "ActsAmsAbilityMultiinstanceHapDRelyHap.hap", + "ActsAmsAbilityMultiinstanceHapERelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/*.hap" + ] + } + ] +} diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..5e2915fe4fc033cd5c9bd579dc08fe7369e51016 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..6d4dc7c06648df436d0c1b7fd7683f5e66b6f030 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/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("AbilityMultiInstanceTest onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("AbilityMultiInstanceTest onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("AbilityMultiInstanceTest onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + console.log("AbilityMultiInstanceTest onWindowStageCreate finish") + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("AbilityMultiInstanceTest onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("AbilityMultiInstanceTest onForeground") + } + + onBackground() { + // Ability has back to background + console.log("AbilityMultiInstanceTest onBackground") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..e5ef3e3680a267a6aa28a510c77f04cc5cd3c0cb --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index.ets @@ -0,0 +1,64 @@ +/* + * 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters['timeout'] = 10000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Test App') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..577f53879917d26276c6ef294f65d9d044533161 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/index/index.ets @@ -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 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/second.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..cdeec85b592406da6a4d4861b1659d7664e560b4 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,1098 @@ +/* + * 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 bundle from '@ohos.bundle' +import missionManager from '@ohos.application.missionManager' +import appManager from '@ohos.application.appManager' + +var subscriberInfoMultiInstance = { + events: ["MultiInstanceStartNext", "MultiInstanceStartFinish"] +}; +const BUNDLE_PATHS = [['/data/ActsAmsAbilityMultiinstanceHapARelyHap.hap'], +['/data/ActsAmsAbilityMultiinstanceHapBRelyHap.hap'], +['/data/ActsAmsAbilityMultiinstanceHapCRelyHap.hap'], +['/data/ActsAmsAbilityMultiinstanceHapDRelyHap.hap'], +['/data/ActsAmsAbilityMultiinstanceHapERelyHap.hap']]; +const BUNDLE_NAMES = ['com.example.amsabilitymultiinstanceappa', 'com.example.amsabilitymultiinstanceappb', +'com.example.amsabilitymultiinstanceappc', 'com.example.amsabilitymultiinstanceappd', +'com.example.amsabilitymultiinstanceappe']; +const BUNDLE_COUNT = 5; +const START_ABILITY_TIMEOUT = 9000; +const MAX_MISSION_NUM = 1024; +const ONACCEPTWANT_KEY_NOTSET_ID = -1; +const ONACCEPTWANT_KEY_UNDEFINED_ID = -2; +const UNSUBSCRIBE_TIMEOUT = 5000; + +async function startAbilityProcess(abilityContext, parameters) { + let bundleName = "com.example.amsabilitymultiinstanceappa"; + let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility"; + + let idx = parameters.nextStep; + switch (parameters.step[idx]) { + case "StartA1": + parameters.startId = 1; + break; + case "StartA2": + parameters.startId = 2; + break; + case "StartANS": + parameters.startId = ONACCEPTWANT_KEY_NOTSET_ID; + break; + case "StartAUD": + parameters.startId = ONACCEPTWANT_KEY_UNDEFINED_ID; + break; + case "StartB": + bundleName = "com.example.amsabilitymultiinstanceappb"; + abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility"; + break; + case "StartC": + bundleName = "com.example.amsabilitymultiinstanceappc"; + abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility"; + break; + case "StartDMain1": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 1; + break; + case "StartDMain2": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility"; + parameters.startId = 2; + break; + case "StartDSec": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility"; + break; + case "StartDThd": + bundleName = "com.example.amsabilitymultiinstanceappd"; + abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility"; + break; + case "StartE": + bundleName = "com.example.amsabilitymultiinstanceappe"; + abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility"; + break; + + default: + break; + } + parameters.nextStep = ++idx; + abilityContext.startAbility({ + bundleName: bundleName, + abilityName: abilityName, + parameters: parameters + }, (error, data) => { + console.log('startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) +} + +function getMissionId() { + return new Promise(async (resolve, reject) => { + var missionId = -1; + var missionInfos = await missionManager.getMissionInfos('', MAX_MISSION_NUM); + for (let i = 0; i < missionInfos.length; i++) { + console.log('getMissionId result: ' + i + '= ' + JSON.stringify(missionInfos[i])) + if ((missionInfos[i].want.abilityName == "com.example.amsabilitymultiinstancetest.MainAbility") && + (missionInfos[i].runningState == 0)) { + missionId = missionInfos[i].missionId; + break; + } + } + console.log('======>getMissionId resolve missionId<=======' + missionId); + resolve(missionId); + }) +} + +export default function abilityTest(abilityContext) { + describe('ActsAbilityTest', function () { + + beforeEach(async (done) => { + console.log('======>beforeEach ininin<======='); + done(); + }) + + afterEach(async (done) => { + let installer = await bundle.getBundleInstaller(); + var count = 0; + var testMissionId; + + testMissionId = await getMissionId(); + console.log('======>afterEach test missionId<=======' + testMissionId); + if (testMissionId != -1) { + await missionManager.moveMissionToFront(testMissionId); + } + + await appManager.killProcessesByBundleName("com.example.amsabilitymultiinstanceappa"); + await appManager.killProcessesByBundleName("com.example.amsabilitymultiinstanceappb"); + await appManager.killProcessesByBundleName("com.example.amsabilitymultiinstanceappc"); + await appManager.killProcessesByBundleName("com.example.amsabilitymultiinstanceappd"); + await appManager.killProcessesByBundleName("com.example.amsabilitymultiinstanceappe"); + done(); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Multi_0100 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_0100', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_0100====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_0100 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(3); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_0100 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('StartAbilityMultiInstanceTester timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_0100 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 3, + nextStep: 0, + step: ["StartA1", "StartB", "StartA1"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_0200 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_0200', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_0200====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_0200 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(3); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_0200 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_0200 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('StartAbilityMultiInstanceTester timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_0200 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 3, + nextStep: 0, + step: ["StartA1", "StartB", "StartA2"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_0300 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_0300', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_0300====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_0300 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(3); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_0300 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_0300 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_0300 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_0300 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 3, + nextStep: 0, + step: ["StartA1", "StartC", "StartA1"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_0400 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_0400', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_0400====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_0400 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(3); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_0400 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_0400 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_0400 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_0400 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 3, + nextStep: 0, + step: ["StartA1", "StartC", "StartA2"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_0600 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_0600', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_0600====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_0600 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(2); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_0600 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_0600 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_0600 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_0600 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 2, + nextStep: 0, + step: ["StartA1", "StartA2"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_0700 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_0700', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_0700====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_0700 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(4); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_0700 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_0700 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_0700 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_0700 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 4, + nextStep: 0, + step: ["StartA1", "StartB", "StartC", "StartA1"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_0800 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_0800', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_0800====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_0800 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(4); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_0800 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_0800 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_0800 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_0800 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 4, + nextStep: 0, + step: ["StartA1", "StartB", "StartC", "StartA2"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_0900 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_0900', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_0900====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_0900 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(4); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_0900 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_0900 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_0900 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_0900 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 4, + nextStep: 0, + step: ["StartB", "StartA1", "StartC", "StartA1"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_1000 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_1000', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_1000====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_1000 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(4); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_1000 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_1000 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_1000 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_1000 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 4, + nextStep: 0, + step: ["StartB", "StartA1", "StartC", "StartA2"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_1100 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_1100', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_1100====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_1100 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(4); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_1100 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_1100 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_1100 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_1100 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 4, + nextStep: 0, + step: ["StartDMain1", "StartDSec", "StartDThd", "StartDMain1"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_1200 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_1200', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_1200====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_1200 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(4); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_1200 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_1200 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_1200 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_1200 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 4, + nextStep: 0, + step: ["StartDMain1", "StartDSec", "StartDThd", "StartDMain2"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_1300 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_1300', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_1300====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_1300 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(2); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_1300 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_1300 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_1300 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_1300 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 2, + nextStep: 0, + step: ["StartB", "StartB"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_1400 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_1400', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_1400====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_1400 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(2); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_1400 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_1400 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_1400 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_1400 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 2, + nextStep: 0, + step: ["StartE", "StartA1"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_1500 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_1500', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_1500====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_1500 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(2); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_1500 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_1500 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_1500 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_1500 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 2, + nextStep: 0, + step: ["StartA1", "StartE"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_1600 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_1600', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_1600====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_1600 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(1); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_1600 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_1600 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_1600 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_1600 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 1, + nextStep: 0, + step: ["StartANS"] + }); + }) + + /* + * @tc.number: ACTS_AbilityMultiInstance_Single_1700 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_AbilityMultiInstance_Single_1700', 0, async function (done) { + console.log('ACTS_AbilityMultiInstance_Single_1700====Subscribe CallBack data:====>" + JSON.stringify(data)); + + if (data.event == "MultiInstanceStartFinish") { + clearTimeout(id); + console.log('ACTS_AbilityMultiInstance_Single_1700 finish callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + expect(checkIndex).assertEqual(1); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + console.log('ACTS_AbilityMultiInstance_Single_1700 finish'); + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_AbilityMultiInstance_Single_1700 callBackSeq = ' + data.data); + expect(data.data).assertEqual(checkEventResults[checkIndex++]); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack====>"); + setTimeout(function () { + done(); + }, UNSUBSCRIBE_TIMEOUT) + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_AbilityMultiInstance_Single_1700 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start AbilityMultiInstanceTester ACTS_AbilityMultiInstance_Single_1700 timer id : ' + id); + + startAbilityProcess(abilityContext, { + startId: 0, + stepNum: 1, + nextStep: 0, + step: ["StartAUD"] + }); + }) + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..882f978e77b1a8fbbf843ccb4dd73c47ed460305 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/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 './Ability.test.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/module.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..8938ebbbcead80c8831f3ebcbf00154338442246 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/module.json @@ -0,0 +1,80 @@ +{ + "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.abilitymultiinstance.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + } + ], + "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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/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/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/abilitymultiinstance/amsabilitymultiinstancetest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actscalltest/BUILD.gn b/aafwk/aafwk_standard/actscalltest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..c8addfd7978cb58b32b8141365acd5c1c2d0b2ea --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/BUILD.gn @@ -0,0 +1,30 @@ +# 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") + +group("actscalltest") { + testonly = true + if (is_standard_system) { + deps = [ + "systemappcalleea:ActsSystemAppCalleeARelyHap", + "systemappcallera:ActsSystemAppCallerARelyHap", + "systemappcallerb:ActsSystemAppCallerBRelyHap", + "systemappcallerc:ActsSystemAppCallerCRelyHap", + "systemcallentrytest:ActsCallTestEntryTest", + "systemcallfeature:ActsCallTestFeatureRelyHap", + "thirdappa:ActsThirdAppARelyHap", + "thirdcalltest:ActsThirdCallTest", + ] + } +} diff --git a/aafwk/aafwk_standard/actscalltest/systemappcalleea/AppScope/app.json b/aafwk/aafwk_standard/actscalltest/systemappcalleea/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..785f8459d6838ce0df58f7ca178277e18fdb41b3 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcalleea/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.systemappcalleea", + "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/aafwk/aafwk_standard/actscalltest/systemappcalleea/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/systemappcalleea/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcalleea/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/aafwk/aafwk_standard/actscalltest/systemappcalleea/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actscalltest/systemappcalleea/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemappcalleea/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/systemappcalleea/BUILD.gn b/aafwk/aafwk_standard/actscalltest/systemappcalleea/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..9a140b14e865138bcf775bc84461d255a2ec1bb5 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcalleea/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("ActsSystemAppCalleeARelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":systemappcalleea_js_assets", + ":systemappcalleea_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsSystemAppCalleeARelyHap" +} + +ohos_app_scope("systemappcalleea_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("systemappcalleea_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("systemappcalleea_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":systemappcalleea_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actscalltest/systemappcalleea/Test.json b/aafwk/aafwk_standard/actscalltest/systemappcalleea/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcalleea/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..21606483f3457f3a691d5d0a28e111ffc5d9d4bf --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcalleea/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" + +var onAcceptWantCalledSeq; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("SystemCallTest MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..60a42118e19549566a263b15111dd132e5269e97 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,181 @@ +/* + * 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' + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} +var event_case2000 = "call_case2000_test"; +var subscribeInfo = { + events: [event_case2000, ], +}; +var subscriber; +function test2200ReleaseCallback(data) { + console.log('SystemAppCalleeA MainAbility test2200ReleaseCallback:' + data); + test2200ReleaseFlag = data.toString(); +} + +var test2200ReleaseFlag = ''; + +function testCall(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemAppCalleeA MainAbility on testCall <======') + data.readSequenceable(recvSequence); + var result = recvSequence.str + 'processed'; + var commonEventData = { + code: 0, + data: 'calleeCheckCallParam', + parameters: { + num: recvSequence.num, + str: recvSequence.str, + result: result + } + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>CallTestSysA SecondAbility Call_Finish<======') + }) + + return recvSequence; +} + +function testCallWithResult(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemAppCalleeA MainAbility on testCall <======') + data.readSequenceable(recvSequence); + let result = recvSequence.str + 'processed'; + recvSequence.setMySequence(recvSequence.num, recvSequence.str, result); + + return recvSequence; +} + +export default class MainAbility extends Ability { + + test2200(data) { + console.log("SystemAppCalleeA MainAbility test2200"); + let recvData = new MySequenceable(0, '', ''); + data.readSequenceable(recvData); + + let want = { + bundleName: "com.example.systemappcalleea", + abilityName: "com.example.systemappcalleea.SecondAbility", + }; + console.log("SystemAppCalleeA MainAbility test2200 before startAbilityByCall"); + let resultData = new MySequenceable(0, '', ''); + globalThis.abilityContext.startAbilityByCall(want).then((caller) => { + let param = new MySequenceable(recvData.num + 1, recvData.str + "SystemAppCalleeA", ''); + caller.onRelease(test2200ReleaseCallback); + caller.callWithResult('test2200', param).then((data2) => { + data2.readSequenceable(resultData); + caller.release(); + for (let start=Date.now(); Date.now() - start <= 200;); + resultData.result = test2200ReleaseFlag; + let commonEventData = { + parameters: { + num: resultData.num, + str: resultData.str, + result: resultData.result, + } + }; + commonEvent.publish('call_case2200_test_result', commonEventData, (err) => { + console.log('SystemAppCalleeA publish call_case2200_test_result event') + }) + + }); + }); + return resultData; + } + + subscribeCallBack(err, data) { + console.log('SystemAppCalleeA MainAbility subscribeCallBack data:' + JSON.stringify(data)); + switch (data.event) { + case event_case2000: + globalThis.abilityContext.terminateSelf(); + break; + default: + console.log('SystemAppCalleeA MainAbility subscribeCallBack event error:' + data.event); + break; + } + } + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemAppCalleeA MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.abilityContext = this.context; + this.callee.on('test2200', this.test2200); + this.callee.on('testCall', testCall); + this.callee.on('testCallWithResult', testCallWithResult); + commonEvent.createSubscriber(subscribeInfo).then((data) => { + console.log("SystemAppCalleeA MainAbility createSubscriber"); + subscriber = data; + commonEvent.subscribe(subscriber, this.subscribeCallBack); + }); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemAppCalleeA MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemAppCalleeA MainAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemAppCalleeA MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemAppCalleeA MainAbility onForeground"); + } + + onBackground() { + // Ability has back to background + console.log("SystemAppCalleeA MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/SecondAbility/SecondAbility.ts b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/SecondAbility/SecondAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..c96d69cb3d9e08644e86cbbecc13f392bd007405 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/SecondAbility/SecondAbility.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 Ability from '@ohos.application.Ability' +import commonEvent from '@ohos.commonevent' + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function testCall(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemAppCalleeA MainAbility on testCall <======') + data.readSequenceable(recvSequence); + var result = recvSequence.str + 'processed'; + var commonEventData = { + code: 0, + data: 'calleeCheckCallParam', + parameters: { + num: recvSequence.num, + str: recvSequence.str, + result: result + } + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>CallTestSysA SecondAbility Call_Finish<======') + }) + + return recvSequence; +} + +function testCallWithResult(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemAppCalleeA MainAbility on testCall <======') + data.readSequenceable(recvSequence); + let result = recvSequence.str + 'processed'; + recvSequence.setMySequence(recvSequence.num, recvSequence.str, result); + + return recvSequence; +} + +export default class SecondAbility extends Ability { + test2200(data) { + console.log("SystemAppCalleeA SecondAbility test2200"); + let recvData = new MySequenceable(0, '', ''); + data.readSequenceable(recvData); + let result = new MySequenceable(recvData.num + 1, recvData.str + "SystemAppCalleeA", ''); + return result; + } + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemAppCalleeA SecondAbility onCreate") + globalThis.abilityWant = want; + globalThis.abilityContext2 = this.context; + this.callee.on('test2200', this.test2200); + this.callee.on('testCall', testCall); + this.callee.on('testCallWithResult', testCallWithResult); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemAppCalleeA SecondAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemAppCalleeA SecondAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemAppCalleeA SecondAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemAppCalleeA SecondAbility onForeground"); + } + + onBackground() { + // Ability has back to background + console.log("SystemAppCalleeA SecondAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/ThirdAbility/ThirdAbility.ts b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/ThirdAbility/ThirdAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..42dd15ffb23595224875d586de09771d213e17e5 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/ThirdAbility/ThirdAbility.ts @@ -0,0 +1,116 @@ +/* + * 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' + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function testCall(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemAppCallerA MainAbility on testCall <======') + data.readSequenceable(recvSequence); + var result = recvSequence.str + 'processed'; + var commonEventData = { + code: 0, + data: 'calleeCheckCallParam', + parameters: { + num: recvSequence.num, + str: recvSequence.str, + result: result + } + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>CallTestSysA SecondAbility Call_Finish<======') + }) + + return recvSequence; +} + +function testCallWithResult(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemAppCallerA MainAbility on testCall <======') + data.readSequenceable(recvSequence); + let result = recvSequence.str + 'processed'; + recvSequence.setMySequence(recvSequence.num, recvSequence.str, result); + + return recvSequence; +} + +export default class ThirdAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemAppCalleeA ThirdAbility onCreate") + this.callee.on('testCall', testCall); + this.callee.on('testCallWithResult', testCallWithResult); + globalThis.abilityWant = want; + globalThis.abilityContext3 = this.context; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemAppCalleeA ThirdAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemAppCalleeA ThirdAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemAppCalleeA ThirdAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemAppCalleeA ThirdAbility onForeground"); + } + + onBackground() { + // Ability has back to background + console.log("SystemAppCalleeA ThirdAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..30b8d934e2b7e2d5f07c2deb7495797e78e6b3d3 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,52 @@ +/* + * 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'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcalleea/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/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/module.json b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..9ed9f1a6e2d1563f3673e75e5b4b0d4c5435b44b --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/module.json @@ -0,0 +1,88 @@ +{ + "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.systemappcalleea.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.systemappcalleea.SecondAbility", + "srcEntrance": "./ets/SecondAbility/SecondAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton" + }, + { + "name": "com.example.systemappcalleea.ThirdAbility", + "srcEntrance": "./ets/ThirdAbility/ThirdAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "standard" + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INSTALL_BUNDLE", + "reason": "need use ohos.permission.INSTALL_BUNDLE" + }, + { + "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.MANAGE_MISSIONS", + "reason": "need use ohos.permission.MANAGE_MISSIONS" + } + ] + } +} diff --git a/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcalleea/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/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actscalltest/systemappcalleea/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcalleea/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/aafwk/aafwk_standard/actscalltest/systemappcalleea/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actscalltest/systemappcalleea/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemappcalleea/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallera/AppScope/app.json b/aafwk/aafwk_standard/actscalltest/systemappcallera/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..182091df8b68144d654f4a2ed1be27fffd229fc3 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallera/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.systemappcallera", + "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/aafwk/aafwk_standard/actscalltest/systemappcallera/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/systemappcallera/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallera/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/aafwk/aafwk_standard/actscalltest/systemappcallera/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actscalltest/systemappcallera/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemappcallera/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallera/BUILD.gn b/aafwk/aafwk_standard/actscalltest/systemappcallera/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..97b079739ce30680b1267390b38dd1b72ce2b8ec --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallera/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("ActsSystemAppCallerARelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":systemappcallera_js_assets", + ":systemappcallera_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsSystemAppCallerARelyHap" +} + +ohos_app_scope("systemappcallera_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("systemappcallera_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("systemappcallera_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":systemappcallera_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallera/Test.json b/aafwk/aafwk_standard/actscalltest/systemappcallera/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallera/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..21606483f3457f3a691d5d0a28e111ffc5d9d4bf --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallera/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" + +var onAcceptWantCalledSeq; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("SystemCallTest MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..aacaa98b10dd9abf470232da1a8d04406513599a --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,204 @@ +/* + * 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' + +var bundleNameCallee = "com.example.systemcalltest"; +var abilityNameCallee = "com.example.systemcalltest.SecondAbility"; +var subscriber; +var caller; +var event_getcaller = "getcaller.com.example.systemcalltest.SecondAbility"; +var event_call = "call.com.example.systemcalltest.SecondAbility"; +var event_release = "release.com.example.systemcalltest.SecondAbility"; +var subscribeInfo = { + events: [event_getcaller, event_call, event_release, ], +}; + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function getCaller(context) { + console.log("SystemAppCallerA MainAbility getCaller"); + let want = { + bundleName: bundleNameCallee, + abilityName: abilityNameCallee, + }; + context.startAbilityByCall(want).then(data => { + if (typeof data !== "object" || data == null) { + console.log('SystemAppCallerA MainAbility startAbilityByCall fail'); + } + caller = data; + }); +} + +function stressCall() { + console.log('SystemAppCallerA MainAbility stressCall begin'); + if (typeof caller !== "object" || caller == null) { + console.log('SystemAppCallerA MainAbility caller error in stressCall'); + } + let times = 10; + for (let i = 0; i < times; i++) { + let data = new MySequenceable(i, "SystemAppCallerA", ''); + caller.call('stressMethod', data); + } +} + +function unsubscribeCallback() { + console.debug("SystemAppCallerA MainAbility unsubscribeCallback"); +} + +function releaseCallee() { + try { + caller.onRelease(data => { + console.log('SystemAppCallerA MainAbility releaseCallBack:' + data); + }); + caller.release(); + } catch (e) { + console.log('SystemAppCallerA MainAbility release fail ' + e); + } + commonEvent.unsubscribe(subscriber, unsubscribeCallback); +} + +function startNext(context) { + console.log("SystemAppCallerA MainAbility startNext"); + let want = { + bundleName: "com.example.systemappcallerb", + abilityName: "com.example.systemappcallerb.MainAbility", + parameters: {case_num: "case5600"}, + } + context.startAbility(want, + (err) => {console.log("SystemAppCallerA MainAbility startAbility callback");}); +} + +function testCall(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemAppCallerA MainAbility on testCall <======') + data.readSequenceable(recvSequence); + var result = recvSequence.str + 'processed'; + var commonEventData = { + code: 0, + data: 'calleeCheckCallParam', + parameters: { + num: recvSequence.num, + str: recvSequence.str, + result: result + } + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>CallTestSysA SecondAbility Call_Finish<======') + }) + return recvSequence; +} + +function testCallWithResult(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemAppCallerA MainAbility on testCall <======') + data.readSequenceable(recvSequence); + let result = recvSequence.str + 'processed'; + recvSequence.setMySequence(recvSequence.num, recvSequence.str, result); + + return recvSequence; +} + +export default class MainAbility extends Ability { + + subscribeCallBack(err, data) { + console.log('SystemAppCallerA MainAbility subscribeCallBack data:' + JSON.stringify(data)); + switch (data.event) { + case event_call: + stressCall(); + break; + case event_release: + releaseCallee(); + break; + default: + console.log('SystemAppCallerA MainAbility subscribeCallBack event error:' + data.event); + break; + } + } + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemAppCallerA MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.abilityContext = this.context; + this.callee.on('testCall', testCall); + this.callee.on('testCallWithResult', testCallWithResult); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemAppCallerA MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemAppCallerA MainAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemAppCallerA MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemAppCallerA MainAbility onForeground"); + commonEvent.createSubscriber(subscribeInfo).then((data) => { + console.log("SystemAppCallerA MainAbility createSubscriber"); + subscriber = data; + commonEvent.subscribe(subscriber, this.subscribeCallBack); + if (globalThis.abilityWant.parameters["case_num"] == "case5600") { + getCaller(this.context); + startNext(this.context); + } + }); + } + + onBackground() { + // Ability has back to background + console.log("SystemAppCallerA MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/SecondAbility/SecondAbility.ts b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/SecondAbility/SecondAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..0a921f1b54fba6d9f05f922968111d5f7072ef6a --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/SecondAbility/SecondAbility.ts @@ -0,0 +1,126 @@ +/* + * 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' + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function testCall(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemAppCallerA SecondAbility on testCall <======') + data.readSequenceable(recvSequence); + var result = recvSequence.str + 'processed'; + var commonEventData = { + code: 0, + data: 'calleeCheckCallParam', + parameters: { + num: recvSequence.num, + str: recvSequence.str, + result: result + } + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>CallTestSysA SecondAbility Call_Finish<======') + }) + return recvSequence; +} + +function testCallWithResult(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemAppCallerA SecondAbility on testCall <======') + data.readSequenceable(recvSequence); + let result = recvSequence.str + 'processed'; + recvSequence.setMySequence(recvSequence.num, recvSequence.str, result); + + return recvSequence; +} + +export default class SecondAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemAppCallerA SecondAbility onCreate") + globalThis.abilityWant = want; + globalThis.abilityContext = this.context; + this.callee.on('testCall', testCall); + this.callee.on('testCallWithResult', testCallWithResult); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemAppCallerA SecondAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemAppCallerA SecondAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemAppCallerA SecondAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemAppCallerA SecondAbility onForeground"); + if ((globalThis.abilityWant.parameters.case_num == "case0700") || + (globalThis.abilityWant.parameters.case_num == "case0800")) { + console.log("SystemAppCallerA SecondAbility special process in"); + var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground"; + var commonEventData = { + data: publishData, + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>SystemAppCallerA SecondAbility Call_Finish<======') + }) + } + } + + onBackground() { + // Ability has back to background + console.log("SystemAppCallerA SecondAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/ThirdAbility/ThirdAbility.ts b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/ThirdAbility/ThirdAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..692c7bfc71dd9ee1210d56658adb061de4015e76 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/ThirdAbility/ThirdAbility.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 Ability from '@ohos.application.Ability' +import commonEvent from '@ohos.commonevent' + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function testCall(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemAppCallerA ThirdAbility on testCall <======') + data.readSequenceable(recvSequence); + var result = recvSequence.str + 'processed'; + var commonEventData = { + code: 0, + data: 'calleeCheckCallParam', + parameters: { + num: recvSequence.num, + str: recvSequence.str, + result: result + } + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>CallTestSysA ThirdAbility Call_Finish<======') + }) + return recvSequence; +} + +function testCallWithResult(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemAppCallerA ThirdAbility on testCall <======') + data.readSequenceable(recvSequence); + let result = recvSequence.str + 'processed'; + recvSequence.setMySequence(recvSequence.num, recvSequence.str, result); + + return recvSequence; +} + +export default class ThirdAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemAppCallerA ThirdAbility onCreate") + globalThis.abilityWant = want; + globalThis.abilityContext = this.context; + this.callee.on('testCall', testCall); + this.callee.on('testCallWithResult', testCallWithResult); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemAppCallerA ThirdAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemAppCallerA ThirdAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemAppCallerA ThirdAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemAppCallerA ThirdAbility onForeground"); + if ((globalThis.abilityWant.parameters.case_num == "case0700") || + (globalThis.abilityWant.parameters.case_num == "case0800")) { + var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground"; + var commonEventData = { + data: publishData, + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>SystemAppCallerA ThirdAbility Call_Finish<======') + }) + } + } + + onBackground() { + // Ability has back to background + console.log("SystemAppCallerA ThirdAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..30b8d934e2b7e2d5f07c2deb7495797e78e6b3d3 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,52 @@ +/* + * 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'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallera/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/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/module.json b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..144073f33a52bb84f5223ecbaab5a0f38912ef68 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/module.json @@ -0,0 +1,88 @@ +{ + "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.systemappcallera.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.systemappcallera.SecondAbility", + "srcEntrance": "./ets/SecondAbility/SecondAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton" + }, + { + "name": "com.example.systemappcallera.ThirdAbility", + "srcEntrance": "./ets/ThirdAbility/ThirdAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "standard" + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INSTALL_BUNDLE", + "reason": "need use ohos.permission.INSTALL_BUNDLE" + }, + { + "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.MANAGE_MISSIONS", + "reason": "need use ohos.permission.MANAGE_MISSIONS" + } + ] + } +} diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallera/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/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actscalltest/systemappcallera/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallera/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/aafwk/aafwk_standard/actscalltest/systemappcallera/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actscalltest/systemappcallera/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemappcallera/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerb/AppScope/app.json b/aafwk/aafwk_standard/actscalltest/systemappcallerb/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..cc201ae2713fc6305d1d02da58f842b08bf8e026 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerb/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.systemappcallerb", + "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/aafwk/aafwk_standard/actscalltest/systemappcallerb/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/systemappcallerb/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerb/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/aafwk/aafwk_standard/actscalltest/systemappcallerb/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actscalltest/systemappcallerb/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemappcallerb/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerb/BUILD.gn b/aafwk/aafwk_standard/actscalltest/systemappcallerb/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..6589529c675aa3095bcb676e463182f3e3b90c93 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerb/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("ActsSystemAppCallerBRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":systemappcallerb_js_assets", + ":systemappcallerb_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsSystemAppCallerBRelyHap" +} + +ohos_app_scope("systemappcallerb_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("systemappcallerb_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("systemappcallerb_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":systemappcallerb_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerb/Test.json b/aafwk/aafwk_standard/actscalltest/systemappcallerb/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerb/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..21606483f3457f3a691d5d0a28e111ffc5d9d4bf --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerb/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" + +var onAcceptWantCalledSeq; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("SystemCallTest MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..ac90747ab00c9d2284e9318875c37a8f4f9fc3bb --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,171 @@ +/* + * 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' + +var bundleNameCallee = "com.example.systemcalltest"; +var abilityNameCallee = "com.example.systemcalltest.SecondAbility"; +var subscriber; +var caller; +var event_getcaller = "getcaller.com.example.systemcalltest.SecondAbility"; +var event_call = "call.com.example.systemcalltest.SecondAbility"; +var event_release = "release.com.example.systemcalltest.SecondAbility"; +var subscribeInfo = { + events: [event_getcaller, event_call, event_release, ], +}; + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function getCaller(context) { + let want = { + bundleName: bundleNameCallee, + abilityName: abilityNameCallee, + }; + context.startAbilityByCall(want).then(data => { + if (typeof data !== "object" || data == null) { + console.log('SystemAppCallerB MainAbility startAbilityByCall fail'); + } + caller = data; + }); +} + +function stressCall() { + console.log('SystemAppCallerB MainAbility stressCall begin'); + if (typeof caller !== "object" || caller == null) { + console.log('SystemAppCallerB MainAbility caller error in stressCall'); + return; + } + let times = 10; + for (let i = 0; i < times; i++) { + let data = new MySequenceable(i, "SystemAppCallerB", ''); + caller.call('stressMethod', data); + } +} + +function unsubscribeCallback() { + console.debug("SystemAppCallerB MainAbility unsubscribeCallback"); +} + +function releaseCallee() { + try { + caller.onRelease(data => { + console.log('SystemAppCallerB MainAbility releaseCallBack:' + data); + }); + caller.release(); + } catch (e) { + console.log('SystemAppCallerB MainAbility release fail ' + e); + } + commonEvent.unsubscribe(subscriber, unsubscribeCallback); +} + +function startNext(context) { + let want = { + bundleName: "com.example.systemappcallerc", + abilityName: "com.example.systemappcallerc.MainAbility", + parameters: {case_num: "case5600"}, + } + context.startAbility(want, + (err) => {console.log("SystemAppCallerB MainAbility startAbility callback");}); + +} + +export default class MainAbility extends Ability { + + subscribeCallBack(err, data) { + console.log('SystemAppCallerB MainAbility subscribeCallBack data:' + JSON.stringify(data)); + switch (data.event) { + case event_call: + stressCall(); + break; + case event_release: + releaseCallee(); + break; + default: + console.log('SystemAppCallerB MainAbility subscribeCallBack event error:' + data.event); + break; + } + } + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemAppCallerB MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.abilityContext = this.context + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemAppCallerB MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemAppCallerB MainAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemAppCallerB MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemAppCallerB MainAbility onForeground"); + commonEvent.createSubscriber(subscribeInfo).then((data) => { + console.log("SystemAppCallerB MainAbility createSubscriber"); + subscriber = data; + commonEvent.subscribe(subscriber, this.subscribeCallBack); + if (globalThis.abilityWant.parameters["case_num"] == "case5600") { + getCaller(this.context); + startNext(this.context); + } + }); + } + + onBackground() { + // Ability has back to background + console.log("SystemAppCallerB MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..30b8d934e2b7e2d5f07c2deb7495797e78e6b3d3 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,52 @@ +/* + * 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'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerb/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/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/module.json b/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..9e2cdcdde294ecd7c9b4614e2db14ac003e5033f --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/module.json @@ -0,0 +1,68 @@ +{ + "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.systemappcallerb.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "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.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + } + ] + } +} diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerb/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/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actscalltest/systemappcallerb/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerb/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/aafwk/aafwk_standard/actscalltest/systemappcallerb/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actscalltest/systemappcallerb/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemappcallerb/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerc/AppScope/app.json b/aafwk/aafwk_standard/actscalltest/systemappcallerc/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..9e36f5a9795e642910f225ac9bce010d53c2e2ae --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerc/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.systemappcallerc", + "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/aafwk/aafwk_standard/actscalltest/systemappcallerc/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/systemappcallerc/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerc/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/aafwk/aafwk_standard/actscalltest/systemappcallerc/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actscalltest/systemappcallerc/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemappcallerc/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerc/BUILD.gn b/aafwk/aafwk_standard/actscalltest/systemappcallerc/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..0e6426ae74f431a985431e1cfc90c49bb8a44dae --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerc/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("ActsSystemAppCallerCRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":systemappcallerc_js_assets", + ":systemappcallerc_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsSystemAppCallerCRelyHap" +} + +ohos_app_scope("systemappcallerc_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("systemappcallerc_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("systemappcallerc_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":systemappcallerc_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerc/Test.json b/aafwk/aafwk_standard/actscalltest/systemappcallerc/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerc/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..21606483f3457f3a691d5d0a28e111ffc5d9d4bf --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerc/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" + +var onAcceptWantCalledSeq; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("SystemCallTest MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..1a019844ce10c499d1ffea3287f89f11a508dc3d --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,168 @@ +/* + * 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' + +var bundleNameCallee = "com.example.systemcalltest"; +var abilityNameCallee = "com.example.systemcalltest.SecondAbility"; +var subscriber; +var caller; +var event_getcaller = "getcaller.com.example.systemcalltest.SecondAbility"; +var event_call = "call.com.example.systemcalltest.SecondAbility"; +var event_release = "release.com.example.systemcalltest.SecondAbility"; +var subscribeInfo = { + events: [event_getcaller, event_call, event_release, ], +}; + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function getCaller(context) { + let want = { + bundleName: bundleNameCallee, + abilityName: abilityNameCallee, + }; + context.startAbilityByCall(want).then(data => { + if (typeof data !== "object" || data == null) { + console.log('SystemAppCallerC MainAbility startAbilityByCall fail'); + } + caller = data; + }); +} + +function stressCall() { + console.log('SystemAppCallerC MainAbility stressCall begin'); + if (typeof caller !== "object" || caller == null) { + console.log('SystemAppCallerC MainAbility caller error in stressCall'); + } + let times = 10; + for (let i = 0; i < times; i++) { + let data = new MySequenceable(i, "SystemAppCallerC", ''); + caller.call('stressMethod', data); + } +} + +function unsubscribeCallback() { + console.debug("SystemAppCallerC MainAbility unsubscribeCallback"); +} + +function releaseCallee() { + try { + caller.onRelease(data => { + console.log('SystemAppCallerC MainAbility releaseCallBack:' + data); + }); + caller.release(); + } catch (e) { + console.log('SystemAppCallerC MainAbility release fail ' + e); + } + commonEvent.unsubscribe(subscriber, unsubscribeCallback); +} + +function triggerStressEvent() { + let commonEventData = {} + commonEvent.publish(event_call, commonEventData, (err) => { + console.log('SystemAppCallerC publish event') + }) +} + +export default class MainAbility extends Ability { + + subscribeCallBack(err, data) { + console.log('SystemAppCallerC MainAbility subscribeCallBack data:' + JSON.stringify(data)); + switch (data.event) { + case event_call: + stressCall(); + break; + case event_release: + releaseCallee(); + break; + default: + console.log('SystemAppCallerC MainAbility subscribeCallBack event error:' + data.event); + break; + } + } + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemAppCallerC MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.abilityContext = this.context; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemAppCallerC MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemAppCallerC MainAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemAppCallerC MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemAppCallerC MainAbility onForeground"); + commonEvent.createSubscriber(subscribeInfo).then((data) => { + console.log("SystemAppCallerC MainAbility createSubscriber"); + subscriber = data; + commonEvent.subscribe(subscriber, this.subscribeCallBack); + for (let start=Date.now(); Date.now() - start <= 100;); + if (globalThis.abilityWant.parameters["case_num"] == "case5600") { + getCaller(this.context); + triggerStressEvent(); + } + }); + } + + onBackground() { + // Ability has back to background + console.log("SystemAppCallerC MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..30b8d934e2b7e2d5f07c2deb7495797e78e6b3d3 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,52 @@ +/* + * 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'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerc/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/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/module.json b/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..85761ba82b64477adeb23f18ac44b9cf05c5b601 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/module.json @@ -0,0 +1,68 @@ +{ + "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.systemappcallerc.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "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.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + } + ] + } +} diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerc/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/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actscalltest/systemappcallerc/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemappcallerc/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/aafwk/aafwk_standard/actscalltest/systemappcallerc/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actscalltest/systemappcallerc/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemappcallerc/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actscalltest/systemcallentrytest/AppScope/app.json b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..9553812f3c2e1911fb8167dc4facbed4a05b9c03 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.systemcalltest", + "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/aafwk/aafwk_standard/actscalltest/systemcallentrytest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/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/aafwk/aafwk_standard/actscalltest/systemcallentrytest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/systemcallentrytest/BUILD.gn b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..27b56a8e78af22bb41fc63ce257b2676eb405505 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/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("ActsCallTestEntryTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":systemcallentrytest_js_assets", + ":systemcallentrytest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsCallTestEntryTest" +} + +ohos_app_scope("systemcallentrytest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("systemcallentrytest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("systemcallentrytest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":systemcallentrytest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actscalltest/systemcallentrytest/Test.json b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..9e244efab107c2acc4f7a1dd68f19e6a3ce92f3a --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/Test.json @@ -0,0 +1,30 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "1000000", + "package": "com.example.systemcalltest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsCallTestEntryTest.hap", + "ActsCallTestFeatureRelyHap.hap", + "ActsSystemAppCallerARelyHap.hap", + "ActsSystemAppCallerBRelyHap.hap", + "ActsSystemAppCallerCRelyHap.hap", + "ActsSystemAppCalleeARelyHap.hap", + "ActsThirdAppARelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..21606483f3457f3a691d5d0a28e111ffc5d9d4bf --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/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" + +var onAcceptWantCalledSeq; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("SystemCallTest MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..694daa7d816cc0bdc722901d6aa30c3c15303f42 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,91 @@ +/* + * 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' + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +export default class MainAbility extends Ability { + test2100(data) { + console.log("SystemCallTest MainAbility test2100 begin"); + let recvData = new MySequenceable(0, '', ''); + data.readSequenceable(recvData); + return new MySequenceable(recvData.num + 1, recvData.str + "Main", recvData.result); + } + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemCallTest MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.callee = this.callee; + this.callee.on('test2100', this.test2100); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemCallTest MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemCallTest 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("SystemCallTest MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemCallTest MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("SystemCallTest MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/SecondAbility/SecondAbility.ts b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/SecondAbility/SecondAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..7108c72c84756e693151a837f43b596522ac803e --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/SecondAbility/SecondAbility.ts @@ -0,0 +1,253 @@ +/* + * 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' + +var callerA = "SystemAppCallerA" +var callSeqA= new Array(); +var callerB = "SystemAppCallerB" +var callSeqB= new Array(); +var callerC = "SystemAppCallerC" +var callSeqC= new Array(); +var seq = 0; + +function isArrayEqual(a1, a2) { + return a1.length==a2.length && a1.every(function(value,index) { return value === a2[index]}); +} +function isArrayEqualWithoutOrder(a1, a2) { + if (a1.length != a2.length) { + return false; + } + for (let ind in a1) { + if (a2.indexOf(a1[ind]) == -1) { + return false; + }; + } + return true; +} +var expectStressResult=[0,1,2,3,4,5,6,7,8,9]; + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function testCall(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemCallTest SecondAbility on testCall <======') + data.readSequenceable(recvSequence); + var result = recvSequence.str + 'processed'; + var commonEventData = { + code: 0, + data: 'calleeCheckCallParam', + parameters: { + num: recvSequence.num, + str: recvSequence.str, + result: result + } + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>CallTestSysA SecondAbility Call_Finish<======') + }) + return recvSequence; +} + +function testCall2(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemCallTest SecondAbility on testCall <======') + data.readSequenceable(recvSequence); + var result = recvSequence.str + 'processed2'; + var commonEventData = { + code: 0, + data: 'calleeCheckCall2Param', + parameters: { + num: recvSequence.num, + str: recvSequence.str, + result: result + } + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>CallTestSysA SecondAbility Call_Finish<======') + }) + return recvSequence; +} + +function testCallWithResult(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemCallTest SecondAbility on testCall <======') + data.readSequenceable(recvSequence); + let result = recvSequence.str + 'processed'; + recvSequence.setMySequence(recvSequence.num, recvSequence.str, result); + + return recvSequence; +} + +function test2100ReleaseCallback(data) { + console.log('SystemCallTest SecondAbility test2100ReleaseCallback:' + data); + test2100ReleaseFlag = data.toString(); +} + +var test2100ReleaseFlag = ''; + +export default class SecondAbility extends Ability { + + test2100(data) { + let recvData = new MySequenceable(0, '', ''); + data.readSequenceable(recvData); + let want = { + bundleName: "com.example.systemcalltest", + abilityName: "com.example.systemcalltest.MainAbility", + }; + console.log("SystemCallTest SecondAbility test2100 before startAbilityByCall"); + let resultData = new MySequenceable(0, '', ''); + globalThis.abilityContext2.startAbilityByCall(want).then((caller) => { + let param = new MySequenceable(recvData.num + 1, recvData.str + "Second", recvData.result); + caller.onRelease(test2100ReleaseCallback); + for (let start=Date.now(); Date.now() - start <= 200;); + caller.callWithResult('test2100', param).then((data2) => { + data2.readSequenceable(resultData); + caller.release(); + for (let start=Date.now(); Date.now() - start <= 200;); + resultData.result = test2100ReleaseFlag; + let commonEventData = { + parameters: { + num: resultData.num, + str: resultData.str, + result: resultData.result, + } + }; + commonEvent.publish('call_case2100_test_result', commonEventData, (err) => { + console.log('SystemCallTest SecondAbility publish call_case2200_test_result event'); + }) + + }); + }); + return resultData; + } + + testOff(data) { + let recvSequence = new MySequenceable(0, '', ''); + data.readSequenceable(recvSequence); + return recvSequence; + } + + stressMethod(data) { + let recvData = new MySequenceable(0, '', ''); + data.readSequenceable(recvData); + console.log('SystemCallTest SecondAbility stressMethod caller ' + recvData.str); + if (recvData.str == callerA) { + callSeqA.push(recvData.num); + } else if (recvData.str == callerB) { + callSeqB.push(recvData.num); + } else if (recvData.str == callerC) { + callSeqC.push(recvData.num); + } + seq++; + if (seq >= 30) { + console.log('SystemCallTest SecondAbility stressMethod SystemAppCallerA ' + callSeqA); + console.log('SystemCallTest SecondAbility stressMethod SystemAppCallerB ' + callSeqB); + console.log('SystemCallTest SecondAbility stressMethod SystemAppCallerC ' + callSeqC); + let stressResult=isArrayEqualWithoutOrder(callSeqA, expectStressResult); + stressResult=stressResult&&isArrayEqualWithoutOrder(callSeqB, expectStressResult); + stressResult=stressResult&&isArrayEqualWithoutOrder(callSeqC, expectStressResult); + console.log('SystemCallTest SecondAbility stressMethod stressResult ' + stressResult); + let commonEventData = { + data: stressResult.toString(), + }; + commonEvent.publish('com.example.systemcalltest.Test5600', commonEventData, (err) => { + console.log('SystemCallTest SecondAbility stress test result event'); + }); + seq=0; + callSeqA = []; + callSeqB = []; + callSeqC = []; + } + return recvData; + } + + loopMethod(data) { + let recvData = new MySequenceable(0, '', ''); + data.readSequenceable(recvData); + return new MySequenceable(recvData.num + 1, recvData.str, ''); + } + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemCallTest SecondAbility onCreate") + globalThis.abilityWant = want; + globalThis.secondCallee = this.callee; + globalThis.abilityContext2 = this.context; + this.callee.on('test2100', this.test2100); + this.callee.on('testOff', this.testOff); + this.callee.on('stressMethod', this.stressMethod); + this.callee.on('loopMethod', this.loopMethod); + this.callee.on('testCall', testCall); + this.callee.on('testCall2', testCall2); + this.callee.on('testCallWithResult', testCallWithResult); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemCallTest SecondAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemCallTest SecondAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/second/second", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemCallTest SecondAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemCallTest SecondAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("SystemCallTest SecondAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..26746b5a84730dfe5b9220652170de21d515737f --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/pages/index/index.ets @@ -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 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 10000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..72e66614c1a8c9068b0b0594d6da4ae52c0912b7 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/pages/second/second.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('SystemCallTest SecondAbility)') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..c3a5c078bf1764d8bd411507c68e691a72a21823 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,1790 @@ +/* + * 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 missionManager from '@ohos.application.missionManager' +import appManager from '@ohos.application.appManager' + +const MAX_MISSION_NUM = 1024; +var sysABundleName = "com.example.systemcalltest"; +var sysAMainAbilityName = "com.example.systemcalltest.MainAbility"; +var sysASecondAbilityName = "com.example.systemcalltest.SecondAbility"; +var systemAppCallerABundleName = "com.example.systemappcallera"; +var systemAppCallerAMainAbilityName = "com.example.systemappcallera.MainAbility"; +var systemAppCallerASecondAbilityName = "com.example.systemappcallera.SecondAbility"; +var systemAppCallerAThirdAbilityName = "com.example.systemappcallera.ThirdAbility"; + +var systemAppCalleeABundleName = "com.example.systemappcalleea"; +var systemAppCalleeAMainAbilityName = "com.example.systemappcalleea.MainAbility"; +var systemAppCalleeASecondAbilityName = "com.example.systemappcalleea.SecondAbility"; +var systemAppCalleeAThirdAbilityName = "com.example.systemappcalleea.ThirdAbility"; + +var systemAppCalleeBBundleName = "com.example.systemappcalleeb"; +var systemAppCalleeBMainAbilityName = "com.example.systemappcalleeb.MainAbility"; +var systemAppCalleeBSecondAbilityName = "com.example.systemappcalleeb.SecondAbility"; + +var systemAppCalleeCBundleName = "com.example.systemappcalleec"; +var systemAppCalleeCMainAbilityName = "com.example.systemappcalleec.MainAbility"; +var systemAppCalleeCSecondAbilityName = "com.example.systemappcalleec.SecondAbility"; + +var thirdAppABundleName = "com.example.thirdappa"; +var thirdAppAMainAbilityName = "com.example.thirdappa.MainAbility"; +var subscriberInfo = { + events: ["CallTest"], +}; +var caseDepBundles = []; + +class MySequenceable { + num: number = 0; + str: String = "default"; + result: String = "default"; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function getMissionId(abilityName, state) { + return new Promise(async (resolve, reject) => { + let missionId = -1; + let missionInfos = await missionManager.getMissionInfos('', MAX_MISSION_NUM); + for (let i = 0; i < missionInfos.length; i++) { + if ((missionInfos[i].want.abilityName == abilityName) + && (missionInfos[i].runningState == state)) { + missionId = missionInfos[i].missionId; + break; + } + } + console.log('======>getMissionId resolve missionId<=======' + missionId); + resolve(missionId); + }) +} + +function delay(time) { + let delta; + if (typeof time != 'number' || time <= 0) { + delta = 100; + } else { + delta = Math.round(time); + } + for (let start = Date.now(); Date.now() - start <= delta; ); +} + +function clearDepProcess(bundleNames, callback, undoneCallBack) { + var result; + var cnt = 0; + + if (bundleNames.length == 0) { + undoneCallBack(); + } + for (let i = 0; i < bundleNames.length; i++) { + result = appManager.killProcessesByBundleName(bundleNames[i], (err, data) => { + console.log("clearDepProcess killProcessesByBundleName bundleName: " + bundleNames[i]); + console.log("clearDepProcess killProcessesByBundleName err: " + JSON.stringify(err)); + console.log("clearDepProcess killProcessesByBundleName data: " + JSON.stringify(data)); + cnt++; + if (cnt == bundleNames.length) { + callback(); + } + }); + } +} + +export default function abilityTest(abilityContext) { + describe('ActsAbilityTest', function () { + + beforeEach(async (done) => { + done(); + }) + + afterEach(async (done) => { + var testMissionId; + + testMissionId = await getMissionId(sysAMainAbilityName, 0); + console.log('======>afterEach test missionId<=======' + testMissionId); + if (testMissionId != -1) { + await missionManager.moveMissionToFront(testMissionId); + } + console.log('======>afterEach test missionId move to front<======='); + + clearDepProcess(caseDepBundles, () => { + caseDepBundles = []; + setTimeout(() => { + done(); + }, 500) + }, () => { + done(); + }); + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_0100 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_0100', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_0100 begin'); + var subscriber; + + function unSubscribeCallBack() { + console.log('ACTS_CommonComponent_Call_0100 unSubscribeCallBack') + done(); + } + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_0100 releaseCallBack' + data); + commonEvent.unsubscribe(subscriber, unSubscribeCallBack); + } + + function subscribeCallBack(err, data) { + console.log('ACTS_CommonComponent_Call_0100 subscribeCallBack data:' + JSON.stringify(data)) + expect(data.data).assertEqual('calleeCheckCallParam'); + expect(data.parameters.num).assertEqual(100); + expect(data.parameters.str).assertEqual('ACTS_CommonComponent_Call_0100'); + expect(data.parameters.result).assertEqual('ACTS_CommonComponent_Call_0100processed'); + console.log('AMS_CallTest_0100 do release'); + caller.release(); + } + + subscriber = await commonEvent.createSubscriber(subscriberInfo); + commonEvent.subscribe(subscriber, subscribeCallBack); + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(100, "ACTS_CommonComponent_Call_0100", 'default'); + caller.call('testCall', param).then(() => { + console.log('ACTS_CommonComponent_Call_0100 call success'); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_0100 call exception' + err); + expect().assertFail(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_0200 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_0200', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_0200 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_0200 releaseCallBack' + data); + done(); + } + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(200, "ACTS_CommonComponent_Call_0200", 'default'); + caller.callWithResult('testCallWithResult', param).then((data) => { + console.log('ACTS_CommonComponent_Call_0200 call success'); + var result = new MySequenceable(0, '', ''); + data.readSequenceable(result); + expect(result.num).assertEqual(200); + expect(result.str).assertEqual('ACTS_CommonComponent_Call_0200'); + expect(result.result).assertEqual('ACTS_CommonComponent_Call_0200processed'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_0200 call exception' + err); + expect().assertFail(); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_0300 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_0300', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_0300 begin'); + var subscriber; + caseDepBundles = [systemAppCalleeABundleName]; + + function unSubscribeCallBack() { + console.log('ACTS_CommonComponent_Call_0300 unSubscribeCallBack') + done(); + } + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_0300 releaseCallBack' + data); + commonEvent.unsubscribe(subscriber, unSubscribeCallBack); + } + + function subscribeCallBack(err, data) { + console.log('ACTS_CommonComponent_Call_0300 subscribeCallBack data:' + JSON.stringify(data)) + expect(data.data).assertEqual('calleeCheckCallParam'); + expect(data.parameters.num).assertEqual(300); + expect(data.parameters.str).assertEqual('ACTS_CommonComponent_Call_0300'); + expect(data.parameters.result).assertEqual('ACTS_CommonComponent_Call_0300processed'); + console.log('ACTS_CommonComponent_Call_0300 do release'); + caller.release(); + } + + subscriber = await commonEvent.createSubscriber(subscriberInfo); + commonEvent.subscribe(subscriber, subscribeCallBack); + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: systemAppCalleeABundleName, + abilityName: systemAppCalleeAMainAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(300, "ACTS_CommonComponent_Call_0300", 'default'); + caller.call('testCall', param).then(() => { + console.log('ACTS_CommonComponent_Call_0300 call success'); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_0300 call exception' + err); + expect().assertFail(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_0400 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_0400', 0, async function (done) { + caseDepBundles = [systemAppCalleeABundleName]; + console.log('ACTS_CommonComponent_Call_0400 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_0400 releaseCallBack' + data); + done(); + } + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: systemAppCalleeABundleName, + abilityName: systemAppCalleeAMainAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(400, "ACTS_CommonComponent_Call_0400", 'default'); + caller.callWithResult('testCallWithResult', param).then((data) => { + console.log('ACTS_CommonComponent_Call_0400 call success'); + var result = new MySequenceable(0, '', ''); + data.readSequenceable(result); + expect(result.num).assertEqual(400); + expect(result.str).assertEqual('ACTS_CommonComponent_Call_0400'); + expect(result.result).assertEqual('ACTS_CommonComponent_Call_0400processed'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_0400 call exception' + err); + expect().assertFail(); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_0500 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_0500', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_0500 begin'); + var subscriber; + var caller1; + var caller2; + caseDepBundles = [systemAppCalleeABundleName]; + + function unSubscribeCallBack() { + console.log('ACTS_CommonComponent_Call_0500 unSubscribeCallBack') + caller1.release(); + done(); + } + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_0500 releaseCallBack' + data); + commonEvent.unsubscribe(subscriber, unSubscribeCallBack); + } + + function subscribeCallBack(err, data) { + console.log('ACTS_CommonComponent_Call_0500 subscribeCallBack data:' + JSON.stringify(data)) + expect(data.data).assertEqual('calleeCheckCallParam'); + expect(data.parameters.num).assertEqual(500); + expect(data.parameters.str).assertEqual('ACTS_CommonComponent_Call_0500'); + expect(data.parameters.result).assertEqual('ACTS_CommonComponent_Call_0500processed'); + console.log('ACTS_CommonComponent_Call_0500 do release'); + caller2.release(); + } + + subscriber = await commonEvent.createSubscriber(subscriberInfo); + commonEvent.subscribe(subscriber, subscribeCallBack); + + caller1 = await globalThis.abilityContext.startAbilityByCall({ + bundleName: systemAppCalleeABundleName, + abilityName: systemAppCalleeAMainAbilityName, + }); + + caller2 = await globalThis.abilityContext.startAbilityByCall({ + bundleName: systemAppCalleeABundleName, + abilityName: systemAppCalleeASecondAbilityName, + }); + + caller2.onRelease(releaseCallback); + let param = new MySequenceable(500, "ACTS_CommonComponent_Call_0500", 'default'); + caller2.call('testCall', param).then(() => { + console.log('ACTS_CommonComponent_Call_0500 call success'); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_0500 call exception' + err); + expect().assertFail(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_0600 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_0600', 0, async function (done) { + caseDepBundles = [systemAppCalleeABundleName]; + console.log('ACTS_CommonComponent_Call_0600 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_0600 releaseCallBack' + data); + caller1.release(); + done(); + } + + let caller1 = await globalThis.abilityContext.startAbilityByCall({ + bundleName: systemAppCalleeABundleName, + abilityName: systemAppCalleeAMainAbilityName, + }); + let caller2 = await globalThis.abilityContext.startAbilityByCall({ + bundleName: systemAppCalleeABundleName, + abilityName: systemAppCalleeASecondAbilityName, + }); + + caller2.onRelease(releaseCallback); + let param = new MySequenceable(600, "ACTS_CommonComponent_Call_0600", 'default'); + caller2.callWithResult('testCallWithResult', param).then((data) => { + console.log('ACTS_CommonComponent_Call_0600 call success'); + var result = new MySequenceable(0, '', ''); + data.readSequenceable(result); + expect(result.num).assertEqual(600); + expect(result.str).assertEqual('ACTS_CommonComponent_Call_0600'); + expect(result.result).assertEqual('ACTS_CommonComponent_Call_0600processed'); + caller2.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_0600 call exception' + err); + expect().assertFail(); + caller2.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_0700 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_0700', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_0700 begin'); + var subscriber; + var caller; + caseDepBundles = [systemAppCalleeABundleName]; + + function unSubscribeCallBack() { + console.log('ACTS_CommonComponent_Call_0700 unSubscribeCallBack') + done(); + } + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_0700 releaseCallBack' + data); + commonEvent.unsubscribe(subscriber, unSubscribeCallBack); + } + + function releaseCallback1(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_0700 releaseCallBack1' + data); + setTimeout(() => { + globalThis.abilityContext.startAbilityByCall({ + bundleName: systemAppCalleeABundleName, + abilityName: systemAppCalleeASecondAbilityName, + }).then(data => { + caller = data; + console.log('ACTS_CommonComponent_Call_0700 caller get') + caller.onRelease(releaseCallback); + let param = new MySequenceable(700, "ACTS_CommonComponent_Call_0700", 'default'); + caller.call('testCall', param).then(() => { + console.log('ACTS_CommonComponent_Call_0700 call success'); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_0700 call exception' + err); + expect().assertFail(); + }) + }) + }, 100); + } + + function subscribeCallBack(err, data) { + console.log('ACTS_CommonComponent_Call_0700 subscribeCallBack data:' + JSON.stringify(data)) + expect(data.data).assertEqual('calleeCheckCallParam'); + expect(data.parameters.num).assertEqual(700); + expect(data.parameters.str).assertEqual('ACTS_CommonComponent_Call_0700'); + expect(data.parameters.result).assertEqual('ACTS_CommonComponent_Call_0700processed'); + console.log('ACTS_CommonComponent_Call_0700 do release'); + caller.release(); + } + + subscriber = await commonEvent.createSubscriber(subscriberInfo); + commonEvent.subscribe(subscriber, subscribeCallBack); + + globalThis.abilityContext.startAbilityByCall({ + bundleName: systemAppCalleeABundleName, + abilityName: systemAppCalleeASecondAbilityName, + }).then(data => { + caller = data; + console.log('ACTS_CommonComponent_Call_0700 caller get') + caller.onRelease(releaseCallback1); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_0800 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_0800', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_0800 begin'); + var caller; + caseDepBundles = [systemAppCalleeABundleName]; + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_0800 releaseCallBack' + data); + done(); + } + + function releaseCallback1(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_0800 releaseCallBack' + data); + setTimeout(() => { + globalThis.abilityContext.startAbilityByCall({ + bundleName: systemAppCalleeABundleName, + abilityName: systemAppCalleeASecondAbilityName, + }).then(data => { + caller = data; + caller.onRelease(releaseCallback); + let param = new MySequenceable(800, "ACTS_CommonComponent_Call_0800", 'default'); + caller.callWithResult('testCallWithResult', param).then((data) => { + console.log('ACTS_CommonComponent_Call_0800 call success'); + var result = new MySequenceable(0, '', ''); + data.readSequenceable(result); + expect(result.num).assertEqual(800); + expect(result.str).assertEqual('ACTS_CommonComponent_Call_0800'); + expect(result.result).assertEqual('ACTS_CommonComponent_Call_0800processed'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_0800 call exception' + err); + expect().assertFail(); + caller.release(); + }) + }); + }, 100); + } + + globalThis.abilityContext.startAbilityByCall({ + bundleName: systemAppCalleeABundleName, + abilityName: systemAppCalleeASecondAbilityName, + }).then(data => { + caller = data; + console.log('ACTS_CommonComponent_Call_0800 caller get') + caller.onRelease(releaseCallback1); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_0900 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_0900', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_0900 begin'); + var subscriber; + caseDepBundles = [thirdAppABundleName]; + var caller; + + function unSubscribeCallBack() { + console.log('ACTS_CommonComponent_Call_0900 unSubscribeCallBack') + done(); + } + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_0900 releaseCallBack' + data); + commonEvent.unsubscribe(subscriber, unSubscribeCallBack); + } + + function subscribeCallBack(err, data) { + console.log('ACTS_CommonComponent_Call_0900 subscribeCallBack data:' + JSON.stringify(data)) + expect(data.data).assertEqual('calleeCheckCallParam'); + expect(data.parameters.num).assertEqual(900); + expect(data.parameters.str).assertEqual('ACTS_CommonComponent_Call_0900'); + expect(data.parameters.result).assertEqual('ACTS_CommonComponent_Call_0900processed'); + console.log('AMS_CallTest_0100 do release'); + caller.release(); + } + + subscriber = await commonEvent.createSubscriber(subscriberInfo); + commonEvent.subscribe(subscriber, subscribeCallBack); + caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: thirdAppABundleName, + abilityName: thirdAppAMainAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(900, "ACTS_CommonComponent_Call_0900", 'default'); + caller.call('testCall', param).then(() => { + console.log('ACTS_CommonComponent_Call_0900 call success'); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_0900 call exception' + err); + expect().assertFail(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_1000 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_1000', 0, async function (done) { + caseDepBundles = [thirdAppABundleName]; + console.log('ACTS_CommonComponent_Call_1000 begin'); + var caller; + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_1000 releaseCallBack' + data); + done(); + } + + caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: thirdAppABundleName, + abilityName: thirdAppAMainAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(1000, "ACTS_CommonComponent_Call_1000", 'default'); + caller.callWithResult('testCallWithResult', param).then((data) => { + console.log('ACTS_CommonComponent_Call_1000 call success'); + var result = new MySequenceable(0, '', ''); + data.readSequenceable(result); + expect(result.num).assertEqual(1000); + expect(result.str).assertEqual('ACTS_CommonComponent_Call_1000'); + expect(result.result).assertEqual('ACTS_CommonComponent_Call_1000processed'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_1000 call exception' + err); + expect().assertFail(); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_1700 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_1700', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_1700 begin'); + var caller; + var exceptionFlag = false; + + try { + caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: systemAppCalleeABundleName, + abilityName: systemAppCalleeAThirdAbilityName, + }); + } catch(err) { + console.log('ACTS_CommonComponent_Call_1700 exception' + err); + exceptionFlag = true; + expect(err.message).assertEqual("function request remote error"); + } + expect(exceptionFlag).assertEqual(true); + done(); + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_1900 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_1900', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_1900 begin'); + var subscriber; + var callBackCnt = 0; + + function checkFinish() { + if (callBackCnt >= 3) { + console.log('ACTS_CommonComponent_Call_1900 finish release') + caller.release(); + } + } + + function unSubscribeCallBack() { + console.log('ACTS_CommonComponent_Call_1900 unSubscribeCallBack') + done(); + } + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_1900 releaseCallBack' + data); + commonEvent.unsubscribe(subscriber, unSubscribeCallBack); + } + + function subscribeCallBack(err, data) { + console.log('ACTS_CommonComponent_Call_1900 subscribeCallBack data:' + JSON.stringify(data)) + if (data.data == 'calleeCheckCallParam') { + expect(data.parameters.num).assertEqual(1900); + expect(data.parameters.str).assertEqual('ACTS_CommonComponent_Call_1900'); + expect(data.parameters.result).assertEqual('ACTS_CommonComponent_Call_1900processed'); + callBackCnt++; + checkFinish(); + } else if (data.data == 'calleeCheckCall2Param') { + expect(data.parameters.num).assertEqual(1900); + expect(data.parameters.str).assertEqual('ACTS_CommonComponent_Call_1900'); + expect(data.parameters.result).assertEqual('ACTS_CommonComponent_Call_1900processed2'); + callBackCnt++; + checkFinish(); + } + } + + subscriber = await commonEvent.createSubscriber(subscriberInfo); + commonEvent.subscribe(subscriber, subscribeCallBack); + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(1900, "ACTS_CommonComponent_Call_1900", 'default'); + caller.call('testCall', param).then(() => { + console.log('ACTS_CommonComponent_Call_1900 call success'); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_1900 call exception' + err); + expect().assertFail(); + }) + caller.call('testCall2', param).then(() => { + console.log('ACTS_CommonComponent_Call_1900 call2 success'); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_1900 call2 exception' + err); + expect().assertFail(); + }) + + caller.callWithResult('testCallWithResult', param).then((data) => { + console.log('ACTS_CommonComponent_Call_1900 call success'); + var result = new MySequenceable(0, '', ''); + data.readSequenceable(result); + expect(result.num).assertEqual(1900); + expect(result.str).assertEqual('ACTS_CommonComponent_Call_1900'); + expect(result.result).assertEqual('ACTS_CommonComponent_Call_1900processed'); + callBackCnt++; + checkFinish(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_1900 call exception' + err); + expect().assertFail(); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_2000 + * @tc.name: The callee exits abnormally after the caller requests the call to be called successfully. + * @tc.desc: Verify that the caller can register the server's death listener. + */ + it('ACTS_CommonComponent_Call_2000', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_2000 begin'); + + function releaseCallback(data) { + console.log('ACTS_CommonComponent_Call_2000 releaseCallBack:' + data); + expect(data).assertEqual("died"); + done(); + } + + let bundleNameCallee = "com.example.systemappcalleea"; + let abilityNameCallee = "com.example.systemappcalleea.MainAbility"; + let want = { + bundleName: bundleNameCallee, + abilityName: abilityNameCallee, + } + let caller = await globalThis.abilityContext.startAbilityByCall(want); + if (typeof caller !== "object" || caller == null) { + console.log('ACTS_CommonComponent_Call_2000 startAbilityByCall fail'); + expect().assertFail(); + } + try { + caller.onRelease(releaseCallback); + } catch (e) { + console.log('ACTS_CommonComponent_Call_2000 Caller onRelease fail ' + e); + expect().assertFail(); + } + await appManager.killProcessesByBundleName(bundleNameCallee); + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_2300 + * @tc.name: Callee is in standalone process AbilityStage of the same app. + * @tc.desc: Verify Callee is in standalone process AbilityStage of the same app. + */ + it('ACTS_CommonComponent_Call_2300', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_2300 begin'); + + let bundleNameCallee = "com.example.systemcalltest"; + let abilityNameCallee = "com.example.second.MainAbility"; + + function releaseCallback(data) { + console.log('ACTS_CommonComponent_Call_2300 releaseCallBack:' + data); + expect(data).assertEqual("release"); + done(); + } + + let want = { + bundleName: bundleNameCallee, + abilityName: abilityNameCallee, + } + let caller = await globalThis.abilityContext.startAbilityByCall(want); + if (typeof caller !== "object" || caller == null) { + console.log('ACTS_CommonComponent_Call_2300 startAbilityByCall fail'); + expect().assertFail(); + done(); + } + + try { + caller.onRelease(releaseCallback); + } catch (e) { + console.log('ACTS_CommonComponent_Call_2300 Caller onRelease fail ' + e); + expect().assertFail(); + done(); + } + let param = new MySequenceable(2300, "case2300", 'default'); + caller.callWithResult('test2300', param).then((data) => { + console.log('ACTS_CommonComponent_Call_2300 callWithResult ' + JSON.stringify(data)); + let result = new MySequenceable(0, '', ''); + data.readSequenceable(result); + expect(result.str).assertEqual("onCreateonBackground"); + expect(result.num).assertEqual(0); + }); + + try { + caller.release(); + } catch (e) { + console.log('ACTS_CommonComponent_Call_2300 Caller Release fail:' + e); + expect().assertFail(); + done(); + } + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_2400 + * @tc.name: The service party cannot provide the corresponding service after calling Callee.off. + * @tc.desc: The verification service party cannot provide the corresponding service after calling Callee.off. + */ + it('ACTS_CommonComponent_Call_2400', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_2400 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_2400 releaseCallBack ' + data); + done(); + } + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(2400, "case2400", 'default'); + let beforeOff = 0; + let afterOff = 0; + await caller.call('testOff', param).then(() => { + console.log('ACTS_CommonComponent_Call_2400 call success'); + beforeOff = 1; + }).catch(err => { + beforeOff = 2; + }) + + globalThis.secondCallee.off('testOff'); + + await caller.call('testOff', param).then(() => { + console.log('ACTS_CommonComponent_Call_2400 call success'); + afterOff = 1; + }).catch(err => { + afterOff = 2; + }) + + expect(beforeOff).assertEqual(1); + expect(afterOff).assertEqual(2); + caller.release(); + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_2500 + * @tc.name: The parameter "method" of the Caller.call function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.call function is an empty string. + */ + it('ACTS_CommonComponent_Call_2500', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_2500 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_2500 releaseCallBack' + data); + done(); + } + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(2500, "case2500", 'default'); + caller.call('', param).then(() => { + console.log('ACTS_CommonComponent_Call_2500 call success'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_2500 call exception' + err); + expect(err.message).assertEqual("function input parameter error"); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_2600 + * @tc.name: The parameter "method" of the Caller.call function is null. + * @tc.desc: Verify that the parameter "method" of the Caller.call function is null. + */ + it('ACTS_CommonComponent_Call_2600', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_2600 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_2600 releaseCallBack' + data); + done(); + } + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(2600, "case2600", 'default'); + caller.call(null, param).then(() => { + console.log('ACTS_CommonComponent_Call_2600 call success'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_2600 call exception' + err); + expect(err.message).assertEqual("function input parameter error"); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_2700 + * @tc.name: The parameter "method" of the Caller.call function is undefined. + * @tc.desc: Verify that the parameter "method" of the Caller.call function is undefined. + */ + it('ACTS_CommonComponent_Call_2700', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_2700 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_2700 releaseCallBack' + data); + done(); + } + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(2700, "case2700", 'default'); + caller.call(undefined, param).then(() => { + console.log('ACTS_CommonComponent_Call_2700 call success'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_2700 call exception' + err); + expect(err.message).assertEqual("function input parameter error"); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_2800 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_2800', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_2800 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_2800 releaseCallBack' + data); + done(); + } + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(2800, "case2800", 'default'); + caller.callWithResult('', param).then((data) => { + console.log('ACTS_CommonComponent_Call_2800 callWithResult success'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_2800 callWithResult exception' + err); + expect(err.message).assertEqual("function input parameter error"); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_2900 + * @tc.name: The parameter "method" of the Caller.callWithResult function is null. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is null. + */ + it('ACTS_CommonComponent_Call_2900', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_2900 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_2900 releaseCallBack' + data); + done(); + } + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(2900, "case2900", 'default'); + caller.callWithResult(null, param).then((data) => { + console.log('ACTS_CommonComponent_Call_2900 callWithResult success'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_2900 callWithResult exception' + err); + expect(err.message).assertEqual("function input parameter error"); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_3000 + * @tc.name: The parameter "method" of the Caller.callWithResult function is undefined. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is undefined. + */ + it('ACTS_CommonComponent_Call_3000', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_3000 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_3000 releaseCallBack' + data); + done(); + } + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(3000, "case3000", 'default'); + caller.callWithResult(undefined, param).then((data) => { + console.log('ACTS_CommonComponent_Call_3000 call success'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_3000 catch exception' + err); + expect(err.message).assertEqual("function input parameter error"); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_3100 + * @tc.name: The parameter method of the Callee.on function is an empty string. + * @tc.desc: Verify that the parameter method of the Callee.on function is an empty string. + */ + it('ACTS_CommonComponent_Call_3100', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_3100 begin'); + + function onTest(data) { + console.log('ACTS_CommonComponent_Call_3100 onTest'); + } + + let finishFlag = 0; + try { + globalThis.callee.on('', onTest); + } catch (err) { + console.log('ACTS_CommonComponent_Call_3100 callee.on err' + err); + expect(err.message).assertEqual("function input parameter error"); + finishFlag = 1; + } + + expect(finishFlag).assertEqual(1); + done(); + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_3200 + * @tc.name: The parameter method of the Callee.on function is null. + * @tc.desc: Verify that the parameter method of the Callee.on function is null. + */ + it('ACTS_CommonComponent_Call_3200', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_3200 begin'); + + function onTest(data) { + console.log('ACTS_CommonComponent_Call_3200 onTest'); + } + + let finishFlag = 0; + try { + globalThis.callee.on(null, onTest); + } catch (err) { + console.log('ACTS_CommonComponent_Call_3200 callee.on err' + err); + expect(err.message).assertEqual("function input parameter error"); + finishFlag = 1; + } + + expect(finishFlag).assertEqual(1); + done(); + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_3300 + * @tc.name: The parameter method of the Caller.callWithResult function is undefined. + * @tc.desc: Verify that the parameter method of the Caller.callWithResult function is undefined. + */ + it('ACTS_CommonComponent_Call_3300', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_3300 begin'); + + function onTest(data) { + console.log('ACTS_CommonComponent_Call_3300 onTest'); + } + + let finishFlag = 0; + try { + globalThis.callee.on(undefined, onTest); + } catch (err) { + console.log('ACTS_CommonComponent_Call_3300 callee.on err' + err); + expect(err.message).assertEqual("function input parameter error"); + finishFlag = 1; + } + + expect(finishFlag).assertEqual(1); + done(); + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_3400 + * @tc.name: The parameter "method" of the Callee.off function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Callee.off function is an empty string. + */ + it('ACTS_CommonComponent_Call_3400', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_3400 begin'); + + let finishFlag = 0; + try { + globalThis.callee.off(''); + } catch (err) { + console.log('ACTS_CommonComponent_Call_3400 callee.off err' + err); + expect(err.message).assertEqual("function input parameter error"); + finishFlag = 1; + } + + expect(finishFlag).assertEqual(1); + done(); + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_3500 + * @tc.name: The parameter "method" of the Callee.off function is null. + * @tc.desc: Verify that the parameter "method" of the Callee.off function is null. + */ + it('ACTS_CommonComponent_Call_3500', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_3500 begin'); + + let finishFlag = 0; + try { + globalThis.callee.off(null); + } catch (err) { + console.log('ACTS_CommonComponent_Call_3500 callee.off err' + err); + expect(err.message).assertEqual("function input parameter error"); + finishFlag = 1; + } + + expect(finishFlag).assertEqual(1); + done(); + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_3600 + * @tc.name: The parameter “method” of the Callee.off function is undefined. + * @tc.desc: Verify that the parameter “method” of the Callee.off function is undefined. + */ + it('ACTS_CommonComponent_Call_3600', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_3600 begin'); + + let finishFlag = 0; + try { + globalThis.callee.off(undefined); + } catch (err) { + console.log('ACTS_CommonComponent_Call_3600 callee.off err' + err); + expect(err.message).assertEqual("function input parameter error"); + finishFlag = 1; + } + + expect(finishFlag).assertEqual(1); + done(); + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_3700 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_3700', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_3700 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_3700 releaseCallBack' + data); + done(); + } + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }); + + console.log('ACTS_CommonComponent_Call_3700 before onRelease') + caller.onRelease(releaseCallback); + console.log('ACTS_CommonComponent_Call_3700 before call') + caller.call('testCall', "").then(() => { + console.log('ACTS_CommonComponent_Call_3700 call success'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_3700 catch exception' + err); + expect(err.message).assertEqual("function input parameter error"); + caller.release(); + }) + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_3800 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_3800', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_3800 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_3800 releaseCallBack' + data); + done(); + } + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }); + + console.log('ACTS_CommonComponent_Call_3800 before onRelease') + caller.onRelease(releaseCallback); + console.log('ACTS_CommonComponent_Call_3800 before call') + caller.call('testCall', null).then(() => { + console.log('ACTS_CommonComponent_Call_3800 call success'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_3800 catch exception' + err); + expect(err.message).assertEqual("function input parameter error"); + caller.release(); + }) + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_3900 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_3900', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_3900 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_3900 releaseCallBack' + data); + done(); + } + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }); + + console.log('ACTS_CommonComponent_Call_3900 before onRelease') + caller.onRelease(releaseCallback); + console.log('ACTS_CommonComponent_Call_3900 before call') + caller.call('testCall', undefined).then(() => { + console.log('ACTS_CommonComponent_Call_3900 call success'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_3900 catch exception' + err); + expect(err.message).assertEqual("function input parameter error"); + caller.release(); + }) + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_4000 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_4000', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_4000 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_4000 release CallBack' + data); + done(); + } + + globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }).then((data) => { + let caller = data; + console.log('ACTS_CommonComponent_Call_4000 before onRelease') + caller.onRelease(releaseCallback); + console.log('ACTS_CommonComponent_Call_4000 before call') + caller.callWithResult('testCallWithResult', "").then((data) => { + console.log('ACTS_CommonComponent_Call_4000 call success'); + expect(data).assertEqual(undefined); + caller.release(); + }).catch((e) => { + console.log('ACTS_CommonComponent_Call_4000 call err' + e); + caller.release(); + }); + }) + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_4100 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_4100', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_4100 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_4100 release CallBack' + data); + done(); + } + + globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }).then((data) => { + let caller = data; + console.log('ACTS_CommonComponent_Call_4100 before onRelease') + caller.onRelease(releaseCallback); + console.log('ACTS_CommonComponent_Call_4100 before call') + caller.callWithResult('testCallWithResult', null).then((data) => { + console.log('ACTS_CommonComponent_Call_4100 call success'); + expect(data).assertEqual(undefined); + caller.release(); + }).catch((e) => { + console.log('ACTS_CommonComponent_Call_4100 call err' + e); + caller.release(); + }); + }) + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_4200 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_4200', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_4200 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_4200 release CallBack' + data); + done(); + } + + globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }).then((data) => { + let caller = data; + console.log('ACTS_CommonComponent_Call_4200 before onRelease') + caller.onRelease(releaseCallback); + console.log('ACTS_CommonComponent_Call_4200 before call') + caller.callWithResult('testCallWithResult', undefined).then((data) => { + console.log('ACTS_CommonComponent_Call_4200 call success'); + expect(data).assertEqual(undefined); + caller.release(); + }).catch((e) => { + console.log('ACTS_CommonComponent_Call_4200 call err' + e); + caller.release(); + }); + }) + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_4300 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_4300', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_4300 begin'); + let finishFlag = 0; + try { + globalThis.callee.on('testCall', ""); + } catch (err) { + console.log('ACTS_CommonComponent_Call_4300 call err' + err); + expect(err.message).assertEqual("function input parameter error"); + finishFlag = 1; + } + + expect(finishFlag).assertEqual(1); + done(); + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_4400 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_4400', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_4400 begin'); + let finishFlag = 0; + try { + globalThis.callee.on('testCall', null); + } catch (err) { + console.log('ACTS_CommonComponent_Call_4400 call err' + err); + expect(err.message).assertEqual("function input parameter error"); + finishFlag = 1; + } + + expect(finishFlag).assertEqual(1); + done(); + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_4500 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_4500', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_4500 begin'); + let finishFlag = 0; + try { + globalThis.callee.on('testCall', undefined); + } catch (err) { + console.log('ACTS_CommonComponent_Call_4500 call err' + err); + expect(err.message).assertEqual("function input parameter error"); + finishFlag = 1; + } + + expect(finishFlag).assertEqual(1); + done(); + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_4800 + * @tc.name: Callee is in standalone process AbilityStage of the same app. + * @tc.desc: Verify Callee is in standalone process AbilityStage of the same app. + */ + it('ACTS_CommonComponent_Call_4800', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_4800 begin'); + + let bundleNameCallee = "com.example.systemcalltest"; + let abilityNameCallee = "com.example.second.MainAbility"; + + function releaseCallback(data) { + console.log('ACTS_CommonComponent_Call_4800 releaseCallBack:' + data); + expect(data).assertEqual("release"); + done(); + } + + let want = { + bundleName: bundleNameCallee, + abilityName: abilityNameCallee, + } + let caller = await globalThis.abilityContext.startAbilityByCall(want); + if (typeof caller !== "object" || caller == null) { + console.log('ACTS_CommonComponent_Call_4800 startAbilityByCall fail'); + expect().assertFail(); + done(); + } + + try { + caller.onRelease(releaseCallback); + } catch (e) { + console.log('ACTS_CommonComponent_Call_4800 Caller onRelease fail ' + e); + expect().assertFail(); + done(); + } + let param = new MySequenceable(4600, "case4600", 'default'); + caller.callWithResult('test4600', param).then((data) => { + let result = new MySequenceable(0, '', ''); + data.readSequenceable(result); + expect(result.str).assertEqual("onCreateonBackground"); + expect(result.num).assertEqual(0); + }); + + try { + caller.release(); + } catch (e) { + console.log('ACTS_CommonComponent_Call_4800 Caller Release fail:' + e); + expect().assertFail(); + done(); + } + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_4900 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_4900', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_4900 begin'); + let caller; + let sequenceable = new MySequenceable(1, 'ACTS_CommonComponent_Call_4900', 'default'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_4900 releaseCallBack ' + data); + caller.call('testCall', sequenceable).then(() => { + console.log('ACTS_CommonComponent_Call_4900 call2 success'); + expect().assertFail(); + done(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_4900 call2 err ' + err); + expect(err.message).assertEqual("function inner object error"); + done(); + }) + } + + globalThis.abilityContext.startAbilityByCall({ + bundleName: sysABundleName, + abilityName: sysASecondAbilityName, + }).then((data) => { + caller = data; + console.log('ACTS_CommonComponent_Call_4900 before onRelease') + caller.onRelease(releaseCallback); + console.log('ACTS_CommonComponent_Call_4900 before call') + delay(100); + caller.call('testCall', sequenceable).then(() => { + console.log('ACTS_CommonComponent_Call_4900 call1 success'); + caller.release(); + }).catch((e) => { + console.log('ACTS_CommonComponent_Call_4900 call err' + e); + expect().assertFail(); + done(); + }); + }) + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_5000 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_5000', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_5000 begin'); + let finishFlag = 0; + + function testCallback_5100() { + console.log('ACTS_CommonComponent_Call_5000 testCallback'); + } + + try { + globalThis.callee.on('ACTS_CommonComponent_Call_5000', testCallback_5100); + } catch (err) { + console.log('ACTS_CommonComponent_Call_5000 call err' + err); + expect().assertFail(); + globalThis.callee.off('ACTS_CommonComponent_Call_5000'); + done(); + } + try { + globalThis.callee.on('ACTS_CommonComponent_Call_5000', testCallback_5100); + } catch (err) { + console.log('ACTS_CommonComponent_Call_5000 call err' + err); + expect(err.message).assertEqual("function is registered"); + finishFlag = 1; + } + + expect(finishFlag).assertEqual(1); + globalThis.callee.off('ACTS_CommonComponent_Call_5000'); + console.log('ACTS_CommonComponent_Call_5000 finished'); + done(); + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_5100 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_5100', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_5100 begin'); + let finishFlag = 0; + + function testCallback_5100() { + console.log('ACTS_CommonComponent_Call_5100 testCallback'); + } + + try { + globalThis.callee.on('ACTS_CommonComponent_Call_5100', testCallback_5100); + globalThis.callee.off('ACTS_CommonComponent_Call_5100'); + } catch (err) { + console.log('ACTS_CommonComponent_Call_5100 first step err' + err); + expect().assertFail(); + globalThis.callee.off('ACTS_CommonComponent_Call_5100'); + done(); + } + try { + globalThis.callee.off('ACTS_CommonComponent_Call_5100'); + } catch (err) { + console.log('ACTS_CommonComponent_Call_5100 call err' + err); + expect(err.message).assertEqual("function not registered"); + finishFlag = 1; + } + + expect(finishFlag).assertEqual(1); + console.log('ACTS_CommonComponent_Call_5100 finished'); + done(); + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_5200 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_5200', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_5200 begin'); + let caller; + let exceptionFlag = false; + + try { + caller = await globalThis.abilityContext.startAbilityByCall(null); + console.log('ACTS_CommonComponent_Call_5200 startAbilityByCall' + JSON.stringify(caller)) + } catch(err) { + console.log('ACTS_CommonComponent_Call_5200 exception' + err); + exceptionFlag = true; + expect(err.message).assertEqual("function input parameter error"); + } + + expect(exceptionFlag).assertEqual(true); + done(); + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_5300 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_5300', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_5300 begin'); + let caller; + let exceptionFlag = false; + + try { + caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: "", + abilityName: "", + }); + console.log('ACTS_CommonComponent_Call_5300 startAbilityByCall' + JSON.stringify(caller)) + } catch(err) { + console.log('ACTS_CommonComponent_Call_5300 exception' + err); + exceptionFlag = true; + expect(err.message).assertEqual("function request remote error"); + } + + expect(exceptionFlag).assertEqual(true); + done(); + }) + + /* + * @tc.number: ACTS_CommonComponent_Call_5400 + * @tc.name: Connects a service ability, which is used to start a cloned page ability. + * @tc.desc: Check the event data of executor page ability publishes + */ + it('ACTS_CommonComponent_Call_5400', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_5400 begin'); + let caller; + let exceptionFlag = false; + + try { + caller = await globalThis.abilityContext.startAbilityByCall(undefined); + console.log('ACTS_CommonComponent_Call_5400 startAbilityByCall' + JSON.stringify(caller)) + } catch(err) { + console.log('ACTS_CommonComponent_Call_5400 exception' + err); + exceptionFlag = true; + expect(err.message).assertEqual("function input parameter error"); + } + + expect(exceptionFlag).assertEqual(true); + done(); + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_5700 + * @tc.name: The mission of callee is not in recent list when startAbilityByCall only. + * @tc.desc: Verify the mission of callee is not in recent list when startAbilityByCall only. + */ + it('ACTS_CommonComponent_Call_5700', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_5700 begin'); + + let bundleNameCallee = "com.example.systemcalltest"; + let abilityNameCallee = "com.example.systemcalltest.SecondAbility"; + let want = { + bundleName: bundleNameCallee, + abilityName: abilityNameCallee, + } + let caller = await globalThis.abilityContext.startAbilityByCall(want); + if (typeof caller !== "object" || caller == null) { + console.log('ACTS_CommonComponent_Call_5700 startAbilityByCall fail'); + expect().assertFail(); + done(); + } + + async function releaseCallback(data) { + console.log('ACTS_CommonComponent_Call_5700 releaseCallBack:' + data); + expect(data).assertEqual("release"); + + let missionId = await getMissionId(abilityNameCallee, 0); + expect(missionId == -1).assertTrue(); + done(); + } + + try { + caller.onRelease(releaseCallback); + } catch (e) { + console.log('ACTS_CommonComponent_Call_5700 Caller onRelease fail ' + e); + expect().assertFail(); + done(); + } + + try { + caller.release(); + } catch (e) { + console.log('ACTS_CommonComponent_Call_5700 Caller Release fail:' + e); + expect().assertFail(); + done(); + } + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_5800 + * @tc.name: The mission of callee is in recent list when startAbilityByCall then startAbility. + * @tc.desc: Verify the mission of callee is in recent list when startAbilityByCall then startAbility. + */ + it('ACTS_CommonComponent_Call_5800', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_5800 begin'); + + let bundleNameCallee = "com.example.systemcalltest"; + let abilityNameCallee = "com.example.systemcalltest.SecondAbility"; + let want = { + bundleName: bundleNameCallee, + abilityName: abilityNameCallee, + } + let caller = await globalThis.abilityContext.startAbilityByCall(want); + if (typeof caller !== "object" || caller == null) { + console.log('ACTS_CommonComponent_Call_5800 startAbilityByCall fail'); + expect().assertFail(); + done(); + } + + function startAbilityCallback(err) { + console.log('ACTS_CommonComponent_Call_5800 startAbilityCallback'); + if (err.code != 0) { + expect().assertFail(); + done(); + } + } + + await globalThis.abilityContext.startAbility(want, startAbilityCallback); + + async function releaseCallback(data) { + console.log('ACTS_CommonComponent_Call_5800 releaseCallBack:' + data); + expect(data).assertEqual("release"); + + let missionId = await getMissionId(abilityNameCallee, 0); + expect(missionId != -1).assertTrue(); + done(); + } + try { + caller.onRelease(releaseCallback); + } catch (e) { + console.log('ACTS_CommonComponent_Call_5800 Caller onRelease fail ' + e); + expect().assertFail(); + done(); + } + + try { + caller.release(); + } catch (e) { + console.log('ACTS_CommonComponent_Call_5800 Caller Release fail:' + e); + expect().assertFail(); + done(); + } + }) + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..882f978e77b1a8fbbf843ccb4dd73c47ed460305 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/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 './Ability.test.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/module.json b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..c351dcc66e2d84cad05ac16d426b11cda07e4b22 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/module.json @@ -0,0 +1,86 @@ +{ + "module": { + "name": "com.example.systemcalltest", + "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.systemcalltest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.systemcalltest.SecondAbility", + "srcEntrance": "./ets/SecondAbility/SecondAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "singleton", + "orientation": "portrait" + } + ], + "requestPermissions": [ + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "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.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + }, + { + "name":"ohos.permission.MANAGE_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.MANAGE_LOCAL_ACCOUNTS" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + } + ] + } +} diff --git a/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/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/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/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/aafwk/aafwk_standard/actscalltest/systemcallentrytest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemcallentrytest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actscalltest/systemcallfeature/AppScope/app.json b/aafwk/aafwk_standard/actscalltest/systemcallfeature/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..9553812f3c2e1911fb8167dc4facbed4a05b9c03 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallfeature/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.systemcalltest", + "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/aafwk/aafwk_standard/actscalltest/systemcallfeature/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/systemcallfeature/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallfeature/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/aafwk/aafwk_standard/actscalltest/systemcallfeature/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actscalltest/systemcallfeature/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemcallfeature/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/systemcallfeature/BUILD.gn b/aafwk/aafwk_standard/actscalltest/systemcallfeature/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..90456de5bbd314ba0f275f91fa0e9b84705cf379 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallfeature/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("ActsCallTestFeatureRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":systemcallfeature_js_assets", + ":systemcallfeature_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsCallTestFeatureRelyHap" +} + +ohos_app_scope("systemcallfeature_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("systemcallfeature_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("systemcallfeature_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":systemcallfeature_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actscalltest/systemcallfeature/Test.json b/aafwk/aafwk_standard/actscalltest/systemcallfeature/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallfeature/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..ebc3c76435b7ce717d56b1cbf9b4463782559c12 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/ets/Application/AbilityStage.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. + */ +import AbilityStage from "@ohos.application.AbilityStage" + +var onAcceptWantCalledSeq; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("SystemCallTest Second Hap MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..f9945fc7250a29654b778002e54611cea8f762ec --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,116 @@ +/* + * 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' + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} +let callSeq = ""; + +export default class MainAbility extends Ability { + test2300(data) { + let recvData = new MySequenceable(0, '', ''); + data.readSequenceable(recvData); + let sendData = new MySequenceable(0, '', ''); + if (recvData.num == 2300 && recvData.str == 'case2300') { + sendData.num = 0; + } else { + sendData.num = 1; + } + sendData.str = callSeq; + return sendData; + } + + test4600(data) { + let recvData = new MySequenceable(0, '', ''); + data.readSequenceable(recvData); + let sendData = new MySequenceable(0, '', ''); + if (recvData.num == 4600 && recvData.str == 'case4600') { + sendData.num = 0; + } else { + sendData.num = 1; + } + sendData.str = callSeq; + return sendData; + } + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemCallTest Second Hap MainAbility onCreate") + globalThis.abilityWant = want; + this.callee.on('test2300', this.test2300); + this.callee.on('test4600', this.test4600); + callSeq = callSeq + "onCreate"; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemCallTest Second Hap MainAbility onDestroy") + callSeq = callSeq + "onDestroy"; + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemCallTest Second Hap MainAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/index", null) + callSeq = callSeq + "onWindowStageCreate"; + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemCallTest Second Hap MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemCallTest Second Hap MainAbility onForeground") + callSeq = callSeq + "onForeground"; + } + + onBackground() { + // Ability has back to background + console.log("SystemCallTest Second Hap MainAbility onBackground") + callSeq = callSeq + "onBackground"; + } +}; + diff --git a/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..6c1e0c8a8105c66af288fbeed942a7d7a67d67c1 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('second module') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..72e66614c1a8c9068b0b0594d6da4ae52c0912b7 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/ets/pages/second/second.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('SystemCallTest SecondAbility)') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/module.json b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..857565bb1d04e52b26be210b38136e0644f08eaf --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/module.json @@ -0,0 +1,73 @@ +{ + "module": { + "name": "com.example.second", + "process": "com.example.secondprocess", + "type": "feature", + "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.second.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name":"ohos.permission.INSTALL_BUNDLE", + "reason":"need use ohos.permission.INSTALL_BUNDLE" + }, + { + "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.MANAGE_MISSIONS", + "reason":"need use ohos.permission.MANAGE_MISSIONS" + }, + { + "name":"ohos.permission.MANAGE_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.MANAGE_LOCAL_ACCOUNTS" + } + ] + } +} diff --git a/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallfeature/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/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actscalltest/systemcallfeature/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/systemcallfeature/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/aafwk/aafwk_standard/actscalltest/systemcallfeature/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actscalltest/systemcallfeature/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/systemcallfeature/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actscalltest/thirdappa/AppScope/app.json b/aafwk/aafwk_standard/actscalltest/thirdappa/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..57198db7f722344bce0b5ff68aa6be4ede5800a2 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdappa/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.thirdappa", + "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/aafwk/aafwk_standard/actscalltest/thirdappa/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/thirdappa/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdappa/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/aafwk/aafwk_standard/actscalltest/thirdappa/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actscalltest/thirdappa/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/thirdappa/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/thirdappa/BUILD.gn b/aafwk/aafwk_standard/actscalltest/thirdappa/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..decf1971558b20cc2f6b99ca7ab79ac11ed42251 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdappa/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("ActsThirdAppARelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":thirdappa_js_assets", + ":thirdappa_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsThirdAppARelyHap" +} + +ohos_app_scope("thirdappa_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("thirdappa_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("thirdappa_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":thirdappa_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actscalltest/thirdappa/Test.json b/aafwk/aafwk_standard/actscalltest/thirdappa/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdappa/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..21606483f3457f3a691d5d0a28e111ffc5d9d4bf --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdappa/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" + +var onAcceptWantCalledSeq; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("SystemCallTest MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..779b4cb42d5ab6422ed9d850bb79b45b7229e48e --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,116 @@ +/* + * 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' + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + + +function testCall(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>ThirdAppA MainAbility on testCall <======') + data.readSequenceable(recvSequence); + var result = recvSequence.str + 'processed'; + var commonEventData = { + code: 0, + data: 'calleeCheckCallParam', + parameters: { + num: recvSequence.num, + str: recvSequence.str, + result: result + } + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>ThirdAppA MainAbility Call_Finish<======') + }) + return recvSequence; +} + +function testCallWithResult(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>ThirdAppA MainAbility on testCall <======') + data.readSequenceable(recvSequence); + let result = recvSequence.str + 'processed'; + recvSequence.setMySequence(recvSequence.num, recvSequence.str, result); + + return recvSequence; +} + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("ThirdAppA MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.abilityContext = this.context; + this.callee.on('testCall', testCall); + this.callee.on('testCallWithResult', testCallWithResult); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ThirdAppA MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ThirdAppA MainAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("ThirdAppA MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("ThirdAppA MainAbility onForeground"); + } + + onBackground() { + // Ability has back to background + console.log("ThirdAppA MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..30b8d934e2b7e2d5f07c2deb7495797e78e6b3d3 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,52 @@ +/* + * 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'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdappa/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/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/module.json b/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..c8fd2c246308f250ceb430c070fcf32eae40b475 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/module.json @@ -0,0 +1,38 @@ +{ + "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.thirdappa.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdappa/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/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actscalltest/thirdappa/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdappa/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/aafwk/aafwk_standard/actscalltest/thirdappa/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actscalltest/thirdappa/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/thirdappa/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/AppScope/app.json b/aafwk/aafwk_standard/actscalltest/thirdcalltest/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..3a18f6bfaf46b34f6674bbeb3dbeb13bf47fee4c --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.thirdcalltest", + "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/aafwk/aafwk_standard/actscalltest/thirdcalltest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/thirdcalltest/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/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/aafwk/aafwk_standard/actscalltest/thirdcalltest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actscalltest/thirdcalltest/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/thirdcalltest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/BUILD.gn b/aafwk/aafwk_standard/actscalltest/thirdcalltest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..cee804add703299b9daa9da89389b2815017a255 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/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("ActsThirdCallTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":thirdcalltest_js_assets", + ":thirdcalltest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsThirdCallTest" +} + +ohos_app_scope("thirdcalltest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("thirdcalltest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("thirdcalltest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":thirdcalltest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/Test.json b/aafwk/aafwk_standard/actscalltest/thirdcalltest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..be829fa64d2f0de17aed753a31a013505eb5a561 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/Test.json @@ -0,0 +1,26 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "1000000", + "package": "com.example.thirdcalltest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsThirdCallTest.hap", + "ActsSystemAppCalleeARelyHap.hap", + "ActsThirdAppARelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..21606483f3457f3a691d5d0a28e111ffc5d9d4bf --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/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" + +var onAcceptWantCalledSeq; + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("SystemCallTest MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/FifthAbility/FifthAbility.ts b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/FifthAbility/FifthAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..adb8a3bff12555e6aabb4f825e71e813368289f2 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/FifthAbility/FifthAbility.ts @@ -0,0 +1,124 @@ +/* + * 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' + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function testCall(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemCallTest FifthAbility on testCall <======') + data.readSequenceable(recvSequence); + var result = recvSequence.str + 'processed'; + var commonEventData = { + code: 0, + data: 'calleeCheckCallParam', + parameters: { + num: recvSequence.num, + str: recvSequence.str, + result: result + } + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>CallTestSysA FifthAbility Call_Finish<======') + }) + return recvSequence; +} + +function testCallWithResult(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemCallTest FifthAbility on testCall <======') + data.readSequenceable(recvSequence); + let result = recvSequence.str + 'processed'; + recvSequence.setMySequence(recvSequence.num, recvSequence.str, result); + + return recvSequence; +} + +export default class FifthAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemCallTest FifthAbility onCreate") + globalThis.abilityWant = want; + this.callee.on('testCall', testCall); + this.callee.on('testCallWithResult', testCallWithResult); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemCallTest FifthAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemCallTest FifthAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/second/second", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemCallTest FifthAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemCallTest FifthAbility onForeground") + if ((globalThis.abilityWant.parameters.case_num == "case1300") || + (globalThis.abilityWant.parameters.case_num == "case1400")) { + var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground"; + var commonEventData = { + data: publishData, + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>SystemAppCallerA FifthAbility Call_Finish<======') + }) + } + } + + onBackground() { + // Ability has back to background + console.log("SystemCallTest FifthAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/ForthAbility/ForthAbility.ts b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/ForthAbility/ForthAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..32c160e4dbe49de7ca327c30de72a9565272a114 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/ForthAbility/ForthAbility.ts @@ -0,0 +1,124 @@ +/* + * 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' + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function testCall(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemCallTest ForthAbility on testCall <======') + data.readSequenceable(recvSequence); + var result = recvSequence.str + 'processed'; + var commonEventData = { + code: 0, + data: 'calleeCheckCallParam', + parameters: { + num: recvSequence.num, + str: recvSequence.str, + result: result + } + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>CallTestSysA ForthAbility Call_Finish<======') + }) + return recvSequence; +} + +function testCallWithResult(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemCallTest ForthAbility on testCall <======') + data.readSequenceable(recvSequence); + let result = recvSequence.str + 'processed'; + recvSequence.setMySequence(recvSequence.num, recvSequence.str, result); + + return recvSequence; +} + +export default class ForthAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemCallTest ForthAbility onCreate") + globalThis.abilityWant = want; + this.callee.on('testCall', testCall); + this.callee.on('testCallWithResult', testCallWithResult); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemCallTest ForthAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemCallTest ForthAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/second/second", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemCallTest ForthAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemCallTest ForthAbility onForeground") + if ((globalThis.abilityWant.parameters.case_num == "case1300") || + (globalThis.abilityWant.parameters.case_num == "case1400")) { + var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground"; + var commonEventData = { + data: publishData, + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>SystemAppCallerA ForthAbility Call_Finish<======') + }) + } + } + + onBackground() { + // Ability has back to background + console.log("SystemCallTest ForthAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..faa1c8399d1dcd2b5a6b9d9b038953a2109641cc --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/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("ThirdCallTest MainAbility onCreate") + globalThis.abilityWant = want; + globalThis.callee = this.callee; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ThirdCallTest MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ThirdCallTest 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("ThirdCallTest MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("ThirdCallTest MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("ThirdCallTest MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/SecondAbility/SecondAbility.ts b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/SecondAbility/SecondAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..3dad2dad35b033cafbf15df5b2e5c7d5fdabacd0 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/SecondAbility/SecondAbility.ts @@ -0,0 +1,124 @@ +/* + * 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' + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function testCall(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemCallTest SecondAbility on testCall <======') + data.readSequenceable(recvSequence); + var result = recvSequence.str + 'processed'; + var commonEventData = { + code: 0, + data: 'calleeCheckCallParam', + parameters: { + num: recvSequence.num, + str: recvSequence.str, + result: result + } + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>CallTestSysA SecondAbility Call_Finish<======') + }) + return recvSequence; +} + +function testCallWithResult(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemCallTest SecondAbility on testCall <======') + data.readSequenceable(recvSequence); + let result = recvSequence.str + 'processed'; + recvSequence.setMySequence(recvSequence.num, recvSequence.str, result); + + return recvSequence; +} + +export default class SecondAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemCallTest SecondAbility onCreate") + globalThis.abilityWant = want; + this.callee.on('testCall', testCall); + this.callee.on('testCallWithResult', testCallWithResult); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemCallTest SecondAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemCallTest SecondAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/second/second", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemCallTest SecondAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemCallTest SecondAbility onForeground") + if ((globalThis.abilityWant.parameters.case_num == "case1300") || + (globalThis.abilityWant.parameters.case_num == "case1400")) { + var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground"; + var commonEventData = { + data: publishData, + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>SystemAppCallerA SecondAbility Call_Finish<======') + }) + } + } + + onBackground() { + // Ability has back to background + console.log("SystemCallTest SecondAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/ThirdAbility/ThirdAbility.ts b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/ThirdAbility/ThirdAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..f0581065ac4438c3bffc2e1a925ae10b0be10ff7 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/ThirdAbility/ThirdAbility.ts @@ -0,0 +1,124 @@ +/* + * 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' + +class MySequenceable { + num: number = 0; + str: String = ""; + result: String = ""; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function testCall(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemCallTest ThirdAbility on testCall <======') + data.readSequenceable(recvSequence); + var result = recvSequence.str + 'processed'; + var commonEventData = { + code: 0, + data: 'calleeCheckCallParam', + parameters: { + num: recvSequence.num, + str: recvSequence.str, + result: result + } + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>CallTestSysA ThirdAbility Call_Finish<======') + }) + return; +} + +function testCallWithResult(data) { + let recvSequence = new MySequenceable(0, '', ''); + console.log('======>SystemCallTest ThirdAbility on testCall <======') + data.readSequenceable(recvSequence); + let result = recvSequence.str + 'processed'; + recvSequence.setMySequence(recvSequence.num, recvSequence.str, result); + + return recvSequence; +} + +export default class ThirdAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SystemCallTest ThirdAbility onCreate") + globalThis.abilityWant = want; + this.callee.on('testCall', testCall); + this.callee.on('testCallWithResult', testCallWithResult); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SystemCallTest ThirdAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SystemCallTest ThirdAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/second/second", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SystemCallTest ThirdAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SystemCallTest ThirdAbility onForeground") + if ((globalThis.abilityWant.parameters.case_num == "case1300") || + (globalThis.abilityWant.parameters.case_num == "case1400")) { + var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground"; + var commonEventData = { + data: publishData, + } + commonEvent.publish('CallTest', commonEventData, (err) => { + console.log('======>SystemAppCallerA ThirdAbility Call_Finish<======') + }) + } + } + + onBackground() { + // Ability has back to background + console.log("SystemCallTest ThirdAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..26746b5a84730dfe5b9220652170de21d515737f --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/pages/index/index.ets @@ -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 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 10000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/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/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..ae7b675b4c655d75cb833aa724649b9e1522910e --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,399 @@ +/* + * 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 missionManager from '@ohos.application.missionManager' + +const MAX_MISSION_NUM = 1024; + +var systemAppCalleeABundleName = "com.example.systemappcalleea"; +var systemAppCalleeAMainAbilityName = "com.example.systemappcalleea.MainAbility"; +var thirdAppABundleName = "com.example.thirdappa"; +var thirdAppAMainAbilityName = "com.example.thirdappa.MainAbility"; +var thirdCallTestBundleName = "com.example.thirdcalltest"; +var thirdCallTestMainAbilityName = "com.example.thirdcalltest.MainAbility"; +var thirdCallTestSecondAbilityName = "com.example.thirdcalltest.SecondAbility"; +var thirdCallTestThirdAbilityName = "com.example.thirdcalltest.ThirdAbility"; +var thirdCallTestForthAbilityName = "com.example.thirdcalltest.ForthAbility"; +var thirdCallTestFifthAbilityName = "com.example.thirdcalltest.FifthAbility"; +var subscriberInfo = { + events: ["CallTest"], +}; + +class MySequenceable { + num: number = 0; + str: string = "default"; + result: string = "default"; + + constructor(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + setMySequence(num, string, result) { + this.num = num; + this.str = string; + this.result = result; + } + + marshalling(messageParcel) { + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + messageParcel.writeString(this.result); + return true; + } + + unmarshalling(messageParcel) { + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + this.result = messageParcel.readString(); + return true; + } +} + +function getMissionId(abilityName, state) { + return new Promise(async (resolve, reject) => { + let missionId = -1; + let missionInfos = await missionManager.getMissionInfos('', MAX_MISSION_NUM); + for (let i = 0; i < missionInfos.length; i++) { + if ((missionInfos[i].want.abilityName == abilityName) + && (missionInfos[i].runningState == state)) { + missionId = missionInfos[i].missionId; + break; + } + } + console.log('======>getMissionId resolve missionId<=======' + missionId); + resolve(missionId); + }) +} + +function delay(time) { + let delta; + if (typeof time != 'number' || time <= 0) { + delta = 100; + } else { + delta = Math.round(time); + } + for (let start = Date.now(); Date.now() - start <= delta; ); +} + +export default function abilityTest(abilityContext) { + describe('ActsAbilityTest', function () { + + beforeEach(async (done) => { + done(); + }) + + afterEach(async (done) => { + setTimeout(() => { + done(); + }, 500) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_1100 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_1100', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_1100 begin'); + var subscriber; + + function unSubscribeCallBack() { + console.log('ACTS_CommonComponent_Call_1100 unSubscribeCallBack') + setTimeout(()=>{done();}, 100) + } + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_1100 releaseCallBack' + data); + commonEvent.unsubscribe(subscriber, unSubscribeCallBack); + } + + function subscribeCallBack(err, data) { + console.log('ACTS_CommonComponent_Call_1100 subscribeCallBack data:' + JSON.stringify(data)) + expect(data.data).assertEqual('calleeCheckCallParam'); + expect(data.parameters.num).assertEqual(1100); + expect(data.parameters.str).assertEqual('ACTS_CommonComponent_Call_1100'); + expect(data.parameters.result).assertEqual('ACTS_CommonComponent_Call_1100processed'); + console.log('AMS_CallTest_0100 do release'); + caller.release(); + } + + subscriber = await commonEvent.createSubscriber(subscriberInfo); + commonEvent.subscribe(subscriber, subscribeCallBack); + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: thirdCallTestBundleName, + abilityName: thirdCallTestForthAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(1100, "ACTS_CommonComponent_Call_1100", 'default'); + caller.call('testCall', param).then(() => { + console.log('ACTS_CommonComponent_Call_1100 call success'); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_1100 call exception' + err); + expect().assertFail(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_1200 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_1200', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_1200 begin'); + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_1200 releaseCallBack' + data); + setTimeout(()=>{done();}, 100) + } + + let caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: thirdCallTestBundleName, + abilityName: thirdCallTestFifthAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(1200, "ACTS_CommonComponent_Call_1200", 'default'); + caller.callWithResult('testCallWithResult', param).then((data) => { + console.log('ACTS_CommonComponent_Call_1200 call success'); + var result = new MySequenceable(0, '', ''); + data.readSequenceable(result); + expect(result.num).assertEqual(1200); + expect(result.str).assertEqual('ACTS_CommonComponent_Call_1200'); + expect(result.result).assertEqual('ACTS_CommonComponent_Call_1200processed'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_1200 call exception' + err); + expect().assertFail(); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_1300 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_1300', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_1300 begin'); + var subscriber; + var caller + + function unSubscribeCallBack() { + console.log('ACTS_CommonComponent_Call_1300 unSubscribeCallBack') + setTimeout(()=>{done();}, 100) + } + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_1300 releaseCallBack' + data); + commonEvent.unsubscribe(subscriber, unSubscribeCallBack); + } + + function releaseCallback1(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_1300 releaseCallBack1' + data); + setTimeout(() => { + globalThis.abilityContext.startAbilityByCall({ + bundleName: thirdCallTestBundleName, + abilityName: thirdCallTestSecondAbilityName, + }).then(data => { + caller = data; + console.log('ACTS_CommonComponent_Call_1300 caller get') + caller.onRelease(releaseCallback); + let param = new MySequenceable(1300, "ACTS_CommonComponent_Call_1300", 'default'); + caller.call('testCall', param).then(() => { + console.log('ACTS_CommonComponent_Call_1300 call success'); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_1300 call exception' + err); + expect().assertFail(); + }) + }) + },100); + } + + function subscribeCallBack(err, data) { + console.log('ACTS_CommonComponent_Call_1300 subscribeCallBack data:' + JSON.stringify(data)) + expect(data.data).assertEqual('calleeCheckCallParam'); + expect(data.parameters.num).assertEqual(1300); + expect(data.parameters.str).assertEqual('ACTS_CommonComponent_Call_1300'); + expect(data.parameters.result).assertEqual('ACTS_CommonComponent_Call_1300processed'); + console.log('ACTS_CommonComponent_Call_1300 do release'); + caller.release(); + } + + subscriber = await commonEvent.createSubscriber(subscriberInfo); + commonEvent.subscribe(subscriber, subscribeCallBack); + + globalThis.abilityContext.startAbilityByCall({ + bundleName: thirdCallTestBundleName, + abilityName: thirdCallTestSecondAbilityName, + }).then(data => { + caller = data; + console.log('ACTS_CommonComponent_Call_1300 caller get') + caller.onRelease(releaseCallback1); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_1400 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_1400', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_1400 begin'); + var caller + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_1400 releaseCallBack' + data); + setTimeout(()=>{done();}, 100) + } + + function releaseCallback1(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_1400 releaseCallBack' + data); + setTimeout(() => { + globalThis.abilityContext.startAbilityByCall({ + bundleName: thirdCallTestBundleName, + abilityName: thirdCallTestSecondAbilityName, + }).then(data => { + caller = data; + caller.onRelease(releaseCallback); + let param = new MySequenceable(1400, "ACTS_CommonComponent_Call_1400", 'default'); + caller.callWithResult('testCallWithResult', param).then((data) => { + console.log('ACTS_CommonComponent_Call_1400 call success'); + var result = new MySequenceable(0, '', ''); + data.readSequenceable(result); + expect(result.num).assertEqual(1400); + expect(result.str).assertEqual('ACTS_CommonComponent_Call_1400'); + expect(result.result).assertEqual('ACTS_CommonComponent_Call_1400processed'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_1400 call exception' + err); + expect().assertFail(); + caller.release(); + }) + }); + },100); + } + + globalThis.abilityContext.startAbilityByCall({ + bundleName: thirdCallTestBundleName, + abilityName: thirdCallTestSecondAbilityName, + }).then(data => { + caller = data; + console.log('ACTS_CommonComponent_Call_1400 caller get') + caller.onRelease(releaseCallback1); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_1500 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_1500', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_1500 begin'); + var caller; + + function releaseCallback(data) { + expect(data).assertEqual('release'); + console.log('ACTS_CommonComponent_Call_1500 releaseCallBack' + data); + done(); + } + + caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: systemAppCalleeABundleName, + abilityName: systemAppCalleeAMainAbilityName, + }); + + caller.onRelease(releaseCallback); + let param = new MySequenceable(1500, "ACTS_CommonComponent_Call_1500", 'default'); + caller.callWithResult('testCallWithResult', param).then((data) => { + console.log('ACTS_CommonComponent_Call_1500 call success'); + var result = new MySequenceable(0, '', ''); + data.readSequenceable(result); + expect(result.num).assertEqual(1500); + expect(result.str).assertEqual('ACTS_CommonComponent_Call_1500'); + expect(result.result).assertEqual('ACTS_CommonComponent_Call_1500processed'); + caller.release(); + }).catch(err => { + console.log('ACTS_CommonComponent_Call_1500 call exception' + err); + expect().assertFail(); + caller.release(); + }) + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_1600 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_1600', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_1600 begin'); + let caller; + let exceptionFlag = false; + + try { + caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: thirdAppABundleName, + abilityName: thirdAppAMainAbilityName, + }); + console.log('ACTS_CommonComponent_Call_1600 startAbilityByCall' + JSON.stringify(caller)) + } catch(err) { + console.log('ACTS_CommonComponent_Call_1600 exception' + err); + exceptionFlag = true; + expect(err.message).assertEqual("function request remote error"); + } + + expect(exceptionFlag).assertEqual(true); + done(); + }) + + /** + * @tc.number: ACTS_CommonComponent_Call_1800 + * @tc.name: The parameter "method" of the Caller.callWithResult function is an empty string. + * @tc.desc: Verify that the parameter "method" of the Caller.callWithResult function is an empty string. + */ + it('ACTS_CommonComponent_Call_1800', 0, async function (done) { + console.log('ACTS_CommonComponent_Call_1800 begin'); + let caller; + let exceptionFlag = false; + + try { + caller = await globalThis.abilityContext.startAbilityByCall({ + bundleName: thirdCallTestBundleName, + abilityName: thirdCallTestThirdAbilityName, + }); + console.log('ACTS_CommonComponent_Call_1800 startAbilityByCall' + JSON.stringify(caller)) + } catch(err) { + console.log('ACTS_CommonComponent_Call_1800 exception' + err); + exceptionFlag = true; + expect(err.message).assertEqual("function request remote error"); + } + + expect(exceptionFlag).assertEqual(true); + done(); + }) + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..882f978e77b1a8fbbf843ccb4dd73c47ed460305 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/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 './Ability.test.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/module.json b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..d6fcdb48b904426b645cc82adacdb54668e8bc89 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/module.json @@ -0,0 +1,78 @@ +{ + "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.thirdcalltest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.thirdcalltest.SecondAbility", + "srcEntrance": "./ets/SecondAbility/SecondAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton" + }, + { + "name": "com.example.thirdcalltest.ThirdAbility", + "srcEntrance": "./ets/ThirdAbility/ThirdAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "standard" + }, + { + "name": "com.example.thirdcalltest.ForthAbility", + "srcEntrance": "./ets/ForthAbility/ForthAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton" + }, + { + "name": "com.example.thirdcalltest.FifthAbility", + "srcEntrance": "./ets/FifthAbility/FifthAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton" + } + ] + } +} diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/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/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actscalltest/thirdcalltest/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/actscalltest/thirdcalltest/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/aafwk/aafwk_standard/actscalltest/thirdcalltest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actscalltest/thirdcalltest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/aafwk/aafwk_standard/actscalltest/thirdcalltest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/BUILD.gn b/aafwk/aafwk_standard/actsstartcomponenttest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..bbb5260599f35b47a90d89bdbdc4e563e640e21d --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/BUILD.gn @@ -0,0 +1,27 @@ +# 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", + ] + } +} diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/app.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..8bb263cd5ffeda467f07d3524c528d85b4d9d307 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/BUILD.gn b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1490f2b07e7f659b330843ce118a9ad3385110c5 --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/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("ActsSpecifiedUserActionextensionZeroTest") { + hap_profile = "entry/src/main/module.json" + 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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/Test.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..54ddad9da9e9250d228cd6096b5a08a290feb86d --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..2af31f94003ccd1a69174aa942c8129dfa6f5d08 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..e2bb24f02d8d0e9b72bea2f2e7faa83c1872b01c --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility2/MainAbility2.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100644 index 0000000000000000000000000000000000000000..16193dc05377887155f14e2cb714438378a6c7f6 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..d689638e378d4661777f73507e56e61398eb057a --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,207 @@ +/* + * 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; + } +} +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) + 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) + + 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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..91a83dbc24c50064a2031ddf77606699a059fac9 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100644 index 0000000000000000000000000000000000000000..c82a4d6aad5ad0ef52ac3e2b4154585d896497d0 --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import commonEvent from "@ohos.commonevent" + +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) { + 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=====>") + }); + } + } + + onDisconnect(want) { + console.log('ServiceAbility2 onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility2 onDestroy'); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/service.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..91a83dbc24c50064a2031ddf77606699a059fac9 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c2511e8ff64181a4aa29ff445e2f506e53b159 --- /dev/null +++ b/aafwk/aafwk_standard/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.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') + 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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..94fe1a9e24e4b1b3b29c3175c233334ff0205cb3 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2ff5edb425dba3b891b8c9be8ecdd720380e6792 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/module.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..9c126792232352538eccbf0e50ad039ffee63058 --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/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.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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_100/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/app.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..ed83806652cf16428f867cec533b239e9b78b05c --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/BUILD.gn b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e15f6fb9d9a79c0726b9ac255abd17af5992cd72 --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/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("ActsSpecifiedUserActionextensiononeTest") { + hap_profile = "entry/src/main/module.json" + 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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/Test.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..69c870be2c8ae8de4cde76c5c86767d4dc201cf4 --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/Test.json @@ -0,0 +1,67 @@ +{ + "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" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/*.hap" + ] + } + ] +} diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..77b702155893ee17996bb4cd08a54c708c6776c5 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9110ed3e98f20b7fcf704bf671c9403c7ca101e --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility2/MainAbility2.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100644 index 0000000000000000000000000000000000000000..7b8511f036e7dd8c50aa1b072e1f7789643aae2f --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..cdb745d7cf1c5a1da64b5c08f8c3698298923a38 --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,125 @@ +/* + * 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; + } +} +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) + 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' + },101,((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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..383f9f0ebefc00d5761c83f88fcd1ba6c9500cd1 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100644 index 0000000000000000000000000000000000000000..e1a52e61124b2ff22256f1fd48dbdf3ec98c189b --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import commonEvent from "@ohos.commonevent" + +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) { + 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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/service.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..383f9f0ebefc00d5761c83f88fcd1ba6c9500cd1 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..c7af41137cd69406214fbe1b42f3261fea4c4aa8 --- /dev/null +++ b/aafwk/aafwk_standard/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.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') + 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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7dc02b5b5e962babf011815ee2abfd5e53b3631d --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,458 @@ +/* + * 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.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_StartServiceAbilityWithAccount_0200 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_StartServiceAbilityWithAccount_0200 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_StartServiceAbilityWithAccount_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.actsspecifieduseractionextensiononetest', + abilityName: 'com.example.actsspecifieduseractionextensiononetest.ServiceAbility' + }, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>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'); + done(); + } + + 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(); + }, 1000) + } + + 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(); + }, 1000) + } + + 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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ecefaf77b73ec4f9ff4bae9da238eb9431fc172b --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/module.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..56ba946b3e9f382f6bf858c7bc3ccbf100a26cb9 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserActionExtension_101/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/app.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..ed5b06c79254f2185f17329ee977b447f3b33dad --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/BUILD.gn b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8393689f2f7effa41c8a9076d984db93306c3f19 --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/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("ActsSpecifiedUserActionZeroTest") { + hap_profile = "entry/src/main/module.json" + 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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/Test.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..dd33d382f46e45855127780caf9573afd5dc9893 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..f85fcf92b35787bd01eb2edb753cdd6b49f1dfdd --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..dda3b5af41be69b50e122118c9b4979f28a962f8 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/MainAbility2/MainAbility2.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100644 index 0000000000000000000000000000000000000000..d03b8a235a71be8d1dc3404879bed68aa995f206 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100644 index 0000000000000000000000000000000000000000..0cbe7345494763b3f6fac1f2227cf2a96278483f --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/service.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..b4e93f63e685c503c43c7e9ba6a88c3ba155fcfa --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c2511e8ff64181a4aa29ff445e2f506e53b159 --- /dev/null +++ b/aafwk/aafwk_standard/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.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') + 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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3aa7c14456fb97e151b01733fb093df5d09ec3be --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/test/abilityTest.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/ets/test/abilityTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..caea5b06e08c276e545e47c776bc396296eebadc --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/module.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..d6278a9b4360ea4445bcec8dbac16a5234330935 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_100/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/app.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..c828e9ea13ce4521ee8fee589fa097bd2562cd28 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/BUILD.gn b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0c9fd928106433015ea6bf82d1e97a7dfec81658 --- /dev/null +++ b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/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("ActsSpecifiedUserActiononeTest") { + hap_profile = "entry/src/main/module.json" + 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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/Test.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..5f76cadc76d94d80dcfd69f5ed322130eadbc98c --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b1c5ee1bb927e65a011b199387cf07e6611773b8 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..dda3b5af41be69b50e122118c9b4979f28a962f8 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/MainAbility2/MainAbility2.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100644 index 0000000000000000000000000000000000000000..0935bca48e44c58c8453102b9c05874cc0150531 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100644 index 0000000000000000000000000000000000000000..ffdaa817467d3076ed3c80771ad3d7c3470d310a --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/service.ts b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..91a83dbc24c50064a2031ddf77606699a059fac9 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c2511e8ff64181a4aa29ff445e2f506e53b159 --- /dev/null +++ b/aafwk/aafwk_standard/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.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') + 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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..53cc0398619d5d572e4dc1ed0cff44f75c2aa040 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/test/abilityTest.ets b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/ets/test/abilityTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..506fdcc1cfdbcef20efffd3ee98dcd63ddde7e5d --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/module.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..9fb5911c1b183e7c33828ef0087b619cbfda5ebd --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actsstartcomponenttest/SpecifiedUserAction_101/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/BUILD.gn b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..3f9e71fd4f7f97b48ec18dc7b2cf3e84652c6403 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/BUILD.gn @@ -0,0 +1,39 @@ +# 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_hap("ActsAmsUsersApi7AppA") { + hap_name = "ActsAmsUsersApi7AppA" + 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" +} + +ohos_js_assets("actsamsusersapi7appa_ts_assets") { + source_dir = "entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} + +ohos_resources("actsamsusersapi7appa_resources") { + sources = [ "entry/src/main/resources" ] + hap_profile = "entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/Test.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/config.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..b6296a1c98d879e07803c83b459e7d105fca42e1 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/config.json @@ -0,0 +1,81 @@ +{ + "app": { + "bundleName": "com.example.userservicesystemapi7", + "vendor": "test", + "version": { + "code": 1000110, + "name": "1.1.1" + }, + "apiVersion": { + "compatible": 9, + "target": 9 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.userservicesystemapi7", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:description_serviceability", + "visible": true, + "type": "service" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/AbilityStage.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..271d9164eb87e27cc9d6cc4515e702471d8889dd --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/AbilityStage.ts @@ -0,0 +1,21 @@ +/* + * 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.AbilitySatage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate"); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..5f8551ea9c615a693294aa3fc84136a333c3b859 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/MainAbility/MainAbility.ts @@ -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 Ability from '@ohos.application.Ability' +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("jws onCreate"); + } + + onDestroy() { + console.log("jws onDestroy"); + } + + onWindowStageCreate(windowStage) { + console.log("jws onWindowStageCreate"); + } + + onWindowStageDestroy() { + console.log("jws onWindowStageDestroy"); + } + + onForeground() { + console.log("jws onForeground"); + } + + onBackground() { + console.log("jws onBackground"); + } + + call(){ + + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/MainAbility/app.ets new file mode 100755 index 0000000000000000000000000000000000000000..eef2fff6d169b8c305daa2acd8db6eb913b31f4e --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/MainAbility/app.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. + */ +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..6b4120bd91a94160e64b02ba8b7b89b413c39389 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,38 @@ +/* + * 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 {Core} from 'deccjsunit/index' + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('onShow finish') + const core = Core.getInstance() + core.init() + const configService = core.getDefaultService('config') + configService.setConfig(this) + core.execute() + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/MainAbility/pages/second.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..65bb9463e1707757f7cb1cdca3d1b7da5dc63170 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/MainAbility/pages/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..35740fba6a5883e9fdb8f1a828c5ba1331bc1b47 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,36 @@ +/* +* 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 commonEvent from "@ohos.commonevent" +import featureAbility from '@ohos.ability.featureAbility' +export default { + onStart() { + console.info('ServiceAbility onStart'); + commonEvent.publish("ACTS_InterfaceMultiUsers_0100_Start_CommonEvent", () => { + console.log(" Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback") + featureAbility.terminateSelf().then(() => { + console.log('terminateSelf promise'); + commonEvent.publish("ACTS_TerminateSelf_CommonEvent", () => { + console.log(" Publish ACTS_TerminateSelf_CommonEvent callback") + }) + }); + }) + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..745bfaffc123f48189566fbfcbfe4e68bb6edb84 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/resources/base/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "ServiceExtAbility" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "description_serviceability", + "value": "hap sample empty service" + }, + { + "name": "description_dataability", + "value": "hap sample empty provider" + }, + { + "name": "description_mainability2", + "value": "eTS_Empty Ability" + }, + { + "name": "entry_MainAbility2", + "value": "entry_MainAbility2" + }, + { + "name": "description_testdataability", + "value": "hap sample empty provider" + }, + { + "name": "permreason_dataability", + "value": "request dataability premission" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersApi7AppA/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/AppScope/app.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..2547e5749a32ffaaec6d8474fd13bbc53771d465 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.acts.actsinterfacemultiusersextensiontest", + "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/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/BUILD.gn b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..1e742fed0e5369d14b5f98dcbdbf61fb3ebe3761 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/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("ActsAmsUsersExtensionSystemTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsusersextensionsystemtest_js_assets", + ":actsamsusersextensionsystemtest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsUsersExtensionSystemTest" +} + +ohos_app_scope("actsamsusersextensionsystemtest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsusersextensionsystemtest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsusersextensionsystemtest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsusersextensionsystemtest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/Test.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..4517a84f854cca81e865ac735997b12e3439d526 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/Test.json @@ -0,0 +1,26 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.acts.actsinterfacemultiusersextensiontest", + "shell-timeout": "300000" + }, + "kits": [ + { + "type": "ShellKit", + "run-command": [ + "acm create -n user101 -t normal", + "acm switch -i 101" + ] + }, + { + "test-file-name": [ + "ActsAmsUsersExtensionSystemTest.hap", + "ActsAmsUsersApi7AppA.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..5e2915fe4fc033cd5c9bd579dc08fe7369e51016 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..10dd9a1eaff7ad67843219facba7f8aea7b5a1a5 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class 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") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..c01f4eb103c1c0412905a1ce909c259f2316cc93 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,53 @@ +/* + * 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" + +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/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..e154f799ab6c4946ecae578febfd3e63dc49d165 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,229 @@ +/* + * 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); + } + 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.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.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.actsinterfacemultiusersextensiontest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub1; + break; + case 3: + this.context.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.MainAbility2' + },{ + windowMode:0 + },(err,data) => { + console.debug("====>startAbility end====>" ); + }) + var myStub7 = new Stub("com.acts.actsinterfacemultiusersextensiontest.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.actsinterfacemultiusersextensiontest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub2; + break; + case 5: + this.context.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.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.actsinterfacemultiusersextensiontest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub3; + break; + case 7: + this.context.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2' + },() => { + console.debug("====>startAbility end====>" ); + }) + var myStub8 = new Stub("com.acts.actsinterfacemultiusersextensiontest.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.actsinterfacemultiusersextensiontest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub4; + break; + case 9: + this.context.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2' + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + var myStub11 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub11; + 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.actsinterfacemultiusersextensiontest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub5; + break; + case 11: + this.context.startAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2' + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + var myStub12 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub12; + 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.actsinterfacemultiusersextensiontest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub6; + break; + case 13: + this.context.startAbility( + { + bundleName: 'com.example.userservicesystemapi7', + abilityName: 'com.example.userservicesystemapi7.ServiceAbility' + }).then(() => { + console.debug("====>startAbility end====>" ); + }) + var myStub9 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub9; + break; + case 14: + this.context.startAbility( + { + bundleName: 'com.example.userservicesystemapi7', + abilityName: 'com.example.userservicesystemapi7.ServiceAbility' + },() => { + console.debug("====>startAbility end====>" ); + }) + var myStub10 = new Stub("com.acts.actsinterfacemultiusersextensiontest.MainAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub10; + break; + default: + break; + } + } + + onDisconnect(want) { + console.log('ServiceAbility onDisconnect'); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..07c346153f01da5bb6df34e6fba6fd7536dcedc9 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.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 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/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..8b2238543638218c823f2414c955176da3af7818 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..5df377fb426eb6dc5ddfe9ee08b28706bb11d7e0 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,974 @@ +/* + * 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_InterfaceMultiUsersExtension_CommonEvent"] + }; +var subscriberInfo_MainAbility2 = { + events: ["ACTS_TerminateSelf_CommonEvent"] +}; +var subscriberInfo_MainAbility3 = { + events: ["ACTS_InterfaceMultiUsers_0100_Start_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('ActsInterfaceMultiUsersExtensionTest', function () { + afterAll(function() { + osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + osAccountManager.activateOsAccount(100, (err)=>{ + console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err)); + osAccountManager.removeOsAccount(101, (err)=>{ + console.debug("====>remove localId: 101" + " err:" + JSON.stringify(err)); + }) + }) + }) + console.debug("====>in ACTS_InterfaceMultiUsers====>"); + /* + * @tc.number : ACTS_ExtensionStartAbility_0100 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options succeeded.(promise) + */ + it('ACTS_ExtensionStartAbility_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.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(()=>{ + done() + },1000) + } + + function timeout() { + console.debug('in ACTS_ExtensionStartAbility_0100 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ExtensionStartAbility_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ExtensionStartAbility_0200 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options failed.(promise) + */ + it('ACTS_ExtensionStartAbility_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_ExtensionStartAbility_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.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + },{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ExtensionStartAbility_0300 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options succeeded.(callback) + */ + it('ACTS_ExtensionStartAbility_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.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(()=>{ + done() + },1000) + } + + function timeout() { + console.debug('in ACTS_ExtensionStartAbility_0300 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ExtensionStartAbility_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ExtensionStartAbility_0400 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options failed.(callback) + */ + it('ACTS_ExtensionStartAbility_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_ExtensionStartAbility_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.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + },{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + }) + + /* + * @tc.number : ACTS_ExtensionStartAbility_0500 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability succeeded.(promise) + */ + it('ACTS_ExtensionStartAbility_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.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(()=>{ + done() + },1000) + } + + function timeout() { + console.debug('in ACTS_ExtensionStartAbility_0500 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ExtensionStartAbility_0500 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_ExtensionStartAbility_0600 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability failed.(promise) + */ + it('ACTS_ExtensionStartAbility_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_ExtensionStartAbility_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.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + },{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ExtensionStartAbility_0700 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability succeeded.(callback) + */ + it('ACTS_ExtensionStartAbility_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.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(()=>{ + done() + },1000) + } + + function timeout() { + console.debug('in ACTS_ExtensionStartAbility_0700 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ExtensionStartAbility_0700 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_ExtensionStartAbility_0800 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability failed.(callback) + */ + it('ACTS_ExtensionStartAbility_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_ExtensionStartAbility_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.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + },{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + + /* + * @tc.number : ACTS_ExtensionStartAbility_0900 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability succeeded.(callback) + */ + it('ACTS_ExtensionStartAbility_0900', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum=13 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + function SubscribeCallBack (err, data) { + expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent").assertTrue(); + console.debug("====>0900 Subscribe CallBack data:====>" + JSON.stringify(data)); + if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ + 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_MainAbility3).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.acts.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(()=>{ + done() + },1000) + } + + function timeout() { + console.debug('in ACTS_ExtensionStartAbility_0900 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ExtensionStartAbility_0900 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_ExtensionStartAbility_1000 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability succeeded.(callback) + */ + it('ACTS_ExtensionStartAbility_1000', 0, async function (done) { + let Subscriber + var flag = true + var startresult = false + globalThis.startnum=14 + console.log('====>globalThis.startnum is====>' + globalThis.startnum); + function SubscribeCallBack (err, data) { + expect(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent").assertTrue(); + console.debug("====>1000 Subscribe CallBack data:====>" + JSON.stringify(data)); + if(data.event == "ACTS_InterfaceMultiUsers_0100_Start_CommonEvent"){ + 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_MainAbility3).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.acts.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(()=>{ + done() + },1000) + } + + function timeout() { + console.debug('in ACTS_ExtensionStartAbility_1000 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ExtensionStartAbility_1000 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_ExtensionTerminateSelf_0100 + * @tc.name : Use terminateself to terminate ability + * @tc.desc : Starting mainability2 with startAbility then terminateself ability succeeded.(promise) + */ + it('ACTS_ExtensionTerminateSelf_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); + } + function onConnectCallback(element, remote) { + console.log('onConnectCallback====> element=' + JSON.stringify(element)); + } + 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("====>0100start connectAbility====>"); + globalThis.number = await abilityContext.connectAbility( + { + bundleName: 'com.acts.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.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_ExtensionTerminateSelf_0100 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ExtensionTerminateSelf_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + /* + * @tc.number : + * @tc.name : Use terminateself to terminate ability + * @tc.desc : Starting mainability2 with startAbility then terminateself ability failed.(promise) + */ + it('ACTS_ExtensionTerminateSelf_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.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + },{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + }) + /* + * @tc.number : ACTS_ExtensionTerminateSelf_0300 + * @tc.name : Use terminateself to terminate ability + * @tc.desc : Starting mainability2 with startAbility then terminateself ability succeeded.(callback) + */ + it('ACTS_ExtensionTerminateSelf_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.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + setTimeout(()=>{ + done() + },1000) + } + + function timeout() { + console.debug('in ACTS_ExtensionTerminateSelf_0300 timeout'); + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_ExtensionTerminateSelf_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + /* + * @tc.number : ACTS_ExtensionTerminateSelf_0400 + * @tc.name : Use terminateself to terminate ability + * @tc.desc : Starting mainability2 with startAbility then terminateself ability failed.(callback) + */ + it('ACTS_ExtensionTerminateSelf_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_ExtensionTerminateSelf_0400 onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_ExtensionTerminateSelf_0400 onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(()=> { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if(flag == true) { + console.debug('ACTS_ExtensionTerminateSelf_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.actsinterfacemultiusersextensiontest', + abilityName: 'com.acts.actsinterfacemultiusersextensiontest.ServiceAbility' + },{ + onConnect:onConnectCallback, + onDisconnect:onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + }) + }) + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..198b3e4099bc53462227bffa2f9c2fcb31c19baa --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/module.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..1d5966b3126c12b0f72496eff26aae2ac13868ba --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/module.json @@ -0,0 +1,120 @@ +{ + "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.actsinterfacemultiusersextensiontest.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.actsinterfacemultiusersextensiontest.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.actsinterfacemultiusersextensiontest.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + }, + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.acts.actsinterfacemultiusersextensiontest.ServiceAbility2", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION" + } + ], + "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.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.MANAGE_LOCAL_ACCOUNTS", + "reason": "need use ohos.permission.MANAGE_LOCAL_ACCOUNTS" + }, + { + "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION", + "reason": "need use ohos.permission.MANAGE_LOCAL_ACCOUNTS" + } + ] + } +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersExtensionSystemTest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/AppScope/app.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..297408f961c12c8282f388072a9a728f23dd792a --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.acts.killprocesshap", + "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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/BUILD.gn b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..b3dd9ae9bfabcba69c160f9853732a22e11c836c --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/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("ActsAmsUsersKillProcessAppA") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsuserskillprocessappa_js_assets", + ":actsamsuserskillprocessappa_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsUsersKillProcessAppA" +} + +ohos_app_scope("actsamsuserskillprocessappa_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsuserskillprocessappa_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsuserskillprocessappa_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsuserskillprocessappa_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/Test.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..d30040749d6bd21e45c46ed08924bf208338070f --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,56 @@ +/* + * 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_KillProcess====>"); +} + +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) + commonEvent.publish("ACTS_KillProcess", 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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..748de696449be140904daf82cb5b33718cd25c91 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* +* 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('hello') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/module.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..f3d6af9ff0f4846f29937d70131c9ab872207b9b --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/module.json @@ -0,0 +1,38 @@ +{ + "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.killprocesshap.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" + ] + } + ] + } + ] + + } +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppA/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/AppScope/app.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..5a34634cb8274dc66cf178b0549d03ca6cd91032 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.acts.killprocessthirdhap", + "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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/BUILD.gn b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..9e4027b42a84f1196a629e190d5d3ae474a94382 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/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("ActsAmsUsersKillProcessAppB") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsuserskillprocessappb_js_assets", + ":actsamsuserskillprocessappb_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsUsersKillProcessAppB" +} + +ohos_app_scope("actsamsuserskillprocessappb_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsuserskillprocessappb_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsuserskillprocessappb_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsuserskillprocessappb_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/Test.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..4f74e976dd4acc570297f0f07df0166b8c1919ea --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/ets/MainAbility/MainAbility.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 appManager from '@ohos.application.appManager' + +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") + console.log("in killhap onForeground") + setTimeout(()=>{ + appManager.killProcessesByBundleName('com.example.killprocessthirdhap').then((data)=>{ + console.info('====>ACTS_KillProcess_0100 killProcessesByBundleName=====>' + JSON.stringify(data)) + }) + },2000) + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..748de696449be140904daf82cb5b33718cd25c91 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* +* 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('hello') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/module.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..27d17718326befffec67b4dfbbc20d483b8e8ae7 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "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.killprocessthirdhap.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" + ] + } + ] + } + ] + } +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppB/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/AppScope/app.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..04957795c479c90fab9058c3ac12a07b543f6113 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.acts.killprocessthirdhap2", + "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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/BUILD.gn b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..9e83279c41e965d1f4e07a362cc2ef5726f2c079 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/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("ActsAmsUsersKillProcessAppC") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsuserskillprocessappc_js_assets", + ":actsamsuserskillprocessappc_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsUsersKillProcessAppC" +} + +ohos_app_scope("actsamsuserskillprocessappc_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsuserskillprocessappc_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsuserskillprocessappc_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsuserskillprocessappc_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/Test.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..09e417a9ef3d968ab8fea897e8cfb02838e03ba7 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/ets/MainAbility/MainAbility.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 appManager from '@ohos.application.appManager' + +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") + console.log("in killhap onForeground") + setTimeout(()=>{ + appManager.killProcessesByBundleName('com.example.killprocessthirdhap2',(err,data)=>{ + console.info('====>ACTS_KillProcess_0100 killProcessesByBundleName=====>' + JSON.stringify(data)) + }) + },2000) + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..748de696449be140904daf82cb5b33718cd25c91 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* +* 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('hello') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/module.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..1f73e0270c62b9cd341bef709512fefc58d092f1 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "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.killprocessthirdhap2.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" + ] + } + ] + } + ] + } +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..f06e218defa7f707e22a3890903c574e1c498217 Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersKillProcessAppC/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/AppScope/app.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..f82b1aae8b0d3d9090c4252e01224d291cf81805 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.acts.actsinterfacemultiuserstest", + "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/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/BUILD.gn b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..40abe7c8643cd5c68f0af33a47a0e71181dd145a --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/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("ActsAmsUsersSystemTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsuserssystemtest_js_assets", + ":actsamsuserssystemtest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsUsersSystemTest" +} + +ohos_app_scope("actsamsuserssystemtest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsuserssystemtest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsuserssystemtest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsuserssystemtest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/Test.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..c602f1fd444422e74fb75da810e38ca999bc9b42 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/Test.json @@ -0,0 +1,33 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.acts.actsinterfacemultiuserstest", + "shell-timeout": "300000" + }, + "kits": [ + { + "type": "ShellKit", + "run-command": [ + "acm create -n user101 -t normal", + "acm switch -i 101" + ], + "teardown-command": [ + "acm switch -i 100", + "acm delete -i 101" + ] + }, + { + "test-file-name": [ + "ActsAmsUsersSystemTest.hap", + "ActsAmsUsersKillProcessAppA.hap", + "ActsAmsUsersKillProcessAppB.hap", + "ActsAmsUsersKillProcessAppC.hap", + "ActsAmsUsersApi7AppA.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": false + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..5e2915fe4fc033cd5c9bd579dc08fe7369e51016 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..10dd9a1eaff7ad67843219facba7f8aea7b5a1a5 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class 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") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..8dd72f5bbe33998402795ef1da0df3d5c547dcb5 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,62 @@ +/* + * 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_StartAbility_0100_CommonEvent====>"); + globalThis.abilityContext.terminateSelf().then(()=>{ + commonEvent.publish("ACTS_TerminateSelf_CommonEvent", PublishCallBackTwo); + console.debug("====>publish ACTS_TerminateSelf_CommonEvent finish====>") + }); + console.debug("====>terminateSelf succese====>") +} +function PublishCallBackTwo(){ + console.debug("====>Publish CallBack ACTS_TerminateSelf_CommonEvent====>"); +} + +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.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/second", null) + commonEvent.publish("ACTS_InterfaceMultiUsers_0100_Start_CommonEvent", PublishCallBackOne); + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("MainAbility2 onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility2 onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility2 onBackground") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility3/MainAbility3.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility3/MainAbility3.ts new file mode 100755 index 0000000000000000000000000000000000000000..b2f395fb4ec2675fc400f6e92441f514fa910972 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/MainAbility3/MainAbility3.ts @@ -0,0 +1,59 @@ +/* + * 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 MainAbility3 extends Ability { + onCreate(want,launchParam){ + // Ability is creating, initialize resources for this ability + console.log("MainAbility3 onCreate") + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbility3 onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + 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() { + //Main window is destroyed, release UI related resources + console.log("MainAbility3 onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility3 onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility3 onBackground") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..b3d958e6505ce967a80cc7e4727aa51078b11f5e --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,47 @@ +/* + * 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 commonEvent from "@ohos.commonevent" + +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility onCreate'); + } + onDestory(){ + console.log('ServiceAbility onDestory'); + } + onRequest(want,startId) { + console.log('ServiceAbility onRequest'); + commonEvent.publish("ACTS_InterfaceMultiUsers_0100_Start_CommonEvent", () => { + console.log(" Publish ACTS_InterfaceMultiUsersExtension_CommonEvent callback") + this.context.terminateSelf().then(()=>{ + console.log(" terminateSelf callback") + }) + }) + } + + onConnect(want) { + console.log('ServiceAbility onConnect'); + } + + onDisconnect(want) { + console.log('ServiceAbility onDisconnect'); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..cd0377c3893f3fd32b9bdcbc1a8d089fa200e891 --- /dev/null +++ b/aafwk/aafwk_standard/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.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'] = 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/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..914f0d2f32e6e9d31e0897165b81abab1529a49b --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,1320 @@ +/* + * 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 appManager from '@ohos.application.appManager' +import osaccount from '@ohos.account.osAccount' + +var subscriberInfo_MainAbility = { + events: ["ACTS_InterfaceMultiUsers_0100_Start_CommonEvent","ACTS_TerminateSelf_CommonEvent"] +}; +var subscriberInfo_killprocess ={ + events:["ACTS_KillProcess"] +} +var osAccountManager +const START_ABILITY_TIMEOUT = 10000; +console.debug("====>in Ability.test====>"); +export default function abilityTest(abilityContext) { + console.debug("====>in function abilityTest====>"); + describe('ActsInterfaceMultiUsersTest', 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_startAbility_0100 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options succeeded.(promise) + */ + it('ACTS_StartAbility_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.actsinterfacemultiuserstest', + abilityName: 'com.acts.actsinterfacemultiuserstest.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_startAbility_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_startAbility_0200 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options failed.(promise) + */ + it('ACTS_StartAbility_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_startAbility_0200 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_startAbility_0300 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options succeeded.(callback) + */ + it('ACTS_StartAbility_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.actsinterfacemultiuserstest', + abilityName: 'com.acts.actsinterfacemultiuserstest.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_startAbility_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_startAbility_0400 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options failed.(callback) + */ + it('ACTS_StartAbility_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_startAbility_0400 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_startAbility_0500 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability succeeded.(promise) + */ + it('ACTS_StartAbility_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.actsinterfacemultiuserstest', + abilityName: 'com.acts.actsinterfacemultiuserstest.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_startAbility_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_startAbility_0600 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability failed.(promise) + */ + it('ACTS_StartAbility_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_startAbility_0200 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_startAbility_0700 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability succeeded.(callback) + */ + it('ACTS_StartAbility_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.actsinterfacemultiuserstest', + abilityName: 'com.acts.actsinterfacemultiuserstest.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_startAbility_0300 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + /* + * @tc.number : ACTS_startAbility_0800 + * @tc.name : start new ability + * @tc.desc : Starting mainability2 with startability failed.(callback) + */ + it('ACTS_StartAbility_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_startAbility_0800 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + + /* + * @tc.number : ACTS_startAbility_0900 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options succeeded.(promise) + */ + it('ACTS_StartAbility_0900', 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.example.userservicesystemapi7', + abilityName: 'com.example.userservicesystemapi7.ServiceAbility' + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + done(); + } + + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_startAbility_0900 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + /* + * @tc.number : ACTS_startAbility_1000 + * @tc.name : start new ability + * @tc.desc : Start an ability with the parameter startability with options succeeded.(promise) + */ + it('ACTS_startAbility_1000', 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.example.userservicesystemapi7', + abilityName: 'com.example.userservicesystemapi7.ServiceAbility' + },()=>{ + console.debug("====>startAbility end====>"); + }) + }) + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + expect(startresult).assertEqual(true); + done(); + } + + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_startAbility_1000 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number : ACTS_StartAbilityForResult_0100 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(promise) + */ + it('ACTS_StartAbilityForResult_0100', 0, async function (done) { + var flag = true + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('AMS_startAbilityForResult_0100 - timeout'); + done(); + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.actsinterfacemultiuserstest', + abilityName: 'com.acts.actsinterfacemultiuserstest.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_StartAbilityForResult_0200 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult failed.(promise) + */ + it('ACTS_StartAbilityForResult_0200', 0, async function (done) { + function timeout() { + console.debug('ACTS_startAbilityForResult_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_StartAbilityForResult_0300 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(callback) + */ + it('ACTS_StartAbilityForResult_0300', 0, async function (done) { + var flag = true + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_startAbilityForResult_0300 - timeout'); + done(); + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.actsinterfacemultiuserstest', + abilityName: 'com.acts.actsinterfacemultiuserstest.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_StartAbilityForResult_0400 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult failed.(callback) + */ + it('ACTS_StartAbilityForResult_0400', 0, async function (done) { + function timeout() { + console.debug('ACTS_startAbilityForResult_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_StartAbilityForResult_0500 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(promise) + */ + it('ACTS_StartAbilityForResult_0500', 0, async function (done) { + var flag = true + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('AMS_startAbilityForResult_0500 - timeout'); + done(); + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.actsinterfacemultiuserstest', + abilityName: 'com.acts.actsinterfacemultiuserstest.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_StartAbilityForResult_0600 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult failed.(promise) + */ + it('ACTS_StartAbilityForResult_0600', 0, async function (done) { + function timeout() { + console.debug('ACTS_startAbilityForResult_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_StartAbilityForResult_0700 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult succeeded.(callback) + */ + it('ACTS_StartAbilityForResult_0700', 0, async function (done) { + var flag = true + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_startAbilityForResult_0700 - timeout'); + done(); + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>start startAbilityForResult====>"); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.acts.actsinterfacemultiuserstest', + abilityName: 'com.acts.actsinterfacemultiuserstest.MainAbility3', + },(err,data)=>{ + console.debug("====>startAbilityForResult end====>"); + flag = false + expect(data.resultCode).assertEqual(1) + expect(data.want.action).assertEqual('ACTION') + done(); + }) + }) + + /* + * @tc.number : ACTS_StartAbilityForResult_0800 + * @tc.name : start new ability for result + * @tc.desc : Starting mainability3 with startAbilityForResult failed.(callback) + */ + it('ACTS_StartAbilityForResult_0800', 0, async function (done) { + function timeout() { + console.debug('ACTS_startAbilityForResult_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 + console.debug("====>terminateresult is:====>" + JSON.stringify(terminateresult)); + 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.actsinterfacemultiuserstest', + abilityName: 'com.acts.actsinterfacemultiuserstest.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) + done(); + } + + 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.actsinterfacemultiuserstest', + abilityName: 'com.acts.actsinterfacemultiuserstest.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.actsinterfacemultiuserstest', + abilityName: 'com.acts.actsinterfacemultiuserstest.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.actsinterfacemultiuserstest', + abilityName: 'com.acts.actsinterfacemultiuserstest.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(); + }) + }) + + /* + * @tc.number : ACTS_KillProcess_0100 + * @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_KillProcess_0100', 0, async function (done) { + var Subscriber + var flag = true + function SubscribeCallBack (err, data) { + expect(data.event == "ACTS_KillProcess").assertTrue(); + console.debug("====>ACTS_KillProcess_0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + appManager.getProcessRunningInfos().then((data)=> { + console.info('====>ACTS_KillProcess_0100 getProcessRunningInfos=====>' + JSON.stringify(data)) + for(var i = 0; ihas com.acts.killprocesshap=====>') + break + } + } + console.log('====>i is:====>' + JSON.stringify(i)) + if(i==data.length && data[i].processName!='com.acts.killprocesshap'){ + expect().assertFail() + } + appManager.killProcessesByBundleName('com.acts.killprocesshap').then((data)=>{ + console.info('====>ACTS_KillProcess_0100 killProcessesByBundleName=====>' + JSON.stringify(data)) + setTimeout(()=>{ + appManager.getProcessRunningInfos().then((data)=> { + console.info('====>ACTS_KillProcess_0100 getProcessRunningInfos2=====>' + JSON.stringify(data)) + for(var i = 0; i { + 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.killprocesshap', + abilityName: 'com.acts.killprocesshap.MainAbility' + }).then((data)=>{ + console.debug("====>startAbility end====>"); + console.debug("====>data is====>" + JSON.stringify(data)); + }) + }) + }) + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + done(); + } + + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_KillProcess_0100 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, 19500); + }) + + /* + * @tc.number : ACTS_KillProcess_0200 + * @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_KillProcess_0200', 0, async function (done) { + var Subscriber + var flag = true + function SubscribeCallBack (err, data) { + expect(data.event == "ACTS_KillProcess").assertTrue(); + console.debug("====>ACTS_KillProcess_0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + appManager.getProcessRunningInfos().then((data)=> { + console.info('====>ACTS_KillProcess_0200 getProcessRunningInfos=====>' + JSON.stringify(data)) + for(var i = 0; ihas com.acts.killprocesshap=====>') + break + } + } + console.log('====>i is:====>' + JSON.stringify(i)) + if(i==data.length && data[i].processName!='com.acts.killprocesshap'){ + expect().assertFail() + } + appManager.killProcessesByBundleName('com.acts.killprocesshap',(data)=>{ + console.info('====>ACTS_KillProcess_0200 killProcessesByBundleName=====>' + JSON.stringify(data)) + setTimeout(()=> { + appManager.getProcessRunningInfos().then((data) => { + console.info('====>ACTS_KillProcess_0200 getProcessRunningInfos2=====>' + JSON.stringify(data)) + for (var i = 0; i < data.length; i++) { + if (data[i].processName == 'com.acts.killprocesshap') { + expect().assertFail() + break + } + } + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + }) + },15000) + }) + }) + } + commonEvent.createSubscriber(subscriberInfo_killprocess).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.killprocesshap', + abilityName: 'com.acts.killprocesshap.MainAbility' + }).then((data)=>{ + console.debug("====>startAbility end====>"); + console.debug("====>data is====>" + JSON.stringify(data)); + }) + }) + }) + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + done(); + } + + function timeout() { + if(flag == true) { + expect().assertFail(); + console.debug('ACTS_KillProcess_0200 - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + + setTimeout(timeout, 19500); + }) + /* + * @tc.number : ACTS_ThirdPartyKillProcess_0100 + * @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_ThirdPartyKillProcess_0100', 0, async function (done) { + console.debug("====>start startAbility====>"); + await abilityContext.startAbility( + { + bundleName: 'com.acts.killprocessthirdhap', + abilityName: 'com.acts.killprocessthirdhap.MainAbility' + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + setTimeout(()=>{ + appManager.getProcessRunningInfos().then((data)=> { + console.info('====>ACTS_KillProcess_0100 getProcessRunningInfos=====>' + JSON.stringify(data)) + for(var i = 0; ihas com.acts.killprocessthirdhap=====>') + break + } + } + console.log('====>i is:====>' + JSON.stringify(i)) + if(i==data.length && data[i].processName!='com.acts.killprocessthirdhap'){ + expect().assertFail() + } + }) + },1000) + setTimeout(()=> { + appManager.getProcessRunningInfos().then((data) => { + console.info('====>ACTS_KillProcess_0100 getProcessRunningInfos2=====>' + JSON.stringify(data)) + for (var i = 0; i < data.length; i++) { + if (data[i].processName == 'com.acts.killprocessthirdhap') { + break + } + } + console.log('====>i2 is:====>' + JSON.stringify(i)) + if(i==data.length && data[i].processName!='com.acts.killprocessthirdhap'){ + expect().assertFail() + } + done() + }) + },15000) + }) + /* + * @tc.number : ACTS_ThirdPartyKillProcess_0200 + * @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_ThirdPartyKillProcess_0200', 0, async function (done) { + console.debug("====>start startAbility====>"); + await abilityContext.startAbility( + { + bundleName: 'com.acts.killprocessthirdhap2', + abilityName: 'com.acts.killprocessthirdhap2.MainAbility' + }).then(() => { + console.debug("====>startAbility end====>"); + }) + setTimeout(() => { + appManager.getProcessRunningInfos().then((data) => { + console.info('====>ACTS_KillProcess_0100 getProcessRunningInfos=====>' + JSON.stringify(data)) + for (var i = 0; i < data.length; i++) { + if (data[i].processName == 'com.acts.killprocessthirdhap2') { + console.info('====>has com.acts.killprocessthirdhap2=====>') + break + } + } + console.log('====>i is:====>' + JSON.stringify(i)) + if (i == data.length && data[i].processName != 'com.acts.killprocessthirdhap2') { + expect().assertFail() + } + }) + },1000) + setTimeout(() => { + appManager.getProcessRunningInfos().then((data) => { + console.info('====>ACTS_KillProcess_0100 getProcessRunningInfos2=====>' + JSON.stringify(data)) + for (var i = 0; i < data.length; i++) { + if (data[i].processName == 'com.acts.killprocessthirdhap2') { + break + } + } + console.log('====>i2 is:====>' + JSON.stringify(i)) + if(i==data.length && data[i].processName!='com.acts.killprocessthirdhap'){ + expect().assertFail() + } + done() + }) + },15000) + }) + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..f4e1c2a61d343de3599bfc16768af46c3df792b0 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/module.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..9cae7b176dd182c1624e18a2f26b48dda690717f --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/module.json @@ -0,0 +1,120 @@ +{ + "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.actsinterfacemultiuserstest.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.actsinterfacemultiuserstest.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.actsinterfacemultiuserstest.MainAbility3", + "srcEntrance": "./ets/MainAbility3/MainAbility3.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.actsinterfacemultiuserstest.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ], + "defPermissions": [ + { + "availableScope": [], + "grantMode": "system_grant", + "name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS" + }, + { + "availableScope": [], + "grantMode": "system_grant", + "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION" + } + ], + "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.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.MANAGE_LOCAL_ACCOUNTS", + "reason": "need use ohos.permission.MANAGE_LOCAL_ACCOUNTS" + }, + { + "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION", + "reason": "need use ohos.permission.MANAGE_LOCAL_ACCOUNTS" + } + ] + } +} diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/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/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/ActsAmsUsersSystemTest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actsusers/BUILD.gn b/aafwk/aafwk_standard/actsusers/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..88ebe65f3a549074bc35da6a9e0a1b6557f99a50 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/BUILD.gn @@ -0,0 +1,31 @@ +# 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("actsusers") { + testonly = true + if (is_standard_system) { + deps = [ + "ActsAmsUsersApi7AppA:ActsAmsUsersApi7AppA", + "ActsAmsUsersExtensionSystemTest:ActsAmsUsersExtensionSystemTest", + "ActsAmsUsersKillProcessAppA:ActsAmsUsersKillProcessAppA", + "ActsAmsUsersKillProcessAppB:ActsAmsUsersKillProcessAppB", + "ActsAmsUsersKillProcessAppC:ActsAmsUsersKillProcessAppC", + "ActsAmsUsersSystemTest:ActsAmsUsersSystemTest", + "actsconnectabilitysystemabilitytest:ActsConnectAbilitySystemAbilityTest", + "actsextensionconnectabilitytest:ActsExtensionConnectAbilityTest", + "actsserviceabilityrelytest:actsServiceAbilityRelyHap", + ] + } +} diff --git a/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/AppScope/app.json b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..1a44bb9e690d0089cd5b7407bcb41183ba2838c8 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actsconnectabilitysystemabilitytest", + "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/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/BUILD.gn b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..28ed27d1d8283ec0a360e38d60cd3b4615b151be --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/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("ActsConnectAbilitySystemAbilityTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsconnectabilitysystemabilitytest_js_assets", + ":actsconnectabilitysystemabilitytest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsConnectAbilitySystemAbilityTest" +} + +ohos_app_scope("actsconnectabilitysystemabilitytest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsconnectabilitysystemabilitytest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsconnectabilitysystemabilitytest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsconnectabilitysystemabilitytest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/Test.json b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..fcdb809aa7d8a2ada304099cf50061bcbdfc0c18 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/Test.json @@ -0,0 +1,31 @@ + +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.actsconnectabilitysystemabilitytest", + "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": [ + "ActsConnectAbilitySystemAbilityTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + + ] +} + diff --git a/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/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/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..a0d6e4c91392be43a37f21a362c20539e437917d --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,42 @@ +import Ability from '@ohos.application.Ability' +// import commonEvent from '@ohos.commonevent' + +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("AbilityMultiInstanceTest onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("AbilityMultiInstanceTest onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("AbilityMultiInstanceTest onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("AbilityMultiInstanceTest onWindowStageDestroy") + } + + + onForeground() { + // Ability has brought to foreground + console.log("AbilityMultiInstanceTest onForeground") + } + + onBackground() { + // Ability has back to background + console.log("AbilityMultiInstanceTest onBackground") + } + +}; diff --git a/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..2d427beac9c2e1551fc14bfb3348ee711aba8eab --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,167 @@ +/* + * 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 commonEvent from '@ohos.commonEvent' +import ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' + +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 ServiceExtensionAbility { + 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.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility2", + } + ); + }; + if (want.action == "Eight") { + extensionContext.connectAbility( + { + bundleName: "com.example.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility3", + } + ); + }; + if (want.action == "Nine") { + console.log('connectAbility 111'); + let num = extensionContext.connectAbility( + { + bundleName: 'com.example.actsconnectabilitysystemabilitytest', + abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2' + }) + setTimeout(()=>{ + extensionContext.disconnectAbility(num).then(()=>{ + console.log('in disconnectAbility'); + }) + },1000) + + }; + if (want.action == "Ten") { + console.log('connectAbility 222'); + let num = extensionContext.connectAbility( + { + bundleName: 'com.example.actsconnectabilitysystemabilitytest', + abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2' + }) + setTimeout(()=>{ + extensionContext.disconnectAbility(num).then(()=>{ + console.log('in disconnectAbility2'); + }) + },1000) + + }; + if (want.action == "Ten one") { + console.log('connectAbility 333'); + let num = extensionContext.connectAbility( + { + bundleName: 'com.example.actsconnectabilitysystemabilitytest', + abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2' + }) + setTimeout(()=>{ + extensionContext.disconnectAbility(2222).then(()=>{ + console.log('in disconnectAbility3'); + }) + },1000) + + }; + if (want.action == "Ten two") { + console.log('connectAbility 444'); + let num = extensionContext.connectAbility( + { + bundleName: 'com.example.actsconnectabilitysystemabilitytest', + abilityName: 'com.example.actsconnectabilitysystemabilitytest.ServiceAbility2' + }) + setTimeout(()=>{ + extensionContext.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/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..b49731a414958a281c2f0c4eab0e7fb408eb2c2f --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/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/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..d991836755b3ef36c6a86bcaa8b8e8f5df1cdf90 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility' +import commonEvent from "@ohos.commonevent" + +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'); + 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/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/ServiceAbility2/service.ts b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..340a610cb718c70c98add0b5d052bb4589185174 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/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/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..85d2f648a55a82c8f8d4abd60faa6c35433363de --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/pages/index/index.ets @@ -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 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) + 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('Hello World1111111') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/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/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..203485bd7e41ab2793c45ffd8d4f417a62501583 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/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/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/test/manyusersabilitytest.test.ets b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/test/manyusersabilitytest.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..9d2c5861584ec7d76c4b8e08fd3249708afc67cf --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/ets/test/manyusersabilitytest.test.ets @@ -0,0 +1,814 @@ +/* + * 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('ActssystemabilityTest', function () { + function onFailedCallBack(code) { + console.log('ACTS_ConnectAbility_0200 Connectability errcode:' + code); + } + + /* + * @tc.number: ACTS_ConnectAbility_0100 + * @tc.name: Connects a service ability + * @tc.desc: Connects a service ability + */ + it('ACTS_ConnectAbility_0100', 0, async function (done) { + console.log('ACTS_ConnectAbility_0100====ACTS_ConnectAbility_0100 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0100_commonEvent"); + console.debug("====>ACTS_ConnectAbility_0100 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ConnectAbility_0100 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_0100).then(async (data) => { + console.debug("====>ACTS_ConnectAbility_0100 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + done(); + } + + function timeout() { + expect().assertFail(); + console.debug('AMS_ConnectAbility_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_ConnectAbility_0100 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", + action: "one", + }, + ); + console.debug("====>ACTS_ConnectAbility_0100 4 "); + + }) + + /* + * @tc.number: ACTS_ConnectAbility_0200 + * @tc.name: Connects a service ability + * @tc.desc: Connects a service ability + */ + it('ACTS_ConnectAbility_0200', 0, async function (done) { + console.log('ACTS_ConnectAbility_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('AMS_ConnectAbility_0200 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbilityone", + action: "two", + }, + { + onFailed: onFailedCallBack, + }, + ); + }) + + /* + * @tc.number: ACTS_DisconnectAbility_0100 + * @tc.name: DisConnects a service ability + * @tc.desc: DisConnects a service ability + */ + it('ACTS_DisconnectAbility_0100', 0, async function (done) { + console.log('ACTS_DisconnectAbility_0100====ACTS_DisconnectAbility_0100 5 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + console.debug("====>ACTS_DisconnectAbility_0100 6====>"); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_DisconnectAbility_0100 6====>"); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } + commonEvent.createSubscriber(subscriberInfoStartAbility_0300).then(async (data) => { + console.debug("====>ACTS_DisconnectAbility_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_DisconnectAbility_0100 3====>"); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", + action: "Three", + }, + ); + console.debug("====>ACTS_DisconnectAbility_0100 4====>"); + }) + + /* + * @tc.number: ACTS_DisconnectAbility_0200 + * @tc.name: DisConnects a service ability + * @tc.desc: DisConnects a service ability + */ + it('ACTS_DisconnectAbility_0200', 0, async function (done) { + console.log('ACTS_DisconnectAbility_0200 1====ACTS_DisconnectAbility_0200 3 CallBack1 data:====>" + JSON.stringify(data)); + commonEvent.createSubscriber(unsubscriberInfoStartAbility_0100).then(async (data) => { + console.debug("====>ACTS_DisconnectAbility_0200 6 Subscriber====>"); + subscriberdisconnect = data; + await commonEvent.subscribe(subscriberdisconnect, subscribedisconnectback); + console.debug("====>ACTS_DisconnectAbility_0200 1111 connectAbility1====>"); + + console.debug("====>ACTS_DisconnectAbility_0200 1111 connectAbility2====>"); + console.debug("====>ACTS_DisconnectAbility_0200 66 Subscriber====>"); + abilityContext.disconnectAbility( + 999, + (error, data) => { + console.log('ACTS_DisconnectAbility_0200 5 DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + }) + } + function subscribedisconnectback(err, data) { + console.debug("====>ACTS_DisconnectAbility_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_DisconnectAbility_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_DisconnectAbility_0200 9 DisconnectAbility result errCode : ' + error.code + " data: " + data) + console.debug("====>ACTS_DisconnectAbility_0200 99 Subscriber====>"); + setTimeout(() => { + done(); + }, 1000) + }); + }) + }) + } + commonEvent.createSubscriber(subscriberInfoStartAbility_0400).then(async (data) => { + console.debug("====>ACTS_DisconnectAbility_0200 10 Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack) + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", + action: "Four", + }, + ); + console.debug("====>connId is:====>" + JSON.stringify(connId)); + console.debug("====>ACTS_DisconnectAbility_0200 1010 Subscriber====>"); + }) + function unSubscribeCallback() { + console.debug("====>ACTS_DisconnectAbility_0200 1111 UnSubscribe CallBack====>"); + done(); + } + }) + + /* + * @tc.number: ACTS_DisconnectAbility_0300 + * @tc.name: DisConnects a service ability + * @tc.desc: DisConnects a service ability + */ + it('ACTS_DisconnectAbility_0300', 0, async function (done) { + console.log('ACTS_DisconnectAbility_0300====ACTS_DisconnectAbility_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_DisconnectAbility_0300 5 DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } + commonEvent.createSubscriber(subscriberInfoStartAbility_0500).then(async (data) => { + console.debug("====>ACTS_DisconnectAbility_0300 1 Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + function unSubscribeCallback() { + console.debug("====>ACTS_DisconnectAbility_0300 6 CallBack====>"); + setTimeout(() => { + done(); + }, 1000) + } + function timeout() { + expect().assertFail(); + console.debug('AMS_ConnectAbility_0500 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('ACTS_DisconnectAbility_0300 7 DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + } + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>ACTS_DisconnectAbility_0300 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", + action: "Five", + }, + ); + console.debug("====>ACTS_DisconnectAbility_0300 4 "); + }) + + /* + * @tc.number: ACTS_DisconnectAbility_0400 + * @tc.name: DisConnects a service ability + * @tc.desc: DisConnects a service ability + */ + it('ACTS_DisconnectAbility_0400', 0, async function (done) { + console.log('ACTS_DisconnectAbility_0400 1====ACTS_DisconnectAbility_0400 3 CallBack1 data:====>" + JSON.stringify(data)); + commonEvent.createSubscriber(unsubscriberInfoStartAbility_0200).then(async (data) => { + console.debug("====>ACTS_DisconnectAbility_0400 6 Subscriber====>"); + subscriberdisconnect = data; + await commonEvent.subscribe(subscriberdisconnect, subscribedisconnectback); + console.debug("====>ACTS_DisconnectAbility_0400 1111 connectAbility1====>"); + + console.debug("====>ACTS_DisconnectAbility_0400 1111 connectAbility2====>"); + console.debug("====>ACTS_DisconnectAbility_0400 66 Subscriber====>"); + abilityContext.disconnectAbility( + 999, + (error, data) => { + console.log('ACTS_DisconnectAbility_0400 5 DisconnectAbility result errCode : ' + error.code + " data: " + data) + }); + }) + } + function subscribedisconnectback(err, data) { + console.debug("====>ACTS_DisconnectAbility_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_DisconnectAbility_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_DisconnectAbility_0400 9 DisconnectAbility result errCode : ' + error.code + " data: " + data) + console.debug("====>ACTS_DisconnectAbility_0400 99 Subscriber====>"); + setTimeout(() => { + done(); + }, 1000) + }); + }) + }) + } + commonEvent.createSubscriber(subscriberInfoStartAbility_0600).then(async (data) => { + console.debug("====>ACTS_DisconnectAbility_0400 10 Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack) + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", + action: "Six", + }, + ); + console.debug("====>connId is:====>" + JSON.stringify(connId)); + console.debug("====>ACTS_DisconnectAbility_0400 1010 Subscriber====>"); + }) + function unSubscribeCallback() { + console.debug("====>ACTS_DisconnectAbility_0400 1111 UnSubscribe CallBack====>"); + done(); + } + }) + + /* + * @tc.number: ACTS_ExtensionConnectAbility_0100 + * @tc.name: DisConnects a service ability + * @tc.desc: DisConnects a service ability + */ + it('ACTS_ExtensionConnectAbility_0100', 0, async function (done) { + console.log('ACTS_ExtensionConnectAbility_0100====ACTS_ExtensionConnectAbility_0100 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0700_commonEvent"); + console.debug("====>ACTS_ExtensionConnectAbility_0100 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ExtensionConnectAbility_0100 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } + commonEvent.createSubscriber(subscriberInfoStartAbility_0700).then(async (data) => { + console.debug("====>ACTS_ExtensionConnectAbility_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_ExtensionConnectAbility_0100 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", + action: "Seven", + }, + ); + console.debug("====>ACTS_ExtensionConnectAbility_0100 4 "); + }) + + /* + * @tc.number: ACTS_ExtensionConnectAbility_0200 + * @tc.name: DisConnects a service ability + * @tc.desc: DisConnects a service ability + */ + it('ACTS_ExtensionConnectAbility_0200', 0, async function (done) { + console.log('ACTS_ExtensionConnectAbility_0200====ACTS_ExtensionConnectAbility_0200 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0800_commonEvent"); + console.debug("====>ACTS_ExtensionConnectAbility_0200 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ExtensionConnectAbility_0200 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } + commonEvent.createSubscriber(subscriberInfoStartAbility_0800).then(async (data) => { + console.debug("====>ACTS_ExtensionConnectAbility_0200 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + setTimeout(() => { + done(); + }, 1000) + } + function timeout() { + console.debug('ACTS_ExtensionConnectAbility_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_ExtensionConnectAbility_0200 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", + action: "Eight", + }, + ); + console.debug("====>ACTS_ExtensionConnectAbility_0200 4 "); + }) + + /* + * @tc.number: ACTS_ExtensionDisconnectAbility_0100 + * @tc.name: DisConnects a service ability + * @tc.desc: DisConnects a service ability + */ + it('ACTS_ExtensionDisconnectAbility_0100', 0, async function (done) { + console.log('ACTS_ExtensionDisconnectAbility_0100====ACTS_ExtensionDisconnectAbility_0100 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0900_commonEvent"); + console.debug("====>ACTS_ExtensionDisconnectAbility_0100 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ExtensionDisconnectAbility_0100 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } + commonEvent.createSubscriber(subscriberInfoStartAbility_0900).then(async (data) => { + console.debug("====>ACTS_ExtensionDisconnectAbility_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_ExtensionDisconnectAbility_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_ExtensionDisconnectAbility_0100 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", + action: "Nine", + }, + ); + console.debug("====>ACTS_ExtensionDisconnectAbility_0100 4 "); + }) + + /* + * @tc.number: ACTS_ExtensionDisconnectAbility_0200 + * @tc.name: DisConnects a service ability + * @tc.desc: DisConnects a service ability + */ + it('ACTS_ExtensionDisconnectAbility_0200', 0, async function (done) { + console.log('ACTS_ExtensionDisconnectAbility_0200====ACTS_ExtensionDisconnectAbility_0200 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_1000_commonEvent"); + console.debug("====>ACTS_ExtensionDisconnectAbility_0200 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ExtensionDisconnectAbility_0200 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } + commonEvent.createSubscriber(subscriberInfoStartAbility_1000).then(async (data) => { + console.debug("====>ACTS_ExtensionDisconnectAbility_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_ExtensionDisconnectAbility_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_ExtensionDisconnectAbility_0200 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", + action: "Ten", + }, + ); + console.debug("====>ACTS_ExtensionDisconnectAbility_0200 4 "); + }) + + /* + * @tc.number: ACTS_ExtensionDisconnectAbility_0300 + * @tc.name: DisConnects a service ability + * @tc.desc: DisConnects a service ability + */ + it('ACTS_ExtensionDisconnectAbility_0300', 0, async function (done) { + console.log('ACTS_ExtensionDisconnectAbility_0300====ACTS_ExtensionDisconnectAbility_0300 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_1100_commonEvent"); + console.debug("====>ACTS_ExtensionDisconnectAbility_0300 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ExtensionDisconnectAbility_0300 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } + commonEvent.createSubscriber(subscriberInfoStartAbility_1100).then(async (data) => { + console.debug("====>ACTS_ExtensionDisconnectAbility_0300 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + setTimeout(() => { + done(); + }, 1000) + } + function timeout() { + console.debug('ACTS_ExtensionDisconnectAbility_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_ExtensionDisconnectAbility_0300 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", + action: "Ten one", + }, + ); + console.debug("====>ACTS_ExtensionDisconnectAbility_0300 4 "); + }) + + /* + * @tc.number: ACTS_ExtensionDisconnectAbility_0400 + * @tc.name: DisConnects a service ability + * @tc.desc: DisConnects a service ability + */ + it('ACTS_ExtensionDisconnectAbility_0400', 0, async function (done) { + console.log('ACTS_ExtensionDisconnectAbility_0400====ACTS_ThirdPartyExtensionDisconnectAbility_0400 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_1200_commonEvent"); + console.debug("====>ACTS_ExtensionDisconnectAbility_0400 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ExtensionDisconnectAbility_0400 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } + commonEvent.createSubscriber(subscriberInfoStartAbility_1200).then(async (data) => { + console.debug("====>ACTS_ExtensionDisconnectAbility_0400 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + }) + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + setTimeout(() => { + done(); + }, 1000) + } + function timeout() { + console.debug('ACTS_ExtensionDisconnectAbility_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_ExtensionDisconnectAbility_0400 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsconnectabilitysystemabilitytest", + abilityName: "com.example.actsconnectabilitysystemabilitytest.ServiceAbility", + action: "Ten two", + }, + ); + console.debug("====>ACTS_ExtensionDisconnectAbility_0400 4 "); + }) + }) +} + + diff --git a/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/module.json b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..486c0cf0f18ffae6f0c18d6a68e00a2813d42047 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/module.json @@ -0,0 +1,108 @@ +{ + "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.actsconnectabilitysystemabilitytest.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 + } + ], + + "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.MANAGE_LOCAL_ACCOUNTS", + "reason": "ceshi" + }, + { + "name": "ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION", + "reason": "ceshi" + }, + { + "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/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/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/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/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/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/actsconnectabilitysystemabilitytest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/AppScope/app.json b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..7ce2b709a13ec669ca664fd4b981930e4b738a86 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actsextensionconnectabilitytest", + "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/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/BUILD.gn b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..eb96980b7174601ae5ea78e5933e51505df3aaa6 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/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("ActsExtensionConnectAbilityTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsextensionconnectabilitytest_js_assets", + ":actsextensionconnectabilitytest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsExtensionConnectAbilityTest" +} + +ohos_app_scope("actsextensionconnectabilitytest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsextensionconnectabilitytest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsextensionconnectabilitytest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsextensionconnectabilitytest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/Test.json b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..d8239bcb30fa3492098a8415759df374c9ad35ae --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/Test.json @@ -0,0 +1,42 @@ + +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.actsextensionconnectabilitytest", + "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": [ + "ActsExtensionConnectAbilityTest.hap", + "actsServiceAbilityRelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "PushKit", + "push": [ + "actsServiceAbilityRelyHap.hap->/data/app/actsServiceAbilityRelyHap.hap"] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 777 /data/app/*.hap" + ] + } + ] +} + diff --git a/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..d38bb6c9cfaf1ff168e13958c960eddb36f1f709 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/Application/AbilityStage.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. + */ +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.startnum = 0 + globalThis.stageContext = this.context; + + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..53688df76245c8f78d15ce89d5f1006c304bc066 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,55 @@ +/* + * 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("AbilityMultiInstanceTest onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("AbilityMultiInstanceTest onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("AbilityMultiInstanceTest onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("AbilityMultiInstanceTest onWindowStageDestroy") + } + + + onForeground() { + // Ability has brought to foreground + console.log("AbilityMultiInstanceTest onForeground") + } + + onBackground() { + // Ability has back to background + console.log("AbilityMultiInstanceTest onBackground") +} + +}; diff --git a/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..d6c2aa64061aab2b7730ab3e39e46af4196a7352 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,62 @@ +/* + * 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' +function publishCallBackOne () { + console.log("========Publish CallBack AMS_ConnectAbility_0300_commonEvent========"); +} +var conn = -1; +export default class ServiceAbility extends ServiceExtensionAbility { + 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 == "Three") { + console.log('connectAbility 111'); + let num = extensionContext.connectAbility( + { + bundleName: 'com.example.actsserviceabilityrelytest', + abilityName: 'com.example.actsserviceabilityrelytest.ServiceAbility' + }) + setTimeout(()=>{ + extensionContext.disconnectAbility(num).then(()=>{ + console.log('in disconnectAbility'); + }) + },1000) + + }; + commonEvent.publish("AMS_ConnectAbility_0300_commonEvent", publishCallBackOne); + + }; + + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} + diff --git a/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..60298e8adaeab8bfa4360309b6f1dc19d161965e --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/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/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..665ce17bbd41a334d2c6af4d8c6c63b7e937c165 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/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 commonEvent from '@ohos.commonevent' +function publishCallBackOne () { + console.log("========Publish CallBack AMS_ConnectAbility_0400_commonEvent========"); +} +var conn = -1; +export default class ServiceAbility2 extends ServiceExtensionAbility { + 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 + + console.log('connectAbility 222'); + let num = extensionContext.connectAbility( + { + bundleName: 'com.example.actsserviceabilityrelytest', + abilityName: 'com.example.actsserviceabilityrelytest.ServiceAbility' + }) + setTimeout(()=>{ + extensionContext.disconnectAbility(num).then(()=>{ + console.log('in disconnectAbility2'); + }) + },1000) + commonEvent.publish("AMS_ConnectAbility_0400_commonEvent", publishCallBackOne); + + }; + + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} + diff --git a/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/ServiceAbility2/service.ts b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..60298e8adaeab8bfa4360309b6f1dc19d161965e --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/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/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..74b56925172fb24e0c1cfea3c4793053a18335ed --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,52 @@ +/* + * 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) + 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('Hello World1111111') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/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/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..8ca5c0a649d0f1c1d950e83ba3787618ed18ba0a --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/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 './actsextensionconnectabilitytest.test.ets' +export default function testsuite(context) { + + abilityTest(context) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/test/actsextensionconnectabilitytest.test.ets b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/test/actsextensionconnectabilitytest.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..9c790e1f1c2eba363c3765f4102d8dcbf0f1ea72 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/ets/test/actsextensionconnectabilitytest.test.ets @@ -0,0 +1,291 @@ +/* + * 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"], +}; +const START_ABILITY_TIMEOUT = 5000; +globalThis.number = 0; + +export default function abilityTest(abilityContext) { + describe('ActsExtensionConnectAbilityTest', function () { + + it('ACTS_ConnectAbility_0300', 0, async function (done) { + console.log('ACTS_ConnectAbility_0300====ACTS_ConnectAbility_0300 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0100_commonEvent"); + console.debug("====>ACTS_ConnectAbility_0300 5 "); + abilityContext.disconnectAbility( + connId, + (err, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + err.code + " data: " + data) + } + ); + console.debug("====>ACTS_ConnectAbility_0300 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_0100).then(async (data) => { + console.debug("====>ACTS_ConnectAbility_0300 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack) + connId = await abilityContext.connectAbility({ + bundleName: "com.example.actsserviceabilityrelytest", + abilityName: "com.example.actsserviceabilityrelytest.ServiceAbility", + }, (err, data) => { + console.log('ACTS_ProcessManage SystemAppA onShowProcess startAbility startServiceAbility: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + }) + + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + setTimeout(() => { + done(); + }, 1000) + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ConnectAbility_0300 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + abilityContext.disconnectAbility( + connId, + (err, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + err.code + " data: " + data) + }); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.debug("====>ACTS_ConnectAbility_0300 4 "); + + }) + + it('ACTS_ConnectAbility_0400', 0, async function (done) { + console.log('ACTS_ConnectAbility_0400====ACTS_ConnectAbility_0400 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0200_commonEvent"); + console.debug("====>ACTS_ConnectAbility_0400 5 "); + abilityContext.disconnectAbility( + connId, + (err, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + err.code + " data: " + data) + } + ); + console.debug("====>ACTS_ConnectAbility_0400 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_0200).then(async (data) => { + console.debug("====>ACTS_ConnectAbility_0400 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + console.debug("====>ACTS_ConnectAbility_0400 3 "); + connId = await abilityContext.connectAbility({ + bundleName: "com.example.actsserviceabilityrelytest", + abilityName: "com.example.actsserviceabilityrelytest.ServiceAbility", + }, (err, data) => { + console.log('ACTS_ProcessManage SystemAppA onShowProcess startAbility startServiceAbility: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + console.debug("====>ACTS_ConnectAbility_0400 4 "); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + setTimeout(() => { + done(); + }, 1000) + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ConnectAbility_0400 timeout'); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + abilityContext.disconnectAbility( + connId, + (err, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + err.code + " data: " + data) + }); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + + }) + + it('ACTS_ExtensionConnectAbility_0300', 0, async function (done) { + console.log('ACTS_ExtensionConnectAbility_0300====ACTS_ExtensionConnectAbility_0300 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0300_commonEvent"); + console.debug("====>ACTS_ExtensionConnectAbility_0300 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ExtensionConnectAbility_0300 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_0300).then(async (data) => { + console.debug("====>ACTS_ExtensionConnectAbility_0300 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsextensionconnectabilitytest", + abilityName: "com.example.actsextensionconnectabilitytest.ServiceAbility", + action:"Three", + }).then(()=>{ + console.debug("====>startAbility end====>"); + }) + console.debug("====>ACTS_ExtensionConnectAbility_0300 4 "); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + setTimeout(() => { + done(); + }, 1000) + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ExtensionConnectAbility_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_ExtensionConnectAbility_0300 3 "); + + }) + + it('ACTS_ExtensionConnectAbility_0400', 0, async function (done) { + console.log('ACTS_ExtensionConnectAbility_0400====ACTS_ExtensionConnectAbility_0400 7 CallBack data:====>" + JSON.stringify(data)); + clearTimeout(id); + expect(data.event).assertEqual("AMS_ConnectAbility_0400_commonEvent"); + console.debug("====>ACTS_ExtensionConnectAbility_0400 5 "); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('featureAbilityTest DisconnectAbility result errCode : ' + error.code + " data: " + data) + } + ); + console.debug("====>ACTS_ExtensionConnectAbility_0400 6 "); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + + } + + + commonEvent.createSubscriber(subscriberInfoStartAbility_0400).then(async (data) => { + console.debug("====>ACTS_ExtensionConnectAbility_0400 2 Subscriber1====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + console.debug("====>ACTS_ExtensionConnectAbility_0400 3 "); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.actsextensionconnectabilitytest", + abilityName: "com.example.actsextensionconnectabilitytest.ServiceAbility2", + action:"Four", + }, + ); + console.debug("====>ACTS_ExtensionConnectAbility_0400 4 "); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe CallBack1====>"); + setTimeout(() => { + done(); + }, 1000) + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ExtensionConnectAbility_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); + + }) + + + + }) +} + + diff --git a/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/module.json b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..791a6b2649a45387be1f24c8a119a8019dde22dd --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/module.json @@ -0,0 +1,100 @@ +{ + "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.actsextensionconnectabilitytest.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.actsextensionconnectabilitytest.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + }, + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.example.actsextensionconnectabilitytest.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/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/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/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/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/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/actsextensionconnectabilitytest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/AppScope/app.json b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..ec8da706d2b5f623da6c5c90ed1b4ce459a12a40 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.actsserviceabilityrelytest", + "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/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/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/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/BUILD.gn b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..eeaa839ab5651544fceacb0492e3618fa45e35de --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/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("actsServiceAbilityRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsserviceabilityrelytest_js_assets", + ":actsserviceabilityrelytest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "actsServiceAbilityRelyHap" +} + +ohos_app_scope("actsserviceabilityrelytest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsserviceabilityrelytest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsserviceabilityrelytest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsserviceabilityrelytest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/Test.json b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..4300a64be9af93e37a31f6b5c6fc734e8f1b4563 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..51cb02ba3f5c7011c1cd433d07deebd47a195704 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,9 @@ +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..876e6b8f28fb52c0d1c52bf295e22c07e62a3fb8 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,45 @@ +import Ability from '@ohos.application.Ability' +import commonEvent from '@ohos.commonevent' +function publishCallBackOne () { + console.log("========Publish CallBack AMS_ConnectAbility_0200_commonEvent========"); +} +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("AbilityMultiInstanceTest onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("AbilityMultiInstanceTest onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("AbilityMultiInstanceTest onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("AbilityMultiInstanceTest onWindowStageDestroy") + } + + + onForeground() { + // Ability has brought to foreground + console.log("AbilityMultiInstanceTest onForeground") + commonEvent.publish("AMS_ConnectAbility_0200_commonEvent", publishCallBackOne); + } + + onBackground() { + // Ability has back to background + console.log("AbilityMultiInstanceTest onBackground") +} + +}; diff --git a/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..e0468359a039138e14f7387ace9083829d47604c --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,47 @@ +/* + * 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' +function publishCallBackOne () { + console.log("========Publish CallBack AMS_ConnectAbility_0100_commonEvent========"); +} +function publishCallBackTwo () { + console.log("========Publish CallBack AMS_ConnectAbility_0200_commonEvent========"); +} + +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.log('ServiceAbility onCreate, want: ' + want.abilityName); + } + + onRequest(want, startId) { + console.log('ServiceAbility onRequest, want: ' + want.abilityName + ', startId: ' + startId); + } + + onConnect(want) { + console.log('ServiceAbility onConnect, want:' + want.abilityName); + commonEvent.publish("AMS_ConnectAbility_0100_commonEvent", publishCallBackOne); + commonEvent.publish("AMS_ConnectAbility_0200_commonEvent", publishCallBackTwo); + }; + + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} + diff --git a/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..c35a26328215e619862c418e9d92a11e6fc85241 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,28 @@ + +/* + * 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('ACTS_ProcessManage ServiceAbility onStart'); + }, + onStop() { + console.info('ACTS_ProcessManage ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ACTS_ProcessManage ServiceAbility onCommand'); + }, + +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..244e5564eaec4b2f2286ef82d607c74d3622cf7f --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,65 @@ +/* + * 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" + + +@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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..1c1c727ff11ecc97909f482c35268db87ae23bb4 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/ets/pages/second/second.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@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/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/module.json b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..1312f59ebb9294e6e4e4bc8a1c9491054b946c8f --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/module.json @@ -0,0 +1,49 @@ +{ + "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.actsserviceabilityrelytest.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.actsserviceabilityrelytest.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ] + + } +} diff --git a/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/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/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/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/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/aafwk/aafwk_standard/actsusers/actsserviceabilityrelytest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/BUILD.gn b/aafwk/aafwk_standard/amscontextualinforquery/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..86a937f43e44cf990e3e51b24bf7b43e99df166b --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/BUILD.gn @@ -0,0 +1,32 @@ +# 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") + +group("amscontextualinforquery") { + testonly = true + if (is_standard_system) { + deps = [ + "actsamsextensionmodulehap:ActsAmsExtensionModuleRelyHap", + "actsamsstaticabilitystagecontexttest:ActsAmsStaticAbilityStageContextTest", + "actsamsstaticextensioninfohap:ActsAmsStaticExtensionInfoRelyHap", + "actsamsstaticextensioninfotest:ActsAmsStaticExtensionInfoTest", + "actsamsstatichapa:ActsAmsStaticARelyHap", + "actsamsstatichapb:ActsAmsStaticBRelyHap", + "actsamsstaticinfomationquerytest:ActsAmsStaticInfoMationQueryTest", + "actsamsstaticinformationmultipletest:ActsAmsStaticInformationMultipleTest", + "actsamsstaticinformationmultitest:ActsAmsStaticInformationMultiTest", + "actsamsstaticquerytesttwohap:ActsAmsStaticQueryTestTwoRelyHap", + ] + } +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/AppScope/app.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..584a67f5b5bb132615ff829664cd57d60fbb81e8 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.extensionmodule", + "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/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/BUILD.gn b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..360d5286174b91725f07b84aa736e5808b7d6dcc --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/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("ActsAmsExtensionModuleRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsextensionmodulerelyhap_js_assets", + ":actsamsextensionmodulerelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsExtensionModuleRelyHap" +} + +ohos_app_scope("actsamsextensionmodulerelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsextensionmodulerelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsextensionmodulerelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsextensionmodulerelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/Test.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..acbfa37240911791c0a2a6f43f3e0349c89729bd --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,99 @@ +/* + * 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 rpc from '@ohos.rpc' + +var connection = -1; +let options = { + onConnect: function(elementName, proxy) { + console.log("mxh onConnect success"); + if (proxy == null) { + console.log("mxh proxy == null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInt(1); + data.writeInt(99); + proxy.sendRequest(1, data, reply, option); + let msg = reply.readInt(); + console.log("mxh onConnect msg:" + msg); + }, + + onDisconnect: function() {console.log("mxh onDisconnect success");}, + onFailed: function() {console.log("mxh onFailed");} +} +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log('mxh MainAbility onCreate is called' + want + launchParam); + } + + onDestroy() { + console.log('mxh MainAbility onDestroy is called'); + } + + onWindowStageCreate(windowStage) { + console.log('mxh MainAbility onWindowStageCreate is called'); + let context = this.context; + globalThis.startServiceExtAbility = (() => { + console.log("mxh startServiceExtAbility begin"); + var want = { + "bundleName": "com.example.ohosproject.hmservice", + "abilityName": "ServiceExtAbility", + } + context.startAbility(want).then((data) => { + console.info("mxh startAbility success:" + JSON.stringify(data)); + }).catch((error) => { + console.error("mxh startAbility failed:" + JSON.stringify(error)); + }) + console.log("mxh startServiceExtAbility end"); + }) + + globalThis.connectServiceExtAbility = (() => { + console.log("mxh connectServiceExtAbility begin"); + var want = { + "bundleName": "com.example.ohosproject.hmservice", + "abilityName": "ServiceExtAbility", + } + connection = context.connectAbility(want, options); + console.log("mxh connectServiceExtAbility end, connection:" + connection); + }) + + globalThis.disconnectServiceExtAbility = (() => { + console.log("mxh disconnectServiceExtAbility begin"); + context.disconnectAbility(connection).then((data) => { + console.info("mxh startAbility success:" + JSON.stringify(data)); + }).catch((error) => { + console.error("mxh startAbility failed:" + JSON.stringify(error)); + }); + console.log("mxh disconnectServiceExtAbility end, connection:" + connection); + }) + + windowStage.setUIContent(this.context, 'pages/index/index', null); + } + + onWindowStageDestroy() { + console.log('mxh MainAbility onWindowStageDestroy is called'); + } + + onForeground() { + console.log('mxh MainAbility onForeground is called'); + } + + onBackground() { + console.log('mxh MainAbility onBackground is called'); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..c24854bcbb880b85d94c0723269765474872c39c --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Extension from '@ohos.application.ServiceExtensionAbility' +import commonEvent from '@ohos.commonevent' + + +export default class ServiceExtAbility extends Extension { + onCreate(want) { + console.info('mxh ServiceAbility onCreate**'); + + } + + onRequest(want, startId) { + console.info('mxh ServiceAbility onRequest**'); + } + + onConnect(want) { + console.info('mxh ServiceAbility onConnect**'); + commonEvent.publish("ACTS_ConnectAbility_0100_CommonEvent", { + parameters: { + extensionAbilityInfo : JSON.stringify(this.context.extensionAbilityInfo), + } + } ,(err) => { + console.log("Demo Publish CallBack MainAbility_Start_CommonEvent") + }); + console.log('Demo SerivceAbilityServer OnConnect start 1'); + } + + onDisconnect(want) { + console.info('mxh ServiceAbility onDisConnect**'); + } + + onDestroy() { + console.info('mxh ServiceAbility onDestroy**'); + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..b49731a414958a281c2f0c4eab0e7fb408eb2c2f --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..64c878fd512c758ba0b6d0fc2fcdb70bd127b4c7 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* + * 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/module.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..c7430ec217ebe78fb5bb9fadb1760fe164abd376 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/module.json @@ -0,0 +1,100 @@ +{ + "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.pmvendorappservice.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": [ + { + "name": "ServiceExtAbility", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "permissions": [ + "ohos.permission.USE_BLUETOOTH" + ], + "metadata": [ + { + "name": "ohos.extension.form", + "value": "MainAbility", + "resource": "@profile:form_config" + } + ], + "visible": true, + "type": "service" + } + ], + "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/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsextensionmodulehap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/AppScope/app.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..7504f565bdea43a23f545c402bf38a742eaaa505 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.staticabilitystagecontext", + "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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/BUILD.gn b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..912a2b7f15ae76682ac91ce3ac8184664cd70484 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/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("ActsAmsStaticAbilityStageContextTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsstaticabilitystagecontexttest_js_assets", + ":actsamsstaticabilitystagecontexttest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsStaticAbilityStageContextTest" +} + +ohos_app_scope("actsamsstaticabilitystagecontexttest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsstaticabilitystagecontexttest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsstaticabilitystagecontexttest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsstaticabilitystagecontexttest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/Test.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..de0174a486340672146f936f8166d4e69284d2dd --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/Test.json @@ -0,0 +1,37 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.staticabilitystagecontext", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsStaticAbilityStageContextTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsAmsStaticAbilityStageContextTest.hap->/data/ActsAmsStaticAbilityStageContextTest.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/test/*.hap" + ] + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..4ca5011008cfcf3af89fe1b915a9a284832631bd --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..2b6f72504aac2fbe391c0844d983d333bd40de33 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class 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.abilityStageContext = 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") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..15bb5b9d0b2f791ec430c1c2dab6c49a0286748f --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/pages/index/index.ets @@ -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 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityStageContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8bca86a74072422ddc9a0c5f08db3e8ef07edd84 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,177 @@ +/* + * 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" + + + +export default function abilityTest(abilityStageContext) { + describe('ActsAbilityStageContextTest', function () { + /** + * @tc.number: ACTS_getApplicationInfo_0300 + * @tc.name: Application query applicationInfo Static information. + * @tc.desc: Verify that the application query applicationInfo static + * information is the same as that in the configuration file. + */ + it('ACTS_getApplicationInfo_0300', 0, async function (done) { + console.log("ACTS_getApplicationInfo_0300 --- start ability=====>'+ abilityContext.applicationInfo") + checkApplicationInfo(abilityStageContext.applicationInfo); + done(); + }) + + /** + * @tc.number: ACTS_getHapModuleInfo_0300 + * @tc.name: Application query currentHapModuleInfo Static information. + * @tc.desc: Verify that the application query currentHapModuleInfo static + * information is the same as that in the configuration file. + */ + it('ACTS_getHapModuleInfo_0300', 0, async function (done) { + console.log("ACTS_getHapModuleInfo_0300 --- start ability=====>'+ abilityContext.currentHapModuleInfo") + checkHapModuleInfo(abilityStageContext.currentHapModuleInfo); + done(); + }) + + function checkApplicationInfo(data) { + console.log("checkApplicationInfo start " + data); + console.log("checkApplicationInfo name : " + data.name); + console.log("checkApplicationInfo description : " + data.description); + console.log("checkApplicationInfo descriptionId : " + data.descriptionId); + console.log("checkApplicationInfo systemApp : " + data.systemApp); + console.log("checkApplicationInfo enabled : " + data.enabled); + console.log("checkApplicationInfo label : " + data.label) + console.log("checkApplicationInfo labelId : " + data.labelId); + console.log("checkApplicationInfo icon : " + data.icon); + console.log("checkApplicationInfo iconId : " + data.iconId); + console.log("checkApplicationInfo process : " + data.process); + console.log("checkApplicationInfo supportedModes : " + data.supportedModes); + console.log("checkApplicationInfo moduleSourceDirs length : " + data.moduleSourceDirs.length); + for (var j = 0; j < data.moduleSourceDirs.length; j++) { + console.log("checkApplicationInfo data.moduleSourceDirs[" + j + "] : " + data.moduleSourceDirs[j]); + } + console.log("checkApplicationInfo permissions length : " + data.permissions.length); + for (var j = 0; j < data.permissions.length; j++) { + console.log("checkApplicationInfo data.permissions[" + j + "] : " + data.permissions[j]); + } + console.log("checkApplicationInfo moduleInfos length : " + data.moduleInfos.length); + for (var j = 0; j < data.moduleInfos.length; j++) { + console.log("checkApplicationInfo data.moduleInfos[" + j + "].moduleName : " + + data.moduleInfos[j].moduleName); + console.log("checkApplicationInfo data.moduleInfos[" + j + "].moduleSourceDir : " + + data.moduleInfos[j].moduleSourceDir); + } + console.log("checkApplicationInfo entryDir : " + data.entryDir); + console.log("checkApplicationInfo codePath : " + data.codePath); + console.log("checkApplicationInfo removable: " + data.removable); + + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.systemApp)).assertEqual("boolean"); + expect(typeof (data.enabled)).assertEqual("boolean"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.iconId)).assertEqual("string"); + expect(typeof (data.process)).assertEqual("string"); + expect(typeof (data.supportedModes)).assertEqual("number"); + expect(Array.isArray(data.moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.moduleInfos)).assertEqual(true); + expect(typeof (data.entryDir)).assertEqual("string"); + expect(typeof (data.codePath)).assertEqual("string"); + expect(typeof (data.removable)).assertEqual("boolean"); + + console.log("checkApplicationInfo_expect_typeof_end") + expect(data.name).assertEqual("com.example.staticabilitystagecontext"); + expect(data.description).assertEqual("$string:description_application"); + expect(data.descriptionId).assertLarger(0); + expect(data.systemApp).assertEqual(true); + expect(data.enabled).assertEqual(true); + expect(data.label).assertEqual("$string:app_name"); + expect(data.labelId.length).assertLarger(0); + expect(data.icon).assertEqual(""); + expect(data.iconId.length).assertLarger(0); + expect(data.process).assertEqual(""); + expect(data.supportedModes).assertEqual(0); + expect(data.moduleSourceDirs.length).assertEqual(1); + expect(data.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/" + + "com.example.staticabilitystagecontext/com.example.staticabilitystagecontext"); + expect(data.moduleInfos.length).assertEqual(1); + expect(data.moduleInfos[0].moduleName).assertEqual("com.example.staticabilitystagecontext"); + expect(data.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.example.staticabilitystagecontext/com.example.staticabilitystagecontext"); + expect(data.entryDir).assertEqual("/data/app/el1/bundle/public/" + + "com.example.staticabilitystagecontext/com.example.staticabilitystagecontext"); + expect(data.codePath).assertEqual("/data/app/el1/bundle/public/" + + "com.example.staticabilitystagecontext"); + expect(data.removable).assertEqual(true); + console.log("checkApplicationInfo end " + data); + } + function checkHapModuleInfo(data) { + console.log("checkHapModuleInfo start " + data); + console.log("checkHapModuleInfo name : " + data.name); + console.log("checkHapModuleInfo description : " + data.description); + console.log("checkHapModuleInfo descriptionId : " + data.descriptionId); + console.log("checkHapModuleInfo icon : " + data.icon); + console.log("checkHapModuleInfo label : " + data.label); + console.log("checkHapModuleInfo labelId : " + data.labelId); + console.log("checkHapModuleInfo iconId : " + data.iconId); + console.log("checkHapModuleInfo backgroundImg : " + data.backgroundImg); + console.log("checkHapModuleInfo supportedModes : " + data.supportedModes); + console.log("checkHapModuleInfo reqCapabilities length : " + data.reqCapabilities.length); + for (var j = 0; j < data.reqCapabilities.length; j++) { + console.log("checkHapModuleInfo data.reqCapabilities[" + j + "] : " + data.reqCapabilities[j]); + } + console.log("checkHapModuleInfo deviceTypes length : " + data.deviceTypes.length); + for (var j = 0; j < data.deviceTypes.length; j++) { + console.log("checkHapModuleInfo data.deviceTypes[" + j + "] : " + data.deviceTypes[j]); + } + console.log("checkHapModuleInfo moduleName : " + data.moduleName); + console.log("checkHapModuleInfo mainAbilityName : " + data.mainAbilityName); + console.log("checkHapModuleInfo installationFree : " + data.installationFree); + + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.backgroundImg)).assertEqual("string"); + expect(typeof (data.supportedModes)).assertEqual("number"); + expect(Array.isArray(data.reqCapabilities)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.abilityInfo)).assertEqual(true); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.mainAbilityName)).assertEqual("string"); + console.log("checkHapModuleInfo_expect_typeof_end") + expect(data.name).assertEqual("com.example.staticabilitystagecontext"); + expect(data.description).assertEqual("$string:phone_entry_dsc"); + expect(data.descriptionId).assertEqual(undefined); + expect(data.icon).assertEqual("$media:icon"); + expect(data.label).assertEqual("$string:entry_label"); + expect(data.labelId).assertEqual(undefined); + expect(data.iconId).assertEqual(undefined); + expect(data.backgroundImg).assertEqual(""); + expect(data.supportedModes).assertEqual(0); + expect(data.reqCapabilities.length).assertEqual(0); + expect(data.reqCapabilities[0]).assertEqual(undefined); + expect(data.deviceTypes.length).assertEqual(1); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(data.moduleName).assertEqual("com.example.staticabilitystagecontext") + expect(data.mainAbilityName).assertEqual("MainAbility"); + expect(data.installationFree).assertEqual(undefined); + console.log("checkHapModuleInfo end " + data); + } + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..882f978e77b1a8fbbf843ccb4dd73c47ed460305 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/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 './Ability.test.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/module.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..c3fd9d3d85c818b4b098acd270c2ef53b3a62a13 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/module.json @@ -0,0 +1,79 @@ +{ + "module": { + "name": "com.example.staticabilitystagecontext", + "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.staticabilitystagecontext.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" + ] + } + ] + } + ], + "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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticabilitystagecontexttest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/AppScope/app.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..ca8f7004d343c7f10966e3e83685fffad86cb6e1 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.staticextensioninfotest", + "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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/BUILD.gn b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..73fef6379681ae8e6c33dd92041162ae91ce012c --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/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("ActsAmsStaticExtensionInfoRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsstaticextensioninforelyhap_js_assets", + ":actsamsstaticextensioninforelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsStaticExtensionInfoRelyHap" +} + +ohos_app_scope("actsamsstaticextensioninforelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsstaticextensioninforelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsstaticextensioninforelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsstaticextensioninforelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/Test.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..5b95af0dbbe7e5517cc22a1f0f054c01aeae64a1 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/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("ACTS_ProcessManage VendorAppService MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ACTS_ProcessManage VendorAppService MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ACTS_ProcessManage VendorAppService 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("ACTS_ProcessManage VendorAppService MainAbility onWindowStageDestroy") + } + + async onForeground() { + // Ability has brought to foreground + console.log("ACTS_ProcessManage VendorAppService MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("ACTS_ProcessManage VendorAppService MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..41e451c73eceee46e6fd5567b6e65ecc9bfcf9cf --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/ServiceAbility/ServiceAbility.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 ServiceExtension from '@ohos.application.ServiceExtensionAbility' +import commonEvent from "@ohos.commonevent" + +export default class ServiceAbility extends ServiceExtension { + onCreate(want,startId) { + globalThis.abilityWant = want; + console.log('ServiceAbility onCreate, want: ' + want.abilityName); + } + + onRequest(want, startId) { + console.log('ServiceAbility onRequest, want: ' + want.abilityName + ', startId: ' + startId); + } + + onConnect(want) { + console.log('ServiceAbility2 onConnect, abilityName:' + want.abilityName); + console.log('ServiceAbility2 onConnect, action:' + want.action); + globalThis.extensionContext = this.context + if (want.action == 'getExtensionInfoTest') { + commonEvent.publish("ACTS_ConnectAbility_0200_CommonEvent", { + parameters: { + hapModuleInfo2: JSON.stringify(this.context.currentHapModuleInfo), + applicationInfo2: JSON.stringify(this.context.applicationInfo) + } + } ,(err) => { + console.log("MainAbility Publish CallBack MainAbility_Start_CommonEvent") + }); + console.log('stub SerivceAbilityServer OnConnect start 2'); + } + } + + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..b49731a414958a281c2f0c4eab0e7fb408eb2c2f --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..64c878fd512c758ba0b6d0fc2fcdb70bd127b4c7 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* + * 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/module.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..e26e51946e95afa2320d70e3791c6ee7bf2e1699 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/module.json @@ -0,0 +1,90 @@ +{ + "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.staticextensioninfotest.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.staticextensioninfotest.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ], + "requestPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "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.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + } + ] + } +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfohap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/AppScope/app.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..60257b2cb7989a7a152312f31af75027d517ccac --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.staticextensioninfo", + "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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/BUILD.gn b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f525fd441cb07cdf74e62e1168ae949fc27529b1 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/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("ActsAmsStaticExtensionInfoTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsstaticextensiontnfotest_js_assets", + ":actsamsstaticextensiontnfotest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsStaticExtensionInfoTest" +} + +ohos_app_scope("actsamsstaticextensiontnfotest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsstaticextensiontnfotest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsstaticextensiontnfotest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsstaticextensiontnfotest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/Test.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..cf48a8c6b27c619923e7cd0833572cba4d686fea --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/Test.json @@ -0,0 +1,41 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.staticextensioninfo", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsStaticExtensionInfoTest.hap", + "ActsAmsStaticExtensionInfoRelyHap.hap", + "ActsAmsExtensionModuleRelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsAmsStaticExtensionInfoTest.hap->/data/ActsAmsStaticExtensionInfoTest.hap", + "ActsAmsStaticExtensionInfoRelyHap.hap->/data/ActsAmsStaticExtensionInfoRelyHap.hap", + "ActsAmsExtensionModuleRelyHap.hap->/data/ActsAmsExtensionModuleRelyHap.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/test/*.hap" + ] + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3c7ec92d3b6040b67f3e0634f09c004da1fe867 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/Application/AbilityStage.ts @@ -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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("MyAbilityStage onCreate") + globalThis.stageContext = this.context; + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..10dd9a1eaff7ad67843219facba7f8aea7b5a1a5 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class 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") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..350d0bf3c7340c44b07029aebd2dbc332b2fab67 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,54 @@ +/* + * 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" + +export default class ServiceAbility extends ServiceExtension { + onCreate(want,startId) { + globalThis.abilityWant = 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'); + } + + onConnect(want) { + console.log('ServiceAbility onConnect, want:' + want.abilityName); + globalThis.extensionContext = this.context + if (want.action == 'getExtensionInfo') { + commonEvent.publish("ACTS_ConnectAbility_0100_CommonEvent", { + parameters: { + hapModuleInfo: JSON.stringify(this.context.currentHapModuleInfo), + applicationInfo: JSON.stringify(this.context.applicationInfo), + } + } ,(err) => { + console.log("MainAbility Publish CallBack MainAbility_Start_CommonEvent") + }); + console.log('stub SerivceAbilityServer OnConnect start 1'); + } + + } + + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..b49731a414958a281c2f0c4eab0e7fb408eb2c2f --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..577f53879917d26276c6ef294f65d9d044533161 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/pages/index/index.ets @@ -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 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..12b8424e4dba4ba2a47828e7c0e62261f0cebdfc --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,471 @@ +/* + * 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 commonEvent from "@ohos.commonevent" +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + +const START_ABILITY_TIMEOUT = 5000; +var subscriberInfoStartAbility_0100 = { + events: ["ACTS_ConnectAbility_0100_CommonEvent"], +}; +var subscriberInfoStartAbility_0200 = { + events: ["ACTS_ConnectAbility_0200_CommonEvent"], +}; + +export default function abilityTest(abilityContext) { + + describe('ActsExtensionAbilityTest', function () { + + /* + * @tc.number: ACTS_getExtensionInfo_0100 + * @tc.name: Start the system permission application to query static information about Extension + * @tc.desc: Enable application ras to query the Extension static information. Verify the query information. + Enable application ras to connect to serviceAbility + */ + it('ACTS_getExtensionInfo_0100', 0, async function (done) { + console.log('ACTS_getExtensionInfo_0100 gyq ====ACTS_getExtensionInfo_0100_Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ACTS_ConnectAbility_0100_CommonEvent") { + clearTimeout(id); + checkHapModuleInfo(JSON.parse(data.parameters['hapModuleInfo'])) + checkApplicationInfo(JSON.parse(data.parameters['applicationInfo'])) + expect(data.event).assertEqual("ACTS_ConnectAbility_0100_CommonEvent"); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + done(); + } + } + commonEvent.createSubscriber(subscriberInfoStartAbility_0100).then(async (data) => { + console.debug("====>ACTS_getExtensionInfo_0100_Create Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.staticextensioninfo", + abilityName: "com.example.staticextensioninfo.ServiceAbility", + action: "getExtensionInfo" + } + ); + console.log('ACTS_getExtensionInfo_0100 ConnectAbility connId : ' + connId); + }) + + function unSubscribeCallback() { + console.debug("====>ACTS_getExtensionInfo_0100_UnSubscribe CallBack====>"); + done(); + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ConnectAbility_0100 timeout'); + done(); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + + + function checkHapModuleInfo(data) { + console.log("checkHapModuleInfo start " + data); + console.log("checkHapModuleInfo name : " + data.name); + console.log("checkHapModuleInfo description : " + data.description); + console.log("checkHapModuleInfo descriptionId : " + data.descriptionId); + console.log("checkHapModuleInfo icon : " + data.icon); + console.log("checkHapModuleInfo label : " + data.label); + console.log("checkHapModuleInfo labelId : " + data.labelId); + console.log("checkHapModuleInfo iconId : " + data.iconId); + console.log("checkHapModuleInfo backgroundImg : " + data.backgroundImg); + console.log("checkHapModuleInfo supportedModes : " + data.supportedModes); + console.log("checkHapModuleInfo reqCapabilities length : " + data.reqCapabilities.length); + for (var j = 0; j < data.reqCapabilities.length; j++) { + console.log("checkHapModuleInfo data.reqCapabilities[" + j + "] : " + data.reqCapabilities[j]); + } + console.log("checkHapModuleInfo deviceTypes length : " + data.deviceTypes.length); + for (var j = 0; j < data.deviceTypes.length; j++) { + console.log("checkHapModuleInfo data.deviceTypes[" + j + "] : " + data.deviceTypes[j]); + } + console.log("checkHapModuleInfo moduleName : " + data.moduleName); + console.log("checkHapModuleInfo mainAbilityName : " + data.mainAbilityName); + console.log("checkHapModuleInfo installationFree : " + data.installationFree); + + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.backgroundImg)).assertEqual("string"); + expect(typeof (data.supportedModes)).assertEqual("number"); + expect(Array.isArray(data.reqCapabilities)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.abilityInfo)).assertEqual(true); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.mainAbilityName)).assertEqual("string"); + console.log("checkHapModuleInfo_expect_typeof_end") + expect(data.name).assertEqual("phone"); + expect(data.description).assertEqual("$string:phone_entry_dsc"); + expect(data.descriptionId).assertEqual(undefined); + expect(data.icon).assertEqual("$media:icon"); + expect(data.label).assertEqual("$string:entry_label"); + expect(data.labelId).assertEqual(undefined); + expect(data.iconId).assertEqual(undefined); + expect(data.backgroundImg).assertEqual(""); + expect(data.supportedModes).assertEqual(0); + expect(data.reqCapabilities.length).assertEqual(0); + expect(data.reqCapabilities[0]).assertEqual(undefined); + expect(data.deviceTypes.length).assertEqual(1); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(data.moduleName).assertEqual("phone") + expect(data.mainAbilityName).assertEqual("MainAbility"); + expect(data.installationFree).assertEqual(undefined); + console.log("checkHapModuleInfo end " + data); + } + function checkApplicationInfo(data) { + console.log("checkApplicationInfo start " + data); + console.log("checkApplicationInfo name : " + data.name); + console.log("checkApplicationInfo description : " + data.description); + console.log("checkApplicationInfo descriptionId : " + data.descriptionId); + console.log("checkApplicationInfo systemApp : " + data.systemApp); + console.log("checkApplicationInfo enabled : " + data.enabled); + console.log("checkApplicationInfo label : " + data.label) + console.log("checkApplicationInfo labelId : " + data.labelId); + console.log("checkApplicationInfo icon : " + data.icon); + console.log("checkApplicationInfo iconId : " + data.iconId); + console.log("checkApplicationInfo process : " + data.process); + console.log("checkApplicationInfo supportedModes : " + data.supportedModes); + console.log("checkApplicationInfo moduleSourceDirs length : " + data.moduleSourceDirs.length); + for (var j = 0; j < data.moduleSourceDirs.length; j++) { + console.log("checkApplicationInfo data.moduleSourceDirs[" + j + "] : " + data.moduleSourceDirs[j]); + } + console.log("checkApplicationInfo permissions length : " + data.permissions.length); + for (var j = 0; j < data.permissions.length; j++) { + console.log("checkApplicationInfo data.permissions[" + j + "] : " + data.permissions[j]); + } + console.log("checkApplicationInfo moduleInfos length : " + data.moduleInfos.length); + for (var j = 0; j < data.moduleInfos.length; j++) { + console.log("checkApplicationInfo data.moduleInfos[" + j + "].moduleName : " + data.moduleInfos[j].moduleName); + console.log("checkApplicationInfo data.moduleInfos[" + j + "].moduleSourceDir:" + + data.moduleInfos[j].moduleSourceDir); + } + console.log("checkApplicationInfo entryDir : " + data.entryDir); + console.log("checkApplicationInfo codePath : " + data.codePath); + console.log("checkApplicationInfo removable: " + data.removable); + + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.systemApp)).assertEqual("boolean"); + expect(typeof (data.enabled)).assertEqual("boolean"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.iconId)).assertEqual("string"); + expect(typeof (data.process)).assertEqual("string"); + expect(typeof (data.supportedModes)).assertEqual("number"); + expect(Array.isArray(data.moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.moduleInfos)).assertEqual(true); + expect(typeof (data.entryDir)).assertEqual("string"); + expect(typeof (data.codePath)).assertEqual("string"); + expect(typeof (data.removable)).assertEqual("boolean"); + console.log("checkApplicationInfo_expect_typeof_end") + expect(data.name).assertEqual("com.example.staticextensioninfo"); + expect(data.description).assertEqual("$string:description_application"); + expect(data.descriptionId).assertLarger(0); + expect(data.systemApp).assertEqual(true); + expect(data.enabled).assertEqual(true); + expect(data.label).assertEqual("$string:app_name"); + expect(data.labelId).assertEqual("16777216"); + expect(data.icon).assertEqual(""); + expect(data.iconId).assertEqual("16777224"); + expect(data.process).assertEqual(""); + expect(data.supportedModes).assertEqual(0); + expect(data.moduleSourceDirs.length).assertEqual(1); + expect(data.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/" + + "com.example.staticextensioninfo/phone"); + expect(data.moduleInfos.length).assertEqual(1); + expect(data.moduleInfos[0].moduleName).assertEqual("phone"); + expect(data.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.example.staticextensioninfo/phone"); + expect(data.entryDir).assertEqual("/data/app/el1/bundle/public/com.example.staticextensioninfo" + + "/phone"); + expect(data.codePath).assertEqual("/data/app/el1/bundle/public/com.example.staticextensioninfo"); + expect(data.removable).assertEqual(true); + console.log("checkApplicationInfo end " + data); + } + }) + + /* + * @tc.number: ACTS_getExtensionInfo_0200 + * @tc.name: Apply StaticExtensionInfo. Connect to StaticExtensionInfoTest to query static information + about an Extension + * @tc.desc: Enabling an application to connect to StaticExtensionInfo. Connecting to StaticExtensionInfoTest + To query static information about an Extension. Verifying the query information + */ + it('ACTS_getExtensionInfo_0200', 0, async function (done) { + console.log('ACTS_getExtensionInfo_0200====ACTS_getExtensionInfo_0200_Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ACTS_ConnectAbility_0200_CommonEvent") { + clearTimeout(id); + checkHapModuleInfo_0200(JSON.parse(data.parameters['hapModuleInfo2'])) + checkApplicationInfo_0200(JSON.parse(data.parameters['applicationInfo2'])) + expect(data.event).assertEqual("ACTS_ConnectAbility_0200_CommonEvent"); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } + } + commonEvent.createSubscriber(subscriberInfoStartAbility_0200).then(async (data) => { + console.debug("====>ACTS_getExtensionInfo_0200_Create Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack);. + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.staticextensioninfotest", + abilityName: "com.example.staticextensioninfotest.ServiceAbility", + action: "getExtensionInfoTest" + } + ); + console.log('ACTS_getExtensionInfo_0200 ConnectAbility connId : ' + connId); + }) + + function unSubscribeCallback() { + console.debug("====>ACTS_getExtensionInfo_0200_UnSubscribe CallBack====>"); + done(); + } + + function timeout() { + expect().assertFail(); + console.debug('ACTS_ConnectAbility_0200 timeout'); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + + + function checkHapModuleInfo_0200(data) { + console.log("checkHapModuleInfo2 start " + data); + console.log("checkHapModuleInfo2 name : " + data.name); + console.log("checkHapModuleInfo2 description : " + data.description); + console.log("checkHapModuleInfo2 descriptionId : " + data.descriptionId); + console.log("checkHapModuleInfo2 icon : " + data.icon); + console.log("checkHapModuleInfo2 label : " + data.label); + console.log("checkHapModuleInfo2 labelId : " + data.labelId); + console.log("checkHapModuleInfo2 iconId : " + data.iconId); + console.log("checkHapModuleInfo2 backgroundImg : " + data.backgroundImg); + console.log("checkHapModuleInfo2 supportedModes : " + data.supportedModes); + console.log("checkHapModuleInfo2 reqCapabilities length : " + data.reqCapabilities.length); + for (var j = 0; j < data.reqCapabilities.length; j++) { + console.log("checkHapModuleInfo2 data.reqCapabilities[" + j + "] : " + data.reqCapabilities[j]); + } + console.log("checkHapModuleInfo2 deviceTypes length : " + data.deviceTypes.length); + for (var j = 0; j < data.deviceTypes.length; j++) { + console.log("checkHapModuleInfo2 data.deviceTypes[" + j + "] : " + data.deviceTypes[j]); + } + console.log("checkHapModuleInfo2 moduleName : " + data.moduleName); + console.log("checkHapModuleInfo2 mainAbilityName : " + data.mainAbilityName); + console.log("checkHapModuleInfo2 installationFree : " + data.installationFree); + + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.backgroundImg)).assertEqual("string"); + expect(typeof (data.supportedModes)).assertEqual("number"); + expect(Array.isArray(data.reqCapabilities)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.abilityInfo)).assertEqual(true); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.mainAbilityName)).assertEqual("string"); + console.log("checkHapModuleInfo_expect_typeof_end") + expect(data.name).assertEqual("phone"); + expect(data.description).assertEqual("$string:phone_entry_dsc"); + expect(data.descriptionId).assertEqual(undefined); + expect(data.icon).assertEqual("$media:icon"); + expect(data.label).assertEqual("$string:entry_label"); + expect(data.labelId).assertEqual(undefined); + expect(data.iconId).assertEqual(undefined); + expect(data.backgroundImg).assertEqual(""); + expect(data.supportedModes).assertEqual(0); + expect(data.reqCapabilities.length).assertEqual(0); + expect(data.reqCapabilities[0]).assertEqual(undefined); + expect(data.deviceTypes.length).assertEqual(1); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(data.moduleName).assertEqual("phone") + expect(data.mainAbilityName).assertEqual("MainAbility"); + expect(data.installationFree).assertEqual(undefined); + console.log("checkHapModuleInfo end " + data); + } + function checkApplicationInfo_0200(data) { + console.log("checkApplicationInfo2 start " + data); + console.log("checkApplicationInfo2 name : " + data.name); + console.log("checkApplicationInfo2 description : " + data.description); + console.log("checkApplicationInfo2 descriptionId : " + data.descriptionId); + console.log("checkApplicationInfo2 systemApp : " + data.systemApp); + console.log("checkApplicationInfo2 enabled : " + data.enabled); + console.log("checkApplicationInfo2 label : " + data.label) + console.log("checkApplicationInfo2 labelId : " + data.labelId); + console.log("checkApplicationInfo2 icon : " + data.icon); + console.log("checkApplicationInfo2 iconId : " + data.iconId); + console.log("checkApplicationInfo2 process : " + data.process); + console.log("checkApplicationInfo2 supportedModes : " + data.supportedModes); + console.log("checkApplicationInfo2 moduleSourceDirs length : " + data.moduleSourceDirs.length); + for (var j = 0; j < data.moduleSourceDirs.length; j++) { + console.log("checkApplicationInfo2 data.moduleSourceDirs[" + j + "] : " + data.moduleSourceDirs[j]); + } + console.log("checkApplicationInfo2 permissions length : " + data.permissions.length); + for (var j = 0; j < data.permissions.length; j++) { + console.log("checkApplicationInfo2 data.permissions[" + j + "] : " + data.permissions[j]); + } + console.log("checkApplicationInfo2 moduleInfos length : " + data.moduleInfos.length); + for (var j = 0; j < data.moduleInfos.length; j++) { + console.log("checkApplicationInfo2 data.moduleInfos[" + j + "].moduleName : " + data.moduleInfos[j].moduleName); + console.log("checkApplicationInfo2 data.moduleInfos[" + j + "].moduleSourceDir:" + + data.moduleInfos[j].moduleSourceDir); + } + console.log("checkApplicationInfo2 entryDir : " + data.entryDir); + console.log("checkApplicationInfo2 codePath : " + data.codePath); + console.log("checkApplicationInfo2 removable: " + data.removable); + + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.systemApp)).assertEqual("boolean"); + expect(typeof (data.enabled)).assertEqual("boolean"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.iconId)).assertEqual("string"); + expect(typeof (data.process)).assertEqual("string"); + expect(typeof (data.supportedModes)).assertEqual("number"); + expect(Array.isArray(data.moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.moduleInfos)).assertEqual(true); + expect(typeof (data.entryDir)).assertEqual("string"); + expect(typeof (data.codePath)).assertEqual("string"); + expect(typeof (data.removable)).assertEqual("boolean"); + console.log("checkApplicationInfo_expect_typeof_end") + expect(data.name).assertEqual("com.example.staticextensioninfotest"); + expect(data.description).assertEqual("$string:description_application"); + expect(data.descriptionId).assertLarger(0); + expect(data.systemApp).assertEqual(true); + expect(data.enabled).assertEqual(true); + expect(data.label).assertEqual("$string:app_name"); + expect(data.labelId.length).assertLarger(0); + expect(data.icon).assertEqual(""); + expect(data.iconId.length).assertLarger(0); + expect(data.process).assertEqual(""); + expect(data.supportedModes).assertEqual(0); + expect(data.moduleSourceDirs.length).assertEqual(1); + expect(data.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/" + + "com.example.staticextensioninfotest/phone"); + expect(data.moduleInfos.length).assertEqual(1); + expect(data.moduleInfos[0].moduleName).assertEqual("phone"); + expect(data.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.example.staticextensioninfotest/phone"); + expect(data.entryDir).assertEqual("/data/app/el1/bundle/public/com.example.staticextensioninfotest" + + "/phone"); + expect(data.codePath).assertEqual("/data/app/el1/bundle/public/com.example.staticextensioninfotest"); + expect(data.removable).assertEqual(true); + console.log("checkApplicationInfo end " + data); + } + }) + + /* + * @tc.number: ACTS_getExtensionInfo_0300 + * @tc.name: Apply StaticExtensionInfo. Connect to StaticExtensionInfoTest to query static information + about an Extension + * @tc.desc: Verify configuration module.json connect service application query property information + */ + it('ACTS_getExtensionInfo_0300', 0, async function (done) { + console.log('ACTS_getExtensionInfo_0300====ACTS_getExtensionInfo_0300_Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ACTS_ConnectAbility_0100_CommonEvent") { + clearTimeout(id); + checkExtensionAbilityInfo(JSON.parse(data.parameters['extensionAbilityInfo'])) + expect(data.event).assertEqual("ACTS_ConnectAbility_0100_CommonEvent"); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + done(); + } + } + commonEvent.createSubscriber(subscriberInfoStartAbility_0100).then(async (data) => { + console.debug("====>ACTS_getExtensionInfo_0300_Create Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.extensionmodule", + abilityName: "ServiceExtAbility", + } + ); + console.log('ACTS_getExtensionInfo_0300 ConnectAbility connId : ' + connId); + }) + + function unSubscribeCallback() { + console.debug("====>ACTS_getExtensionInfo_0300_UnSubscribe CallBack====>"); + } + + function timeout() { + expect().assertFail(); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('DisconnectAbility_0300 result errCode : ' + error.code + " data: " + data) + done(); + }, + ); + console.debug('ACTS_ConnectAbility_0300 timeout'); + done(); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + + + function checkExtensionAbilityInfo(data) { + console.log("checkHapModuleInfo_expect_typeof_end3") + console.log("checkAbilityInfo metadata length : " + data.metadata.length); + console.log("checkAbilityInfo metadata length : " + data.metadata[0].name); + expect(data.metadata[0].name).assertEqual("ohos.extension.form"); + expect(data.metadata[0].value).assertEqual("MainAbility"); + expect(data.metadata[0].resource).assertEqual("@profile:form_config"); + expect(data.bundleName).assertEqual("com.example.extensionmodule"); + expect(data.moduleName).assertEqual("phone"); + expect(data.name).assertEqual("ServiceExtAbility"); + expect(data.permissions.length).assertEqual(1); + expect(data.permissions[0]).assertEqual("ohos.permission.USE_BLUETOOTH"); + expect(data.isVisible).assertEqual(true); + expect(data.extensionAbilityType).assertLarger(0); + expect(data.readPermission).assertEqual(""); + expect(data.writePermission).assertEqual(""); + expect(data.enabled).assertEqual(true) + console.log("checkExtensionAbilityInfo3 end " + data); + } + }) + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..882f978e77b1a8fbbf843ccb4dd73c47ed460305 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/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 './Ability.test.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/module.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..0fb12a5a8e89cbba99e1a8e5f08b874681e3e67b --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/module.json @@ -0,0 +1,94 @@ +{ + "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.staticextensioninfo.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.staticextensioninfo.ServiceAbility", + "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.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.USE_BLUETOOTH", + "reason":"need use ohos.permission.USE_BLUETOOTH" + } + ] + } +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticextensioninfotest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/AppScope/app.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..51ee16f27e59280d635c2735b336a197fbdd1266 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.staticinformationmultihappackage", + "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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/BUILD.gn b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..2e0822e7659a40f014de29c173e08b1b63da6374 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/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("ActsAmsStaticARelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsstaticarelyhap_js_assets", + ":actsamsstaticarelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsStaticARelyHap" +} + +ohos_app_scope("actsamsstaticarelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsstaticarelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsstaticarelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsstaticarelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/Test.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1fa1d96e06db9a3f2e81e4e7ea8403cb472b49cc --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,83 @@ +/* + * 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 MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("ACTS_getAbilityInfo_0400 MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ACTS_getAbilityInfo_0400 MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ACTS_getAbilityInfo_0400 MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("ACTS_getAbilityInfo_0400 MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("ACTS_getAbilityInfo_0400 MainAbility onForeground") + if (globalThis.abilityWant.action == 'startHapA') { + globalThis.abilityContext.startAbility({ + bundleName: "com.example.staticinformationmultihappackage", + abilityName: "com.example.feature.MainAbility", + action: "startHapB" + }, (error, data) => { + console.log('ACTS_getAbilityInfo_0400 MainAbility onForeground - startAbility restart singleton: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + commonEvent.publish("MainAbility_Start_CommonEvent_multi_hap_entry", { + parameters: { + hapModuleInfo: JSON.stringify(globalThis.abilityContext.currentHapModuleInfo), + applicationInfo: JSON.stringify(globalThis.abilityContext.applicationInfo), + abilityInfo: JSON.stringify(globalThis.abilityContext.abilityInfo) + } + }, (err) => { + console.log("ACTS_getAbilityInfo_0400 MainAbility Publish CallBack onForeground") + }); + } + console.log("ACTS_getAbilityInfo_0400 MainAbility onForeground") + + if (globalThis.abilityWant.action == 'multiple') { + commonEvent.publish("MainAbility_Start_CommonEvent_multiple_hap_entry", { + parameters: { + hapModuleInfo: JSON.stringify(globalThis.abilityContext.currentHapModuleInfo), + applicationInfo: JSON.stringify(globalThis.abilityContext.applicationInfo), + abilityInfo: JSON.stringify(globalThis.abilityContext.abilityInfo) + } + }, (err) => { + console.log("ACTS_getAbilityInfo_0400 MainAbility Publish CallBack onForeground") + }); + } + } + + onBackground() { + // Ability has back to background + console.log("ACTS_getAbilityInfo_0400 MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b4d13665a43355326d696a631eb752ffc191d41e --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,38 @@ + +/* + * 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/module.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..0cd086184c1bc7228f5f2bdc7620ffa1d1b2ce42 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/module.json @@ -0,0 +1,83 @@ +{ + "module": { + "name": "com.example.staticinformationmultihappackage", + "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.staticinformationmultihappackage.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" + ] + } + ] + } + ], + "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.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.USE_BLUETOOTH", + "reason":"need use ohos.permission.USE_BLUETOOTH" + } + ] + } +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapa/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/AppScope/app.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..51ee16f27e59280d635c2735b336a197fbdd1266 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.staticinformationmultihappackage", + "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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/BUILD.gn b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..2550f6187977034683736e2bbe87a3bf4e7e499b --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/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("ActsAmsStaticBRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsstaticbrelyhap_js_assets", + ":actsamsstaticbrelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsStaticBRelyHap" +} + +ohos_app_scope("actsamsstaticbrelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsstaticbrelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsstaticbrelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsstaticbrelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/Test.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ba2697bb640e6f7c293aa11a828cdc3d4836958b --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3e08c80b63d42d5ce329428013d890a395b6085 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,62 @@ +/* + * 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 MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("ACTS_getAbilityInfo_0400 MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ACTS_getAbilityInfo_0400 MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ACTS_getAbilityInfo_0400 MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("ACTS_getAbilityInfo_0400 MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("ACTS_getAbilityInfo_0400 MainAbility onForeground") + if (globalThis.abilityWant.action == 'startHapB') { + commonEvent.publish("MainAbility_Start_CommonEvent_multi_hap_feature", { + parameters: { + hapModuleInfo: JSON.stringify(globalThis.abilityContext.currentHapModuleInfo), + applicationInfo: JSON.stringify(globalThis.abilityContext.applicationInfo), + abilityInfo: JSON.stringify(globalThis.abilityContext.abilityInfo) + } + }, (err) => { + console.log("ACTS_getAbilityInfo_0400 MainAbility Publish CallBack onForeground") + }); + } + } + + onBackground() { + // Ability has back to background + console.log("ACTS_getAbilityInfo_0400 MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..64c878fd512c758ba0b6d0fc2fcdb70bd127b4c7 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* + * 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/module.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..2f74083c67495ec0c7229a36186c25574d37e028 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/module.json @@ -0,0 +1,83 @@ +{ + "module": { + "name": "com.example.feature", + "type": "feature", + "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.feature.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" + ] + } + ] + } + ], + "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.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.USE_BLUETOOTH", + "reason":"need use ohos.permission.USE_BLUETOOTH" + } + ] + } +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstatichapb/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/AppScope/app.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..2c629769e8ba2edb6a25e494a46a8a2f9245e20c --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.staticinfomationquery", + "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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/BUILD.gn b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..afd32ec85ed39a18afebf3af68e415a8a285e155 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/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("ActsAmsStaticInfoMationQueryTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsstaticinfomationquerytest_js_assets", + ":actsamsstaticinfomationquerytest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsStaticInfoMationQueryTest" +} + +ohos_app_scope("actsamsstaticinfomationquerytest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsstaticinfomationquerytest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsstaticinfomationquerytest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsstaticinfomationquerytest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/Test.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3c91d1031a89c120f95bc6648539ab231bad56d9 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/Test.json @@ -0,0 +1,31 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.example.staticinfomationquery", + "shell-timeout": "300000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsStaticInfoMationQueryTest.hap", + "ActsAmsStaticQueryTestTwoRelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/*.hap" + ] + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..5e2915fe4fc033cd5c9bd579dc08fe7369e51016 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..10dd9a1eaff7ad67843219facba7f8aea7b5a1a5 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class 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") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..577f53879917d26276c6ef294f65d9d044533161 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/pages/index/index.ets @@ -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 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ac4b9b9f880638c3eea63d85b635c5b13c4c490 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,363 @@ +/* + * 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 subscriberInfo_MainAbility_ability = { + events: ["MainAbility_Start_CommonEvent_ability", "SecondAbility_Start_CommonEvent_ability"], +}; +var subscriberInfo_MainAbility_ability_0300 = { + events: ["MainAbility_Start_CommonEvent_ability_0300","SecondAbility_Start_CommonEvent_ability_0300"], +}; + +export default function abilityTest(abilityContext) { + describe('ActsStaticInfoMationQueryTest', function () { + /** + * @tc.number: ACTS_getAbilityInfo_0100 + * @tc.name: Application query abilityInfo Static information. + * @tc.desc: Verify that the application query abilityInfo static + * information is the same as that in the configuration file. + */ + it('ACTS_getAbilityInfo_0100', 0, async function (done) { + console.log("ACTS_getAbilityInfo_0100 --- start ability=====>'+ abilityContext.abilityInfo") + checkAbilityInfo(abilityContext.abilityInfo); + done(); + }) + + /** + * @tc.number: ACTS_getApplicationInfo_0100 + * @tc.name: Application query applicationInfo Static information. + * @tc.desc: Verify that the application query applicationInfo static + * information is the same as that in the configuration file. + */ + it('ACTS_getApplicationInfo_0100', 0, async function (done) { + console.log("ACTS_getApplicationInfo_0100 --- start ability=====>'+ abilityContext.applicationInfo") + checkApplicationInfo(abilityContext.applicationInfo); + done(); + }) + + /** + * @tc.number: ACTS_getHapModuleInfo_0100 + * @tc.name: Application query currentHapModuleInfo Static information. + * @tc.desc: Verify that the application query currentHapModuleInfo static + * information is the same as that in the configuration file. + */ + it('ACTS_getHapModuleInfo_0100', 0, async function (done) { + console.log("ACTS_getHapModuleInfo_0100 --- start ability=====>'+ abilityContext.currentHapModuleInfo") + checkHapModuleInfo(abilityContext.currentHapModuleInfo); + done(); + }) + + /** + * @tc.number: ACTS_getAbilityInfo_0200 + * @tc.name: Start different abilities of the application to obtain the static information of the + * abilityInfo、applicationInfo、currentHapModuleInfo. + * @tc.desc: Verify that the static information of the abilityInfo、applicationInfo、currentHapModuleInfo can be + * queried by different abilities to start the application, which is the same as the information of the + * abilityInfo、applicationInfo、currentHapModuleInfo in the configuration file, + * and the information obtained by starting different abilities is different + */ + it('ACTS_getAbilityInfo_0200', 0, async function (done) { + console.log("ACTS_getAbilityInfo_0200 --- start") + var Subscriber; + var mainHap = false; + var secondHap = false; + function SubscribeCallBack(err, data) { + console.debug("ACTS_getAbilityInfo_0200====>Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == 'MainAbility_Start_CommonEvent_ability') { + mainHap = true; + console.log("ACTS_getAbilityInfo_0200====> MainAbility_Start_CommonEvent_ability") + let abilityInfo = JSON.parse(data.parameters['abilityInfo']) + let hapModuleInfo = JSON.parse(data.parameters['hapModuleInfo']) + let applicationInfo =JSON.parse(data.parameters['applicationInfo']) + expect(hapModuleInfo.name).assertEqual("com.example.staticquerytesttwo"); + expect(applicationInfo.name).assertEqual("com.example.staticquerytesttwo"); + expect(abilityInfo.name).assertEqual("com.example.staticquerytesttwo.MainAbility"); + } else if (data.event == 'SecondAbility_Start_CommonEvent_ability'){ + secondHap = true; + console.log("ACTS_getAbilityInfo_0200====> SecondAbility_Start_CommonEvent_ability") + let abilityInfo1 = JSON.parse(data.parameters['abilityInfo']) + let hapModuleInfo1 = JSON.parse(data.parameters['hapModuleInfo']) + let applicationInfo1 =JSON.parse(data.parameters['applicationInfo']) + expect(hapModuleInfo1.name).assertEqual("com.example.staticquerytesttwo"); + expect(applicationInfo1.name).assertEqual("com.example.staticquerytesttwo"); + expect(abilityInfo1.name).assertEqual("com.example.staticquerytesttwo.MainAbility"); + } + if(mainHap && secondHap){ + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + } + commonEvent.createSubscriber(subscriberInfo_MainAbility_ability).then(async (data) => { + console.debug("ACTS_getAbilityInfo_0200====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + Subscriber.getSubscribeInfo().then((data)=>{ + console.log('ACTS_getAbilityInfo_0200 - Subscriber: ' + JSON.stringify(data)) + }) + abilityContext.startAbility({ + bundleName: "com.example.staticquerytesttwo", + abilityName: "com.example.staticquerytesttwo.MainAbility", + action:"getAbilityContext" + }, (error, data) => { + console.log('ACTS_getAbilityInfo_0200_startMainAbility: ' + JSON.stringify(error) + + ", " + JSON.stringify(data)) + }) + }) + function UnSubscribeCallback() { + console.debug("ACTS_getAbilityInfo_0200====>UnSubscribe CallBack====>"); + done(); + } + }) + + function checkAbilityInfo(data) { + console.log("checkAbilityInfo start " + data); + console.log("checkAbilityInfo bundleName : " + data.bundleName); + console.log("checkAbilityInfo name : " + data.name); + console.log("checkAbilityInfo label : " + data.label); + console.log("checkAbilityInfo description : " + data.description); + console.log("checkAbilityInfo icon : " + data.icon); + console.log("checkAbilityInfo labelId : " + data.labelId); + console.log("checkAbilityInfo descriptionId : " + data.descriptionId); + console.log("checkAbilityInfo iconId : " + data.iconId); + console.log("checkAbilityInfo moduleName : " + data.moduleName); + console.log("checkAbilityInfo process : " + data.process); + console.log("checkAbilityInfo targetAbility : " + data.targetAbility); + console.log("checkAbilityInfo backgroundModes : " + data.backgroundModes); + console.log("checkAbilityInfo isVisible : " + data.isVisible); + console.log("checkAbilityInfo formEnabled : " + data.formEnabled); + console.log("checkAbilityInfo type : " + data.type) + console.log("checkAbilityInfo subType : " + data.subType); + console.log("checkAbilityInfo orientation : " + data.orientation); + console.log("checkAbilityInfo launchMode : " + data.launchMode); + console.log("checkAbilityInfo permissions length : " + data.permissions.length); + console.log("checkAbilityInfo permissions: " + data.permissions); + for (var j = 0; j < data.permissions.length; j++) { + console.log("getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]); + } + console.log("checkAbilityInfo deviceTypes length : " + data.deviceTypes.length); + for (var j = 0; j < data.deviceTypes.length; j++) { + console.log("getAbilityInfo data.deviceTypes[" + j + "] : " + data.deviceTypes[j]); + } + console.log("checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length); + for (var j = 0; j < data.deviceCapabilities.length; j++) { + console.log("getAbilityInfo data.deviceCapabilities[" + j + "] : " + data.deviceCapabilities[j]); + } + console.log("checkAbilityInfo readPermission : " + data.readPermission); + console.log("checkAbilityInfo writePermission : " + data.writePermission); + console.log("checkAbilityInfo formEntity : " + data.formEntity); + console.log("checkAbilityInfo minFormHeight : " + data.minFormHeight); + console.log("checkAbilityInfo defaultFormHeight : " + data.defaultFormHeight); + console.log("checkAbilityInfo minFormWidth : " + data.minFormWidth); + console.log("checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth); + console.log("checkAbilityInfo uri : " + data.uri); + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.bundleName)).assertEqual("string"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("number"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.iconId)).assertEqual("number"); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.process)).assertEqual("string"); + expect(typeof (data.targetAbility)).assertEqual("string"); + expect(typeof (data.backgroundModes)).assertEqual("number"); + expect(typeof (data.isVisible)).assertEqual("boolean"); + expect(typeof (data.formEnabled)).assertEqual("boolean"); + expect(typeof (data.type)).assertEqual("number"); + expect(typeof (data.subType)).assertEqual("number"); + expect(typeof (data.orientation)).assertEqual("number"); + expect(typeof (data.launchMode)).assertEqual("number"); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); + expect(typeof (data.readPermission)).assertEqual("string"); + expect(typeof (data.writePermission)).assertEqual("string"); + expect(typeof (data.applicationInfo)).assertEqual("object"); + expect(typeof (data.formEntity)).assertEqual("number"); + expect(typeof (data.minFormHeight)).assertEqual("number"); + expect(typeof (data.defaultFormHeight)).assertEqual("number"); + expect(typeof (data.minFormWidth)).assertEqual("number"); + expect(typeof (data.defaultFormWidth)).assertEqual("number"); + expect(typeof (data.uri)).assertEqual("string"); + + expect(data.bundleName).assertEqual("com.example.staticinfomationquery"); + expect(data.name).assertEqual("com.example.staticinfomationquery.MainAbility"); + expect(data.label).assertEqual("$string:entry_label"); + expect(data.description).assertEqual("$string:phone_entry_main"); + expect(data.icon).assertEqual("$media:icon"); + expect(data.labelId).assertLarger(0); + expect(data.descriptionId).assertLarger(0); + expect(data.iconId).assertLarger(0); + expect(data.moduleName).assertEqual("com.example.staticinfomationquery"); + expect(data.process).assertEqual(""); + expect(data.targetAbility).assertEqual(""); + expect(data.backgroundModes).assertEqual(0); + expect(data.isVisible).assertEqual(true); + expect(data.formEnabled).assertEqual(false); + expect(data.type).assertEqual(1); + expect(data.subType).assertEqual(0); + expect(data.orientation).assertEqual(0); + expect(data.launchMode).assertEqual(0); + expect(data.permissions.length).assertEqual(0); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(data.deviceTypes.length).assertEqual(1); + expect(data.deviceCapabilities.length).assertEqual(0); + expect(data.readPermission).assertEqual(""); + expect(data.writePermission).assertEqual(""); + expect(data.formEntity).assertEqual(0); + expect(data.minFormHeight).assertEqual(0); + expect(data.defaultFormHeight).assertEqual(0); + expect(data.minFormWidth).assertEqual(0); + expect(data.defaultFormWidth).assertEqual(0); + expect(data.uri).assertEqual(""); + console.log("checkAbilityInfo end " + data); + } + function checkApplicationInfo(data) { + console.log("checkApplicationInfo start " + data); + console.log("checkApplicationInfo name : " + data.name); + console.log("checkApplicationInfo description : " + data.description); + console.log("checkApplicationInfo descriptionId : " + data.descriptionId); + console.log("checkApplicationInfo systemApp : " + data.systemApp); + console.log("checkApplicationInfo enabled : " + data.enabled); + console.log("checkApplicationInfo label : " + data.label) + console.log("checkApplicationInfo labelId : " + data.labelId); + console.log("checkApplicationInfo icon : " + data.icon); + console.log("checkApplicationInfo iconId : " + data.iconId); + console.log("checkApplicationInfo process : " + data.process); + console.log("checkApplicationInfo supportedModes : " + data.supportedModes); + console.log("checkApplicationInfo moduleSourceDirs length : " + data.moduleSourceDirs.length); + for (var j = 0; j < data.moduleSourceDirs.length; j++) { + console.log("checkApplicationInfo data.moduleSourceDirs[" + j + "] : " + data.moduleSourceDirs[j]); + } + console.log("checkApplicationInfo permissions length : " + data.permissions.length); + for (var j = 0; j < data.permissions.length; j++) { + console.log("checkApplicationInfo data.permissions[" + j + "] : " + data.permissions[j]); + } + console.log("checkApplicationInfo moduleInfos length : " + data.moduleInfos.length); + for (var j = 0; j < data.moduleInfos.length; j++) { + console.log("checkApplicationInfo data.moduleInfos[" + j + "].moduleName : " + + data.moduleInfos[j].moduleName); + console.log("checkApplicationInfo data.moduleInfos[" + j + "].moduleSourceDir : " + + data.moduleInfos[j].moduleSourceDir); + } + + console.log("checkApplicationInfo entryDir : " + data.entryDir); + console.log("checkApplicationInfo codePath : " + data.codePath); + console.log("checkApplicationInfo removable: " + data.removable); + + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.descriptionId)).assertEqual("number"); + expect(typeof (data.systemApp)).assertEqual("boolean"); + expect(typeof (data.enabled)).assertEqual("boolean"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.labelId)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.iconId)).assertEqual("string"); + expect(typeof (data.process)).assertEqual("string"); + expect(typeof (data.supportedModes)).assertEqual("number"); + expect(Array.isArray(data.moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.moduleInfos)).assertEqual(true); + expect(typeof (data.entryDir)).assertEqual("string"); + expect(typeof (data.codePath)).assertEqual("string"); + expect(typeof (data.removable)).assertEqual("boolean"); + console.log("checkApplicationInfo_expect_typeof_end") + expect(data.name).assertEqual("com.example.staticinfomationquery"); + expect(data.description).assertEqual("$string:description_application"); + expect(data.descriptionId).assertLarger(0); + expect(data.systemApp).assertEqual(true); + expect(data.enabled).assertEqual(true); + expect(data.label).assertEqual("$string:app_name"); + expect(data.labelId.length).assertLarger(0); + expect(data.icon).assertEqual(""); + expect(data.iconId.length).assertLarger(0); + expect(data.process).assertEqual(""); + expect(data.supportedModes).assertEqual(0); + expect(data.moduleSourceDirs.length).assertEqual(1); + expect(data.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/" + + "com.example.staticinfomationquery/com.example.staticinfomationquery"); + expect(data.moduleInfos.length).assertEqual(1); + expect(data.moduleInfos[0].moduleName).assertEqual("com.example.staticinfomationquery"); + expect(data.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/" + + "com.example.staticinfomationquery/com.example.staticinfomationquery"); + expect(data.entryDir).assertEqual("/data/app/el1/bundle/public/" + + "com.example.staticinfomationquery/com.example.staticinfomationquery"); + expect(data.codePath).assertEqual("/data/app/el1/bundle/public/com.example.staticinfomationquery") + expect(data.removable).assertEqual(true); + console.log("checkApplicationInfo end " + data); + } + function checkHapModuleInfo(data) { + console.log("checkHapModuleInfo start " + data); + console.log("checkHapModuleInfo name : " + data.name); + console.log("checkHapModuleInfo description : " + data.description); + console.log("checkHapModuleInfo descriptionId : " + data.descriptionId); + console.log("checkHapModuleInfo icon : " + data.icon); + console.log("checkHapModuleInfo label : " + data.label); + console.log("checkHapModuleInfo labelId : " + data.labelId); + console.log("checkHapModuleInfo iconId : " + data.iconId); + console.log("checkHapModuleInfo backgroundImg : " + data.backgroundImg); + console.log("checkHapModuleInfo supportedModes : " + data.supportedModes); + console.log("checkHapModuleInfo reqCapabilities length : " + data.reqCapabilities.length); + for (var j = 0; j < data.reqCapabilities.length; j++) { + console.log("checkHapModuleInfo data.reqCapabilities[" + j + "] : " + data.reqCapabilities[j]); + } + console.log("checkHapModuleInfo deviceTypes length : " + data.deviceTypes.length); + for (var j = 0; j < data.deviceTypes.length; j++) { + console.log("checkHapModuleInfo data.deviceTypes[" + j + "] : " + data.deviceTypes[j]); + } + + console.log("checkHapModuleInfo moduleName : " + data.moduleName); + console.log("checkHapModuleInfo mainAbilityName : " + data.mainAbilityName); + console.log("checkHapModuleInfo installationFree : " + data.installationFree); + + expect(typeof (data)).assertEqual("object"); + expect(typeof (data.name)).assertEqual("string"); + expect(typeof (data.description)).assertEqual("string"); + expect(typeof (data.icon)).assertEqual("string"); + expect(typeof (data.label)).assertEqual("string"); + expect(typeof (data.backgroundImg)).assertEqual("string"); + expect(typeof (data.supportedModes)).assertEqual("number"); + expect(Array.isArray(data.reqCapabilities)).assertEqual(true); + expect(Array.isArray(data.deviceTypes)).assertEqual(true); + expect(Array.isArray(data.abilityInfo)).assertEqual(true); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.mainAbilityName)).assertEqual("string"); + console.log("checkHapModuleInfo_expect_typeof_end") + expect(data.name).assertEqual("com.example.staticinfomationquery"); + expect(data.description).assertEqual("$string:phone_entry_dsc"); + expect(data.descriptionId).assertEqual(undefined); + expect(data.icon).assertEqual("$media:icon"); + expect(data.label).assertEqual("$string:entry_label"); + expect(data.labelId).assertEqual(undefined); + expect(data.iconId).assertEqual(undefined); + expect(data.backgroundImg).assertEqual(""); + expect(data.supportedModes).assertEqual(0); + expect(data.reqCapabilities.length).assertEqual(0); + expect(data.reqCapabilities[0]).assertEqual(undefined); + expect(data.deviceTypes.length).assertEqual(1); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(data.moduleName).assertEqual("com.example.staticinfomationquery") + expect(data.mainAbilityName).assertEqual("MainAbility"); + expect(data.installationFree).assertEqual(undefined); + console.log("checkHapModuleInfo end " + data); + } + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..882f978e77b1a8fbbf843ccb4dd73c47ed460305 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/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 './Ability.test.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/module.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..9428138b0d8bf374c48986815a473c69a1159672 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/module.json @@ -0,0 +1,79 @@ +{ + "module": { + "name": "com.example.staticinfomationquery", + "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.staticinfomationquery.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" + ] + } + ] + } + ], + "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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinfomationquerytest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/AppScope/app.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..c0e6260cc59a8aa851b1261340c1ab5abc510771 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.staticinformationmultiple", + "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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/BUILD.gn b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b10fa4c97c6389bd04b968a0c3b7e32fd8ff8d17 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/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("ActsAmsStaticInformationMultipleTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsstaticinformationmultipletest_js_assets", + ":actsamsstaticinformationmultipletest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsStaticInformationMultipleTest" +} + +ohos_app_scope("actsamsstaticinformationmultipletest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsstaticinformationmultipletest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsstaticinformationmultipletest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsstaticinformationmultipletest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/Test.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..e91b26d39e3366865648104104927e92d3e312d7 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/Test.json @@ -0,0 +1,41 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.staticinformationmultiple", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsStaticInformationMultipleTest.hap", + "ActsAmsStaticQueryTestTwoRelyHap.hap", + "ActsAmsStaticARelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsAmsStaticInformationMultipleTest.hap->/data/ActsAmsStaticInformationMultipleTest.hap", + "ActsAmsStaticQueryTestTwoRelyHap.hap->/data/ActsAmsStaticQueryTestTwoRelyHap.hap", + "ActsAmsStaticARelyHap.hap->/data/ActsAmsStaticARelyHap.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/test/*.hap" + ] + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..5e2915fe4fc033cd5c9bd579dc08fe7369e51016 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..10dd9a1eaff7ad67843219facba7f8aea7b5a1a5 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class 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") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..577f53879917d26276c6ef294f65d9d044533161 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/pages/index/index.ets @@ -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 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f199475b7ca1a465241681a4b9eeee1b979662bc --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/test/Ability.test.ets @@ -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. + */ +// @ts-nocheck +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"; +import commonEvent from '@ohos.commonevent'; +import bundle from '@ohos.bundle'; +import missionManager from '@ohos.application.missionManager'; + +const BUNDLE_PATHS = [['/data/ActsAmsStaticQueryTestTwoRelyHap.hap'],['/data/ActsAmsStaticARelyHap.hap']]; +const BUNDLE_NAMES = ['com.example.staticquerytesttwo','com.example.staticinformationmultihappackage']; +const PATHS_COUNT = 2; +const BUNDLE_COUNT = 2; +const MAX_MISSION_NUM = 1024; +var subscriberInfo = { + events: ['MainAbility_Start_CommonEvent_multi_hap_entryB', 'MainAbility_Start_CommonEvent_multiple_hap_entry'] +}; + +function getMissionId() { + return new Promise(async (resolve, reject) => { + var missionId = -1; + var missionInfos = await missionManager.getMissionInfos('', MAX_MISSION_NUM); + console.log('======>ACTS_getAbilityInfo_0500 getMissionId missionInfos<=======' + missionInfos); + for (let i = 0; i < missionInfos.length; i++) { + console.log('getMissionId result: ' + i + '= ' + JSON.stringify(missionInfos[i])) + if ((missionInfos[i].want.abilityName == "com.example.staticinformationmultiple.MainAbility") && + (missionInfos[i].runningState == 0)) { + missionId = missionInfos[i].missionId; + break; + } + } + console.log('======>ACTS_getAbilityInfo_0500 getMissionId resolve missionId<=======' + missionId); + resolve(missionId); + }) +} + +export default function abilityTest(abilityContext) { + describe('ActsAbilityTest', function () { + + // beforeEach(async (done) => { + // console.log('======>beforeEach ininin<======='); + // let installer = await bundle.getBundleInstaller(); + // var count = 0; + + // for (let i = 0; i < PATHS_COUNT; i++) { + // installer.install(BUNDLE_PATHS[i], { + // userId: 100, + // installFlag: 1, + // isKeepData: false + // }, (err, data) => { + // count++; + // console.log('======>beforeEach install finish <=======' + err.code); + // console.log('======>beforeEach install finish <=======' + data.status); + // console.log('======>beforeEach install finish <=======' + data.statusMessage); + // if (count == BUNDLE_COUNT) { + // done(); + // } + // }) + // } + // }) + + // afterEach(async (done) => { + // let installer = await bundle.getBundleInstaller(); + // var count = 0; + // var testMissionId; + + // testMissionId = await getMissionId(); + // console.log('======>afterEach test missionId<=======' + testMissionId); + // await missionManager.moveMissionToFront(testMissionId); + + // for (let i = 0; i < BUNDLE_COUNT; i++) { + // installer.uninstall(BUNDLE_NAMES[i], { + // userId: 100, + // installFlag: 1, + // isKeepData: false + // }, (err, data) => { + // count++; + // console.log('======>afterEach uninstall finish <=======' + err.code); + // console.log('======>afterEach uninstall finish <=======' + data.status); + // console.log('======>afterEach uninstall finish <=======' + data.statusMessage); + // if (count == BUNDLE_COUNT) { + // done(); + // } + // }) + // } + // }) + + /** + * @tc.number: ACTS_getAbilityInfo_0400 + * @tc.name: Starting singleton ability the second time does triggers onNewWant. + * @tc.desc: Starting singleton ability the second time does triggers onNewWant. + */ + it('ACTS_getAbilityInfo_0500', 0, async function (done) { + console.log("ACTS_getAbilityInfo_0500 --- start") + var Subscriber; + var EntryHap = false; + var FeatureHap = false; + + abilityContext.startAbility({ + bundleName: "com.example.staticquerytesttwo", + abilityName: "com.example.staticquerytesttwo.MainAbility", + action:"startmultiple" + }, (error, data) => { + console.log('ACTS_getAbilityInfo_0500 - startAbility start HapA: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_getAbilityInfo_0500====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function SubscribeCallBack(err, data) { + console.debug("ACTS_getAbilityInfo_0500====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_getAbilityInfo_0500====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + if (data.event == 'MainAbility_Start_CommonEvent_multi_hap_entryB') { + EntryHap = true; + console.log("ACTS_getAbilityInfo_0500====> MainAbility_Start_CommonEvent_multi_hap_entryB") + let abilityInfo = JSON.parse(data.parameters['abilityInfo']) + let hapModuleInfo = JSON.parse(data.parameters['hapModuleInfo']) + let applicationInfo =JSON.parse(data.parameters['applicationInfo']) + console.log("ACTS_getAbilityInfo_0500_entry_abilityInfo" + abilityInfo.name) + console.log("ACTS_getAbilityInfo_0500_entry_applicationInfo" + applicationInfo.name) + console.log("ACTS_getAbilityInfo_0500_entry_hapModuleInfo" + hapModuleInfo.name) + expect(abilityInfo.name).assertEqual("com.example.staticquerytesttwo.MainAbility"); + expect(applicationInfo.name).assertEqual("com.example.staticquerytesttwo"); + expect(hapModuleInfo.name).assertEqual("com.example.staticquerytesttwo"); + } else if (data.event == 'MainAbility_Start_CommonEvent_multiple_hap_entry'){ + FeatureHap = true; + console.log("ACTS_getAbilityInfo_0500====> MainAbility_Start_CommonEvent_multi_hap_feature") + let abilityInfo1 = JSON.parse(data.parameters['abilityInfo']) + let hapModuleInfo1 = JSON.parse(data.parameters['hapModuleInfo']) + let applicationInfo1 =JSON.parse(data.parameters['applicationInfo']) + console.log("ACTS_getAbilityInfo_0500_feature_abilityInfo" + abilityInfo1.name) + console.log("ACTS_getAbilityInfo_0500_feature_applicationInfo" + applicationInfo1.name) + console.log("ACTS_getAbilityInfo_0500_feature_hapModuleInfo" + hapModuleInfo1.name) + expect(abilityInfo1.name).assertEqual("com.example.staticinformationmultihappackage.MainAbility"); + expect(applicationInfo1.name).assertEqual("com.example.staticinformationmultihappackage"); + expect(hapModuleInfo1.name).assertEqual("com.example.staticinformationmultihappackage"); + } + if(EntryHap && FeatureHap){ + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + } + function UnSubscribeCallback() { + console.debug("ACTS_getAbilityInfo_0500====>UnSubscribe CallBack====>"); + done(); + } + }) + + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..882f978e77b1a8fbbf843ccb4dd73c47ed460305 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/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 './Ability.test.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/module.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..e43f7f15e3df7c678a1a48f6cba6aba7c2cf89ef --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/module.json @@ -0,0 +1,83 @@ +{ + "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.staticinformationmultiple.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" + ] + } + ] + } + ], + "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.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.USE_BLUETOOTH", + "reason":"need use ohos.permission.USE_BLUETOOTH" + } + ] + } +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultipletest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/AppScope/app.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..e332008de0ae13271257ed81d4efcff5bcad18e6 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.staticinformationmultihap", + "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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/BUILD.gn b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..31ab0c9605b302da4fab40889a2b7ec938b1d53e --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/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("ActsAmsStaticInformationMultiTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsstaticinformationmultitest_js_assets", + ":actsamsstaticinformationmultitest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsStaticInformationMultiTest" +} + +ohos_app_scope("actsamsstaticinformationmultitest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsstaticinformationmultitest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsstaticinformationmultitest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsstaticinformationmultitest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/Test.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3468759f9464518c3758a5887feda290196f24e8 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/Test.json @@ -0,0 +1,41 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.staticinformationmultihap", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsStaticInformationMultiTest.hap", + "ActsAmsStaticARelyHap.hap", + "ActsAmsStaticBRelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsAmsStaticInformationMultiTest.hap->/data/ActsAmsStaticInformationMultiTest.hap", + "ActsAmsStaticARelyHap.hap->/data/ActsAmsStaticARelyHap.hap", + "ActsAmsStaticBRelyHap.hap->/data/ActsAmsStaticBRelyHap.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/test/*.hap" + ] + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..5e2915fe4fc033cd5c9bd579dc08fe7369e51016 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..10dd9a1eaff7ad67843219facba7f8aea7b5a1a5 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class 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") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..577f53879917d26276c6ef294f65d9d044533161 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/pages/index/index.ets @@ -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 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9012968ae04645dcd5eb7bf464b6b41b8378c452 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,162 @@ +/* + * 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. + */ +// @ts-nocheck +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index"; +import commonEvent from '@ohos.commonevent'; +import bundle from '@ohos.bundle'; +import missionManager from '@ohos.application.missionManager'; + +const BUNDLE_PATH = ['/data/ActsAmsStaticARelyHap.hap','/data/ActsAmsStaticBRelyHap.hap']; +const BUNDLE_NAME = ['com.example.staticinformationmultihappackage']; +const PATHS_COUNT = 1; +const BUNDLE_COUNT = 1; +const MAX_MISSION_NUM = 1024; +var subscriberInfo = { + events: ['MainAbility_Start_CommonEvent_multi_hap_entry', 'MainAbility_Start_CommonEvent_multi_hap_feature'], +}; + +function getMissionId() { + return new Promise(async (resolve, reject) => { + var missionId = -1; + var missionInfos = await missionManager.getMissionInfos('', MAX_MISSION_NUM); + console.log('======>ACTS_getAbilityInfo_0400 getMissionId missionInfos<=======' + missionInfos); + for (let i = 0; i < missionInfos.length; i++) { + console.log('getMissionId result: ' + i + '= ' + JSON.stringify(missionInfos[i])) + if ((missionInfos[i].want.abilityName == "com.example.staticinformationmultihap.MainAbility") && + (missionInfos[i].runningState == 0)) { + missionId = missionInfos[i].missionId; + break; + } + } + console.log('======>ACTS_getAbilityInfo_0400 getMissionId resolve missionId<=======' + missionId); + resolve(missionId); + }) +} + +export default function abilityTest(abilityContext) { + describe('ActsAbilityTest', function () { + + beforeEach(async (done) => { + let installer = await bundle.getBundleInstaller(); + var count = 0; + installer.install(BUNDLE_PATH, { + userId: 100, + installFlag: 1, + isKeepData: false + }, (err, data) => { + count++; + console.log('======>ACTS_getAbilityInfo_0400 beforeEach install finish<=======' + err.code); + console.log('======>ACTS_getAbilityInfo_0400 beforeEach install finish<=======' + data.status); + console.log('======>ACTS_getAbilityInfo_0400 beforeEach install finish<=======' + + data.statusMessage); + if(count == PATHS_COUNT){ + done(); + } + }) + }) + + afterEach(async (done) => { + let installer = await bundle.getBundleInstaller(); + var count = 0; + var testMissionId; + + testMissionId = await getMissionId(); + console.log('======>ACTS_getAbilityInfo_0400 afterEach test missionId<=======' + testMissionId); + await missionManager.moveMissionToFront(testMissionId); + console.log('======>ACTS_getAbilityInfo_0400 afterEach test move<======='); + installer.uninstall(BUNDLE_NAME, { + userId: 100, + installFlag: 1, + isKeepData: false + }, (err, data) => { + count++; + console.log('======>ACTS_getAbilityInfo_0400 afterEach uninstall finish<=======' + err.code); + console.log('======>ACTS_getAbilityInfo_0400 afterEach uninstall finish<=======' + data.status); + console.log('======>ACTS_getAbilityInfo_0400 afterEach uninstall finish<=======' + + data.statusMessage); + if(count == BUNDLE_COUNT){ + done(); + } + }) + }) + + /** + * @tc.number: ACTS_getAbilityInfo_0400 + * @tc.name: Starting singleton ability the second time does triggers onNewWant. + * @tc.desc: Starting singleton ability the second time does triggers onNewWant. + */ + it('ACTS_getAbilityInfo_0400', 0, async function (done) { + console.log("ACTS_getAbilityInfo_0400 --- start") + var Subscriber; + var EntryHap = false; + var FeatureHap = false; + + abilityContext.startAbility({ + bundleName: "com.example.staticinformationmultihappackage", + abilityName: "com.example.staticinformationmultihappackage.MainAbility", + action:"startHapA" + }, (error, data) => { + console.log('ACTS_getAbilityInfo_0400 - startAbility start HapA: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_getAbilityInfo_0400====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function SubscribeCallBack(err, data) { + console.debug("ACTS_getAbilityInfo_0400====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_getAbilityInfo_0400====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + if (data.event == 'MainAbility_Start_CommonEvent_multi_hap_entry') { + EntryHap = true; + console.log("ACTS_getAbilityInfo_0400====> MainAbility_Start_CommonEvent_multi_hap_entry") + let abilityInfo = JSON.parse(data.parameters['abilityInfo']) + let hapModuleInfo = JSON.parse(data.parameters['hapModuleInfo']) + let applicationInfo =JSON.parse(data.parameters['applicationInfo']) + console.log("ACTS_getAbilityInfo_0400_entry_abilityInfo" + abilityInfo.name) + console.log("ACTS_getAbilityInfo_0400_entry_applicationInfo" + applicationInfo.name) + console.log("ACTS_getAbilityInfo_0400_entry_hapModuleInfo" + hapModuleInfo.name) + expect(abilityInfo.name).assertEqual("com.example.staticinformationmultihappackage.MainAbility"); + expect(applicationInfo.name).assertEqual("com.example.staticinformationmultihappackage"); + expect(hapModuleInfo.name).assertEqual("com.example.staticinformationmultihappackage"); + } else if (data.event == 'MainAbility_Start_CommonEvent_multi_hap_feature'){ + FeatureHap = true; + console.log("ACTS_getAbilityInfo_0400====> MainAbility_Start_CommonEvent_multi_hap_feature") + let abilityInfo1 = JSON.parse(data.parameters['abilityInfo']) + let hapModuleInfo1 = JSON.parse(data.parameters['hapModuleInfo']) + let applicationInfo1 =JSON.parse(data.parameters['applicationInfo']) + console.log("ACTS_getAbilityInfo_0400_feature_abilityInfo" + abilityInfo1.name) + console.log("ACTS_getAbilityInfo_0400_feature_applicationInfo" + applicationInfo1.name) + console.log("ACTS_getAbilityInfo_0400_feature_hapModuleInfo" + hapModuleInfo1.name) + expect(abilityInfo1.name).assertEqual("com.example.feature.MainAbility"); + expect(applicationInfo1.name).assertEqual("com.example.staticinformationmultihappackage"); + expect(hapModuleInfo1.name).assertEqual("com.example.feature"); + } + if(EntryHap && FeatureHap){ + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + } + function UnSubscribeCallback() { + console.debug("ACTS_getAbilityInfo_0400====>UnSubscribe CallBack====>"); + done(); + } + }) + + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..882f978e77b1a8fbbf843ccb4dd73c47ed460305 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/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 './Ability.test.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/module.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..becb94d1a5146a0fe2fef38f27542b2955e9cf09 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/module.json @@ -0,0 +1,83 @@ +{ + "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.staticinformationmultihap.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" + ] + } + ] + } + ], + "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.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name":"ohos.permission.GET_RUNNING_INFO", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.USE_BLUETOOTH", + "reason":"need use ohos.permission.USE_BLUETOOTH" + } + ] + } +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticinformationmultitest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/AppScope/app.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..f20d851e26c4327075cd9c3c02c0cf7afad3f513 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.staticquerytesttwo", + "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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/BUILD.gn b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..54cfa87f7eb8b953381b5c160c94db84024bfe8d --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/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("ActsAmsStaticQueryTestTwoRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsstaticquerytesttworelyhap_js_assets", + ":actsamsstaticquerytesttworelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsStaticQueryTestTwoRelyHap" +} + +ohos_app_scope("actsamsstaticquerytesttworelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsstaticquerytesttworelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsstaticquerytesttworelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsstaticquerytesttworelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/Test.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ec00ae24b1e4b73c5d7e3eaea6111e218d5dfaac --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/Test.json @@ -0,0 +1,4 @@ +{ + "description": "Configuration for hjunit demo Tests" + +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..5c09242f70e8d039556e2f3c1ac637d8e50193f0 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/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.stageContext = this.context; + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..893309b45527918e2a15fa83d4f7757d2059bcd8 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,93 @@ +/* + * 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 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 + if (globalThis.abilityWant.action == 'getAbilityContext') { + commonEvent.publish("MainAbility_Start_CommonEvent_ability", { + parameters: { + hapModuleInfo: JSON.stringify(globalThis.abilityContext.currentHapModuleInfo), + applicationInfo: JSON.stringify(globalThis.abilityContext.applicationInfo), + abilityInfo: JSON.stringify(globalThis.abilityContext.abilityInfo) + } + } ,(err) => { + console.log("MainAbility Publish CallBack MainAbility_Start_CommonEvent") + }); + globalThis.abilityContext.startAbility({ + bundleName: "com.example.staticquerytesttwo", + abilityName: "com.example.staticquerytesttwo.SecondAbility", + action:"getAbilityContext2" + }, (error, data) => { + console.log('ACTS_getAbilityInfo_0200_startSecondAbility: ' + JSON.stringify(error) + + ", " + JSON.stringify(data)) + }) + console.log('stub SerivceAbilityServer OnConnect start 2'); + } + console.log("MainAbility onForeground") + + if (globalThis.abilityWant.action == 'startmultiple') { + globalThis.abilityContext.startAbility({ + bundleName: "com.example.staticinformationmultihappackage", + abilityName: "com.example.staticinformationmultihappackage.MainAbility", + action: "multiple" + }, (err, data) => { + console.log('ACTS_getAbilityInfo_0500 MainAbility onForeground - startAbility restart singleton: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + commonEvent.publish("MainAbility_Start_CommonEvent_multi_hap_entryB", { + parameters: { + hapModuleInfo: JSON.stringify(globalThis.abilityContext.currentHapModuleInfo), + applicationInfo: JSON.stringify(globalThis.abilityContext.applicationInfo), + abilityInfo: JSON.stringify(globalThis.abilityContext.abilityInfo) + } + }, (err) => { + console.log("ACTS_getAbilityInfo_0500 MainAbility Publish CallBack onForeground") + }); + } + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/SecondMainAbility/SecondMainAbility.ts b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/SecondMainAbility/SecondMainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b387f0da49067c9f2bcc615f011592361fed733 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/SecondMainAbility/SecondMainAbility.ts @@ -0,0 +1,65 @@ +/* + * 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 SecondAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("SecondAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("SecondAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("SecondAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/index", null) + globalThis.ability2Context = this.context; + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("SecondAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("SecondAbility onForeground") + if (globalThis.abilityWant.action == 'getAbilityContext2') { + commonEvent.publish("SecondAbility_Start_CommonEvent_ability", { + parameters: { + hapModuleInfo: JSON.stringify(globalThis.abilityContext.currentHapModuleInfo), + applicationInfo: JSON.stringify(globalThis.abilityContext.applicationInfo), + abilityInfo: JSON.stringify(globalThis.abilityContext.abilityInfo) + } + } ,(err) => { + console.log("MainAbility Publish CallBack MainAbility_Start_CommonEvent") + }); + console.log('stub SerivceAbilityServer OnConnect start 2'); + } + } + + onBackground() { + // Ability has back to background + console.log("SecondAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..966ded012ca6e039819b546671a166b0b0c38c62 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,65 @@ +/* + * 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" + + +@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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/module.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..b5a08e893aaa08480222c9cbd7c9d7e0580da5ae --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/module.json @@ -0,0 +1,47 @@ +{ + "module": { + "name": "com.example.staticquerytesttwo", + "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.staticquerytesttwo.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.staticquerytesttwo.SecondAbility", + "srcEntrance": "./ets/SecondMainAbility/SecondMainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait" + } + ] + + } +} diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/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/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/aafwk/aafwk_standard/amscontextualinforquery/actsamsstaticquerytesttwohap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/BUILD.gn b/aafwk/aafwk_standard/amsdisplayIdtest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8b0fd6b7548a343682bf2fee525b15687f967005 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/BUILD.gn @@ -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. + +import("//test/xts/tools/build/suite.gni") + +group("amsdisplayIdtest") { + testonly = true + if (is_standard_system) { + deps = [ + "actsamsspecifytesthap:ActsAmsSpecifyTestRelyHap", + "actsamsstartabilityforresulttest:ActsAmsStartAbilityForResultTest", + "actsamsstartabilitytest:ActsAmsStartAbilityTest", + ] + } +} diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/AppScope/app.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..15d65f48a3eebe1e89a1e4f93641f7e0c607da9b --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actsspecifytesthap", + "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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/BUILD.gn b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8fc1a913df959da0344acbbf289217139a75c667 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/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("ActsAmsSpecifyTestRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsspecifytestrelyhap_js_assets", + ":actsamsspecifytestrelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsSpecifyTestRelyHap" +} + +ohos_app_scope("actsamsspecifytestrelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsspecifytestrelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsspecifytestrelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsspecifytestrelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/Test.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..5542b3126bb6456bc45e722e9f03a89b56b1a0a6 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,113 @@ +/* +* 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' + +var callBackSeq = ""; + +function publishCallBack() { + console.debug("====>Publish CallBack ====>"); +} + +async function startAbilityProcess(abilityContext, options, parameters) { + let bundleName; + let abilityName; + + let idx = parameters.nextStep; + switch (parameters.step[idx]) { + case "testA": + bundleName = "com.example.actsspecifytesthap"; + abilityName = "com.example.actsspecifytesthap.MainAbility"; + break; + default: + break; + } + parameters.nextStep = ++idx; + abilityContext.startAbility({ + bundleName: bundleName, + abilityName: abilityName, + parameters: parameters, + }, options, (error, data) => { + console.log('startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) +} + +async function onShowProcess() { + var abilityWant = globalThis.abilityWant; + var callBackData = "actsspecifytesthap:" + callBackData += callBackSeq; + + var commonEventPublishData = { + data: callBackData, + parameters: { + displayId: globalThis.abilityWant.parameters['ohos.aafwk.param.displayId'], + windowMode: globalThis.abilityWant.parameters['ohos.aafwk.param.windowMode'], +} + }; + + console.log("AbilityMultiInstanceAppA abilityWant = " + JSON.stringify(abilityWant)); + if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) { + commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, () => { + console.log('============>querytestsecond success==========>>') + callBackSeq = ""; + }); + } else { + commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => { + callBackSeq = ""; + console.log('============>querytest success==========>>') + startAbilityProcess(globalThis.abilityContext, globalThis.abilityWant.options, abilityWant.parameters); + }); + } +} + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("actsspecifytesthap onCreate") + callBackSeq += "onCreate"; + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("actsspecifytesthap onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("actsspecifytesthap onWindowStageCreate") + // callBackSeq += "onWindowStageCreate"; + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index", null) + console.log("actsspecifytesthap onWindowStageCreate finish") + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("actsspecifytesthap onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("actsspecifytesthap onForeground") + callBackSeq += "onForeground"; + onShowProcess(); + } + + onBackground() { + // Ability has back to background + console.log("actsspecifytesthap onBackground") + } +}; diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..16e1531e48430510168d31c9f8d8c595c3b62ab9 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* +* 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/module.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..3b88ad073cd61130f3c94e109cff474dd0c1e74d --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/module.json @@ -0,0 +1,79 @@ +{ + "module": { + "name": "com.example.actsspecifytesthap", + "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.actsspecifytesthap.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" + ] + } + ] + } + ], + "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.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason": "need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS" + }, + { + "name": "ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason": "need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name": "ohos.permission.GET_RUNNING_INFO", + "reason": "need use ohos.permission.GET_RUNNING_INFO" + } + ] + } +} diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsspecifytesthap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/AppScope/app.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..bd0c44cd4609bcf39f6b5c75cec0e5492eb8ac93 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.startabilityforresult", + "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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/BUILD.gn b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ee4111aafaad52fa22a39ea12ca4dd55d3f9a827 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/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("ActsAmsStartAbilityForResultTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsstartabilityforresulttest_js_assets", + ":actsamsstartabilityforresulttest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsStartAbilityForResultTest" +} + +ohos_app_scope("actsamsstartabilityforresulttest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsstartabilityforresulttest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsstartabilityforresulttest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsstartabilityforresulttest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/Test.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3fc9e19ad6b75568322c6fabafec85d5b0af7dc0 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/Test.json @@ -0,0 +1,37 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.startabilityforresult", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsStartAbilityForResultTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsAmsStartAbilityForResultTest.hap->/data/test/ActsAmsStartAbilityForResultTest.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/test/*.hap" + ] + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..4ca5011008cfcf3af89fe1b915a9a284832631bd --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..10dd9a1eaff7ad67843219facba7f8aea7b5a1a5 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class 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") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/MainAbility2/MainAbility2.ts b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100644 index 0000000000000000000000000000000000000000..5f95ec63f76c300ee2f4519356cb9c21fad77d4b --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,72 @@ +/* + * 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' + +async function onShowProcess() { + var abilityWant = globalThis.abilityWant; + + var commonEventPublishData = { + parameters: { + displayId: globalThis.abilityWant.parameters['ohos.aafwk.param.displayId'], + windowMode: globalThis.abilityWant.parameters['ohos.aafwk.param.windowMode'], + } + }; + + console.log("AbilityMultiInstanceAppA abilityWant = " + JSON.stringify(abilityWant)); + + commonEvent.publish("ACTS_TerminateSelf_CommonEvent", commonEventPublishData, () => { + console.log('============>querytestsecond success==========>>') + globalThis.abilityContext.terminateSelf(); + }); + +} +export default class MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("MainAbility2 onCreate") + globalThis.abilityWant = want; + console.log("AbilityMultiInstanceAppA abilityWant = " + JSON.stringify( globalThis.abilityWant)); + } + + 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.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/second/second", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility onForeground") + onShowProcess(); + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/MainAbility2/app.ets b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/MainAbility2/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..bc55af9d45ac17a34a0a4217fd32bf5a2409d573 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/MainAbility2/app.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. + */ +export default { + onCreate() { + console.info('Application2 onCreate') + + }, + onDestroy() { + console.info('Application2 onDestroy') + }, +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1f5d8221bf50adbcea94dddb6516cb2823fdcb90 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,56 @@ +/* + * 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.ServiceExtensionAbility' + +export default class ServiceAbility extends ServiceExtension { + onCreate(want,startId) { + globalThis.abilityWant = 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'); + } + + onConnect(want) { + console.log('ServiceAbility onConnect, want:' + want.abilityName); + globalThis.extensionContext = this.context + if (want.action == 'getExtensionInfotwo') { + this.context.startAbility( + { + bundleName: 'com.example.startabilityforresult', + abilityName: 'com.example.startabilityforresult.MainAbility2' + }, + { + windowMode: 2, + displayId: 10, + }).then(() => { + console.log("====>end startAbility====>success!") + }) + console.log('stub SerivceAbilityServer OnConnect start 2'); + } + + } + + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..b49731a414958a281c2f0c4eab0e7fb408eb2c2f --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f6803bdae181846c8faa6210088026e705074ce7 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/pages/index/index.ets @@ -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 file from '@system.file'; + +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" +import testsuite from "../../test/List.test.ets" +var testTime = 0; + +@Entry +@Component +struct Index { + + aboutToAppear(){ + console.info("start run testcase!!!!") + if(testTime++==0){ + 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..dbd1d391804815917106dc34bbd4d8ca58e2b219 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,278 @@ +/* + * 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' + +var subscriberInfo_MainAbility = { + events: ["ACTS_ConnectAbility_0100_CommonEvent", "ACTS_TerminateSelf_CommonEvent", "ACTS_TerminateSelf_CommonEvent9"] +}; +const START_ABILITY_TIMEOUT = 5000; +console.debug("====>in Ability.test====>"); + +export default function abilityTest(abilityContext) { + describe('ActsGetDisplayIdStartAbilityForResultTest', function () { + console.debug("====>in ActsGetDisplayIdStartAbilityForResultTest====>"); + + /* + * @tc.number: ACTS_startAbilityForResult_0100 + * @tc.name: Get the specified displayId to start Ability + * @tc.desc: Verify Get displayId to startAbilityForResult Ability + */ + it('ACTS_startAbilityForResult_0100', 0, async function (done) { + console.log('ACTS_startAbilityForResult_0100====ACTS_startAbilityForResult_0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + + async function processInfoCheck(data) { + console.info('====> ACTS_startAbilityForResult_0100=====>'); + expect(data.parameters['displayId']).assertEqual(15); + expect(data.parameters['windowMode']).assertEqual(0); + done(); + } + + if (data.event == "ACTS_TerminateSelf_CommonEvent") { + console.info('====> ACTS_startAbilityForResult_0100 start success=====>'); + clearTimeout(id); + processInfoCheck(data); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } + } + + commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { + console.debug("====>ACTS_startAbilityForResult_0100 Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.example.startabilityforresult', + abilityName: 'com.example.startabilityforresult.MainAbility2', + }, { + windowMode: 0, + displayId: 15 + }).then(() => { + console.debug("====>ACTS_startAbilityForResult_0100 end====>"); + }) + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe0100 CallBack====>"); + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_startAbilityForResult_0100 timeout'); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start ACTS_startAbilityForResult_0100 timer id : ' + id); + + }) + + /* + * @tc.number: ACTS_startAbilityForResult_0200 + * @tc.name: Get the specified displayId to start Ability + * @tc.desc: Verify that the ability to startAbilityForResult when displayId is a string + */ + it('ACTS_startAbilityForResult_0200', 0, async function (done) { + console.log('ACTS_startAbilityForResult_0200====ACTS_startAbilityForResult_0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + + async function processInfoCheck() { + console.info('====> ACTS_startAbilityForResult_0200=====>'); + expect(data.parameters['displayId']).assertEqual(0); + expect(data.parameters['windowMode']).assertEqual(0); + commonEvent.unsubscribe(subscriber, unSubscribeCallback); + done(); + } + + if (data.event == "ACTS_TerminateSelf_CommonEvent") { + console.info('====> ACTS_startAbilityForResult_0200 start success=====>'); + clearTimeout(id); + processInfoCheck(); + } + } + + commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { + console.debug("====>ACTS_startAbilityForResult_0200 Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.example.startabilityforresult', + abilityName: 'com.example.startabilityforresult.MainAbility2', + }, { + windowMode: 0, + displayId: undefined + }).then(() => { + console.debug("====>ACTS_startAbilityForResult_0200 end====>"); + }).catch((err) => { + expect().assertFail(); + console.debug("====>ACTS_startAbilityForResult_0200 err====>" + err); + }) + }) + + function unSubscribeCallback() { + console.debug("====>ACTS_startAbilityForResult_0200 UnSubscribe CallBack====>"); + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_startAbilityForResult_0200 timeout'); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start ACTS_startAbilityForResult_0200 timer id : ' + id); + + }) + + /* + * @tc.number: ACTS_startAbilityForResult_0300 + * @tc.name: Get the specified displayId to start Ability + * @tc.desc: Validation parameters want to filter the DISPLAY_ID of parameters + */ + it('ACTS_startAbilityForResult_0300', 0, async function (done) { + console.log('ACTS_startAbilityForResult_0300====ACTS_startAbilityForResult_0300 Subscribe CallBack data:====>" + JSON.stringify(data)); + + async function processInfoCheck(data) { + console.info('====> ACTS_getDisplayIdTest_0600=====>'); + expect(data.parameters['displayId']).assertEqual(0); + expect(data.parameters['windowMode']).assertEqual(0); + done(); + } + + if (data.event == "ACTS_TerminateSelf_CommonEvent") { + console.info('====> ACTS_startAbilityForResult_0300 start success=====>'); + clearTimeout(id); + processInfoCheck(data); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } + } + + commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { + console.debug("====>ACTS_startAbilityForResult_0300 Create Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + await abilityContext.startAbilityForResult( + { + bundleName: 'com.example.startabilityforresult', + abilityName: 'com.example.startabilityforresult.MainAbility2', + parameters: + { + "ohos.aafwk.param.displayId": 10, + } + }, { + }).then(() => { + console.debug("====>ACTS_startAbilityForResult_0300 end====>"); + }).catch((err) => { + expect().assertFail(); + console.debug("====>ACTS_startAbilityForResult_0300 err====>" + err); + }) + }) + + + function unSubscribeCallback() { + console.debug("====>ACTS_startAbilityForResult_0300 UnSubscribe CallBack====>"); + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_startAbilityForResult_0300 timeout'); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start ACTS_startAbilityForResult_0300 timer id : ' + id); + + }) + + /* + * @tc.number: ACTS_startAbilityForResult_0400 + * @tc.name: Get the specified displayId to start Ability + * @tc.desc: Verify the connection to the service application startup page to obtain the specified displayId + */ + it('ACTS_startAbilityForResult_0400', 0, async function (done) { + console.log('ACTS_startAbilityForResult_0400====ACTS_startAbilityForResult_0400_Subscribe CallBack data:====>" + JSON.stringify(data)); + if (data.event == "ACTS_TerminateSelf_CommonEvent") { + clearTimeout(id); + expect(data.parameters['displayId']).assertEqual(10); + expect(data.parameters['windowMode']).assertEqual(2); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + expect(data.event).assertEqual("ACTS_TerminateSelf_CommonEvent"); + + } + } + commonEvent.createSubscriber(subscriberInfo_MainAbility).then(async (data) => { + console.debug("====>ACTS_startAbilityForResult_0400_Create Subscriber====>"); + subscriber = data; + await commonEvent.subscribe(subscriber, subscribeCallBack); + connId = await abilityContext.connectAbility( + { + bundleName: "com.example.startabilityforresult", + abilityName: "com.example.startabilityforresult.ServiceAbility", + action: "getExtensionInfotwo" + } + ); + console.log('ACTS_startAbilityForResult_0400 ConnectAbility connId : ' + connId); + }) + + function unSubscribeCallback() { + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('startAbilityForResult_0400 Disconnect result errCode : ' + error.code + " data: " + data) + done(); + }, + ); + console.debug("====>ACTS_startAbilityForResult_0400_UnSubscribe CallBack====>"); + } + + function timeout() { + expect().assertFail(); + abilityContext.disconnectAbility( + connId, + (error, data) => { + console.log('DisconnectAbility_0400 result errCode : ' + error.code + " data: " + data) + done(); + }, + ); + console.debug('ACTS_startAbilityForResult_0400 timeout'); + done(); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + + + }) + + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..882f978e77b1a8fbbf843ccb4dd73c47ed460305 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/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 './Ability.test.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/module.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..e03188518a858b3cda3905fd65cc2bc754384a4f --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/module.json @@ -0,0 +1,98 @@ +{ + "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.startabilityforresult.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.startabilityforresult.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.example.startabilityforresult.ServiceAbility", + "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.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason": "need use ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS" + }, + { + "name": "ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason": "need use ohos.permission.CLEAN_BACKGROUND_PROCESSES" + }, + { + "name": "ohos.permission.GET_RUNNING_INFO", + "reason": "need use ohos.permission.GET_RUNNING_INFO" + } + ] + } +} diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilityforresulttest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/AppScope/app.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..08b02ce9f242531a7e31db3e05be32945aa148ee --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.actsgetdisplayidtest", + "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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/BUILD.gn b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f9aae81712c7f90addbf93787dc5455706d944b7 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/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("ActsAmsStartAbilityTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsstartabilitytest_js_assets", + ":actsamsstartabilitytest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsStartAbilityTest" +} + +ohos_app_scope("actsamsstartabilitytest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsstartabilitytest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsstartabilitytest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsstartabilitytest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/Test.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..8fd2437efb85f7b1972f76a74980e12f28887b87 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/Test.json @@ -0,0 +1,37 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.actsgetdisplayidtest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsStartAbilityTest.hap", + "ActsAmsSpecifyTestRelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test" + ] + }, + { + "type": "PushKit", + "push": [ + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/test/*.hap" + ] + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..5e2915fe4fc033cd5c9bd579dc08fe7369e51016 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..10dd9a1eaff7ad67843219facba7f8aea7b5a1a5 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class 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") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..577f53879917d26276c6ef294f65d9d044533161 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/pages/index/index.ets @@ -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 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab579310cff112bd2191a015b76cd8fca3eb5a7d --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,323 @@ +/* + * 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 bundle from '@ohos.bundle' +import missionManager from '@ohos.application.missionManager' +import appManager from '@ohos.application.appManager' + + +var subscriberInfoMultiInstance = { + events: ["MultiInstanceStartNext", "MultiInstanceStartFinish", "TestAppOnForeground"] +}; +const START_ABILITY_TIMEOUT = 5000; +const MAX_MISSION_NUM = 1024; + +async function startAbilityProcess(abilityContext, options, parameters) { + let bundleName; + let abilityName; + + try { + let idx = parameters.nextStep; + switch (parameters.step[idx]) { + case "testA": + bundleName = "com.example.actsspecifytesthap"; + abilityName = "com.example.actsspecifytesthap.MainAbility"; + break; + default: + break; + } + parameters.nextStep = ++idx; + abilityContext.startAbility({ + bundleName: bundleName, + abilityName: abilityName, + parameters: parameters, + }, options, (error, data) => { + console.log('startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + } catch (err) { + console.log('ACTS_getDisplayIdTest_0100 err: ' + err) + } +} + +function getMissionId() { + return new Promise(async (resolve, reject) => { + var missionId = -1; + var missionInfos = await missionManager.getMissionInfos('', MAX_MISSION_NUM); + for (let i = 0; i < missionInfos.length; i++) { + console.log('getMissionId result: ' + i + '= ' + JSON.stringify(missionInfos[i])) + if ((missionInfos[i].want.abilityName == "com.example.actsgetdisplayidtest.MainAbility") && + (missionInfos[i].runningState == 0)) { + missionId = missionInfos[i].missionId; + break; + } + } + console.log('======>getMissionId resolve missionId<=======' + missionId); + resolve(missionId); + }) +} + +export default function abilityTest(abilityContext) { + describe('ActsGetDisplayIdStartAbilityTest', function () { + + afterEach(async (done) => { + let installer = await bundle.getBundleInstaller(); + var count = 0; + var testMissionId; + + testMissionId = await getMissionId(); + console.log('======>afterEach test missionId<=======' + testMissionId); + await missionManager.moveMissionToFront(testMissionId); + await appManager.killProcessesByBundleName("com.example.actsspecifytesthap"); + done(); + }) + + + /* + * @tc.number: ACTS_StartAbility_0100 + * @tc.name: Get the specified displayId to start Ability + * @tc.desc: Verify Get displayId to start Ability + */ + it('ACTS_StartAbility_0100', 0, async function (done) { + console.log('ACTS_StartAbility_0100====ACTS_StartAbility_0100 Subscribe CallBack data:====>" + JSON.stringify(data)); + + async function processInfoCheck(data) { + console.info('====> ACTS_StartAbility_0100=====>'); + expect(data.parameters['displayId']).assertEqual(15); + expect(data.parameters['windowMode']).assertEqual(0); + done(); + } + + if (data.event == "MultiInstanceStartFinish") { + console.info('====> ACTS_StartAbility_0100 start success=====>'); + clearTimeout(id); + processInfoCheck(data); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_StartAbility_0100 callBackSeq = ' + data.data); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create0100 Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe0100 CallBack====>"); + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_StartAbility_0100 timeout'); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start ACTS_StartAbility_0100 timer id : ' + id); + + startAbilityProcess(abilityContext, { + windowMode: 0, + displayId: 15 + }, { + startId: 0, + stepNum: 1, + nextStep: 0, + step: ["testA"], + }); + }) + + /* + * @tc.number: ACTS_StartAbility_0200 + * @tc.name: Get the specified displayId to start Ability + * @tc.desc: Verify that the ability to start when displayId is a string + */ + it('ACTS_StartAbility_0200', 0, async function (done) { + console.log('ACTS_StartAbility_0200====ACTS_StartAbility_0200 Subscribe CallBack data:====>" + JSON.stringify(data)); + + async function processInfoCheck(data) { + console.info('====> ACTS_StartAbility_0200=====>'); + expect(data.parameters['displayId']).assertEqual(0); + expect(data.parameters['windowMode']).assertEqual(0); + done(); + } + + if (data.event == "MultiInstanceStartFinish") { + console.info('====> ACTS_StartAbility_0200 start success=====>'); + clearTimeout(id); + processInfoCheck(data); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_StartAbility_0200 callBackSeq = ' + data.data); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create0200 Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe0200 CallBack====>"); + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_StartAbility_0200 timeout'); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start ACTS_StartAbility_0200 timer id : ' + id); + + startAbilityProcess(abilityContext, { + windowMode: 0, + displayId: "abc" + }, { + startId: 0, + stepNum: 1, + nextStep: 0, + step: ["testA"] + }); + }) + + /* + * @tc.number: ACTS_StartAbility_0300 + * @tc.name: Get the specified displayId to start Ability + * @tc.desc: Verify that the ability to start when the displayId is undefined + */ + it('ACTS_StartAbility_0300', 0, async function (done) { + console.log('ACTS_StartAbility_0300====ACTS_StartAbility_0300 Subscribe CallBack data:====>" + JSON.stringify(data)); + + async function processInfoCheck(data) { + console.info('====> ACTS_StartAbility_0300=====>'); + expect(data.parameters['displayId']).assertEqual(0); + expect(data.parameters['windowMode']).assertEqual(0); + done(); + } + + if (data.event == "MultiInstanceStartFinish") { + console.info('====> ACTS_StartAbility_0300 start success=====>'); + clearTimeout(id); + processInfoCheck(data); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_StartAbility_0300 callBackSeq = ' + data.data); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create0300 Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe0300 CallBack====>"); + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_StartAbility_0300 timeout'); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start ACTS_StartAbility_0300 timer id : ' + id); + + startAbilityProcess(abilityContext, { + windowMode: 0, + displayId: undefined + }, { + startId: 0, + stepNum: 1, + nextStep: 0, + step: ["testA"], + }); + }) + + /* + * @tc.number: ACTS_StartAbility_0400 + * @tc.name: Get the specified displayId to start Ability + * @tc.desc: Validation parameters want to filter the DISPLAY_ID of parameters + */ + it('ACTS_StartAbility_0400', 0, async function (done) { + console.log('ACTS_StartAbility_0400====ACTS_StartAbility_0400 Subscribe CallBack data:====>" + JSON.stringify(data)); + + async function processInfoCheck(data) { + console.info('====> ACTS_StartAbility_0400=====>'); + expect(data.parameters['windowMode']).assertEqual(0); + expect(data.parameters['displayId']).assertEqual(0); + done(); + } + + if (data.event == "MultiInstanceStartFinish") { + console.info('====> ACTS_StartAbility_0400 start success=====>'); + clearTimeout(id); + processInfoCheck(data); + commonEvent.unsubscribe(subscriber, unSubscribeCallback) + } else if (data.event == "MultiInstanceStartNext") { + console.log('ACTS_StartAbility_0400 callBackSeq = ' + data.data); + } + } + + commonEvent.createSubscriber(subscriberInfoMultiInstance).then(async (data) => { + console.debug("====>Create0400 Subscriber====>"); + subscriber = data; + commonEvent.subscribe(subscriber, subscribeCallBack); + }) + + function unSubscribeCallback() { + console.debug("====>UnSubscribe0400 CallBack====>"); + } + + function timeout() { + expect().assertFail(); + console.log('ACTS_StartAbility_0400 timeout'); + } + + id = setTimeout(timeout, START_ABILITY_TIMEOUT); + console.log('Start ACTS_StartAbility_0400 timer id : ' + id); + + startAbilityProcess(abilityContext, {}, { + startId: 0, + stepNum: 1, + nextStep: 0, + step: ["testA"], + "ohos.aafwk.param.displayId": 10, + }); + }) + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..882f978e77b1a8fbbf843ccb4dd73c47ed460305 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/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 './Ability.test.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/module.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..ccdf974f472223c915e5236d94b4ddffa488bb04 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/module.json @@ -0,0 +1,79 @@ +{ + "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.actsgetdisplayidtest.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" + ] + } + ] + } + ], + "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.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason": "need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name": "ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason": "need use ohos.permission.GET_RUNNING_INFO" + } + ] + } +} diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/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/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/amsdisplayIdtest/actsamsstartabilitytest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/AppScope/app.json b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..401aac00598c6c67b5ddbbcdcd7022d8be6e4f9f --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.acts.killprocesswithaccountpackage", + "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/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/BUILD.gn b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..ee3d4bb15b5c621c33284b16330a95eaae9e777e --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/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("ActsKillProcessWithAccountRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actskillprocesswithaccountrelyhap_js_assets", + ":actskillprocesswithaccountrelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsKillProcessWithAccountRelyHap" +} + +ohos_app_scope("actskillprocesswithaccountrelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actskillprocesswithaccountrelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actskillprocesswithaccountrelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actskillprocesswithaccountrelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/Test.json b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/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/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..8a70e879c3db1c3ad36ef8efc171e158b83f7452 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/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("MainAbilityT onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("MainAbilityT onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("MainAbilityT onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbilityT onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbilityT onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbilityT onBackground") + } +}; diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..099b533ed6b997475b3d3c130147c8d7f9bf0513 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/ets/pages/index/index.ets @@ -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 router from '@system.router'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('The test application started successfully') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/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/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/module.json b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..fb28a871510b5d914d7a378d143ca1b497160793 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "com.acts.killprocesswithaccountpackage", + "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.killprocesswithaccountpackage.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" + ] + } + ] + } + ] + } +} diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/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/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/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/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountRelyHap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/AppScope/app.json b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..d7596220a8dc4b409ca821c57b3f45f2264bb314 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.acts.killprocesswithaccount", + "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/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/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/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/BUILD.gn b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..571627b22367abbf9e09dbbffdf6e5d8b52ebb7c --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/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("ActsKillProcessWithAccountTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actskillprocesswithaccounttest_js_assets", + ":actskillprocesswithaccounttest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsKillProcessWithAccountTest" +} + +ohos_app_scope("actskillprocesswithaccounttest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actskillprocesswithaccounttest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actskillprocesswithaccounttest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actskillprocesswithaccounttest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/Test.json b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ed5cc409f3b222829c83ce36b462419bab09b5d --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/Test.json @@ -0,0 +1,37 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.acts.killprocesswithaccount", + "shell-timeout": "300000" + }, + "kits": [ + { + "test-file-name": [ + "ActsKillProcessWithAccountTest.hap", + "ActsKillProcessWithAccountRelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsKillProcessWithAccountRelyHap.hap->/data/ActsKillProcessWithAccountRelyHap.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 777 /data/*.hap" + ] + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..5e2915fe4fc033cd5c9bd579dc08fe7369e51016 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/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/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..bbe9a6885ae0945499644fe5f1f40ebabe12b606 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/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/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..cdc6a3a98fefdc4f1aee7660fc23052a85ac7143 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/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.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') + 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('停止进程') + .fontSize(60) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/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/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..a9ab83a999dd4010c87024576d7bc318edfe7c39 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,320 @@ +/* + * 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 appManager from '@ohos.application.AppManager'; +import osaccount from '@ohos.account.osAccount' + +const NULL_ACCOUNT_ID = 102; +const BUNDLE_NAME = 'com.acts.killprocesswithaccountpackage'; +const NULL_BUNDLE_NAME = 'com.aaa.bbb'; +const SETVALUE = 3000; +const SETVALUECOPY = 1500; +const SLEEPVALUE = 500; + +export default function killProcessWithAccountTest(abilityContext) { + describe('Acts_killProcessWithAccountTest', function () { + var ACCOUNT_ID; + var flag = false; + beforeAll(function() { + var osAccountManager = osaccount.getAccountManager(); + console.debug("====>get AccountManager finish===="); + osAccountManager.activateOsAccount(100, (err)=>{ + console.debug("====>activateOsAccount localId: 100 err:" + JSON.stringify(err)); + osAccountManager.getOsAccountLocalIdFromProcess((err,data)=>{ + console.debug("====>getOsAccountLocalIdFromProcess" + " err:" + JSON.stringify(err)); + console.debug("====>getOsAccountLocalIdFromProcess" + " data:" + JSON.stringify(data)); + ACCOUNT_ID = data; + flag = true; + }) + }) + }) + + + beforeEach(async (done) => { + console.log('======>beforeEach killProcessWithAccountTest<======='); + if(flag == false){ + setTimeout(()=>{ + abilityContext.startAbilityWithAccount( + { + bundleName: 'com.acts.killprocesswithaccountpackage', + abilityName: 'com.acts.killprocesswithaccountpackage.MainAbility' + }, ACCOUNT_ID, + { + windowMode: 2, + displayId: 1 + }).then(() => { + console.log(" ====>ACTS_KillProcessWithAccount startability ====> success! ") + done(); + }) + },1000) + }else{ + abilityContext.startAbilityWithAccount( + { + bundleName: 'com.acts.killprocesswithaccountpackage', + abilityName: 'com.acts.killprocesswithaccountpackage.MainAbility' + }, ACCOUNT_ID, + { + windowMode: 2, + displayId: 1 + }).then(() => { + console.log(" ====>ACTS_KillProcessWithAccount startability ====> success! ") + done(); + }) + } + }) + + function sleep(delay) { + var start = (new Date()).getTime(); + while((new Date()).getTime() - start < delay) { + continue; + } + } + + function checkRunningProcess(name, dataInfo) { + for (let i = 0, len = dataInfo.length; i < len; i++) { + if (dataInfo[i].processName == name) { + return true; + } + } + return false; + } + + /** + * @tc.number: ACTS_KillProcessWithAccount_0100 + * @tc.name: Provide the system interface of the specified user management application. + * @tc.desc: Validates the ability to stop the specified process for the specified user. + */ + it('ACTS_KillProcessWithAccount_0100', 0, async function (done) { + console.debug("====>ACTS_KillProcessWithAccount_0100 start startAbility====>"); + + var procrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0100 ==1== getProcessRunningInfos ======> ' + + JSON.stringify(procrssinfo)); + var infores = checkRunningProcess('com.acts.killprocesswithaccountpackage', procrssinfo) + console.log("====>ACTS_KillProcessWithAccount_0100====>infores = " + infores) + expect(infores).assertEqual(true); + + appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(() => { + console.log('ACTS_KillProcessWithAccount_0100 ======> '); + }) + + setTimeout(async() => { + var copyprocrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0100 getProcessRunningInfos ======> ' + + JSON.stringify(copyprocrssinfo)); + var outcopy = checkRunningProcess('com.acts.killprocesswithaccountpackage', copyprocrssinfo) + console.log("====>ACTS_KillProcessWithAccount_0100====>outcopy = " + outcopy) + expect(outcopy).assertEqual(false); + done(); + }, SETVALUE) + }) + + /** + * @tc.number: ACTS_KillProcessWithAccount_0300 + * @tc.name: Provide the system interface of the specified user management application. + * @tc.desc: Authentication cannot stop the specified process for the specified user. + */ + it('ACTS_KillProcessWithAccount_0300', 0, async function (done) { + console.debug("====>ACTS_KillProcessWithAccount_0300 start startAbility====>"); + + var getinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0300 getProcessRunningInfos =1= ======> ' + + JSON.stringify(getinfo)); + var res = checkRunningProcess('com.acts.killprocesswithaccountpackage', getinfo) + console.log("====>ACTS_KillProcessWithAccount_0300====>res = " + res) + expect(res).assertEqual(true); + + appManager.killProcessWithAccount(NULL_BUNDLE_NAME, ACCOUNT_ID).then(() => { + console.log('ACTS_KillProcessWithAccount_0300 ======> '); + }) + + setTimeout(async() => { + var procrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0300 ==1== getProcessRunningInfos ======> ' + + JSON.stringify(procrssinfo)); + var infores = checkRunningProcess('com.acts.killprocesswithaccountpackage', procrssinfo) + console.log("====>ACTS_KillProcessWithAccount_0300====>infores = " + infores) + expect(infores).assertEqual(true); + + await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async() => { + console.log('ACTS_KillProcessWithAccount_0300 killProcess ======> start'); + sleep(SLEEPVALUE) + var copyprocrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0300 getProcessRunningInfos ======> ' + + JSON.stringify(copyprocrssinfo)); + var outcopy = checkRunningProcess('com.acts.killprocesswithaccountpackage', copyprocrssinfo) + console.log("====>ACTS_KillProcessWithAccount_0300====> outcopy = " + outcopy) + expect(outcopy).assertEqual(false); + done(); + }) + }, SETVALUECOPY) + }) + + /** + * @tc.number: ACTS_KillProcessWithAccount_0400 + * @tc.name: Provide the system interface of the specified user management application. + * @tc.desc: Authentication cannot stop the specified process for the specified user. + */ + it('ACTS_KillProcessWithAccount_0400', 0, async function (done) { + console.debug("====>ACTS_KillProcessWithAccount_0400 start startAbility====>"); + + var getinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0400 getProcessRunningInfos =1= ======> ' + JSON.stringify(getinfo)); + var res = checkRunningProcess('com.acts.killprocesswithaccountpackage', getinfo) + console.log("====>ACTS_KillProcessWithAccount_0400====>res = " + res) + expect(res).assertEqual(true); + + appManager.killProcessWithAccount(BUNDLE_NAME, NULL_ACCOUNT_ID).then(() => { + console.log('ACTS_KillProcessWithAccount_0400 killProcess ======> start'); + }) + + setTimeout(async() => { + var procrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0400 ==1== getProcessRunningInfos ======> ' + + JSON.stringify(procrssinfo)); + var infores = checkRunningProcess('com.acts.killprocesswithaccountpackage', procrssinfo) + console.log("====>ACTS_KillProcessWithAccount_0400====>infores = " + infores) + expect(infores).assertEqual(true); + + appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async() => { + console.log('ACTS_KillProcessWithAccount_0400 killProcess2 ======> start'); + + sleep(SLEEPVALUE) + var copyprocrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0400 ==2== getProcessRunningInfos ======> ' + + JSON.stringify(copyprocrssinfo)); + var out = checkRunningProcess('com.acts.killprocesswithaccountpackage', copyprocrssinfo) + console.log("====>ACTS_KillProcessWithAccount_0400====>infores = " + out) + expect(out).assertEqual(false); + done(); + }) + }, SETVALUECOPY) + }) + + /** + * @tc.number: ACTS_KillProcessWithAccount_0500 + * @tc.name: Provide the system interface of the specified user management application. + * @tc.desc: Validates the ability to stop the specified process for the specified user. + */ + it('ACTS_KillProcessWithAccount_0500', 0, async function (done) { + console.debug("====>ACTS_KillProcessWithAccount_0500 start startAbility====>"); + + var procrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0500 ==1== getProcessRunningInfos ======> ' + + JSON.stringify(procrssinfo)); + var infores = checkRunningProcess('com.acts.killprocesswithaccountpackage', procrssinfo) + console.log("====>ACTS_KillProcessWithAccount_0500====>infores = " + infores) + expect(infores).assertEqual(true); + + await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID,(async() => { + console.log('ACTS_KillProcessWithAccount_0500 killProcess ======> start'); + })) + + setTimeout(async() => { + var copyprocrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0500 getProcessRunningInfos ======> ' + + JSON.stringify(copyprocrssinfo)); + var outcopy = checkRunningProcess('com.acts.killprocesswithaccountpackage', copyprocrssinfo) + console.log("====>ACTS_KillProcessWithAccount_0500====>outcopy = " + outcopy) + expect(outcopy).assertEqual(false); + done(); + }, SETVALUE) + }) + + /** + * @tc.number: ACTS_KillProcessWithAccount_0700 + * @tc.name: Provide the system interface of the specified user management application. + * @tc.desc: Authentication cannot stop the specified process for the specified user. + */ + it('ACTS_KillProcessWithAccount_0700', 0, async function (done) { + console.debug("====>ACTS_KillProcessWithAccount_0700 start startAbility====>"); + + var getinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0700 getProcessRunningInfos =1= ======> ' + + JSON.stringify(getinfo)); + var res = checkRunningProcess('com.acts.killprocesswithaccountpackage', getinfo) + console.log("====>ACTS_KillProcessWithAccount_0700====>res = " + res) + expect(res).assertEqual(true); + + appManager.killProcessWithAccount(NULL_BUNDLE_NAME,ACCOUNT_ID,(() => { + console.log('ACTS_KillProcessWithAccount_0700 killProcess ======> start'); + })) + + setTimeout(async() => { + var procrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0700 ==1== getProcessRunningInfos ======> ' + + JSON.stringify(procrssinfo)); + var infores = checkRunningProcess('com.acts.killprocesswithaccountpackage', procrssinfo) + console.log("====>ACTS_KillProcessWithAccount_0700====>infores = " + infores) + expect(infores).assertEqual(true); + + await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async() => { + console.log('ACTS_KillProcessWithAccount_0700 killProcess ======> start'); + sleep(SLEEPVALUE) + var copyprocrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0700 getProcessRunningInfos ======> ' + + JSON.stringify(copyprocrssinfo)); + var outcopy = checkRunningProcess('com.acts.killprocesswithaccountpackage', copyprocrssinfo) + console.log("====>ACTS_KillProcessWithAccount_0700====> outcopy = " + outcopy) + expect(outcopy).assertEqual(false); + done(); + }) + }, SETVALUECOPY) + }) + + /** + * @tc.number: ACTS_KillProcessWithAccount_0800 + * @tc.name: Provide the system interface of the specified user management application. + * @tc.desc: Authentication cannot stop the specified process for the specified user. + */ + it('ACTS_KillProcessWithAccount_0800', 0, async function (done) { + console.debug("====>ACTS_KillProcessWithAccount_0800 start startAbility====>"); + + var getinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0800 getProcessRunningInfos =1= ======> ' + + JSON.stringify(getinfo)); + var res = checkRunningProcess('com.acts.killprocesswithaccountpackage', getinfo) + console.log("====>ACTS_KillProcessWithAccount_0800====>res = " + res) + expect(res).assertEqual(true); + + appManager.killProcessWithAccount(BUNDLE_NAME, NULL_ACCOUNT_ID,(() => { + console.log('ACTS_KillProcessWithAccount_0800 killProcess ======> start'); + })) + + setTimeout(async() => { + var procrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0800 ==1== getProcessRunningInfos ======> ' + + JSON.stringify(procrssinfo)); + var infores = checkRunningProcess('com.acts.killprocesswithaccountpackage', procrssinfo) + console.log("====>ACTS_KillProcessWithAccount_0800====>infores = " + infores) + expect(infores).assertEqual(true); + + await appManager.killProcessWithAccount(BUNDLE_NAME, ACCOUNT_ID).then(async() => { + console.log('ACTS_KillProcessWithAccount_0800 killProcess ======> start'); + sleep(SLEEPVALUE) + var copyprocrssinfo = await appManager.getProcessRunningInfos() + console.log('ACTS_KillProcessWithAccount_0800 getProcessRunningInfos ======> ' + + JSON.stringify(copyprocrssinfo)); + var outcopy = checkRunningProcess('com.acts.killprocesswithaccountpackage', copyprocrssinfo) + console.log("====>ACTS_KillProcessWithAccount_0800====> outcopy = " + outcopy) + expect(outcopy).assertEqual(false); + done(); + }) + }, SETVALUECOPY) + }) + + }) +}; diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..882f978e77b1a8fbbf843ccb4dd73c47ed460305 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/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 './Ability.test.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/module.json b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..cf635c27fcebe0b370f622173adb8a542a22492b --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/module.json @@ -0,0 +1,75 @@ +{ + "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.killprocesswithaccount.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" + ] + } + ] + } + ], + "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.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.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + }, + { + "name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + } + ] + } +} diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/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/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/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/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/killprocesswithaccountstage/ActsKillProcessWithAccountTest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/killprocesswithaccountstage/BUILD.gn b/aafwk/aafwk_standard/killprocesswithaccountstage/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..477f57284154b22a22657b27f932ce1162c73b6a --- /dev/null +++ b/aafwk/aafwk_standard/killprocesswithaccountstage/BUILD.gn @@ -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("//test/xts/tools/build/suite.gni") + +group("killprocesswithaccountstage") { + testonly = true + if (is_standard_system) { + deps = [ + "ActsKillProcessWithAccountRelyHap:ActsKillProcessWithAccountRelyHap", + "ActsKillProcessWithAccountTest:ActsKillProcessWithAccountTest", + ] + } +} diff --git a/aafwk/aafwk_standard/newwant/BUILD.gn b/aafwk/aafwk_standard/newwant/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..75fae526627198e44de25373ce89adcb584c6674 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/BUILD.gn @@ -0,0 +1,27 @@ +# 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") + +group("newwant") { + testonly = true + if (is_standard_system) { + deps = [ + "actsnewwantapi7relyhap:ActsAmsNewWantApi7RelyHap", + "actsnewwantarelyhap:ActsAmsNewWantARelyHap", + "actsnewwantbrelyhap:ActsAmsNewWantBRelyHap", + "actsnewwantrelyhap:ActsAmsNewWantRelyHap", + "actsnewwanttest:ActsAmsNewWantTest", + ] + } +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/BUILD.gn b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..b198f2ee22e58daee5f0292376ad560968247edc --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/BUILD.gn @@ -0,0 +1,35 @@ +# 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_hap("ActsAmsNewWantApi7RelyHap") { + hap_profile = "./entry/src/main/config.json" + hap_name = "ActsAmsNewWantApi7RelyHap" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./entry/src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./entry/src/main/js/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/config.json b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..2b2738b6e0a640428d6ed6b37945c1148058a32e --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/config.json @@ -0,0 +1,87 @@ +{ + "app": { + "bundleName": "com.example.newwanthapapi7", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.newwanthapapi7", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "visible": true, + "name": "com.example.newwanthapapi7.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "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" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/app.js b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/app.js new file mode 100755 index 0000000000000000000000000000000000000000..875191631733a62e2bdff76d6b5a2e2f1b130937 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/app.js @@ -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. + */ + +export default { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/i18n/en-US.json b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/i18n/en-US.json new file mode 100755 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/i18n/zh-CN.json b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/i18n/zh-CN.json new file mode 100755 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/pages/index/index.css b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/pages/index/index.css new file mode 100755 index 0000000000000000000000000000000000000000..6fda792753f2e15f22b529c7b90a82185b2770bf --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/pages/index/index.css @@ -0,0 +1,9 @@ +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/pages/index/index.hml b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/pages/index/index.hml new file mode 100755 index 0000000000000000000000000000000000000000..f64b040a5ae394dbaa5e185e1ecd4f4556b92184 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/pages/index/index.hml @@ -0,0 +1,5 @@ +
+ + {{ $t('strings.hello') }} {{ title }} + +
diff --git a/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/pages/index/index.js b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/pages/index/index.js new file mode 100755 index 0000000000000000000000000000000000000000..8075462004ab121244be198f0d7dfa290db53a4d --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/default/pages/index/index.js @@ -0,0 +1,85 @@ +/* + * 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 app from '@system.app' +import device from '@system.device' +import router from '@system.router' +import { Core, ExpectExtend } from 'deccjsunit/index' +import featureAbility from '@ohos.ability.featureability' + +const injectRef = Object.getPrototypeOf(global) || global +injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') + +export default { + data: { + title: "" + }, + onInit() { + console.info('ACTS_NewWant Api7 onInit'); + this.title = "ProcessManageSystemAppA"; + }, + onReady() { + console.info('ACTS_NewWant Api7 onReady'); + }, + onActive() { + console.info('ACTS_NewWant Api7 onActive'); + }, + async onShow() { + console.info('ACTS_NewWant Api7 onShow'); + + await featureAbility.startAbility( + { + want: + { + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.SecondAbility", + action: "restartSecondAbility0800", + }, + } + ); + + }, + onInactive() { + console.info('ACTS_NewWant Api7 onInactive'); + }, + onHide() { + console.info('ACTS_NewWant Api7 onHide'); + }, + onDestroy() { + console.info('ACTS_NewWant Api7 onDestroy'); + }, + onBackPress() { + console.info('ACTS_NewWant Api7 onBackPress'); + }, + onNewRequest() { + console.info('ACTS_NewWant Api7 onNewRequest'); + }, + onStartContinuation() { + console.info('ACTS_NewWant Api7 onStartContinuation'); + }, + onSaveData(value) { + console.info('ACTS_NewWant Api7 onSaveData:' + JSON.stringify(value)); + }, + onRestoreData(value) { + console.info('ACTS_NewWant Api7 onRestoreData:' + JSON.stringify(value)); + }, + onCompleteContinuation(code) { + console.info('ACTS_NewWant Api7 onCompleteContinuation:' + JSON.stringify(code)); + }, + onConfigurationUpdated(configuration) { + console.info('ACTS_NewWant Api7 onConfigurationUpdated:' + JSON.stringify(configuration)); + } +} + diff --git a/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/resources/base/element/string.json b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..d405647b90183b99fb4e15025a9fe12c85c495d4 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "app_name", + "value": "MyApplication" + }, + { + "name": "mainability_description", + "value": "JS_Phone_Empty Feature Ability" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/resources/base/media/icon.png b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/entry/src/main/js/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwantapi7relyhap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/AppScope/app.json b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..54b2e3d929dee8122734cd793c58ab3f42707c2c --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.newwanthapa", + "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/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/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/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/BUILD.gn b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..8739ecfb60413bb5ad946a0146b06e30ace99030 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/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("ActsAmsNewWantARelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsnewwantarelyhap_js_assets", + ":actsnewwantarelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsNewWantARelyHap" +} + +ohos_app_scope("actsnewwantarelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsnewwantarelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsnewwantarelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsnewwantarelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/Test.json b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..6726477872fb03a764124e61a8c04d4fa985c97b --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.newwanthapc", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsNewWantARelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..110b635df49acfaea90f40fac2e11ba1730698f6 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/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/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..b7cc44b8a7f64ef00dcb7d95157e27e9ff4267e0 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,92 @@ +/* + * 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 MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("ACTS_NewWant MainAbility onCreate") + globalThis.abilityWant = want; + commonEvent.publish("onCreateMain_To_Test_CommonEvent", () => { + console.log("ACTS_NewWant Publish CallBack onCreateMain_To_Test_CommonEvent") + }); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ACTS_NewWant MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ACTS_NewWant MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + + commonEvent.publish("onWindowStageCreateMain_To_Test_CommonEvent", () => { + console.log("ACTS_NewWant Publish CallBack onWindowStageCreateMain_To_Test_CommonEvent") + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("ACTS_NewWant MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("ACTS_NewWant MainAbility onForeground") + if (globalThis.abilityWant.action == 'startHapC') { + globalThis.abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.SecondAbility", + action: "startHapA0600" + }, (error, data) => { + console.log('ACTS_NewWant MainAbility onForeground - startAbility start HapA: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + } + commonEvent.publish("onForegroundMain_To_Test_CommonEvent", () => { + console.log("ACTS_NewWant Publish CallBack onForegroundMain_To_Test_CommonEvent") + }); + } + + onBackground() { + // Ability has back to background + console.log("ACTS_NewWant MainAbility onBackground") + } + + onNewWant(want) { + // Ability has brought to foreground when it already in foreground + console.log("ACTS_NewWant MainAbility onNewWant") + globalThis.abilityWant = want; + console.log("ACTS_NewWant MainAbility onNewWant deviceId :" + want) + console.log("ACTS_NewWant MainAbility onNewWant deviceId :" + want.deviceId) + console.log("ACTS_NewWant MainAbility onNewWant bundleName :" + want.bundleName) + console.log("ACTS_NewWant MainAbility onNewWant abilityName :" + want.abilityName) + console.log("ACTS_NewWant MainAbility onNewWant uri :" + want.uri) + console.log("ACTS_NewWant MainAbility onNewWant type :" + want.type) + console.log("ACTS_NewWant MainAbility onNewWant flags :" + want.flags) + console.log("ACTS_NewWant MainAbility onNewWant action :" + want.action) + var publishData = { + data: want.action + } + commonEvent.publish("onNewWantMain_To_Test_CommonEvent", publishData, () => { + console.log("ACTS_NewWant Publish CallBack onNewWantMain_To_Test_CommonEvent") + }); + } +}; diff --git a/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..b5d99a3b33c482e4eaba6ef8732ecb03e26b1de5 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,34 @@ +/* + * 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('NewWantHapA MainAbility') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/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/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/module.json b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..7dd56920a8940087dea3f74f42c759d80a4bafae --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/module.json @@ -0,0 +1,65 @@ +{ + "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.newwanthapc.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "singleton", + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + } + ], + "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" + } + ] + + } +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/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/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/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/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwantarelyhap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/AppScope/app.json b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..07a9a570f9804b57e42b410d4d99b66ff0a33967 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.newwanthap", + "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/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/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/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/BUILD.gn b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..5ff1b8f79d2af4b81619fb2c51bfb7a8d56d0513 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/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("ActsAmsNewWantBRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsnewwantbrelyhap_js_assets", + ":actsnewwantbrelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsNewWantBRelyHap" +} + +ohos_app_scope("actsnewwantbrelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsnewwantbrelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsnewwantbrelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsnewwantbrelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/Test.json b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..5d03e342a51156059d3ae38ea9199705d902e036 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "180000", + "package": "com.example.newwanthapb", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsNewWantBRelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..b44ce4627f394138ce64d0d042822a881b3bb9d2 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/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.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..916d23571b6d899c5cb38c871a2319a514795ca3 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,92 @@ +/* + * 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 MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("ACTS_NewWant MainAbility onCreate") + globalThis.abilityWant = want; + commonEvent.publish("onCreateMain_To_Test_CommonEvent", () => { + console.log("ACTS_NewWant Publish CallBack onCreateMain_To_Test_CommonEvent") + }); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ACTS_NewWant MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ACTS_NewWant MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + + commonEvent.publish("onWindowStageCreateMain_To_Test_CommonEvent", () => { + console.log("ACTS_NewWant Publish CallBack onWindowStageCreateMain_To_Test_CommonEvent") + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("ACTS_NewWant MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("ACTS_NewWant MainAbility onForeground") + if (globalThis.abilityWant.action == 'startHapB') { + globalThis.abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.SecondAbility", + action: "startHapA0500" + }, (error, data) => { + console.log('ACTS_NewWant MainAbility onForeground - startAbility start HapA: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + } + commonEvent.publish("onForegroundMain_To_Test_CommonEvent", () => { + console.log("ACTS_NewWant Publish CallBack onForegroundMain_To_Test_CommonEvent") + }); + } + + onBackground() { + // Ability has back to background + console.log("ACTS_NewWant MainAbility onBackground") + } + + onNewWant(want) { + // Ability has brought to foreground when it already in foreground + console.log("ACTS_NewWant MainAbility onNewWant") + globalThis.abilityWant = want; + console.log("ACTS_NewWant MainAbility onNewWant deviceId :" + want) + console.log("ACTS_NewWant MainAbility onNewWant deviceId :" + want.deviceId) + console.log("ACTS_NewWant MainAbility onNewWant bundleName :" + want.bundleName) + console.log("ACTS_NewWant MainAbility onNewWant abilityName :" + want.abilityName) + console.log("ACTS_NewWant MainAbility onNewWant uri :" + want.uri) + console.log("ACTS_NewWant MainAbility onNewWant type :" + want.type) + console.log("ACTS_NewWant MainAbility onNewWant flags :" + want.flags) + console.log("ACTS_NewWant MainAbility onNewWant action :" + want.action) + var publishData = { + data: want.action + } + commonEvent.publish("onNewWantMain_To_Test_CommonEvent", publishData, () => { + console.log("ACTS_NewWant Publish CallBack onNewWantMain_To_Test_CommonEvent") + }); + } +}; diff --git a/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..7de1dbf050e6af338ae385db8f41a96be249c0e6 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,35 @@ +/* + * 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('NewWantHapA MainAbility') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..da74051a99a220c14eb6942d51794bfebbdc405f --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/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/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/module.json b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..3b33503efa2e175ab55e125347b936b82e92839a --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/module.json @@ -0,0 +1,65 @@ +{ + "module": { + "name": "com.example.newwanthapb", + "type": "feature", + "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.newwanthapb.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "singleton", + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + } + ], + "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" + } + ] + + } +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/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/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/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/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwantbrelyhap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/AppScope/app.json b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..07a9a570f9804b57e42b410d4d99b66ff0a33967 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.newwanthap", + "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/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/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/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/BUILD.gn b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..104d7ef93c610e421dc35dee50dec0a065229f37 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/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("ActsAmsNewWantRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsnewwantrelyhap_js_assets", + ":actsnewwantrelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsNewWantRelyHap" +} + +ohos_app_scope("actsnewwantrelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsnewwantrelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsnewwantrelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsnewwantrelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/Test.json b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..4300a64be9af93e37a31f6b5c6fc734e8f1b4563 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..b44ce4627f394138ce64d0d042822a881b3bb9d2 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/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.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..283ebefaa00560e36a18a49659cba26e161e616e --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,110 @@ +/* + * 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 MainAbility extends Ability { + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("ACTS_NewWant MainAbility onCreate") + globalThis.abilityWant = want; + commonEvent.publish("onCreateMain_To_Test_CommonEvent", () => { + console.log("ACTS_NewWant Publish CallBack onCreateMain_To_Test_CommonEvent") + }); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ACTS_NewWant MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ACTS_NewWant MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + + commonEvent.publish("onWindowStageCreateMain_To_Test_CommonEvent", () => { + console.log("ACTS_NewWant Publish CallBack onWindowStageCreateMain_To_Test_CommonEvent") + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("ACTS_NewWant MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("ACTS_NewWant MainAbility onForeground") + if (globalThis.abilityWant.action == 'startStandard0400') { + globalThis.abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.SecondAbility", + action: "restartSingleton" + }, (error, data) => { + console.log('ACTS_NewWant MainAbility onForeground - startAbility restart singleton: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + } + if (globalThis.abilityWant.action == 'startStandard0300') { + globalThis.abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.SecondAbility", + action: "startSingleton0300" + }, (error, data) => { + console.log('ACTS_NewWant MainAbility onForeground - startAbility restart singleton: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + } + if (globalThis.abilityWant.action == 'startMainAbility0700') { + globalThis.abilityContext.connectAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.ServiceAbility", + action: "connectServiceAbility0700" + }, (error, data) => { + console.log('ACTS_NewWant MainAbility onForeground - startAbility startServiceAbility: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + } + commonEvent.publish("onForegroundMain_To_Test_CommonEvent", () => { + console.log("ACTS_NewWant MainAbility Publish CallBack onForegroundMain_To_Test_CommonEvent") + }); + } + + onBackground() { + // Ability has back to background + console.log("ACTS_NewWant MainAbility onBackground") + } + + onNewWant(want) { + // Ability has brought to foreground when it already in foreground + console.log("ACTS_NewWant MainAbility onNewWant") + globalThis.abilityWant = want; + console.log("ACTS_NewWant MainAbility onNewWant deviceId :" + want) + console.log("ACTS_NewWant MainAbility onNewWant deviceId :" + want.deviceId) + console.log("ACTS_NewWant MainAbility onNewWant bundleName :" + want.bundleName) + console.log("ACTS_NewWant MainAbility onNewWant abilityName :" + want.abilityName) + console.log("ACTS_NewWant MainAbility onNewWant uri :" + want.uri) + console.log("ACTS_NewWant MainAbility onNewWant type :" + want.type) + console.log("ACTS_NewWant MainAbility onNewWant flags :" + want.flags) + console.log("ACTS_NewWant MainAbility onNewWant action :" + want.action) + + commonEvent.publish("onNewWantMain_To_Test_CommonEvent", () => { + console.log("ACTS_NewWant MainAbility Publish CallBack onNewWantMain_To_Test_CommonEvent") + }); + } +}; diff --git a/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/SecondAbility/SecondAbility.ts b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/SecondAbility/SecondAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..31adfe1539605a25531339828a3f0b7d34901b0d --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/SecondAbility/SecondAbility.ts @@ -0,0 +1,146 @@ +/* + * 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 SecondAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("ACTS_NewWant SecondAbility onCreate") + globalThis.abilityWant = want; + commonEvent.publish("onCreateSecond_To_Test_CommonEvent", () => { + console.log("ACTS_NewWant Publish CallBack onCreateSecond_To_Test_CommonEvent") + }); + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ACTS_NewWant SecondAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ACTS_NewWant SecondAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + + commonEvent.publish("onWindowStageCreateSecond_To_Test_CommonEvent", () => { + console.log("ACTS_NewWant Publish CallBack onWindowStageCreateSecond_To_Test_CommonEvent") + }); + } + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("ACTS_NewWant SecondAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + var connId; + console.log("ACTS_NewWant SecondAbility onForeground") + if (globalThis.abilityWant.action == 'startSingleton0400') + { + globalThis.abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.MainAbility", + action:"startStandard0400" + }, (error, data) => { + console.log('ACTS_NewWant SecondAbility onForeground - startAbility start standard: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + } + if (globalThis.abilityWant.action == 'startSingleton0300') + { + globalThis.abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.MainAbility", + action:"restartSingleton" + }, (error, data) => { + console.log('ACTS_NewWant SecondAbility onForeground - startAbility restart standard: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + } + if (globalThis.abilityWant.action == 'startHapA0500') { + globalThis.abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapb.MainAbility", + action: "restartHapB" + }, (error, data) => { + console.log('ACTS_NewWant SecondAbility onForeground - startAbility restart HapB: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + } + if (globalThis.abilityWant.action == 'startHapA0600') { + globalThis.abilityContext.startAbility({ + bundleName: "com.example.newwanthapa", + abilityName: "com.example.newwanthapc.MainAbility", + action: "restartHapC" + }, (error, data) => { + console.log('ACTS_NewWant SecondAbility onForeground - startAbility restart HapC: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + } + if (globalThis.abilityWant.action == 'startSecondAbility0700') { + globalThis.abilityContext.startAbility( + { + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.MainAbility", + action: "startMainAbility0700" + }, (error, data) => { + console.log('ACTS_NewWant SecondAbility onForeground - startAbility startMainAbility0700: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }); + } + if (globalThis.abilityWant.action == 'startSecondAbility0800') { + globalThis.abilityContext.startAbility( + { + bundleName: "com.example.newwanthapapi7", + abilityName: "com.example.newwanthapapi7.MainAbility", + action: "startapi70800" + }, (error, data) => { + console.log('ACTS_NewWant SecondAbility onForeground - startAbility startapi70800: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }); + } + commonEvent.publish("onForegroundSecond_To_Test_CommonEvent", () => { + console.log("ACTS_NewWant SecondAbility Publish CallBack onForegroundSecond_To_Test_CommonEvent") + }); + } + + onBackground() { + // Ability has back to background + console.log("ACTS_NewWant SecondAbility onBackground") + } + + onNewWant(want) { + // Ability has brought to foreground when it already in foreground + console.log("ACTS_NewWant SecondAbility onNewWant") + globalThis.abilityWant = want; + console.log("ACTS_NewWant SecondAbility onNewWant deviceId :" + want.deviceId) + console.log("ACTS_NewWant SecondAbility onNewWant bundleName :" + want.bundleName) + console.log("ACTS_NewWant SecondAbility onNewWant abilityName :" + want.abilityName) + console.log("ACTS_NewWant SecondAbility onNewWant uri :" + want.uri) + console.log("ACTS_NewWant SecondAbility onNewWant type :" + want.type) + console.log("ACTS_NewWant SecondAbility onNewWant flags :" + want.flags) + console.log("ACTS_NewWant SecondAbility onNewWant action :" + want.action) + var publishData = { + data: want.action + } + commonEvent.publish("onNewWantSecond_To_Test_CommonEvent", publishData,() => { + console.log("ACTS_NewWant SecondAbility Publish CallBack onNewWantSecond_To_Test_CommonEvent") + }); + } +}; diff --git a/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..b011fe64c0f5aedebdf461bf3d329cdf893bc05e --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,52 @@ +/* + * 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' + +export default class ServiceAbility extends ServiceExtension { + onCreate(want, startId) { + globalThis.abilityWant = want; + console.log('ACTS_NewWant ServiceAbility onCreate, want: ' + want.abilityName); + } + + onRequest(want, startId) { + console.log('ACTS_NewWant ServiceAbility onRequest, want: ' + want.abilityName + ', startId: ' + startId); + } + + onConnect(want) { + var connId; + console.log('ACTS_NewWant ServiceAbility onConnect, want:' + want.abilityName); + globalThis.extensionContext = this.context + if (globalThis.abilityWant.action == 'connectServiceAbility0700') { + console.log('ACTS_NewWant ServiceAbility onConnect, action:' + globalThis.abilityWant.action); + this.context.startAbility( + { + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.SecondAbility", + action: "restartSecondAbility0700" + }, + ) + } + } + + onDisconnect(want) { + console.log('ACTS_NewWant ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ACTS_NewWant ServiceAbility onDestroy'); + } +}; diff --git a/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..8f18a61d57fe4cc71cd70bae4d9378d284df0e2c --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/ServiceAbility/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/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..ec61f51e52e37bdc07570771f3a0373033941aab --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,38 @@ +/* + * 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!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('NewWantHapA MainAbility') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..da74051a99a220c14eb6942d51794bfebbdc405f --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/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/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/module.json b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..1c9da0c5dd6ab3a761929c0504118abf35d16c1f --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/module.json @@ -0,0 +1,86 @@ +{ + "module": { + "name": "com.example.newwanthapa", + "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.newwanthapa.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "standard", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + }, + { + "name": "com.example.newwanthapa.SecondAbility", + "srcEntrance": "./ets/SecondAbility/SecondAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton" + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "name": "com.example.newwanthapa.ServiceAbility", + "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" + } + ] + + } +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/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/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/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/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwantrelyhap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/newwant/actsnewwanttest/AppScope/app.json b/aafwk/aafwk_standard/newwant/actsnewwanttest/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..79b38c8ef05b4fb2290cb8cd27bf2296819a9b1c --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwanttest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.newwanttest", + "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/aafwk/aafwk_standard/newwant/actsnewwanttest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/newwant/actsnewwanttest/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwanttest/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/aafwk/aafwk_standard/newwant/actsnewwanttest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/newwant/actsnewwanttest/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwanttest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/newwant/actsnewwanttest/BUILD.gn b/aafwk/aafwk_standard/newwant/actsnewwanttest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..63217f54f89fa5c3ef0d084d3fa96830f5e3d56a --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwanttest/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("ActsAmsNewWantTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsnewwanttest_js_assets", + ":actsnewwanttest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsNewWantTest" +} + +ohos_app_scope("actsnewwanttest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsnewwanttest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsnewwanttest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsnewwanttest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/newwant/actsnewwanttest/Test.json b/aafwk/aafwk_standard/newwant/actsnewwanttest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..6ffb225f0c54d65cf88fdde373e2e747653fe03d --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwanttest/Test.json @@ -0,0 +1,40 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.newwanttest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsNewWantTest.hap", + "ActsAmsNewWantRelyHap.hap", + "ActsAmsNewWantBRelyHap.hap", + "ActsAmsNewWantARelyHap.hap", + "ActsAmsNewWantApi7RelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + }, + { + "type": "PushKit", + "push": [ + + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/*.hap" + ] + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..f9496184771ff98f0ce1d3e05d310d8594e015df --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwanttest/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.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..a573c393727b6ddbbc0e5269b57333ba91ab58db --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,52 @@ +/* + * 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") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..1f4b8cf4618b0e2bfe187886920ccb54ac9207df --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,67 @@ +/* + * 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..da74051a99a220c14eb6942d51794bfebbdc405f --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwanttest/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/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..6619aff7d184f95d6e0d3195f283967be22759b3 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,653 @@ +/* + * 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 missionManager from '@ohos.application.missionManager' +import appManager from '@ohos.application.appManager' + +const MAX_MISSION_NUM = 1024; +var subscriberInfo = { + events: ['onCreateMain_To_Test_CommonEvent', + 'onWindowStageCreateMain_To_Test_CommonEvent', + 'onForegroundMain_To_Test_CommonEvent', + 'onNewWantMain_To_Test_CommonEvent', + 'onCreateSecond_To_Test_CommonEvent', + 'onWindowStageCreateSecond_To_Test_CommonEvent', + 'onForegroundSecond_To_Test_CommonEvent', + 'onNewWantSecond_To_Test_CommonEvent', + ], +}; + +function getMissionId() { + return new Promise(async (resolve, reject) => { + var missionId = -1; + var missionInfos = await missionManager.getMissionInfos('', MAX_MISSION_NUM); + console.log('======>ACTS_NewWant_Test getMissionId missionInfos<=======' + missionInfos); + for (let i = 0; i < missionInfos.length; i++) { + console.log('getMissionId result: ' + i + '= ' + JSON.stringify(missionInfos[i])) + if ((missionInfos[i].want.abilityName == "com.example.newwanttest.MainAbility") && + (missionInfos[i].runningState == 0)) { + missionId = missionInfos[i].missionId; + break; + } + } + console.log('======>ACTS_NewWant_Test getMissionId resolve missionId<=======' + missionId); + resolve(missionId); + }) +} + +export default function abilityTest(abilityContext) { + describe('ActsNewWantTest', function () { + + afterEach(async (done) => { + + var testMissionId; + testMissionId = await getMissionId(); + console.log('======>ACTS_NewWant_Test afterEach test missionId<=======' + testMissionId); + await missionManager.moveMissionToFront(testMissionId); + console.log('======>ACTS_NewWant_Test afterEach test move<======='); + + await appManager.killProcessesByBundleName("com.example.newwanthapapi7"); + await appManager.killProcessesByBundleName("com.example.newwanthapa"); + await appManager.killProcessesByBundleName("com.example.newwanthap"); + + done(); + }) + + /** + * @tc.number: ACTS_NewWant_Test_0100 + * @tc.name: Starting standard Ability for the first time does not trigger onNewWant. + * @tc.desc: Starting standard Ability for the first time does not trigger onNewWant. + */ + it('ACTS_NewWant_Test_0100', 0, async function (done) { + console.log("ACTS_NewWant_Test_0100 --- start") + var Subscriber; + var flagOnCreate = 0; + var flagOnWindowStageCreate = 0; + var flagOnForeground = 0; + var flagOnNewWant = 0; + + abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.MainAbility" + }, (error, data) => { + console.log('ACTS_NewWant_Test_0100 - startAbility start standard: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_NewWant_Test_0100====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function SubscribeCallBack(err, data) { + + console.debug("ACTS_NewWant_Test_0100====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_NewWant_Test_0100====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'onCreateMain_To_Test_CommonEvent': + flagOnCreate++; + break; + case 'onWindowStageCreateMain_To_Test_CommonEvent': + flagOnWindowStageCreate++; + break; + case 'onForegroundMain_To_Test_CommonEvent': + flagOnForeground++; + break; + case 'onNewWantMain_To_Test_CommonEvent': + flagOnNewWant++; + break; + } + console.debug("ACTS_NewWant_Test_0100====>flagOnCreate:====>" + + flagOnCreate) + console.debug("ACTS_NewWant_Test_0100====>flagOnWindowStageCreate:====>" + + flagOnWindowStageCreate) + console.debug("ACTS_NewWant_Test_0100====>flagOnForeground:====>" + + flagOnForeground) + console.debug("ACTS_NewWant_Test_0100====>flagOnNewWant:====>" + + flagOnNewWant) + if (flagOnCreate == 1 && flagOnWindowStageCreate == 1 + && flagOnForeground == 1 && flagOnNewWant == 0) { + expect(flagOnCreate).assertEqual(1); + expect(flagOnWindowStageCreate).assertEqual(1); + expect(flagOnForeground).assertEqual(1); + expect(flagOnNewWant).assertEqual(0); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + } + + function UnSubscribeCallback() { + console.debug("ACTS_NewWant_Test_0100====>UnSubscribe CallBack====>"); + done(); + } + }) + + /** + * @tc.number: ACTS_NewWant_Test_0200 + * @tc.name: Starting singleton Ability for the first time does not trigger onNewWant. + * @tc.desc: Starting singleton Ability for the first time does not trigger onNewWant. + */ + it('ACTS_NewWant_Test_0200', 0, async function (done) { + console.log("ACTS_NewWant_Test_0200 --- start") + var Subscriber; + var flagOnCreate = 0; + var flagOnWindowStageCreate = 0; + var flagOnForeground = 0; + var flagOnNewWant = 0; + + abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.SecondAbility" + }, (error, data) => { + console.log('ACTS_NewWant_Test_0200 - startAbility start singleton: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_NewWant_Test_0200====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function SubscribeCallBack(err, data) { + + console.debug("ACTS_NewWant_Test_0200====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_NewWant_Test_0200====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'onCreateSecond_To_Test_CommonEvent': + flagOnCreate++; + break; + case 'onWindowStageCreateSecond_To_Test_CommonEvent': + flagOnWindowStageCreate++; + break; + case 'onForegroundSecond_To_Test_CommonEvent': + flagOnForeground++; + break; + case 'onNewWantSecond_To_Test_CommonEvent': + flagOnNewWant++; + break; + } + console.debug("ACTS_NewWant_Test_0200====>flagOnCreate:====>" + + flagOnCreate) + console.debug("ACTS_NewWant_Test_0200====>flagOnWindowStageCreate:====>" + + flagOnWindowStageCreate) + console.debug("ACTS_NewWant_Test_0200====>flagOnForeground:====>" + + flagOnForeground) + console.debug("ACTS_NewWant_Test_0200====>flagOnNewWant:====>" + + flagOnNewWant) + if (flagOnCreate == 1 && flagOnWindowStageCreate == 1 + && flagOnForeground == 1 && flagOnNewWant == 0) { + expect(flagOnCreate).assertEqual(1); + expect(flagOnWindowStageCreate).assertEqual(1); + expect(flagOnForeground).assertEqual(1); + expect(flagOnNewWant).assertEqual(0); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + } + + function UnSubscribeCallback() { + console.debug("ACTS_NewWant_Test_0200====>UnSubscribe CallBack====>"); + done(); + } + }) + + /** + * @tc.number: ACTS_NewWant_Test_0300 + * @tc.name: Starting standard ability the second time does not trigger onNewWant. + * @tc.desc: Starting standard ability the second time does not trigger onNewWant. + */ + it('ACTS_NewWant_Test_0300', 0, async function (done) { + console.log("ACTS_NewWant_Test_0300 --- start") + var Subscriber; + var flagOnCreate = 0; + var flagOnWindowStageCreate = 0; + var flagOnForeground = 0; + var flagOnNewWant = 0; + + abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.MainAbility", + action: "startStandard0300" + }, (error, data) => { + console.log('ACTS_NewWant_Test_0300 - startAbility start standard: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_NewWant_Test_0300====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function SubscribeCallBack(err, data) { + + console.debug("ACTS_NewWant_Test_0300====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_NewWant_Test_0300====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'onCreateMain_To_Test_CommonEvent': + flagOnCreate++; + break; + case 'onWindowStageCreateMain_To_Test_CommonEvent': + flagOnWindowStageCreate++; + break; + case 'onForegroundMain_To_Test_CommonEvent': + flagOnForeground++; + break; + case 'onNewWantMain_To_Test_CommonEvent': + flagOnNewWant++; + break; + } + console.debug("ACTS_NewWant_Test_0300====>flagOnCreate:====>" + + flagOnCreate) + console.debug("ACTS_NewWant_Test_0300====>flagOnWindowStageCreate:====>" + + flagOnWindowStageCreate) + console.debug("ACTS_NewWant_Test_0300====>flagOnForeground:====>" + + flagOnForeground) + console.debug("ACTS_NewWant_Test_0300====>flagOnNewWant:====>" + + flagOnNewWant) + + if (flagOnCreate == 2 && flagOnWindowStageCreate == 2 + && flagOnForeground == 2 && flagOnNewWant == 0) { + expect(flagOnCreate).assertEqual(2); + expect(flagOnWindowStageCreate).assertEqual(2); + expect(flagOnForeground).assertEqual(2); + expect(flagOnNewWant).assertEqual(0); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + } + function UnSubscribeCallback() { + console.debug("ACTS_NewWant_Test_0300====>UnSubscribe CallBack====>"); + done(); + } + }) + + /** + * @tc.number: ACTS_NewWant_Test_0400 + * @tc.name: Two abilities of the same hap + * @tc.desc: Starting singleton ability the second time does triggers onNewWant. + */ + it('ACTS_NewWant_Test_0400', 0, async function (done) { + console.log("ACTS_NewWant_Test_0400 --- start") + var Subscriber; + var flagOnCreate = 0; + var flagOnWindowStageCreate = 0; + var flagOnForeground = 0; + var flagOnNewWant = 0; + + abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.SecondAbility", + action: "startSingleton0400" + }, (error, data) => { + console.log('ACTS_NewWant_Test_0400 - startAbility start singleton: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + + + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_NewWant_Test_0400====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function SubscribeCallBack(err, data) { + + console.debug("ACTS_NewWant_Test_0400====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_NewWant_Test_0400====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'onCreateSecond_To_Test_CommonEvent': + flagOnCreate++; + break; + case 'onWindowStageCreateSecond_To_Test_CommonEvent': + flagOnWindowStageCreate++; + break; + case 'onForegroundSecond_To_Test_CommonEvent': + flagOnForeground++; + break; + case 'onNewWantSecond_To_Test_CommonEvent': + flagOnNewWant++; + expect(data.data).assertEqual('restartSingleton'); + break; + } + console.debug("ACTS_NewWant_Test_0400====>flagOnCreate:====>" + + flagOnCreate) + console.debug("ACTS_NewWant_Test_0400====>flagOnWindowStageCreate:====>" + + flagOnWindowStageCreate) + console.debug("ACTS_NewWant_Test_0400====>flagOnForeground:====>" + + flagOnForeground) + console.debug("ACTS_NewWant_Test_0400====>flagOnNewWant:====>" + + flagOnNewWant) + + if (flagOnCreate == 1 && flagOnWindowStageCreate == 1 + && flagOnForeground == 2 && flagOnNewWant == 1) { + expect(flagOnCreate).assertEqual(1); + expect(flagOnWindowStageCreate).assertEqual(1); + expect(flagOnForeground).assertEqual(2); + expect(flagOnNewWant).assertEqual(1); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + } + + function UnSubscribeCallback() { + console.debug("ACTS_NewWant_Test_0400====>UnSubscribe CallBack====>"); + done(); + } + }) + + /** + * @tc.number: ACTS_NewWant_Test_0500 + * @tc.name: Two haps of the same app + * @tc.desc: Starting singleton ability the second time does triggers onNewWant. + */ + it('ACTS_NewWant_Test_0500', 0, async function (done) { + console.log("ACTS_NewWant_Test_0500 --- start") + var Subscriber; + var flagOnCreate = 0; + var flagOnWindowStageCreate = 0; + var flagOnForeground = 0; + var flagOnNewWant = 0; + + abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapb.MainAbility", + action: "startHapB" + }, (error, data) => { + console.log('ACTS_NewWant_Test_0500 - startAbility start HapB: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_NewWant_Test_0500====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function SubscribeCallBack(err, data) { + + console.debug("ACTS_NewWant_Test_0500====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_NewWant_Test_0500====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'onCreateMain_To_Test_CommonEvent': + flagOnCreate++; + break; + case 'onWindowStageCreateMain_To_Test_CommonEvent': + flagOnWindowStageCreate++; + break; + case 'onForegroundMain_To_Test_CommonEvent': + flagOnForeground++; + break; + case 'onNewWantMain_To_Test_CommonEvent': + flagOnNewWant++; + expect(data.data).assertEqual('restartHapB'); + break; + } + console.debug("ACTS_NewWant_Test_0500====>flagOnCreate:====>" + + flagOnCreate) + console.debug("ACTS_NewWant_Test_0500====>flagOnWindowStageCreate:====>" + + flagOnWindowStageCreate) + console.debug("ACTS_NewWant_Test_0500====>flagOnForeground:====>" + + flagOnForeground) + console.debug("ACTS_NewWant_Test_0500====>flagOnNewWant:====>" + + flagOnNewWant) + + if (flagOnCreate == 1 && flagOnWindowStageCreate == 1 + && flagOnForeground == 2 && flagOnNewWant == 1) { + expect(flagOnCreate).assertEqual(1); + expect(flagOnWindowStageCreate).assertEqual(1); + expect(flagOnForeground).assertEqual(2); + expect(flagOnNewWant).assertEqual(1); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + } + + function UnSubscribeCallback() { + console.debug("ACTS_NewWant_Test_0500====>UnSubscribe CallBack====>"); + done(); + } + }) + + /** + * @tc.number: ACTS_NewWant_Test_0600 + * @tc.name: Cross-application + * @tc.desc: Starting singleton ability the second time does triggers onNewWant. + */ + it('ACTS_NewWant_Test_0600', 0, async function (done) { + console.log("ACTS_NewWant_Test_0600 --- start") + var Subscriber; + var flagOnCreate = 0; + var flagOnWindowStageCreate = 0; + var flagOnForeground = 0; + var flagOnNewWant = 0; + + abilityContext.startAbility({ + bundleName: "com.example.newwanthapa", + abilityName: "com.example.newwanthapc.MainAbility", + action: "startHapC" + }, (error, data) => { + console.log('ACTS_NewWant_Test_0600 - startAbility start HapC: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_NewWant_Test_0600====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function SubscribeCallBack(err, data) { + + console.debug("ACTS_NewWant_Test_0600====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_NewWant_Test_0600====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'onCreateMain_To_Test_CommonEvent': + flagOnCreate++; + break; + case 'onWindowStageCreateMain_To_Test_CommonEvent': + flagOnWindowStageCreate++; + break; + case 'onForegroundMain_To_Test_CommonEvent': + flagOnForeground++; + break; + case 'onNewWantMain_To_Test_CommonEvent': + flagOnNewWant++; + expect(data.data).assertEqual('restartHapC'); + break; + } + console.debug("ACTS_NewWant_Test_0600====>flagOnCreate:====>" + + flagOnCreate) + console.debug("ACTS_NewWant_Test_0600====>flagOnWindowStageCreate:====>" + + flagOnWindowStageCreate) + console.debug("ACTS_NewWant_Test_0600====>flagOnForeground:====>" + + flagOnForeground) + console.debug("ACTS_NewWant_Test_0600====>flagOnNewWant:====>" + + flagOnNewWant) + + if (flagOnCreate == 1 && flagOnWindowStageCreate == 1 + && flagOnForeground == 2 && flagOnNewWant == 1) { + expect(flagOnCreate).assertEqual(1); + expect(flagOnWindowStageCreate).assertEqual(1); + expect(flagOnForeground).assertEqual(2); + expect(flagOnNewWant).assertEqual(1); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + } + + function UnSubscribeCallback() { + console.debug("ACTS_NewWant_Test_0600====>UnSubscribe CallBack====>"); + done(); + } + }) + + /** + * @tc.number: ACTS_NewWant_Test_0700 + * @tc.name: Service ability + * @tc.desc: Starting singleton ability the second time does triggers onNewWant. + */ + it('ACTS_NewWant_Test_0700', 0, async function (done) { + console.log("ACTS_NewWant_Test_0700 --- start") + var Subscriber; + var flagOnCreate = 0; + var flagOnWindowStageCreate = 0; + var flagOnForeground = 0; + var flagOnNewWant = 0; + + abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.SecondAbility", + action: "startSecondAbility0700" + }, (error, data) => { + console.log('ACTS_NewWant_Test_0700 - startAbility start SecondAbility: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_NewWant_Test_0700====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function SubscribeCallBack(err, data) { + + console.debug("ACTS_NewWant_Test_0700====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_NewWant_Test_0700====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'onCreateSecond_To_Test_CommonEvent': + flagOnCreate++; + break; + case 'onWindowStageCreateSecond_To_Test_CommonEvent': + flagOnWindowStageCreate++; + break; + case 'onForegroundSecond_To_Test_CommonEvent': + flagOnForeground++; + break; + case 'onNewWantSecond_To_Test_CommonEvent': + flagOnNewWant++; + expect(data.data).assertEqual('restartSecondAbility0700'); + break; + } + console.debug("ACTS_NewWant_Test_0700====>flagOnCreate:====>" + + flagOnCreate) + console.debug("ACTS_NewWant_Test_0700====>flagOnWindowStageCreate:====>" + + flagOnWindowStageCreate) + console.debug("ACTS_NewWant_Test_0700====>flagOnForeground:====>" + + flagOnForeground) + console.debug("ACTS_NewWant_Test_0700====>flagOnNewWant:====>" + + flagOnNewWant) + + if (flagOnCreate == 1 && flagOnWindowStageCreate == 1 + && flagOnForeground == 2 && flagOnNewWant == 1) { + expect(flagOnCreate).assertEqual(1); + expect(flagOnWindowStageCreate).assertEqual(1); + expect(flagOnForeground).assertEqual(2); + expect(flagOnNewWant).assertEqual(1); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + } + function UnSubscribeCallback() { + console.debug("ACTS_NewWant_Test_0700====>UnSubscribe CallBack====>"); + done(); + } + }) + + /** + * @tc.number: ACTS_NewWant_Test_0800 + * @tc.name: API8 startup API7 + * @tc.desc: Starting singleton ability the second time does triggers onNewWant. + */ + it('ACTS_NewWant_Test_0800', 0, async function (done) { + console.log("ACTS_NewWant_Test_0800 --- start") + var Subscriber; + var flagOnCreate = 0; + var flagOnWindowStageCreate = 0; + var flagOnForeground = 0; + var flagOnNewWant = 0; + + abilityContext.startAbility({ + bundleName: "com.example.newwanthap", + abilityName: "com.example.newwanthapa.SecondAbility", + action: "startSecondAbility0800" + }, (error, data) => { + console.log('ACTS_NewWant_Test_0800 - startAbility start SecondAbility: ' + + JSON.stringify(error) + ", " + JSON.stringify(data)) + }) + + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_NewWant_Test_0800====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + function SubscribeCallBack(err, data) { + + console.debug("ACTS_NewWant_Test_0800====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_NewWant_Test_0800====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'onCreateSecond_To_Test_CommonEvent': + flagOnCreate++; + break; + case 'onWindowStageCreateSecond_To_Test_CommonEvent': + flagOnWindowStageCreate++; + break; + case 'onForegroundSecond_To_Test_CommonEvent': + flagOnForeground++; + break; + case 'onNewWantSecond_To_Test_CommonEvent': + flagOnNewWant++; + expect(data.data).assertEqual('restartSecondAbility0800'); + break; + } + console.debug("ACTS_NewWant_Test_0800====>flagOnCreate:====>" + + flagOnCreate) + console.debug("ACTS_NewWant_Test_0800====>flagOnWindowStageCreate:====>" + + flagOnWindowStageCreate) + console.debug("ACTS_NewWant_Test_0800====>flagOnForeground:====>" + + flagOnForeground) + console.debug("ACTS_NewWant_Test_0800====>flagOnNewWant:====>" + + flagOnNewWant) + + if (flagOnCreate == 1 && flagOnWindowStageCreate == 1 + && flagOnForeground == 2 && flagOnNewWant == 1) { + expect(flagOnCreate).assertEqual(1); + expect(flagOnWindowStageCreate).assertEqual(1); + expect(flagOnForeground).assertEqual(2); + expect(flagOnNewWant).assertEqual(1); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + } + function UnSubscribeCallback() { + console.debug("ACTS_NewWant_Test_0800====>UnSubscribe CallBack====>"); + done(); + } + }) + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..64b2a602ef6008d172769f05b9a6c07ad9fe6db5 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwanttest/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) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/module.json b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..3ecfc06f7d7dabe7f0b63024032048553cc03d25 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/module.json @@ -0,0 +1,80 @@ +{ + "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.newwanttest.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" + ] + } + ] + } + ], + "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/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwanttest/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/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/newwant/actsnewwanttest/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/newwant/actsnewwanttest/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/aafwk/aafwk_standard/newwant/actsnewwanttest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/newwant/actsnewwanttest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/aafwk/aafwk_standard/newwant/actsnewwanttest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/non_concurrent/BUILD.gn b/aafwk/aafwk_standard/non_concurrent/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..baccf60e023a77fc58dc59f1313154c0acd110f9 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/BUILD.gn @@ -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("//test/xts/tools/build/suite.gni") + +group("non_concurrent") { + testonly = true + if (is_standard_system) { + deps = [ + "acts_systemappa_test:ActsSystemAppATest", + "acts_systemappone_rely_test:ActsSystemAppOneRelyHap", + ] + } +} diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/AppScope/app.json b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..5ce28640c9db3948d59a6a6c0ef3ec4afc6a4e10 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.actsabilitypermissiontest", + "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/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/BUILD.gn b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..2b0e3dd3cdbb673279f5239fe862fe8085662bb7 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/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("ActsSystemAppATest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actssystemappatest_js_assets", + ":actssystemappatest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsSystemAppATest" +} + +ohos_app_scope("actssystemappatest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actssystemappatest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actssystemappatest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actssystemappatest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/Test.json b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..40ee14906032c8a2ea5cdeca9605fa0aa5bb12ad --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/Test.json @@ -0,0 +1,62 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "300000", + "package": "com.example.actsabilitypermissiontest", + "shell-timeout": "300000" + }, + "kits": [ + { + "test-file-name": [ + "ActsSystemAppATest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsSystemAppATest.hap->/system/app/ActsSystemAppATest.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "acm create -n 101 -t normal", + "acm switch -i 101" + ] + }, + { + "type": "PushKit", + "push": [ + "ActsSystemAppOneRelyHap.hap->/system/app/ActsSystemAppOneRelyHap.hap" + ] + }, + { + "test-file-name": [ + "ActsSystemAppOneRelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "acm switch -i 100" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/*.hap" + ] + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/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/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..8084b50ef553d46316625d9047b7daabebd2e7d8 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/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/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/MainAbility2/MainAbility2.ts b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..d294b1f2ac021e2e1d9c2f86a1d88d8c9005912a --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/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 PublishCallBackOne1() { + console.debug("====>Publish CallBack ACTS_ThirdPartyAbilityPermission_0100_CommonEvent====>"); + globalThis.ability2Context.terminateSelf(); + console.debug("====>close this context====>") +} + + +export default class MainAbility2 extends Ability { + + onCreate(want, launchParam) { + 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") + windowStage.setUIContent(this.context, "pages/index/index2", null) + globalThis.ability2Context = this.context; + commonEvent.publish("ACTS_AbilityPermission_0100_Start_CommonEvent", PublishCallBackOne1); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("MainAbility2 onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("MainAbility2 onForeground") + } + + onBackground() { + // Ability has back to background + console.log("MainAbility2 onBackground") + } +}; diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..8177fd62ac44317c61168fb47697550a8465cabf --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,61 @@ +/* + * 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; + } +} +function PublishCallBackOne8() { + console.debug("====>Publish CallBack ACTS_AbilityPermission_0400====>"); + console.debug("====>close this context====>0400====>") +} +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); + } + + onConnect(want) { + console.log('ServiceAbility onConnect, want:' + want.abilityName); + console.log('ServiceAbility onConnect, action:' + want.action); + if (want.action == 'StartAbilityPromise') { + commonEvent.publish("ACTS_AbilityPermission_0400_Start_CommonEvent", PublishCallBackOne8); + var myStub = new Stub("com.example.actsabilitypermissiontest.ServiceAbility"); + console.log('ThirdAbility onConnect before returnU100:') + return myStub; + console.log('after return') + } + } + + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..af219b5e18c7a8228170921c67c330c9e0f9df36 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/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/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..6f254e65161679e8034527ea64867819d5ff38c1 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/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) + 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('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/pages/index/index2.ets b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/pages/index/index2.ets new file mode 100755 index 0000000000000000000000000000000000000000..f595421dee25894d57787e07ff8b111256599843 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/pages/index/index2.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('页面2') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/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/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/test/AbilityPermission.test.ets b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/test/AbilityPermission.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..782326157c6499fc24fc5b3e421f68180e1f471d --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/test/AbilityPermission.test.ets @@ -0,0 +1,274 @@ +/* + * 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. + */ +// @ts-nocheck +import osaccount from '@ohos.account.osaccount' +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index" +import commonEvent from '@ohos.commonevent' +var AbilityPermission1 = { + events: ["ACTS_AbilityPermission_0100_Start_CommonEvent"] +} +var AbilityPermission3 = { + events: ["ACTS_AbilityPermission_0300_Start_CommonEvent"] +} +var AbilityPermission4 = { + events: ["ACTS_AbilityPermission_0400_Start_CommonEvent"] +} +var AbilityPermission6 = { + events: ["ACTS_AbilityPermission_0600_Start_CommonEvent"] +} +const START_ABILITY_TIMEOUT = 3000; +export default function abilityPermissionTest(abilityContext) { + describe('ActsAbilityPermissionTest', function () { + var osAccountManager = osaccount.getAccountManager(); + var userA; + var userB; + beforeAll(async function(done){ + osAccountManager.getOsAccountLocalIdFromProcess().then((data)=>{ + userA = data + userB=userA+1 + console.log("userA=====>"+userA) + done() + }); + + }) + afterAll(async function(done){ + await osAccountManager.removeOsAccount(userB, (err)=>{ + console.debug("====>remove localId: " + userB + " err:" + JSON.stringify(err)); + expect(err.code).assertEqual(0); + done(); + }) + }) + + /* + * @tc.number: ACTS_AbilityPermission_0100 + * @tc.name: In non-concurrent mode, if the target application is not the current user, it is forbidden to start + * @tc.desc: Start an ability that belongs to the current user with the current user + */ + it('ACTS_AbilityPermission_0100', 0, async function (done) { + console.log("ACTS_AbilityPermission_0100====>callback start====>") + var Subscriber; + var flag = true; + + function SubscribeCallBack(err, data) { + console.debug("ACTS_AbilityPermission_0100====>Subscribe CallBack data:====>" + JSON.stringify(data)); + expect(data.event == 'ACTS_AbilityPermission_0100_Start_CommonEvent').assertTrue() + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + + commonEvent.createSubscriber(AbilityPermission1).then(async (data) => { + console.debug("ACTS_AbilityPermission_0100====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + console.debug("====>start startAbility_100====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actsabilitypermissiontest', + abilityName: 'com.example.actsabilitypermissiontest.MainAbility2' + }, userA, () => { + console.debug("====>startAbility end_100====>"); + }) + }) + + function UnSubscribeCallback() { + flag = false + console.debug("ACTS_AbilityPermission_0100====>UnSubscribe CallBack====>"+flag); + done(); + } + setTimeout(()=>{ + if (flag == true) { + expect().assertFail(); + console.debug('in ACTS_AbilityPermission_0100====>timeout====>'+flag); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + console.debug('ACTS_AbilityPermission_0100====>timeout====>'); + }, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number: ACTS_AbilityPermission_0300 + * @tc.name: In non-concurrent mode, if the target application is not the current user, it is forbidden to start + * @tc.desc: Start an ability under user U101 with the current user + */ + it('ACTS_AbilityPermission_0300', 0, async function (done) { + console.log("ACTS_AbilityPermission_0300====>callback start====>") + var Subscriber + var flag = 0; + console.debug("====>get AccountManager finish===="); + + function SubscribeCallBack(err, data) { + console.debug("ACTS_AbilityPermission_0300====>Subscribe CallBack data:====>" + JSON.stringify(data)); + expect(data.event == 'ACTS_AbilityPermission_0300_Start_CommonEvent').assertTrue() + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + + commonEvent.createSubscriber(AbilityPermission3).then(async (data) => { + console.debug("ACTS_AbilityPermission_0300====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + console.debug("====>start startAbility_0300====>"); + await abilityContext.startAbilityWithAccount( + { + bundleName: 'com.example.actssystemappuonehundredonerelytest', + abilityName: 'com.example.actssystemappuonehundredonerelytest.MainAbility' + }, userA ).then().catch((err) => { + console.debug("ACTS_AbilityPermission_0300====>" + err) + + console.debug("====>startAbility end_0300====>"); + }) + }) + function UnSubscribeCallback() { + if(flag == 0) { + expect().assertFail(); + } + console.debug("ACTS_AbilityPermission_0300====>UnSubscribe CallBack====>"); + done(); + } + function timeout() { + console.debug('ACTS_AbilityPermission_0300====>timeout====>'); + if(flag == 0){ + flag = 1; + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number: ACTS_AbilityPermission_0400 + * @tc.name: In non-concurrent mode, if the target application is not the current user, it is forbidden to start + * @tc.desc: Bind an Ability to which you belong with the current user + */ + it('ACTS_AbilityPermission_0400', 0, async function (done) { + console.log("ACTS_AbilityPermission_0400====>callback start====>") + let Subscriber + var flag = true + + function SubscribeCallBack(err, data) { + expect(data.event == "ACTS_AbilityPermission_0400_Start_CommonEvent").assertTrue(); + console.debug("====>0400 Subscribe CallBack data:====>" + JSON.stringify(data)); + abilityContext.disconnectAbility(globalThis.number).then((data) => { + console.debug("====>data is====>" + JSON.stringify(data)); + }) + console.log('====>disconnectAbility finish'); + } + + function onConnectCallback(element, remote) { + console.log('ACTS_AbilityPermission_0400_Start_CommonEvent onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_AbilityPermission_0400_Start_CommonEvent onConnectCallback====> remote=' + JSON.stringify(remote)); + setTimeout(() => { + console.log('====>in timeout'); + console.debug("====>flag is====>" + JSON.stringify(flag)); + if (flag == true) { + console.debug('ACTS_AbilityPermission_0400_Start_CommonEvent - 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) + } + + commonEvent.createSubscriber(AbilityPermission4).then(async (data) => { + console.debug("====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBack); + console.debug("====>0400start connectAbility====>"); + globalThis.number = await abilityContext.connectAbilityWithAccount( + { + bundleName: 'com.example.actsabilitypermissiontest', + abilityName: 'com.example.actsabilitypermissiontest.ServiceAbility', + action: "StartAbilityPromise" + }, userA, { + onConnect: onConnectCallback, + onDisconnect: onDisconnectCallback, + onFailed: onFailedCallback + }) + console.debug("====>number is====>" + JSON.stringify(globalThis.number)); + }) + + function UnSubscribeCallback() { + console.debug("====>UnSubscribeCallback====>"); + flag = false + done() + } + + function timeout() { + console.debug('in ACTS_AbilityPermission_0400_Start_CommonEvent timeout'); + if (flag == true) { + expect().assertFail(); + console.debug('ACTS_AbilityPermission_0400_Start_CommonEvent - timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) + } + } + setTimeout(timeout, START_ABILITY_TIMEOUT); + }) + + /* + * @tc.number: ACTS_AbilityPermission_0600 + * @tc.name: In non-concurrent mode, if the target application is not the current user, it is forbidden to start + * @tc.desc: Bind a U101 Ability with the current user + */ + it('ACTS_AbilityPermission_0600', 0, async function (done) { + console.log("ACTS_AbilityPermission_0600====>callback start====>") + let Subscriber + let connId + function onConnectCallbackC(element, remote) { + console.log('ACTS_AbilityPermission_0600_Start_CommonEvent onConnectCallback====> element=' + JSON.stringify(element)); + console.log('ACTS_AbilityPermission_0600_Start_CommonEvent onConnectCallback====> remote=' + JSON.stringify(remote)); + expect().assertFail(); + } + function onDisconnectCallbackC(element) { + console.log('onDisconnectCallback====> element=' + JSON.stringify(element)); + } + function onFailedCallbackC(code) { + console.log('onFailedCallback====> code=' + JSON.stringify(code)) + } + function SubscribeCallBackF(err, data) { + console.debug("====>0600 Subscribe CallBack data:====>" + JSON.stringify(data)); + } + function UnSubscribeCallbackF() { + console.debug("====>UnSubscribeCallback====>"); + } + commonEvent.createSubscriber(AbilityPermission6).then(async (data) => { + console.debug("====>Create Subscriber====>"); + Subscriber = data; + commonEvent.subscribe(Subscriber, SubscribeCallBackF); + }) + console.debug("====>0600start connectAbility====>"); + connId = await abilityContext.connectAbilityWithAccount( + { + bundleName: 'com.example.actssystemappuonehundredonerelytest', + abilityName: 'com.example.actssystemappuonehundredonerelytest.ServiceAbility', + action: "StartAbilityPromise" + }, userA, { + onConnect: onConnectCallbackC, + onDisconnect: onDisconnectCallbackC, + onFailed: onFailedCallbackC + }) + console.debug("====>number is====>" + JSON.stringify(connId)); + setTimeout(() =>{ + console.debug('in ACTS_AbilityPermission_0600_Start_CommonEvent timeout'); + commonEvent.unsubscribe(Subscriber, UnSubscribeCallbackF) + done() + }, START_ABILITY_TIMEOUT); + }) + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..c3f15765b2bc58fe35d8411173ec242e0fbb1d2e --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * 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 abilityPermissionText from './AbilityPermission.test.ets' + +export default function testsuite(context) { + abilityPermissionText(context) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/module.json b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..ddbd5e11855d5f31c8ab49c6950308e17f62f8b0 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/module.json @@ -0,0 +1,121 @@ +{ + "module": { + "name": "com.example.actsabilitypermissiontest", + "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.actsabilitypermissiontest.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.actsabilitypermissiontest.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.actsabilitypermissiontest.ServiceAbility", + "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" + }, + { + "name":"ohos.permission.MANAGE_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.MANAGE_LOCAL_ACCOUNTS" + }, + { + "name":"ohos.permission.INTERACT_ACROSS)LOCAL_ACCOUNTS_EXTENSION", + "reason":"need use ohos.permission.INTERACT_ACROSS)LOCAL_ACCOUNTS_EXTENSION" + }, + { + "name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS", + "reason":"need use ohos.permission.GET_RUNNING_INFO" + } + ] + } +} diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/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/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/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/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/non_concurrent/acts_systemappa_test/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/AppScope/app.json b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..18517fb4971dd5588a86c493accf5bda6d20d4d7 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.acts.pmvendorappa", + "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/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/BUILD.gn b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..29f5958dfdb3899771a84dfff99cf7445eeb3860 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/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("ActsSystemAppOneRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":acts_systemappone_rely_test_js_assets", + ":acts_systemappone_rely_test_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsSystemAppOneRelyHap" +} + +ohos_app_scope("acts_systemappone_rely_test_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("acts_systemappone_rely_test_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("acts_systemappone_rely_test_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":acts_systemappone_rely_test_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/Test.json b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/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/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..d05a5ffe2686111c5457e6918a5a6229a7e6ae04 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,59 @@ +/* + * 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 PublishCallBackOne3() { + console.debug("====>Publish CallBack ACTS_StartAbility_0300_CommonEvent====>"); + setTimeout(globalThis.abilityContext.terminateSelfWithResult(()=>{ + console.debug("====>terminateSelfWithResult succese====>") + }),1000) +} + +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 + commonEvent.publish("ACTS_AbilityPermission_0300_Start_CommonEvent", PublishCallBackOne3); + 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/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..346c6e55ee287aa06ab8c669880d1b6c0f174e98 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/ServiceAbility/ServiceAbility.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 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; + } +} +function PublishCallBackOne8() { + console.debug("====>Publish CallBack ACTS_AbilityPermission_0600====>"); + console.debug("====>close this context====>0600====>") +} +export default class ServiceAbility extends ServiceExtension { + onCreate(want) { + console.log('====>user101====>') + } + + onRequest(want, startId) { + console.log('ServiceAbility onRequest, want: ' + want.abilityName + ', startId: ' + startId); + } + + onConnect(want) { + console.log('ServiceAbility onConnect, want:' + want.abilityName); + if (want.action == 'StartAbilityPromise') { + commonEvent.publish("ACTS_AbilityPermission_0600_Start_CommonEvent", PublishCallBackOne8); + var myStub = new Stub("com.example.actssystemappuonehundredonerelytest.ServiceAbility"); + console.log('ThirdAbility onConnect before return:') + return myStub; + console.log('ServiceAbility onCreate, want: ' + want.abilityName); + } + } + + onDisconnect(want) { + console.log('ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ServiceAbility onDestroy'); + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..af219b5e18c7a8228170921c67c330c9e0f9df36 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/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/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..845ac99a65c818dddc9fdd0db462499ef02cdb11 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/pages/index/index.ets @@ -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 router from '@system.router'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/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/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/module.json b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..4368135e3eb898185cf91bb30b831f37fb40a10e --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/module.json @@ -0,0 +1,48 @@ +{ + "module": { + "name": "com.example.actssystemappuonehundredonerelytest", + "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.actssystemappuonehundredonerelytest.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.actssystemappuonehundredonerelytest.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + } + ] + } +} diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/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/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/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/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/non_concurrent/acts_systemappone_rely_test/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/processmultiinstance/BUILD.gn b/aafwk/aafwk_standard/processmultiinstance/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..d34fecffd0d4209e55e7e77786136e0957ecc30b --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/BUILD.gn @@ -0,0 +1,31 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +group("processmultiinstance") { + testonly = true + if (is_standard_system) { + deps = [ + "actsamsprocessmultiinstancehapaarelyhap:ActsAmsProcessMultiinstanceHapAARelyHap", + "actsamsprocessmultiinstancehapabrelyhap:ActsAmsProcessMultiinstanceHapABRelyHap", + "actsamsprocessmultiinstancehapbarelyhap:ActsAmsProcessMultiinstanceHapBARelyHap", + "actsamsprocessmultiinstancehapbbrelyhap:ActsAmsProcessMultiinstanceHapBBRelyHap", + "actsamsprocessmultiinstancehapbcrelyhap:ActsAmsProcessMultiinstanceHapBCRelyHap", + "actsamsprocessmultiinstancehapbdrelyhap:ActsAmsProcessMultiinstanceHapBDRelyHap", + "actsamsprocessmultiinstancehapberelyhap:ActsAmsProcessMultiinstanceHapBERelyHap", + "actsamsprocessmultiinstancehapbfrelyhap:ActsAmsProcessMultiinstanceHapBFRelyHap", + "actsamsprocessmultiinstancetest:ActsAmsProcessMultiinstanceTest", + ] + } +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/AppScope/app.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..6ee7789158606606bfa9ef49384505f61b912da1 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.multiinstancehapa", + "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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/BUILD.gn b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..15d4aa6e7df70e622ad1ebe9d3053cbc1790a1bf --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/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("ActsAmsProcessMultiinstanceHapAARelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsprocessmultiinstancehapaarelyhap_js_assets", + ":actsamsprocessmultiinstancehapaarelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsProcessMultiinstanceHapAARelyHap" +} + +ohos_app_scope("actsamsprocessmultiinstancehapaarelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsprocessmultiinstancehapaarelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsprocessmultiinstancehapaarelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsprocessmultiinstancehapaarelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/Test.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..599b77156107cb0535c6711ec09ad4d84eb95d59 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,56 @@ +/* +* 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 MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("ACTS_Process_MultiInstance_HapAA MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ACTS_Process_MultiInstance_HapAA MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ACTS_Process_MultiInstance_HapAA MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + + commonEvent.publish("HapAA_To_Test_CommonEvent", () => { + console.log("ACTS_Process_MultiInstance_HapAA Publish CallBack HapAA_To_Test_CommonEvent") + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("ACTS_Process_MultiInstance_HapAA MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("ACTS_Process_MultiInstance_HapAA MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("ACTS_Process_MultiInstance_HapAA MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..16e1531e48430510168d31c9f8d8c595c3b62ab9 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* +* 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/module.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..446592a4a927b92ce50acd0133907ba243939177 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "com.example.multiinstancehapaa", + "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.multiinstancehapaa.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" + ] + } + ] + } + ] + } +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapaarelyhap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/AppScope/app.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..6ee7789158606606bfa9ef49384505f61b912da1 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.multiinstancehapa", + "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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/BUILD.gn b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..ab19e57fe806a8baa4642f65b475ecd5fd3ac812 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/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("ActsAmsProcessMultiinstanceHapABRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsprocessmultiinstancehapabrelyhap_js_assets", + ":actsamsprocessmultiinstancehapabrelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsProcessMultiinstanceHapABRelyHap" +} + +ohos_app_scope("actsamsprocessmultiinstancehapabrelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsprocessmultiinstancehapabrelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsprocessmultiinstancehapabrelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsprocessmultiinstancehapabrelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/Test.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..66fcd8524f4cad081eb920d92e4a0432d90e7b7d --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,56 @@ +/* +* 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 MainAbility extends Ability { + + onCreate(want, launchParam) { + // Ability is creating, initialize resources for this ability + console.log("ACTS_Process_MultiInstance_HapAB MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ACTS_Process_MultiInstance_HapAB MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ACTS_Process_MultiInstance_HapAB MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + + commonEvent.publish("HapAB_To_Test_CommonEvent", () => { + console.log("ACTS_Process_MultiInstance_HapAB Publish CallBack HapAB_To_Test_CommonEvent") + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("ACTS_Process_MultiInstance_HapAB MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("ACTS_Process_MultiInstance_HapAB MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("ACTS_Process_MultiInstance_HapAB MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..16e1531e48430510168d31c9f8d8c595c3b62ab9 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* +* 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..f5a3a748b7c8bbde987cd058278509dcbba40225 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/ets/pages/second/second.ets @@ -0,0 +1,43 @@ +import router from '@system.router'; + +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +@Entry +@Component +struct 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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/module.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..3193a5605479849365d3bb60edc4d37bd8665579 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/module.json @@ -0,0 +1,38 @@ +{ + "module": { + "name": "com.example.multiinstancehapab", + "process": "com.example.multiinstancehapb", + "type": "feature", + "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.multiinstancehapab.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" + ] + } + ] + } + ] + } +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapabrelyhap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/AppScope/app.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..76222f851e61f51a03ff471901db40753056811d --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.multiinstancehapb", + "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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/BUILD.gn b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..778c308e58e82176510172e822e66464c47a5408 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/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("ActsAmsProcessMultiinstanceHapBARelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsprocessmultiinstancehapbarelyhap_js_assets", + ":actsamsprocessmultiinstancehapbarelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsProcessMultiinstanceHapBARelyHap" +} + +ohos_app_scope("actsamsprocessmultiinstancehapbarelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsprocessmultiinstancehapbarelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsprocessmultiinstancehapbarelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsprocessmultiinstancehapbarelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/Test.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..e1686a6d33fa4b43e1313f0e15c7b5a5938fb236 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,59 @@ +/* +* 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' + +let connectionId = -1; + +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; + + let context = 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("ACTS_Process_MultiInstance_HapBA MainAbility onForeground") + commonEvent.publish("HapBA_To_Test_CommonEvent", () => { + console.log("ACTS_Process_MultiInstance_HapBA Publish CallBack HapBA_To_Test_CommonEvent") + }); + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..16e1531e48430510168d31c9f8d8c595c3b62ab9 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* +* 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/module.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..e1da94c048965f6d6ad4ad79fcb77a4e3c459b51 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "com.example.multiinstancehapba", + "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.multiinstancehapba.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" + ] + } + ] + } + ] + } +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbarelyhap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/AppScope/app.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..76222f851e61f51a03ff471901db40753056811d --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.multiinstancehapb", + "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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/BUILD.gn b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..aaa7d85692984d86cc3d12eab8cd20a383d1a533 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/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("ActsAmsProcessMultiinstanceHapBBRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsprocessmultiinstancehapbbrelyhap_js_assets", + ":actsamsprocessmultiinstancehapbbrelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsProcessMultiinstanceHapBBRelyHap" +} + +ohos_app_scope("actsamsprocessmultiinstancehapbbrelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsprocessmultiinstancehapbbrelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsprocessmultiinstancehapbbrelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsprocessmultiinstancehapbbrelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/Test.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..8515c5d80e6b8a08ec788737caf2fd89f13179c9 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,59 @@ +/* +* 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' + +let connectionId = -1; + +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; + + let context = 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("ACTS_Process_MultiInstance_HapBB MainAbility onForeground") + commonEvent.publish("HapBB_To_Test_CommonEvent", () => { + console.log("ACTS_Process_MultiInstance_HapBB Publish CallBack HapBB_To_Test_CommonEvent") + }); + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..16e1531e48430510168d31c9f8d8c595c3b62ab9 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* +* 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/module.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..e4b42227e3264d56542896c78e078b8ea3a2505a --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "com.example.multiinstancehapbb", + "type": "feature", + "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.multiinstancehapbb.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" + ] + } + ] + } + ] + } +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbbrelyhap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/AppScope/app.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..76222f851e61f51a03ff471901db40753056811d --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.multiinstancehapb", + "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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/BUILD.gn b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..9622d12b376457eee1eee2dbdc6b7a30a2bde5c4 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/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("ActsAmsProcessMultiinstanceHapBCRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsprocessmultiinstancehapbcrelyhap_js_assets", + ":actsamsprocessmultiinstancehapbcrelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsProcessMultiinstanceHapBCRelyHap" +} + +ohos_app_scope("actsamsprocessmultiinstancehapbcrelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsprocessmultiinstancehapbcrelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsprocessmultiinstancehapbcrelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsprocessmultiinstancehapbcrelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/Test.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..e3aa90e973e783a669d8a36ceef1a9ac4ec51a4b --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,59 @@ +/* +* 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' + +let connectionId = -1; + +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; + + let context = 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("ACTS_Process_MultiInstance_HapBC MainAbility onForeground") + commonEvent.publish("HapBC_To_Test_CommonEvent", () => { + console.log("ACTS_Process_MultiInstance_HapBC Publish CallBack HapBC_To_Test_CommonEvent") + }); + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..16e1531e48430510168d31c9f8d8c595c3b62ab9 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* +* 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/module.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..d2d2f40655aadee00aea9911c317f4972104a925 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/module.json @@ -0,0 +1,38 @@ +{ + "module": { + "name": "com.example.multiinstancehapbc", + "process": "com.example.multiinstancehapc", + "type": "feature", + "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.multiinstancehapbc.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" + ] + } + ] + } + ] + } +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbcrelyhap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/AppScope/app.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..76222f851e61f51a03ff471901db40753056811d --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.multiinstancehapb", + "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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/BUILD.gn b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..8a0b91598ef8aa2ba5b824627b8c07974ce1abe9 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/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("ActsAmsProcessMultiinstanceHapBDRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsprocessmultiinstancehapbdrelyhap_js_assets", + ":actsamsprocessmultiinstancehapbdrelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsProcessMultiinstanceHapBDRelyHap" +} + +ohos_app_scope("actsamsprocessmultiinstancehapbdrelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsprocessmultiinstancehapbdrelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsprocessmultiinstancehapbdrelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsprocessmultiinstancehapbdrelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/Test.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..fc5179338a01281e2226be0451d6977f254ede6b --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,59 @@ +/* +* 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' + +let connectionId = -1; + +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; + + let context = 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("ACTS_Process_MultiInstance_HapBD MainAbility onForeground") + commonEvent.publish("HapBD_To_Test_CommonEvent", () => { + console.log("ACTS_Process_MultiInstance_HapBD Publish CallBack HapBD_To_Test_CommonEvent") + }); + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..16e1531e48430510168d31c9f8d8c595c3b62ab9 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* +* 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/module.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..63cfcda752b11f9b0987415bd8f3ce3472289e93 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/module.json @@ -0,0 +1,38 @@ +{ + "module": { + "name": "com.example.multiinstancehapbd", + "process": "com.example.multiinstancehapc", + "type": "feature", + "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.multiinstancehapbd.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" + ] + } + ] + } + ] + } +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbdrelyhap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/AppScope/app.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..76222f851e61f51a03ff471901db40753056811d --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.multiinstancehapb", + "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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/BUILD.gn b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..96589490845a2c9fea4f5a5072e46e25a9727d72 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/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("ActsAmsProcessMultiinstanceHapBERelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsprocessmultiinstancehapberelyhap_js_assets", + ":actsamsprocessmultiinstancehapberelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsProcessMultiinstanceHapBERelyHap" +} + +ohos_app_scope("actsamsprocessmultiinstancehapberelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsprocessmultiinstancehapberelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsprocessmultiinstancehapberelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsprocessmultiinstancehapberelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/Test.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..b6e1480bd12c8f20b6577ed6d7e384b9df5668da --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,59 @@ +/* +* 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' + +let connectionId = -1; + +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; + + let context = 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("ACTS_Process_MultiInstance_HapBE MainAbility onForeground") + commonEvent.publish("HapBE_To_Test_CommonEvent", () => { + console.log("ACTS_Process_MultiInstance_HapBE Publish CallBack HapBE_To_Test_CommonEvent") + }); + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..16e1531e48430510168d31c9f8d8c595c3b62ab9 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* +* 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/module.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..0e86d9f9494f46ad1c51df84d6a01dab7f0bebcb --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/module.json @@ -0,0 +1,38 @@ +{ + "module": { + "name": "com.example.multiinstancehapbe", + "process": "com.example.multiinstancehapa", + "type": "feature", + "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.multiinstancehapbe.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" + ] + } + ] + } + ] + } +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapberelyhap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/AppScope/app.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..76222f851e61f51a03ff471901db40753056811d --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.multiinstancehapb", + "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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/BUILD.gn b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..c7581a194ffaeff5364faeccfc8d2d24a7df29ec --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/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("ActsAmsProcessMultiinstanceHapBFRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsprocessmultiinstancehapbfrelyhap_js_assets", + ":actsamsprocessmultiinstancehapbfrelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsProcessMultiinstanceHapBFRelyHap" +} + +ohos_app_scope("actsamsprocessmultiinstancehapbfrelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsprocessmultiinstancehapbfrelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsprocessmultiinstancehapbfrelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsprocessmultiinstancehapbfrelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/Test.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..7aff48f51c3baa464e71cf1800a3088c3b9b9529 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,59 @@ +/* +* 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' + +let connectionId = -1; + +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; + + let context = 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("ACTS_Process_MultiInstance_HapBF MainAbility onForeground") + commonEvent.publish("HapBF_To_Test_CommonEvent", () => { + console.log("ACTS_Process_MultiInstance_HapBF Publish CallBack HapBF_To_Test_CommonEvent") + }); + } + + onBackground() { + // Ability has back to background + console.log("MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..16e1531e48430510168d31c9f8d8c595c3b62ab9 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* +* 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/module.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..e3a2ad35e22b8f34607c0441e6bac4d6698ea910 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/module.json @@ -0,0 +1,38 @@ +{ + "module": { + "name": "com.example.multiinstancehapbf", + "process": "com.example.multiinstancehapb", + "type": "feature", + "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.multiinstancehapbf.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" + ] + } + ] + } + ] + } +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancehapbfrelyhap/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/AppScope/app.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..8e76b5483c81fdcc0c6abb7d98d9e2b1be4873ee --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.processmultiinstance", + "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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/BUILD.gn b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..db27e6d747f67941fdbc62f62599910d8b704adc --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/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("ActsAmsProcessMultiinstanceTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamsprocessmultiinstance_js_assets", + ":actsamsprocessmultiinstance_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsProcessMultiinstanceTest" +} + +ohos_app_scope("actsamsprocessmultiinstance_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamsprocessmultiinstance_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamsprocessmultiinstance_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamsprocessmultiinstance_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/Test.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..797855ab78f33f0284f04763117c5d76bb2a1519 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/Test.json @@ -0,0 +1,44 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.processmultiinstance", + "shell-timeout": "300000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsProcessMultiinstanceTest.hap", + "ActsAmsProcessMultiinstanceHapAARelyHap.hap", + "ActsAmsProcessMultiinstanceHapABRelyHap.hap", + "ActsAmsProcessMultiinstanceHapBARelyHap.hap", + "ActsAmsProcessMultiinstanceHapBBRelyHap.hap", + "ActsAmsProcessMultiinstanceHapBCRelyHap.hap", + "ActsAmsProcessMultiinstanceHapBDRelyHap.hap", + "ActsAmsProcessMultiinstanceHapBERelyHap.hap", + "ActsAmsProcessMultiinstanceHapBFRelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + }, + { + "type": "PushKit", + "push": [ + + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/*.hap" + ] + } + ] +} diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..5e2915fe4fc033cd5c9bd579dc08fe7369e51016 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..10dd9a1eaff7ad67843219facba7f8aea7b5a1a5 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import Ability from '@ohos.application.Ability' + +export default class 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") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..577f53879917d26276c6ef294f65d9d044533161 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/pages/index/index.ets @@ -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 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..471d6d80e4baadb0d7644f0e42c8732b3fa8e4d5 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,829 @@ +/* +* 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 abilityManager from '@ohos.application.abilitymanager'; +import appManager from '@ohos.application.appManager' +import missionManager from '@ohos.application.missionManager' + +const TIMEOUT = 1000; +var subscriberInfo = { + events: ['HapAA_To_Test_CommonEvent', + 'HapAB_To_Test_CommonEvent', + 'HapBA_To_Test_CommonEvent', + 'HapBB_To_Test_CommonEvent', + 'HapBC_To_Test_CommonEvent', + 'HapBD_To_Test_CommonEvent', + 'HapBE_To_Test_CommonEvent', + 'HapBF_To_Test_CommonEvent', + ], +}; + +var processNameA = "com.example.multiinstancehapa"; +var processNameB = "com.example.multiinstancehapb"; +var processNameC = "com.example.multiinstancehapc"; + +export default function abilityTest(abilityContext) { + describe('ActsProcessMultiInstanceTest', function () { + + afterEach(async (done) => { + + await appManager.killProcessesByBundleName("com.example.multiinstancehapa"); + await appManager.killProcessesByBundleName("com.example.multiinstancehapb"); + + done(); + }) + + /** + * @tc.number: ACTS_Process_MultiInstance_0100 + * @tc.name: Check that two HAP packages in one App, the module process are both empty + * @tc.desc: Check that two HAP packages in one App, the module process are both empty, + * run in the same process. + */ + it('ACTS_Process_MultiInstance_0100', 0, async function (done) { + console.log("ACTS_Process_MultiInstance_0100 --- start") + var Subscriber; + var abilityinfos; + var flagBAToTest = false; + var flagBBToTest = false; + + function SubscribeCallBack(err, data) { + try { + console.debug("ACTS_Process_MultiInstance_0100====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_Process_MultiInstance_0100====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'HapBA_To_Test_CommonEvent': + flagBAToTest = true; + break; + case 'HapBB_To_Test_CommonEvent': + flagBBToTest = true; + break; + } + console.debug("ACTS_Process_MultiInstance_0100====>SubscribeCallBack flagBAToTest:====>" + + flagBAToTest) + console.debug("ACTS_Process_MultiInstance_0100====>SubscribeCallBack flagBBToTest:====>" + + flagBBToTest) + setTimeout(function () { + if (flagBAToTest == true && flagBBToTest == true) { + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, TIMEOUT); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0100====>SubscribeCallBack err:====>" + err) + expect(err).assertFail(); + done(); + } + } + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_Process_MultiInstance_0100====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + async function UnSubscribeCallback() { + try { + console.debug("ACTS_Process_MultiInstance_0100====>UnSubscribeCallback in====>") + abilityinfos = await abilityManager.getAbilityRunningInfos(); + console.debug("ACTS_Process_MultiInstance_0100====>abilityinfos:====>" + + JSON.stringify(abilityinfos)); + var pidba; + var pidbb; + var abilityhapbaExist = false; + var abilityhapbbExist = false; + for (var i = 0; i < abilityinfos.length; i++) { + if ((abilityinfos[i].processName == processNameB)) { + console.debug("ACTS_Process_MultiInstance_0100 PD abilityinfos[" + i + "].ability.abilityName:" + + JSON.stringify(abilityinfos[i].ability.abilityName)); + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapba.MainAbility') { + abilityhapbaExist = true; + pidba = abilityinfos[i].pid + } + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapbb.MainAbility') { + abilityhapbbExist = true; + pidbb = abilityinfos[i].pid + } + } + } + console.debug("ACTS_Process_MultiInstance_0100====>UnSubscribeCallback abilityhapbaExist:====>" + + abilityhapbaExist); + console.debug("ACTS_Process_MultiInstance_0100====>UnSubscribeCallback abilityhapbbExist:====>" + + abilityhapbbExist); + console.debug("ACTS_Process_MultiInstance_0100====>UnSubscribeCallback pidba:====>" + + pidba); + console.debug("ACTS_Process_MultiInstance_0100====>UnSubscribeCallback pidbb:====>" + + pidbb); + expect(abilityhapbaExist).assertEqual(true); + expect(abilityhapbbExist).assertEqual(true); + expect(pidba).assertEqual(pidbb); + console.debug("ACTS_Process_MultiInstance_0100====>UnSubscribe CallBack====>"); + done(); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0100====>UnSubscribeCallback err:====>" + + JSON.stringify(err)); + expect(err).assertFail(); + done(); + } + } + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapb", + abilityName: "com.example.multiinstancehapba.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0100 - startAbilityhapba: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapb", + abilityName: "com.example.multiinstancehapbb.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0100 - startAbilityhapbb: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_Process_MultiInstance_0200 + * @tc.name: Check that two HAP packages in one App, the module process name is the same. + * @tc.desc: Check that two HAP packages in one App, the module process name is the same, + * run in the same process. + */ + it('ACTS_Process_MultiInstance_0200', 0, async function (done) { + console.log("ACTS_Process_MultiInstance_0200 --- start") + var Subscriber; + var abilityinfos; + var flagBCToTest = false; + var flagBDToTest = false; + + function SubscribeCallBack(err, data) { + try { + console.debug("ACTS_Process_MultiInstance_0200====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_Process_MultiInstance_0200====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'HapBC_To_Test_CommonEvent': + flagBCToTest = true; + break; + case 'HapBD_To_Test_CommonEvent': + flagBDToTest = true; + break; + } + console.debug("ACTS_Process_MultiInstance_0200====>SubscribeCallBack flagBCToTest:====>" + + flagBCToTest) + console.debug("ACTS_Process_MultiInstance_0200====>SubscribeCallBack flagBDToTest:====>" + + flagBDToTest) + setTimeout(function () { + if (flagBCToTest == true && flagBDToTest == true) { + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, TIMEOUT); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0200====>SubscribeCallBack err:====>" + err) + expect(err).assertFail(); + done(); + } + } + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_Process_MultiInstance_0200====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + async function UnSubscribeCallback() { + try { + console.debug("ACTS_Process_MultiInstance_0200====>UnSubscribeCallback in====>") + + abilityinfos = await abilityManager.getAbilityRunningInfos(); + console.debug("ACTS_Process_MultiInstance_0200====>abilityinfos:====>" + + JSON.stringify(abilityinfos)); + var pidbc; + var pidbd; + var abilityhapbcExist = false; + var abilityhapbdExist = false; + for (var i = 0; i < abilityinfos.length; i++) { + if ((abilityinfos[i].processName == processNameC)) { + console.debug("ACTS_Process_MultiInstance_0200 PC abilityinfos[" + i + "].ability.abilityName:" + + JSON.stringify(abilityinfos[i].ability.abilityName)); + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapbc.MainAbility') { + abilityhapbcExist = true; + pidbc = abilityinfos[i].pid + } + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapbd.MainAbility') { + abilityhapbdExist = true; + pidbd = abilityinfos[i].pid + } + } + } + console.debug("ACTS_Process_MultiInstance_0200====>UnSubscribeCallback abilityhapbcExist:====>" + + abilityhapbcExist); + console.debug("ACTS_Process_MultiInstance_0200====>UnSubscribeCallback abilityhapbdExist:====>" + + abilityhapbdExist); + console.debug("ACTS_Process_MultiInstance_0200====>UnSubscribeCallback pidbc:====>" + + pidbc); + console.debug("ACTS_Process_MultiInstance_0200====>UnSubscribeCallback pidbd:====>" + + pidbd); + expect(abilityhapbcExist).assertEqual(true); + expect(abilityhapbdExist).assertEqual(true); + expect(pidbc).assertEqual(pidbd); + console.debug("ACTS_Process_MultiInstance_0200====>UnSubscribe CallBack====>"); + done(); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0200====>UnSubscribeCallback err:====>" + + JSON.stringify(err)); + expect(err).assertFail(); + done(); + } + } + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapb", + abilityName: "com.example.multiinstancehapbc.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0200 - startAbilityhapbc: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapb", + abilityName: "com.example.multiinstancehapbd.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0200 - startAbilityhapbd: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_Process_MultiInstance_0300 + * @tc.name: Check that two HAP packages in one App, the module process names are different. + * @tc.desc: Check that two HAP packages in one App, the module process names are different, + * run in different processes,the process names are different. + */ + it('ACTS_Process_MultiInstance_0300', 0, async function (done) { + console.log("ACTS_Process_MultiInstance_0300 --- start") + var Subscriber; + var abilityinfos; + var flagBDToTest = false; + var flagBEToTest = false; + + function SubscribeCallBack(err, data) { + try { + console.debug("ACTS_Process_MultiInstance_0300====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_Process_MultiInstance_0300====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'HapBD_To_Test_CommonEvent': + flagBDToTest = true; + break; + case 'HapBE_To_Test_CommonEvent': + flagBEToTest = true; + break; + } + console.debug("ACTS_Process_MultiInstance_0300====>SubscribeCallBack flagBDToTest:====>" + + flagBDToTest) + console.debug("ACTS_Process_MultiInstance_0300====>SubscribeCallBack flagBEToTest:====>" + + flagBEToTest) + setTimeout(function () { + if (flagBDToTest == true && flagBEToTest == true) { + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, TIMEOUT); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0300====>SubscribeCallBack err:====>" + err) + expect(err).assertFail(); + done(); + } + } + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_Process_MultiInstance_0300====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + async function UnSubscribeCallback() { + try { + console.debug("ACTS_Process_MultiInstance_0300====>UnSubscribeCallback in====>") + + abilityinfos = await abilityManager.getAbilityRunningInfos(); + console.debug("ACTS_Process_MultiInstance_0300====>abilityinfos:====>" + + JSON.stringify(abilityinfos)); + var pidbd; + var pidbe; + var abilityhapbdExist = false; + var abilityhapbeExist = false; + for (var i = 0; i < abilityinfos.length; i++) { + if ((abilityinfos[i].processName == processNameC)) { + console.debug("ACTS_Process_MultiInstance_0300 PC abilityinfos[" + i + "].ability.abilityName:" + + JSON.stringify(abilityinfos[i].ability.abilityName)); + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapbd.MainAbility') { + abilityhapbdExist = true; + pidbd = abilityinfos[i].pid + } + } + if ((abilityinfos[i].processName == processNameA)) { + console.debug("ACTS_Process_MultiInstance_0300 PA abilityinfos[" + i + "].ability.abilityName:" + + JSON.stringify(abilityinfos[i].ability.abilityName)); + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapbe.MainAbility') { + abilityhapbeExist = true; + pidbe = abilityinfos[i].pid + } + } + } + console.debug("ACTS_Process_MultiInstance_0300====>UnSubscribeCallback abilityhapbdExist:====>" + + abilityhapbdExist); + console.debug("ACTS_Process_MultiInstance_0300====>UnSubscribeCallback abilityhapbeExist:====>" + + abilityhapbeExist); + console.debug("ACTS_Process_MultiInstance_0300====>UnSubscribeCallback pidbd:====>" + + pidbd); + console.debug("ACTS_Process_MultiInstance_0300====>UnSubscribeCallback pidbe:====>" + + pidbe); + expect(abilityhapbdExist).assertEqual(true); + expect(abilityhapbeExist).assertEqual(true); + expect(pidbd != pidbe).assertEqual(true); + + console.debug("ACTS_Process_MultiInstance_0300====>UnSubscribe CallBack====>"); + done(); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0300====>UnSubscribeCallback err:====>" + + JSON.stringify(err)); + expect(err).assertFail(); + done(); + } + } + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapb", + abilityName: "com.example.multiinstancehapbd.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0300 - startAbilityhapbd: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapb", + abilityName: "com.example.multiinstancehapbe.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0300 - startAbilityhapbe: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_Process_MultiInstance_0400 + * @tc.name: Check that two HAP packages in one App, one hap's module process names is empty, + * the other's app process name is bundlename. + * @tc.desc: Check that two HAP packages in one App, one hap's module process names is empty, + * the other's module process name is bundlename,run in the same process. + */ + it('ACTS_Process_MultiInstance_0400', 0, async function (done) { + console.log("ACTS_Process_MultiInstance_0400 --- start") + var Subscriber; + var abilityinfos; + var flagBAToTest = false; + var flagBFToTest = false; + + function SubscribeCallBack(err, data) { + try { + console.debug("ACTS_Process_MultiInstance_0400====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_Process_MultiInstance_0400====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'HapBA_To_Test_CommonEvent': + flagBAToTest = true; + break; + case 'HapBF_To_Test_CommonEvent': + flagBFToTest = true; + break; + } + console.debug("ACTS_Process_MultiInstance_0400====>SubscribeCallBack flagBAToTest:====>" + + flagBAToTest) + console.debug("ACTS_Process_MultiInstance_0400====>SubscribeCallBack flagBFToTest:====>" + + flagBFToTest) + setTimeout(function () { + if (flagBAToTest == true && flagBFToTest == true) { + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, TIMEOUT); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0400====>SubscribeCallBack err:====>" + err) + expect(err).assertFail(); + done(); + } + } + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_Process_MultiInstance_0400====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + async function UnSubscribeCallback() { + try { + console.debug("ACTS_Process_MultiInstance_0400====>UnSubscribeCallback in====>") + + abilityinfos = await abilityManager.getAbilityRunningInfos(); + console.debug("ACTS_Process_MultiInstance_0400====>abilityinfos:====>" + + JSON.stringify(abilityinfos)); + var pidba; + var pidbf; + var abilityhapbaExist = false; + var abilityhapbfExist = false; + for (var i = 0; i < abilityinfos.length; i++) { + if ((abilityinfos[i].processName == processNameB)) { + console.debug("ACTS_Process_MultiInstance_0400 PD abilityinfos[" + i + "].ability.abilityName:" + + JSON.stringify(abilityinfos[i].ability.abilityName)); + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapba.MainAbility') { + abilityhapbaExist = true; + pidba = abilityinfos[i].pid + } + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapbf.MainAbility') { + abilityhapbfExist = true; + pidbf = abilityinfos[i].pid + } + } + } + console.debug("ACTS_Process_MultiInstance_0400====>UnSubscribeCallback abilityhapbaExist:====>" + + abilityhapbaExist); + console.debug("ACTS_Process_MultiInstance_0400====>UnSubscribeCallback abilityhapbfExist:====>" + + abilityhapbfExist); + console.debug("ACTS_Process_MultiInstance_0400====>UnSubscribeCallback pidba:====>" + + pidba); + console.debug("ACTS_Process_MultiInstance_0400====>UnSubscribeCallback pidbf:====>" + + pidbf); + expect(abilityhapbaExist).assertEqual(true); + expect(abilityhapbfExist).assertEqual(true); + expect(pidba).assertEqual(pidbf); + + console.debug("ACTS_Process_MultiInstance_0400====>UnSubscribe CallBack====>"); + done(); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0400====>UnSubscribeCallback err:====>" + + JSON.stringify(err)); + expect(err).assertFail(); + done(); + } + } + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapb", + abilityName: "com.example.multiinstancehapba.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0400 - startAbilityhapba: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapb", + abilityName: "com.example.multiinstancehapbf.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0400 - startAbilityhapbf: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_Process_MultiInstance_0500 + * @tc.name: Check that two HAP packages in two Apps, one hap's process names is empty, + * the other's module process name is the same with the other's bundlename. + * @tc.desc: Check that two HAP packages in two Apps, one hap's module process names is empty, + * the other's module process name is the same with the other's bundlename,run in different processes. + */ + it('ACTS_Process_MultiInstance_0500', 0, async function (done) { + console.log("ACTS_Process_MultiInstance_0500 --- start") + var Subscriber; + var abilityinfos; + var flagAAToTest = false; + var flagBEToTest = false; + + function SubscribeCallBack(err, data) { + try { + console.debug("ACTS_Process_MultiInstance_0500====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_Process_MultiInstance_0500====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'HapAA_To_Test_CommonEvent': + flagAAToTest = true; + break; + case 'HapBE_To_Test_CommonEvent': + flagBEToTest = true; + break; + } + console.debug("ACTS_Process_MultiInstance_0500====>SubscribeCallBack flagAAToTest:====>" + + flagAAToTest) + console.debug("ACTS_Process_MultiInstance_0500====>SubscribeCallBack flagBEToTest:====>" + + flagBEToTest) + setTimeout(function () { + if (flagAAToTest == true && flagBEToTest == true) { + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, TIMEOUT); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0500====>SubscribeCallBack err:====>" + err) + expect(err).assertFail(); + done(); + } + } + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_Process_MultiInstance_0500====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + async function UnSubscribeCallback() { + try { + console.debug("ACTS_Process_MultiInstance_0500====>UnSubscribeCallback in====>") + + abilityinfos = await abilityManager.getAbilityRunningInfos(); + console.debug("ACTS_Process_MultiInstance_0500====>abilityinfos:====>" + + JSON.stringify(abilityinfos)); + var pidaa; + var pidbe; + var abilityhapaaExist = false; + var abilityhapbeExist = false; + for (var i = 0; i < abilityinfos.length; i++) { + if ((abilityinfos[i].processName == processNameA)) { + console.debug("ACTS_Process_MultiInstance_0500 PA abilityinfos[" + i + "].ability.abilityName:" + + JSON.stringify(abilityinfos[i].ability.abilityName)); + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapaa.MainAbility') { + abilityhapaaExist = true; + pidaa = abilityinfos[i].pid + } + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapbe.MainAbility') { + abilityhapbeExist = true; + pidbe = abilityinfos[i].pid + } + } + } + console.debug("ACTS_Process_MultiInstance_0500====>UnSubscribeCallback abilityhapaaExist:====>" + + abilityhapaaExist); + console.debug("ACTS_Process_MultiInstance_0500====>UnSubscribeCallback abilityhapbeExist:====>" + + abilityhapbeExist); + console.debug("ACTS_Process_MultiInstance_0500====>UnSubscribeCallback pidaa:====>" + + pidaa); + console.debug("ACTS_Process_MultiInstance_0500====>UnSubscribeCallback pidbe:====>" + + pidbe); + expect(abilityhapaaExist).assertEqual(true); + expect(abilityhapbeExist).assertEqual(true); + expect(pidaa != pidbe).assertEqual(true); + + console.debug("ACTS_Process_MultiInstance_0500====>UnSubscribe CallBack====>"); + done(); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0500====>UnSubscribeCallback err:====>" + + JSON.stringify(err)); + expect(err).assertFail(); + done(); + } + } + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapa", + abilityName: "com.example.multiinstancehapaa.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0500 - startAbilityhapaa: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapb", + abilityName: "com.example.multiinstancehapbe.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0500 - startAbilityhapbe: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_Process_MultiInstance_0600 + * @tc.name: Check that two HAP packages in two Apps,one hap's process name is empty + * and the other's process name is differet form the others' bundlename. + * @tc.desc: Check that two HAP packages in two Apps,one hap's process name is empty + * and the other's process name is differet form the others' bundlename,run in different processes. + */ + it('ACTS_Process_MultiInstance_0600', 0, async function (done) { + console.log("ACTS_Process_MultiInstance_0600 --- start") + var Subscriber; + var abilityinfos; + var flagAAToTest = false; + var flagBFToTest = false; + + function SubscribeCallBack(err, data) { + try { + console.debug("ACTS_Process_MultiInstance_0600====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_Process_MultiInstance_0600====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'HapAA_To_Test_CommonEvent': + flagAAToTest = true; + break; + case 'HapBF_To_Test_CommonEvent': + flagBFToTest = true; + break; + } + console.debug("ACTS_Process_MultiInstance_0600====>SubscribeCallBack flagAEToTest:====>" + + flagAAToTest) + console.debug("ACTS_Process_MultiInstance_0600====>SubscribeCallBack flagBCToTest:====>" + + flagBFToTest) + setTimeout(function () { + if (flagAAToTest == true && flagBFToTest == true) { + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, TIMEOUT); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0600====>SubscribeCallBack err:====>" + err) + expect(err).assertFail(); + done(); + } + } + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_Process_MultiInstance_0600====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + async function UnSubscribeCallback() { + try { + console.debug("ACTS_Process_MultiInstance_0600====>UnSubscribeCallback in====>") + abilityinfos = await abilityManager.getAbilityRunningInfos(); + console.debug("ACTS_Process_MultiInstance_0600====>abilityinfos:====>" + + JSON.stringify(abilityinfos)); + var pidaa; + var pidbf; + var abilityhapaaExist = false; + var abilityhapbfExist = false; + for (var i = 0; i < abilityinfos.length; i++) { + if ((abilityinfos[i].processName == processNameA)) { + console.debug("ACTS_Process_MultiInstance_0600 PA abilityinfos[" + i + "].ability.abilityName:" + + JSON.stringify(abilityinfos[i].ability.abilityName)); + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapaa.MainAbility') { + abilityhapaaExist = true; + pidaa = abilityinfos[i].pid + } + } + if ((abilityinfos[i].processName == processNameB)) { + console.debug("ACTS_Process_MultiInstance_0600 PB abilityinfos[" + i + "].ability.abilityName:" + + JSON.stringify(abilityinfos[i].ability.abilityName)); + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapbf.MainAbility') { + abilityhapbfExist = true; + pidbf = abilityinfos[i].pid + } + } + } + console.debug("ACTS_Process_MultiInstance_0600====>UnSubscribeCallback abilityhapaaExist:====>" + + abilityhapaaExist); + console.debug("ACTS_Process_MultiInstance_0600====>UnSubscribeCallback abilityhapbfExist:====>" + + abilityhapbfExist); + console.debug("ACTS_Process_MultiInstance_0600====>UnSubscribeCallback pidaa:====>" + + pidaa); + console.debug("ACTS_Process_MultiInstance_0600====>UnSubscribeCallback pidbf:====>" + + pidbf); + expect(abilityhapaaExist).assertEqual(true); + expect(abilityhapbfExist).assertEqual(true); + expect(pidaa != pidbf).assertEqual(true); + + console.debug("ACTS_Process_MultiInstance_0600====>UnSubscribe CallBack====>"); + done(); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0600====>UnSubscribeCallback err:====>" + + JSON.stringify(err)); + expect(err).assertFail(); + done(); + } + } + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapa", + abilityName: "com.example.multiinstancehapaa.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0600 - startAbilityhapaa: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapb", + abilityName: "com.example.multiinstancehapbf.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0600 - startAbilityhapbf: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + }) + + /** + * @tc.number: ACTS_Process_MultiInstance_0700 + * @tc.name: Check that two HAP packages in two Apps,two haps' process names are not empty and different + * @tc.desc: Check that two HAP packages in two Apps,two haps' process names are not empty and different, + * run in different processes. + */ + it('ACTS_Process_MultiInstance_0700', 0, async function (done) { + console.log("ACTS_Process_MultiInstance_0700 --- start") + var Subscriber; + var abilityinfos; + var flagABToTest = false; + var flagBCToTest = false; + + function SubscribeCallBack(err, data) { + try { + console.debug("ACTS_Process_MultiInstance_0700====>Subscribe CallBack data:====>" + + JSON.stringify(data)); + console.debug("ACTS_Process_MultiInstance_0700====>Subscribe CallBack data.event:====>" + + JSON.stringify(data.event)); + switch (data.event) { + case 'HapAB_To_Test_CommonEvent': + flagABToTest = true; + break; + case 'HapBC_To_Test_CommonEvent': + flagBCToTest = true; + break; + } + console.debug("ACTS_Process_MultiInstance_0700====>SubscribeCallBack flagABToTest:====>" + + flagABToTest) + console.debug("ACTS_Process_MultiInstance_0700====>SubscribeCallBack flagBCToTest:====>" + + flagBCToTest) + setTimeout(function () { + if (flagABToTest == true && flagBCToTest == true) { + commonEvent.unsubscribe(Subscriber, UnSubscribeCallback); + } + }, TIMEOUT); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0700====>SubscribeCallBack err:====>" + err) + expect(err).assertFail(); + done(); + } + } + commonEvent.createSubscriber(subscriberInfo).then(async (data) => { + console.debug("ACTS_Process_MultiInstance_0700====>Create Subscriber====>"); + Subscriber = data; + await commonEvent.subscribe(Subscriber, SubscribeCallBack); + }) + + async function UnSubscribeCallback() { + try { + console.debug("ACTS_Process_MultiInstance_0700====>UnSubscribeCallback in====>") + + abilityinfos = await abilityManager.getAbilityRunningInfos(); + console.debug("ACTS_Process_MultiInstance_0700====>abilityinfos:====>" + + JSON.stringify(abilityinfos)); + var pidab; + var pidbc; + var abilityhapabExist = false; + var abilityhapbcExist = false; + for (var i = 0; i < abilityinfos.length; i++) { + if ((abilityinfos[i].processName == processNameB)) { + console.debug("ACTS_Process_MultiInstance_0700 PB abilityinfos[" + i + "].ability.abilityName:" + + JSON.stringify(abilityinfos[i].ability.abilityName)); + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapab.MainAbility') { + abilityhapabExist = true; + pidab = abilityinfos[i].pid + } + } + if ((abilityinfos[i].processName == processNameC)) { + console.debug("ACTS_Process_MultiInstance_0700 PC abilityinfos[" + i + "].ability.abilityName:" + + JSON.stringify(abilityinfos[i].ability.abilityName)); + if (abilityinfos[i].ability.abilityName == 'com.example.multiinstancehapbc.MainAbility') { + abilityhapbcExist = true; + pidbc = abilityinfos[i].pid + } + } + } + console.debug("ACTS_Process_MultiInstance_0700====>UnSubscribeCallback abilityhapabExist:====>" + + abilityhapabExist); + console.debug("ACTS_Process_MultiInstance_0700====>UnSubscribeCallback abilityhapbcExist:====>" + + abilityhapbcExist); + console.debug("ACTS_Process_MultiInstance_0700====>UnSubscribeCallback pidac:====>" + + pidab); + console.debug("ACTS_Process_MultiInstance_0700====>UnSubscribeCallback pidbf:====>" + + pidbc); + expect(abilityhapabExist).assertEqual(true); + expect(abilityhapbcExist).assertEqual(true); + expect(pidab != pidbc).assertEqual(true); + console.debug("ACTS_Process_MultiInstance_0700====>UnSubscribe CallBack====>"); + done(); + } catch (err) { + console.debug("ACTS_Process_MultiInstance_0700====>UnSubscribeCallback err:====>" + + JSON.stringify(err)); + expect(err).assertFail(); + done(); + } + } + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapa", + abilityName: "com.example.multiinstancehapab.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0700 - startAbilityhapab: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + abilityContext.startAbility({ + bundleName: "com.example.multiinstancehapb", + abilityName: "com.example.multiinstancehapbc.MainAbility", + }, (err, data) => { + console.log('ACTS_Process_MultiInstance_0700 - startAbilityhapbc: ' + + JSON.stringify(err) + ", " + JSON.stringify(data)) + }) + }) + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..882f978e77b1a8fbbf843ccb4dd73c47ed460305 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/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 './Ability.test.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/module.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..0152946dc4cd7e2cd788feae646b840fcd02f670 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/module.json @@ -0,0 +1,79 @@ +{ + "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.processmultiinstance.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" + ] + } + ] + } + ], + "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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/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/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/processmultiinstance/actsamsprocessmultiinstancetest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/zidltest/BUILD.gn b/aafwk/aafwk_standard/zidltest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..c69bcff75081286174e6dcd57cb965057c7c23c4 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/BUILD.gn @@ -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("//test/xts/tools/build/suite.gni") + +group("zidltest") { + testonly = true + if (is_standard_system) { + deps = [ + "actsamszidlclienttest:ActsAmsZidlClientTest", + "actsamszidlservice:ActsAmsZidlServiceRelyHap", + ] + } +} diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/AppScope/app.json b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..3567b671b330d5000c31f698382abd15a10fcab7 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"com.example.zidlclienttest", + "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/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/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/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/BUILD.gn b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..0b5cd1ac3d950b101919eb3f2854e4f7fcc56a99 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/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("ActsAmsZidlClientTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamszidlclienttest_js_assets", + ":actsamszidlclienttest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsZidlClientTest" +} + +ohos_app_scope("actsamszidlclienttest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamszidlclienttest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamszidlclienttest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamszidlclienttest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/Test.json b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..00594c18413b8e10e7a2f9df0717edcd8a996a10 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/Test.json @@ -0,0 +1,31 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "1000000", + "package": "com.example.zidlclienttest", + "shell-timeout": "300000" + }, + "kits": [ + { + "test-file-name": [ + "ActsAmsZidlClientTest.hap", + "ActsAmsZidlServiceRelyHap.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/*.hap" + ] + } + ] +} diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..5e2915fe4fc033cd5c9bd579dc08fe7369e51016 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/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/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..809b6249166af9f894e0713c2c85221af8c0972c --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/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("ZidlClientTest onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ZidlClientTest onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ZidlClientTest onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + console.log("ZidlClientTest onWindowStageCreate finish") + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("ZidlClientTest onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("ZidlClientTest onForeground") + } + + onBackground() { + // Ability has back to background + console.log("ZidlClientTest onBackground") + } +}; \ No newline at end of file diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..d9ce38a659aabf98179dd813759aabf7d40739c6 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,433 @@ +/* +* 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 {voidOutStringCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidOutIntCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidOutMapStringIntCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidOutStringArrayCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidInOutMapStringIntCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidInOutStringArrayCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidInOutIntCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidInOutStringCallback} from "./zidlTool/i_zidl_tool_test"; +import {booleanVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {byteVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {shortVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {intVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {longVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {floatVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {doubleVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {stringVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {sequenceableVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {interfaceVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {mapStringStringVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {doubleArrayVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidOrderOutInCallback} from "./zidlTool/i_zidl_tool_test" +import {voidOrderInOutInCallback} from "./zidlTool/i_zidl_tool_test" +import {voidOrderOutInOutCallback} from "./zidlTool/i_zidl_tool_test" +import {voidOrderInInOutOutCallback} from "./zidlTool/i_zidl_tool_test" +import {onewayVoidVoidCallback} from "./zidlTool/i_zidl_tool_test" +import {voidInMapStringIntCallback} from "./zidlTool/i_zidl_tool_test" +import {voidVoidCallback} from "./zidlTool/i_zidl_tool_test" +import {voidInStringArrayCallback} from "./zidlTool/i_zidl_tool_test" +import ZidlTestServiceStub from './zidlTool/zidl_tool_test_stub'; +import MySequenceable from "./zidlTool/my_sequenceable"; +import InterfaceDeclareProxy from './interfaceDeclare/interface_declare_proxy' +import InterfaceDeclareStub from './interfaceDeclare/interface_declare_stub' +import {voidInIntCallback} from "./zidlTool/i_zidl_tool_test" +import {voidInStringCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeBooleanCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeByteCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeShortCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeIntCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeLongCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeFloatCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeDoubleCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeStringCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeSequenceableCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeInterfaceCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeMapStringStringCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeDoubleArrayCallback} from "./zidlTool/i_zidl_tool_test" +import {testInterfaceCallback} from './interfaceDeclare/i_interface_declare' + +var SUCCESS = 0; +var FAIL = 1; + +class ZidlTestImp extends ZidlTestServiceStub { + + onewayVoidVoid(callback: onewayVoidVoidCallback) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_0200 called"); + callback(SUCCESS); + } + + voidVoid(callback: voidVoidCallback) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_0300 called"); + callback(SUCCESS); + } + + booleanVoid(callback: booleanVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_0400 called"); + var boolean = true; + callback(SUCCESS, boolean); + } + + byteVoid(callback: byteVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_0500 called"); + var mybyte = 1; + callback(SUCCESS, mybyte); + } + + shortVoid(callback: shortVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_0600 called"); + var myshort = 222; + callback(SUCCESS, myshort); + } + + intVoid(callback: intVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_0700 called"); + var myint = 333; + callback(SUCCESS, myint); + } + + longVoid(callback: longVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_0800 called"); + var mylong = 4444; + callback(SUCCESS, mylong); + } + + floatVoid(callback: floatVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_0900 called"); + var myfloat = 10.1; + callback(SUCCESS, myfloat); + } + + doubleVoid(callback: doubleVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_1000 called"); + var mydouble = 22.1; + callback(SUCCESS, mydouble); + } + + stringVoid(callback: stringVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_1100 called"); + var mystring = "stringVoid"; + callback(SUCCESS, mystring); + } + + sequenceableVoid(callback: sequenceableVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_1200 called"); + let mySequence = new MySequenceable(); + callback(SUCCESS, mySequence); + } + + interfaceVoid(callback: interfaceVoidCallback) { + class InterfaceDeclare extends InterfaceDeclareStub { + testInterface(data: number, callback: testInterfaceCallback): void{ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_1300 interfaceStub called"); + let result = FAIL; + + if (data == 1500) { + result = SUCCESS; + } + callback(result); + } + } + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_1300 toolStub called"); + let serverInterface = new InterfaceDeclare('serverInterface'); + callback(SUCCESS, serverInterface); + } + + mapStringStringVoid(callback: mapStringStringVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_1400 called"); + let myMap = new Map(); + myMap.set("string1","string2"); + callback(SUCCESS, myMap); + } + + doubleArrayVoid(callback: doubleArrayVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_1500 called"); + var array = [1.1, 2.1, 3.1]; + callback(SUCCESS, array); + } + + voidInMapStringInt(myMap, callback: voidInMapStringIntCallback){ + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_1600_1 called:'+ myMap.get("string1")); + if(myMap.get("string1") == 1){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidInStringArray(strarray, callback: voidInStringArrayCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_1600_2 called:"+ JSON.stringify(strarray)); + if(strarray[0] == "aaa"&&strarray[1] == "bbb"&&strarray[2] == "ccc"){ + callback(SUCCESS); + }else { + callback(FAIL); + } + } + + voidOutMapStringInt(callback : voidOutMapStringIntCallback){ + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_1700 called'); + var map=new Map(); + map.set("voidOutMapStringInt", 1); + callback(SUCCESS, map); + } + + voidOutStringArray(callback :voidOutStringArrayCallback){ + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_1700 called'); + var strarray = ["aa", "dd"]; + callback(SUCCESS, strarray); + } + + voidInOutMapStringInt(mapIn, callback: voidInOutMapStringIntCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_1800 called'); + var errCode = FAIL; + if ((mapIn.get("voidInOutMapStringInt1") == 1801) && + (mapIn.get("voidInOutMapStringInt2") == 1802)) { + mapIn.set("voidInOutMapStringInt1", 1802); + mapIn.set("voidInOutMapStringInt2", 1801); + errCode = SUCCESS; + } + callback(errCode, mapIn); + } + + voidInOutStringArray(strArrayIn, callback: voidInOutStringArrayCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_1800 called'); + var errCode = FAIL; + if ((strArrayIn[0] == "ddd") && + (strArrayIn[1] == "ccc")) { + strArrayIn[0] = "aaa"; + strArrayIn[1] = "bbb"; + errCode = SUCCESS; + } + callback(errCode, strArrayIn); + } + + voidInInt(number, callback : voidInIntCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_1900 called:'+ JSON.stringify(number)); + if(number == 8888){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidInString(string, callback : voidInStringCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_1900 called:'+ JSON.stringify(string)); + if(string == "voidInString"){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidOutInt(callback : voidOutIntCallback){ + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2000 called'); + var number = 123; + callback(SUCCESS, number); + } + + voidOutString(callback : voidOutStringCallback){ + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2000 called'); + var string = "voidOutString"; + callback(SUCCESS, string); + } + + voidInOutInt(number, callback: voidInOutIntCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2100_1 called:'+ JSON.stringify(number)); + var num = 456789; + if(number == 123456){ + callback(SUCCESS, num); + }else{ + callback(FAIL, number); + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2100_1 Call_Fail') + } + } + voidInOutString(strinput, callback: voidInOutStringCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2100_2 called:'+ JSON.stringify(strinput)); + var str = "456789"; + if(strinput == "voidInOutString"){ + callback(SUCCESS, str); + }else{ + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2100_2 Call_Fail'); + callback(FAIL, strinput); + } + } + + voidParameterTypeBoolean(oBooleanTrue, callback : voidParameterTypeBooleanCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2200 called:'+ JSON.stringify(oBooleanTrue)); + if(oBooleanTrue == true){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeByte(number, callback : voidParameterTypeByteCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2300 called:'+ JSON.stringify(number)); + if(number == 1111){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeShort(number, callback : voidParameterTypeShortCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2400 called:'+ JSON.stringify(number)); + if(number == 2222){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeInt(number, callback : voidParameterTypeIntCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2500 called:'+ JSON.stringify(number)); + if(number == 3333){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeLong(number, callback : voidParameterTypeLongCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2600 called:'+ JSON.stringify(number)); + if(number == 4444){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeFloat(number, callback : voidParameterTypeFloatCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2700 called:'+ JSON.stringify(number)); + if(number == 5555.1){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeDouble(number, callback : voidParameterTypeDoubleCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2800 called:'+ JSON.stringify(number)); + if(number == 6666.1){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeString(string, callback : voidParameterTypeStringCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_2900 called:'+ JSON.stringify(string)); + if(string == "voidParameterTypeString"){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeSequenceable(MySequenceable, callback : voidParameterTypeSequenceableCallback) { + console.log('ZidlTest Process Server ACTS_Zidl_Js2JsSingle_3000 called:'+ JSON.stringify(MySequenceable)); + if((MySequenceable != null) && (MySequenceable.getNum() == 32) && (MySequenceable.getString() == "nihao")){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeInterface(param: InterfaceDeclareProxy, callback : voidParameterTypeInterfaceCallback) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_3100 called"); + let proxy = new InterfaceDeclareProxy(param); + proxy.testInterface(3300, (errCode)=>{ + if (errCode == SUCCESS) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_3100 callback SUCCESS"); + callback(SUCCESS); + } else { + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_3100 callback FAIL"); + callback(FAIL); + } + }); + + } + + voidParameterTypeMapStringString(map, callback : voidParameterTypeMapStringStringCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_3200 called:'+ map.get("voidParameterTypeMapStringString")); + if(map.get("voidParameterTypeMapStringString") == "fdhatdh"){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeDoubleArray(array, callback : voidParameterTypeDoubleArrayCallback){ + console.log('ZidlTest Server ACTS_Zidl_Js2JsSingle_3300 called:'+ JSON.stringify(array)); + if(array.length == 2 && array[0] == 1.1 && array[1] == 2.1){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidOrderOutIn(paramI, callback: voidOrderOutInCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_3400 called" + paramI); + var mystring = "hello world"; + callback(SUCCESS, mystring); + } + + voidOrderInOutIn(paramI, paramS, callback: voidOrderInOutInCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_3500 called" + paramI + " " + paramS); + var mynumber = 6; + callback(SUCCESS, mynumber); + } + + voidOrderOutInOut(paramS, callback: voidOrderOutInOutCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_3600 called" + paramS); + var mynumber = 3; + var mystring = "paramcallback"; + callback(SUCCESS, mynumber, mystring); + } + + voidOrderInInOutOut(paramS, paramI, callback: voidOrderInInOutOutCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_3700 called" + paramS + " " + paramI); + var mystring = "callback"; + var mynumber = 4; + callback(SUCCESS, mynumber, mystring); + } +} + +export default class ServiceAbility extends ServiceExtension { + onCreate(want,startId) { + globalThis.abilityWant = want; + console.log('ZidlClientTest ServiceAbility onCreate, want: ' + want.abilityName); + } + + onRequest(want, startId) { + console.log('ZidlClientTest ServiceAbility onRequest, want: ' + want.abilityName + + ', startId: ' + startId); + } + + onConnect(want) { + console.log('ZidlClientTest ServiceAbility onConnect, want:' + want.abilityName); + return new ZidlTestImp('connect'); + } + + onDisconnect(want) { + console.log('ZidlClientTest ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ZidlClientTest ServiceAbility onDestroy'); + } +}; diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/interfaceDeclare/i_interface_declare.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/interfaceDeclare/i_interface_declare.ts new file mode 100755 index 0000000000000000000000000000000000000000..9c6b544fcf622de7f85f5301f307857f855f2ec6 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/interfaceDeclare/i_interface_declare.ts @@ -0,0 +1,21 @@ +/* + * 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. + */ + + +export default interface IInterfaceDeclare { + testInterface(data: number, callback: testInterfaceCallback): void; +} +export type testInterfaceCallback = (errCode: number) => void; + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/interfaceDeclare/interface_declare_proxy.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/interfaceDeclare/interface_declare_proxy.ts new file mode 100755 index 0000000000000000000000000000000000000000..fadb691def524f2745a670d6c4c9cfbb4fffd475 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/interfaceDeclare/interface_declare_proxy.ts @@ -0,0 +1,44 @@ +/* + * 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 {testInterfaceCallback} from "./i_interface_declare"; +import IInterfaceDeclare from "./i_interface_declare"; +import rpc from "@ohos.rpc"; + +export default class InterfaceDeclareProxy implements IInterfaceDeclare { + constructor(proxy) { + this.proxy = proxy; + } + + testInterface(data: number, callback: testInterfaceCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(data); + this.proxy.sendRequest(InterfaceDeclareProxy.COMMAND_TEST_INTERFACE, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + static readonly COMMAND_TEST_INTERFACE = 1; + private proxy +} + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/interfaceDeclare/interface_declare_stub.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/interfaceDeclare/interface_declare_stub.ts new file mode 100755 index 0000000000000000000000000000000000000000..fa6208b1f94fc17dd376c3495e9ceea3c317ee0b --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/interfaceDeclare/interface_declare_stub.ts @@ -0,0 +1,47 @@ +/* + * 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 {testInterfaceCallback} from "./i_interface_declare"; +import IInterfaceDeclare from "./i_interface_declare"; +import rpc from "@ohos.rpc"; + +export default class InterfaceDeclareStub extends rpc.RemoteObject implements IInterfaceDeclare { + constructor(des: string) { + super(des); + } + + onRemoteRequest(code: number, data, reply, option): boolean { + console.log("onRemoteRequest called, code = " + code); + switch(code) { + case InterfaceDeclareStub.COMMAND_TEST_INTERFACE: { + let _data = data.readInt(); + this.testInterface(_data, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + default: { + console.log("invalid request code" + code); + break; + } + } + return false; + } + + testInterface(data: number, callback: testInterfaceCallback): void{} + + static readonly COMMAND_TEST_INTERFACE = 1; +} + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..b49731a414958a281c2f0c4eab0e7fb408eb2c2f --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/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/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/zidlTool/i_zidl_tool_test.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/zidlTool/i_zidl_tool_test.ts new file mode 100755 index 0000000000000000000000000000000000000000..ac9da635209b8b8a170f587485ab01a1e9844fcb --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/zidlTool/i_zidl_tool_test.ts @@ -0,0 +1,105 @@ +/* + * 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 MySequenceable from "./my_sequenceable"; +import IInterfaceDeclare from "../interfaceDeclare/i_interface_declare"; + +export default interface IZidlToolTest { + onewayVoidVoid(callback: onewayVoidVoidCallback): void; + voidVoid(callback: voidVoidCallback): void; + booleanVoid(callback: booleanVoidCallback): void; + byteVoid(callback: byteVoidCallback): void; + shortVoid(callback: shortVoidCallback): void; + intVoid(callback: intVoidCallback): void; + longVoid(callback: longVoidCallback): void; + floatVoid(callback: floatVoidCallback): void; + doubleVoid(callback: doubleVoidCallback): void; + stringVoid(callback: stringVoidCallback): void; + sequenceableVoid(callback: sequenceableVoidCallback): void; + interfaceVoid(callback: interfaceVoidCallback): void; + mapStringStringVoid(callback: mapStringStringVoidCallback): void; + doubleArrayVoid(callback: doubleArrayVoidCallback): void; + voidInMapStringInt(param: Map, callback: voidInMapStringIntCallback): void; + voidInStringArray(param: string[], callback: voidInStringArrayCallback): void; + voidOutMapStringInt(callback: voidOutMapStringIntCallback): void; + voidOutStringArray(callback: voidOutStringArrayCallback): void; + voidInOutMapStringInt(param: Map, callback: voidInOutMapStringIntCallback): void; + voidInOutStringArray(param: string[], callback: voidInOutStringArrayCallback): void; + voidInInt(param: number, callback: voidInIntCallback): void; + voidInString(param: string, callback: voidInStringCallback): void; + voidOutInt(callback: voidOutIntCallback): void; + voidOutString(callback: voidOutStringCallback): void; + voidInOutInt(param: number, callback: voidInOutIntCallback): void; + voidInOutString(param: string, callback: voidInOutStringCallback): void; + voidParameterTypeBoolean(param: boolean, callback: voidParameterTypeBooleanCallback): void; + voidParameterTypeByte(param: number, callback: voidParameterTypeByteCallback): void; + voidParameterTypeShort(param: number, callback: voidParameterTypeShortCallback): void; + voidParameterTypeInt(param: number, callback: voidParameterTypeIntCallback): void; + voidParameterTypeLong(param: number, callback: voidParameterTypeLongCallback): void; + voidParameterTypeFloat(param: number, callback: voidParameterTypeFloatCallback): void; + voidParameterTypeDouble(param: number, callback: voidParameterTypeDoubleCallback): void; + voidParameterTypeString(param: string, callback: voidParameterTypeStringCallback): void; + voidParameterTypeSequenceable(param: MySequenceable, callback: voidParameterTypeSequenceableCallback): void; + voidParameterTypeInterface(param: IInterfaceDeclare, callback: voidParameterTypeInterfaceCallback): void; + voidParameterTypeMapStringString(param: Map, callback: voidParameterTypeMapStringStringCallback): void; + voidParameterTypeDoubleArray(param: number[], callback: voidParameterTypeDoubleArrayCallback): void; + voidOrderOutIn(paramI: number, callback: voidOrderOutInCallback): void; + voidOrderInOutIn(paramI: number, paramS: string, callback: voidOrderInOutInCallback): void; + voidOrderOutInOut(paramS: string, callback: voidOrderOutInOutCallback): void; + voidOrderInInOutOut(paramS: string, paramI: number, callback: voidOrderInInOutOutCallback): void; +} +export type onewayVoidVoidCallback = (errCode: number) => void; +export type voidVoidCallback = (errCode: number) => void; +export type booleanVoidCallback = (errCode: number, returnValue: boolean) => void; +export type byteVoidCallback = (errCode: number, returnValue: number) => void; +export type shortVoidCallback = (errCode: number, returnValue: number) => void; +export type intVoidCallback = (errCode: number, returnValue: number) => void; +export type longVoidCallback = (errCode: number, returnValue: number) => void; +export type floatVoidCallback = (errCode: number, returnValue: number) => void; +export type doubleVoidCallback = (errCode: number, returnValue: number) => void; +export type stringVoidCallback = (errCode: number, returnValue: string) => void; +export type sequenceableVoidCallback = (errCode: number, returnValue: MySequenceable) => void; +export type interfaceVoidCallback = (errCode: number, returnValue: IInterfaceDeclare) => void; +export type mapStringStringVoidCallback = (errCode: number, returnValue: Map) => void; +export type doubleArrayVoidCallback = (errCode: number, returnValue: number[]) => void; +export type voidInMapStringIntCallback = (errCode: number) => void; +export type voidInStringArrayCallback = (errCode: number) => void; +export type voidOutMapStringIntCallback = (errCode: number, param: Map) => void; +export type voidOutStringArrayCallback = (errCode: number, param: string[]) => void; +export type voidInOutMapStringIntCallback = (errCode: number, param: Map) => void; +export type voidInOutStringArrayCallback = (errCode: number, param: string[]) => void; +export type voidInIntCallback = (errCode: number) => void; +export type voidInStringCallback = (errCode: number) => void; +export type voidOutIntCallback = (errCode: number, param: number) => void; +export type voidOutStringCallback = (errCode: number, param: string) => void; +export type voidInOutIntCallback = (errCode: number, param: number) => void; +export type voidInOutStringCallback = (errCode: number, param: string) => void; +export type voidParameterTypeBooleanCallback = (errCode: number) => void; +export type voidParameterTypeByteCallback = (errCode: number) => void; +export type voidParameterTypeShortCallback = (errCode: number) => void; +export type voidParameterTypeIntCallback = (errCode: number) => void; +export type voidParameterTypeLongCallback = (errCode: number) => void; +export type voidParameterTypeFloatCallback = (errCode: number) => void; +export type voidParameterTypeDoubleCallback = (errCode: number) => void; +export type voidParameterTypeStringCallback = (errCode: number) => void; +export type voidParameterTypeSequenceableCallback = (errCode: number) => void; +export type voidParameterTypeInterfaceCallback = (errCode: number) => void; +export type voidParameterTypeMapStringStringCallback = (errCode: number) => void; +export type voidParameterTypeDoubleArrayCallback = (errCode: number) => void; +export type voidOrderOutInCallback = (errCode: number, paramS: string) => void; +export type voidOrderInOutInCallback = (errCode: number, paramI: number) => void; +export type voidOrderOutInOutCallback = (errCode: number, paramI: number, paramS: string) => void; +export type voidOrderInInOutOutCallback = (errCode: number, paramI: number, paramS2: string) => void; + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/zidlTool/my_sequenceable.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/zidlTool/my_sequenceable.ts new file mode 100755 index 0000000000000000000000000000000000000000..0030fa8fefb9f88efbb1cbefa804919da4499cc2 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/zidlTool/my_sequenceable.ts @@ -0,0 +1,28 @@ +export default class MySequenceable { + constructor() { + this.num = 14; + this.str = "hello"; + } + getNum() : number { + return this.num; + } + + getString() : string { + return this.str; + } + + marshalling(messageParcel) { + console.info('marshalling++++'); + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + return true; + } + unmarshalling(messageParcel) { + console.info('unmarshalling++++'); + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + return true; + } + private num; + private str; +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/zidlTool/zidl_tool_test_stub.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/zidlTool/zidl_tool_test_stub.ts new file mode 100755 index 0000000000000000000000000000000000000000..466bc3d6040a0b3c01ca401b05d96dc1a55cacb9 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility/zidlTool/zidl_tool_test_stub.ts @@ -0,0 +1,549 @@ +/* + * 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 {onewayVoidVoidCallback} from "./i_zidl_tool_test"; +import {voidVoidCallback} from "./i_zidl_tool_test"; +import {booleanVoidCallback} from "./i_zidl_tool_test"; +import {byteVoidCallback} from "./i_zidl_tool_test"; +import {shortVoidCallback} from "./i_zidl_tool_test"; +import {intVoidCallback} from "./i_zidl_tool_test"; +import {longVoidCallback} from "./i_zidl_tool_test"; +import {floatVoidCallback} from "./i_zidl_tool_test"; +import {doubleVoidCallback} from "./i_zidl_tool_test"; +import {stringVoidCallback} from "./i_zidl_tool_test"; +import {sequenceableVoidCallback} from "./i_zidl_tool_test"; +import {interfaceVoidCallback} from "./i_zidl_tool_test"; +import {mapStringStringVoidCallback} from "./i_zidl_tool_test"; +import {doubleArrayVoidCallback} from "./i_zidl_tool_test"; +import {voidInMapStringIntCallback} from "./i_zidl_tool_test"; +import {voidInStringArrayCallback} from "./i_zidl_tool_test"; +import {voidOutMapStringIntCallback} from "./i_zidl_tool_test"; +import {voidOutStringArrayCallback} from "./i_zidl_tool_test"; +import {voidInOutMapStringIntCallback} from "./i_zidl_tool_test"; +import {voidInOutStringArrayCallback} from "./i_zidl_tool_test"; +import {voidInIntCallback} from "./i_zidl_tool_test"; +import {voidInStringCallback} from "./i_zidl_tool_test"; +import {voidOutIntCallback} from "./i_zidl_tool_test"; +import {voidOutStringCallback} from "./i_zidl_tool_test"; +import {voidInOutIntCallback} from "./i_zidl_tool_test"; +import {voidInOutStringCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeBooleanCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeByteCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeShortCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeIntCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeLongCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeFloatCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeDoubleCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeStringCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeSequenceableCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeInterfaceCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeMapStringStringCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeDoubleArrayCallback} from "./i_zidl_tool_test"; +import {voidOrderOutInCallback} from "./i_zidl_tool_test"; +import {voidOrderInOutInCallback} from "./i_zidl_tool_test"; +import {voidOrderOutInOutCallback} from "./i_zidl_tool_test"; +import {voidOrderInInOutOutCallback} from "./i_zidl_tool_test"; +import IZidlToolTest from "./i_zidl_tool_test"; +import rpc from "@ohos.rpc"; +import MySequenceable from "./my_sequenceable"; +import IInterfaceDeclare from "../interfaceDeclare/i_interface_declare"; +import InterfaceDeclareStub from "../interfaceDeclare/interface_declare_stub"; + +export default class ZidlToolTestStub extends rpc.RemoteObject implements IZidlToolTest { + constructor(des: string) { + super(des); + } + + onRemoteRequest(code: number, data, reply, option): boolean { + console.log("onRemoteRequest called, code = " + code); + switch(code) { + case ZidlToolTestStub.COMMAND_ONEWAY_VOID_VOID: { + this.onewayVoidVoid((errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_VOID: { + this.voidVoid((errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_BOOLEAN_VOID: { + this.booleanVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(returnValue ? 1 : 0); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_BYTE_VOID: { + this.byteVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_SHORT_VOID: { + this.shortVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_INT_VOID: { + this.intVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_LONG_VOID: { + this.longVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeLong(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_FLOAT_VOID: { + this.floatVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeFloat(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_DOUBLE_VOID: { + this.doubleVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeDouble(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_STRING_VOID: { + this.stringVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeString(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_SEQUENCEABLE_VOID: { + this.sequenceableVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeSequenceable(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_INTERFACE_VOID: { + this.interfaceVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeRemoteObject(returnValue as InterfaceDeclareStub); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_MAP_STRING_STRING_VOID: { + this.mapStringStringVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(returnValue.size); + for (let [key, value] of returnValue) { + reply.writeString(key); + reply.writeString(value); + } + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_DOUBLE_ARRAY_VOID: { + this.doubleArrayVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeDoubleArray(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_MAP_STRING_INT: { + let _param = new Map(); + let _paramSize = data.readInt(); + for (let i = 0; i < _paramSize; ++i) { + let key = data.readString(); + let value = data.readInt(); + _param.set(key, value); + } + this.voidInMapStringInt(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_STRING_ARRAY: { + let _param = data.readStringArray(); + this.voidInStringArray(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_OUT_MAP_STRING_INT: { + this.voidOutMapStringInt((errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(param.size); + for (let [key, value] of param) { + reply.writeString(key); + reply.writeInt(value); + } + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_OUT_STRING_ARRAY: { + this.voidOutStringArray((errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeStringArray(param); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_OUT_MAP_STRING_INT: { + let _param = new Map(); + let _paramSize = data.readInt(); + for (let i = 0; i < _paramSize; ++i) { + let key = data.readString(); + let value = data.readInt(); + _param.set(key, value); + } + this.voidInOutMapStringInt(_param, (errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(param.size); + for (let [key, value] of param) { + reply.writeString(key); + reply.writeInt(value); + } + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_OUT_STRING_ARRAY: { + let _param = data.readStringArray(); + this.voidInOutStringArray(_param, (errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeStringArray(param); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_INT: { + let _param = data.readInt(); + this.voidInInt(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_STRING: { + let _param = data.readString(); + this.voidInString(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_OUT_INT: { + this.voidOutInt((errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(param); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_OUT_STRING: { + this.voidOutString((errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeString(param); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_OUT_INT: { + let _param = data.readInt(); + this.voidInOutInt(_param, (errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(param); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_OUT_STRING: { + let _param = data.readString(); + this.voidInOutString(_param, (errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeString(param); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_BOOLEAN: { + let _param = data.readInt() == 1 ? true : false; + this.voidParameterTypeBoolean(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_BYTE: { + let _param = data.readInt(); + this.voidParameterTypeByte(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_SHORT: { + let _param = data.readInt(); + this.voidParameterTypeShort(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_INT: { + let _param = data.readInt(); + this.voidParameterTypeInt(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_LONG: { + let _param = data.readLong(); + this.voidParameterTypeLong(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_FLOAT: { + let _param = data.readFloat(); + this.voidParameterTypeFloat(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_DOUBLE: { + let _param = data.readDouble(); + this.voidParameterTypeDouble(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_STRING: { + let _param = data.readString(); + this.voidParameterTypeString(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_SEQUENCEABLE: { + let _param = new MySequenceable(); + data.readSequenceable(_param); + this.voidParameterTypeSequenceable(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_INTERFACE: { + let _param = data.readRemoteObject(); + this.voidParameterTypeInterface(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_MAP_STRING_STRING: { + let _param = new Map(); + let _paramSize = data.readInt(); + for (let i = 0; i < _paramSize; ++i) { + let key = data.readString(); + let value = data.readString(); + _param.set(key, value); + } + this.voidParameterTypeMapStringString(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_DOUBLE_ARRAY: { + let _param = data.readDoubleArray(); + this.voidParameterTypeDoubleArray(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_ORDER_OUT_IN: { + let _paramI = data.readInt(); + this.voidOrderOutIn(_paramI, (errCode, paramS) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeString(paramS); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_ORDER_IN_OUT_IN: { + let _paramI = data.readInt(); + let _paramS = data.readString(); + this.voidOrderInOutIn(_paramI, _paramS, (errCode, paramI) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(paramI); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_ORDER_OUT_IN_OUT: { + let _paramS = data.readString(); + this.voidOrderOutInOut(_paramS, (errCode, paramI, paramS) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(paramI); + reply.writeString(paramS); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_ORDER_IN_IN_OUT_OUT: { + let _paramS = data.readString(); + let _paramI = data.readInt(); + this.voidOrderInInOutOut(_paramS, _paramI, (errCode, paramI, paramS2) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(paramI); + reply.writeString(paramS2); + } + }); + return true; + } + default: { + console.log("invalid request code" + code); + break; + } + } + return false; + } + + onewayVoidVoid(callback: onewayVoidVoidCallback): void{} + voidVoid(callback: voidVoidCallback): void{} + booleanVoid(callback: booleanVoidCallback): void{} + byteVoid(callback: byteVoidCallback): void{} + shortVoid(callback: shortVoidCallback): void{} + intVoid(callback: intVoidCallback): void{} + longVoid(callback: longVoidCallback): void{} + floatVoid(callback: floatVoidCallback): void{} + doubleVoid(callback: doubleVoidCallback): void{} + stringVoid(callback: stringVoidCallback): void{} + sequenceableVoid(callback: sequenceableVoidCallback): void{} + interfaceVoid(callback: interfaceVoidCallback): void{} + mapStringStringVoid(callback: mapStringStringVoidCallback): void{} + doubleArrayVoid(callback: doubleArrayVoidCallback): void{} + voidInMapStringInt(param: Map, callback: voidInMapStringIntCallback): void{} + voidInStringArray(param: string[], callback: voidInStringArrayCallback): void{} + voidOutMapStringInt(callback: voidOutMapStringIntCallback): void{} + voidOutStringArray(callback: voidOutStringArrayCallback): void{} + voidInOutMapStringInt(param: Map, callback: voidInOutMapStringIntCallback): void{} + voidInOutStringArray(param: string[], callback: voidInOutStringArrayCallback): void{} + voidInInt(param: number, callback: voidInIntCallback): void{} + voidInString(param: string, callback: voidInStringCallback): void{} + voidOutInt(callback: voidOutIntCallback): void{} + voidOutString(callback: voidOutStringCallback): void{} + voidInOutInt(param: number, callback: voidInOutIntCallback): void{} + voidInOutString(param: string, callback: voidInOutStringCallback): void{} + voidParameterTypeBoolean(param: boolean, callback: voidParameterTypeBooleanCallback): void{} + voidParameterTypeByte(param: number, callback: voidParameterTypeByteCallback): void{} + voidParameterTypeShort(param: number, callback: voidParameterTypeShortCallback): void{} + voidParameterTypeInt(param: number, callback: voidParameterTypeIntCallback): void{} + voidParameterTypeLong(param: number, callback: voidParameterTypeLongCallback): void{} + voidParameterTypeFloat(param: number, callback: voidParameterTypeFloatCallback): void{} + voidParameterTypeDouble(param: number, callback: voidParameterTypeDoubleCallback): void{} + voidParameterTypeString(param: string, callback: voidParameterTypeStringCallback): void{} + voidParameterTypeSequenceable(param: MySequenceable, callback: voidParameterTypeSequenceableCallback): void{} + voidParameterTypeInterface(param: IInterfaceDeclare, callback: voidParameterTypeInterfaceCallback): void{} + voidParameterTypeMapStringString(param: Map, callback: voidParameterTypeMapStringStringCallback): void{} + voidParameterTypeDoubleArray(param: number[], callback: voidParameterTypeDoubleArrayCallback): void{} + voidOrderOutIn(paramI: number, callback: voidOrderOutInCallback): void{} + voidOrderInOutIn(paramI: number, paramS: string, callback: voidOrderInOutInCallback): void{} + voidOrderOutInOut(paramS: string, callback: voidOrderOutInOutCallback): void{} + voidOrderInInOutOut(paramS: string, paramI: number, callback: voidOrderInInOutOutCallback): void{} + + static readonly COMMAND_ONEWAY_VOID_VOID = 1; + static readonly COMMAND_VOID_VOID = 2; + static readonly COMMAND_BOOLEAN_VOID = 3; + static readonly COMMAND_BYTE_VOID = 4; + static readonly COMMAND_SHORT_VOID = 5; + static readonly COMMAND_INT_VOID = 6; + static readonly COMMAND_LONG_VOID = 7; + static readonly COMMAND_FLOAT_VOID = 8; + static readonly COMMAND_DOUBLE_VOID = 9; + static readonly COMMAND_STRING_VOID = 10; + static readonly COMMAND_SEQUENCEABLE_VOID = 11; + static readonly COMMAND_INTERFACE_VOID = 12; + static readonly COMMAND_MAP_STRING_STRING_VOID = 13; + static readonly COMMAND_DOUBLE_ARRAY_VOID = 14; + static readonly COMMAND_VOID_IN_MAP_STRING_INT = 15; + static readonly COMMAND_VOID_IN_STRING_ARRAY = 16; + static readonly COMMAND_VOID_OUT_MAP_STRING_INT = 17; + static readonly COMMAND_VOID_OUT_STRING_ARRAY = 18; + static readonly COMMAND_VOID_IN_OUT_MAP_STRING_INT = 19; + static readonly COMMAND_VOID_IN_OUT_STRING_ARRAY = 20; + static readonly COMMAND_VOID_IN_INT = 21; + static readonly COMMAND_VOID_IN_STRING = 22; + static readonly COMMAND_VOID_OUT_INT = 23; + static readonly COMMAND_VOID_OUT_STRING = 24; + static readonly COMMAND_VOID_IN_OUT_INT = 25; + static readonly COMMAND_VOID_IN_OUT_STRING = 26; + static readonly COMMAND_VOID_PARAMETER_TYPE_BOOLEAN = 27; + static readonly COMMAND_VOID_PARAMETER_TYPE_BYTE = 28; + static readonly COMMAND_VOID_PARAMETER_TYPE_SHORT = 29; + static readonly COMMAND_VOID_PARAMETER_TYPE_INT = 30; + static readonly COMMAND_VOID_PARAMETER_TYPE_LONG = 31; + static readonly COMMAND_VOID_PARAMETER_TYPE_FLOAT = 32; + static readonly COMMAND_VOID_PARAMETER_TYPE_DOUBLE = 33; + static readonly COMMAND_VOID_PARAMETER_TYPE_STRING = 34; + static readonly COMMAND_VOID_PARAMETER_TYPE_SEQUENCEABLE = 35; + static readonly COMMAND_VOID_PARAMETER_TYPE_INTERFACE = 36; + static readonly COMMAND_VOID_PARAMETER_TYPE_MAP_STRING_STRING = 37; + static readonly COMMAND_VOID_PARAMETER_TYPE_DOUBLE_ARRAY = 38; + static readonly COMMAND_VOID_ORDER_OUT_IN = 39; + static readonly COMMAND_VOID_ORDER_IN_OUT_IN = 40; + static readonly COMMAND_VOID_ORDER_OUT_IN_OUT = 41; + static readonly COMMAND_VOID_ORDER_IN_IN_OUT_OUT = 42; +} + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..3f6957e65b120da38469d647448653046b29112a --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -0,0 +1,64 @@ +/* +* 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 ZidlTestServiceStubOneway from './zidlToolOneWay/interface_attribute_declaratoin_oneway_stub'; +import {voidVoidFirstCallback} from './zidlToolOneWay/i_interface_attribute_declaratoin_oneway' +import {voidVoidSecondCallback} from './zidlToolOneWay/i_interface_attribute_declaratoin_oneway' +import {voidVoidThirdCallback} from './zidlToolOneWay/i_interface_attribute_declaratoin_oneway' + +const SUCCESS = 0; +const FAIL = 1; + +class ZidlTestImpOneway extends ZidlTestServiceStubOneway { + voidVoidFirst(callback: voidVoidFirstCallback) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_0100_1 called"); + callback(SUCCESS); + } + + voidVoidSecond(callback: voidVoidSecondCallback) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_0100_2 called"); + callback(SUCCESS); + } + + voidVoidThird(callback: voidVoidThirdCallback) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_0100_3 called"); + callback(SUCCESS); + } +} + +export default class ServiceAbility2 extends ServiceExtension { + onCreate(want,startId) { + globalThis.abilityWant = want; + console.log('ZidlClientTest ServiceAbility2 onCreate, want: ' + want.abilityName); + } + + onRequest(want, startId) { + console.log('ZidlClientTest ServiceAbility2 onRequest, want: ' + want.abilityName + + ', startId: ' + startId); + } + + onConnect(want) { + console.log('ZidlClientTest ServiceAbility2 onConnect, want:' + want.abilityName); + return new ZidlTestImpOneway('connect'); + } + + onDisconnect(want) { + console.log('ZidlClientTest ServiceAbility2 onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('ZidlClientTest ServiceAbility2 onDestroy'); + } +}; diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility2/service.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..b49731a414958a281c2f0c4eab0e7fb408eb2c2f --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/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/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility2/zidlToolOneWay/i_interface_attribute_declaratoin_oneway.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility2/zidlToolOneWay/i_interface_attribute_declaratoin_oneway.ts new file mode 100755 index 0000000000000000000000000000000000000000..943d83dc857cd02cccbddfd143c4b3e504ebf825 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility2/zidlToolOneWay/i_interface_attribute_declaratoin_oneway.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ + + +export default interface IInterfaceAttributeDeclaratoinOneway { + voidVoidFirst(callback: voidVoidFirstCallback): void; + voidVoidSecond(callback: voidVoidSecondCallback): void; + voidVoidThird(callback: voidVoidThirdCallback): void; +} +export type voidVoidFirstCallback = (errCode: number) => void; +export type voidVoidSecondCallback = (errCode: number) => void; +export type voidVoidThirdCallback = (errCode: number) => void; + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility2/zidlToolOneWay/interface_attribute_declaratoin_oneway_stub.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility2/zidlToolOneWay/interface_attribute_declaratoin_oneway_stub.ts new file mode 100755 index 0000000000000000000000000000000000000000..a2b75c5f4d97885876f91ef457802e77e20914e2 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/ServiceAbility2/zidlToolOneWay/interface_attribute_declaratoin_oneway_stub.ts @@ -0,0 +1,64 @@ +/* + * 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 {voidVoidFirstCallback} from "./i_interface_attribute_declaratoin_oneway"; +import {voidVoidSecondCallback} from "./i_interface_attribute_declaratoin_oneway"; +import {voidVoidThirdCallback} from "./i_interface_attribute_declaratoin_oneway"; +import IInterfaceAttributeDeclaratoinOneway from "./i_interface_attribute_declaratoin_oneway"; +import rpc from "@ohos.rpc"; + +export default class InterfaceAttributeDeclaratoinOnewayStub extends rpc.RemoteObject implements IInterfaceAttributeDeclaratoinOneway { + constructor(des: string) { + super(des); + } + + onRemoteRequest(code: number, data, reply, option): boolean { + console.log("onRemoteRequest called, code = " + code); + switch(code) { + case InterfaceAttributeDeclaratoinOnewayStub.COMMAND_VOID_VOID_FIRST: { + this.voidVoidFirst((errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case InterfaceAttributeDeclaratoinOnewayStub.COMMAND_VOID_VOID_SECOND: { + this.voidVoidSecond((errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case InterfaceAttributeDeclaratoinOnewayStub.COMMAND_VOID_VOID_THIRD: { + this.voidVoidThird((errCode) => { + reply.writeInt(errCode); + }); + return true; + } + default: { + console.log("invalid request code" + code); + break; + } + } + return false; + } + + voidVoidFirst(callback: voidVoidFirstCallback): void{} + voidVoidSecond(callback: voidVoidSecondCallback): void{} + voidVoidThird(callback: voidVoidThirdCallback): void{} + + static readonly COMMAND_VOID_VOID_FIRST = 1; + static readonly COMMAND_VOID_VOID_SECOND = 2; + static readonly COMMAND_VOID_VOID_THIRD = 3; +} + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/interfaceDeclare/i_interface_declare.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/interfaceDeclare/i_interface_declare.ts new file mode 100755 index 0000000000000000000000000000000000000000..9c6b544fcf622de7f85f5301f307857f855f2ec6 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/interfaceDeclare/i_interface_declare.ts @@ -0,0 +1,21 @@ +/* + * 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. + */ + + +export default interface IInterfaceDeclare { + testInterface(data: number, callback: testInterfaceCallback): void; +} +export type testInterfaceCallback = (errCode: number) => void; + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/interfaceDeclare/interface_declare_proxy.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/interfaceDeclare/interface_declare_proxy.ts new file mode 100755 index 0000000000000000000000000000000000000000..fadb691def524f2745a670d6c4c9cfbb4fffd475 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/interfaceDeclare/interface_declare_proxy.ts @@ -0,0 +1,44 @@ +/* + * 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 {testInterfaceCallback} from "./i_interface_declare"; +import IInterfaceDeclare from "./i_interface_declare"; +import rpc from "@ohos.rpc"; + +export default class InterfaceDeclareProxy implements IInterfaceDeclare { + constructor(proxy) { + this.proxy = proxy; + } + + testInterface(data: number, callback: testInterfaceCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(data); + this.proxy.sendRequest(InterfaceDeclareProxy.COMMAND_TEST_INTERFACE, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + static readonly COMMAND_TEST_INTERFACE = 1; + private proxy +} + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/interfaceDeclare/interface_declare_stub.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/interfaceDeclare/interface_declare_stub.ts new file mode 100755 index 0000000000000000000000000000000000000000..fa6208b1f94fc17dd376c3495e9ceea3c317ee0b --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/interfaceDeclare/interface_declare_stub.ts @@ -0,0 +1,47 @@ +/* + * 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 {testInterfaceCallback} from "./i_interface_declare"; +import IInterfaceDeclare from "./i_interface_declare"; +import rpc from "@ohos.rpc"; + +export default class InterfaceDeclareStub extends rpc.RemoteObject implements IInterfaceDeclare { + constructor(des: string) { + super(des); + } + + onRemoteRequest(code: number, data, reply, option): boolean { + console.log("onRemoteRequest called, code = " + code); + switch(code) { + case InterfaceDeclareStub.COMMAND_TEST_INTERFACE: { + let _data = data.readInt(); + this.testInterface(_data, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + default: { + console.log("invalid request code" + code); + break; + } + } + return false; + } + + testInterface(data: number, callback: testInterfaceCallback): void{} + + static readonly COMMAND_TEST_INTERFACE = 1; +} + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/pages/index.ets b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/pages/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..e5ef3e3680a267a6aa28a510c77f04cc5cd3c0cb --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/pages/index.ets @@ -0,0 +1,64 @@ +/* + * 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters['timeout'] = 10000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Test App') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..577f53879917d26276c6ef294f65d9d044533161 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/pages/index/index.ets @@ -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 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) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/pages/second.ets b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/pages/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..33d9ae45245db03fd252ef7c1a85c9e284028e0d --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/pages/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/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/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/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/test/Ability.test.ets b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/test/Ability.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..7c31cb69818fe99a9442ea3aab183216260f6d74 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,1586 @@ +/* + * 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 MySequenceable from '../zidlTool/my_sequenceable' +import ZidlTestServiceProxy from '../zidlTool/zidl_tool_test_proxy' +import ZidlTestServiceProxyOneway from '../zidlToolOneWay/interface_attribute_declaratoin_oneway_proxy' +import InterfaceDeclareStub from '../interfaceDeclare/interface_declare_stub' +import InterfaceDeclareProxy from '../interfaceDeclare/interface_declare_proxy' +import { testInterfaceCallback } from '../interfaceDeclare/i_interface_declare' + +var connectionId = -1; +var connectionOnewayId = -1; +var connectionIdSingle = -1; +var connectionOnewayIdSingle = -1; +var testProxyMulti; +var testProxyMultiOneway; +var testProxySingle; +var testProxySingleOneway; +const SUCCESS = 0; +const FAIL = 1; + +export default function abilityTest(abilityContext) { + describe('ActsAbilityTest', function () { + + beforeAll(async (done) => { + var count = 0; + + function checkDone() { + if (count >= 4) { + done(); + } + } + + var paMultiConnect = { + onConnect: function (elementName, proxy) { + console.log("ZidlTest Client Faconnection onConnect called."); + console.log("ZidlTest Client Faconnection onConnect elementName = " + elementName); + console.log("ZidlTest Client Faconnection onConnect proxy = " + proxy); + testProxyMulti = new ZidlTestServiceProxy(proxy); + count++; + checkDone(); + }, + onDisconnect: function (elementName) { + console.log("ZidlTest Client onDisconnectService onDisconnect"); + }, + onFailed: function (code) { + console.log("ZidlTest Client onDisconnectService onFailed"); + count++; + checkDone(); + } + }; + + var paMultiOnewayConnect = { + onConnect: function (elementName, proxy) { + console.log("ZidlTest Client Faconnection onConnect called."); + console.log("ZidlTest Client Faconnection onConnect elementName = " + elementName); + console.log("ZidlTest Client Faconnection onConnect proxy = " + proxy); + testProxyMultiOneway = new ZidlTestServiceProxyOneway(proxy); + count++; + checkDone(); + }, + onDisconnect: function (elementName) { + console.log("ZidlTest Client onDisconnectService onDisconnect"); + }, + onFailed: function (code) { + console.log("ZidlTest Client onDisconnectService onFailed"); + count++; + checkDone(); + } + }; + + var paSingleConnect = { + onConnect: function (elementName, proxy) { + console.log("ZidlTest Client Faconnection onConnect called."); + console.log("ZidlTest Client Faconnection onConnect elementName = " + elementName); + console.log("ZidlTest Client Faconnection onConnect proxy = " + proxy); + testProxySingle = new ZidlTestServiceProxy(proxy); + count++; + checkDone(); + }, + onDisconnect: function (elementName) { + console.log("ZidlTest Client onDisconnectService onDisconnect"); + }, + onFailed: function (code) { + console.log("ZidlTest Client onDisconnectService onFailed"); + count++; + checkDone(); + } + }; + + var paSingleOnewayConnect = { + onConnect: function (elementName, proxy) { + console.log("ZidlTest Client Faconnection onConnect called."); + console.log("ZidlTest Client Faconnection onConnect elementName = " + elementName); + console.log("ZidlTest Client Faconnection onConnect proxy = " + proxy); + testProxySingleOneway = new ZidlTestServiceProxyOneway(proxy); + count++; + checkDone(); + }, + onDisconnect: function (elementName) { + console.log("ZidlTest Client onDisconnectService onDisconnect"); + }, + onFailed: function (code) { + console.log("ZidlTest Client onDisconnectService onFailed"); + count++; + checkDone(); + } + }; + + let wantMulti = { + "bundleName": "com.example.zidlservice", + "abilityName": "com.example.zidlservice.ServiceAbility" + }; + let wantMultiOneway = { + "bundleName": "com.example.zidlservice", + "abilityName": "com.example.zidlservice.ServiceAbility2" + }; + let wantSingle = { + "bundleName": "com.example.zidlclienttest", + "abilityName": "com.example.zidlclienttest.ServiceAbility" + }; + let wantSingleOneway = { + "bundleName": "com.example.zidlclienttest", + "abilityName": "com.example.zidlclienttest.ServiceAbility2" + }; + + console.info('ZidlTest Client connectAbility start'); + connectionId = globalThis.abilityContext.connectAbility(wantMulti, paMultiConnect); + console.info('ZidlTest Client connectAbility end connectionId = ' + connectionId); + connectionOnewayId = globalThis.abilityContext.connectAbility(wantMultiOneway, paMultiOnewayConnect); + console.info('ZidlTest Client connectAbility end connectionOnewayId = ' + connectionOnewayId); + + connectionIdSingle = globalThis.abilityContext.connectAbility(wantSingle, paSingleConnect); + console.info('ZidlTest Client connectAbility end connectionIdSingle = ' + connectionIdSingle); + connectionOnewayIdSingle = globalThis.abilityContext.connectAbility(wantSingleOneway, paSingleOnewayConnect); + console.info('ZidlTest Client connectAbility end connectionOnewayIdSingle = ' + connectionOnewayIdSingle); + }) + + afterEach(async (done) => { + setTimeout(() => { + done(); + }, 200) + }) + + afterAll(async (done) => { + var count = 0; + + function checkDone() { + if (count >= 4) { + done(); + } + } + + globalThis.abilityContext.disconnectAbility(connectionId, (err) => { + console.info('ZidlTest Client disconnectAbility result ' + JSON.stringify(err)); + connectionId = -1; + testProxyMulti = null; + count++; + checkDone(); + }) + + globalThis.abilityContext.disconnectAbility(connectionOnewayId, (err) => { + console.info('ZidlTest Client disconnectAbility2 result ' + JSON.stringify(err)); + connectionOnewayId = -1; + testProxyMultiOneway = null; + count++; + checkDone(); + }) + + globalThis.abilityContext.disconnectAbility(connectionIdSingle, (err) => { + console.info('ZidlTest Client disconnectAbility result ' + JSON.stringify(err)); + connectionIdSingle = -1; + testProxyMulti = null; + count++; + checkDone(); + }) + + globalThis.abilityContext.disconnectAbility(connectionOnewayIdSingle, (err) => { + console.info('ZidlTest Client disconnectAbility2 result ' + JSON.stringify(err)); + connectionOnewayIdSingle = -1; + testProxyMultiOneway = null; + count++; + checkDone(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_0100 + * @tc.name: support method attributes declaration [oneway] + * @tc.desc: [oneway] interface zidl.systemtest.IInterfaceAttributeDeclaratoinOneway {} + */ + it('ACTS_Zidl_Js2JsMulti_0100', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_0100 begin'); + var flagFir = false; + var flagSec = false; + var flagThi = false; + + function checkFinish() { + if (flagFir && flagSec && flagThi) { + done(); + } + } + + setTimeout(function () { + testProxyMultiOneway.voidVoidFirst((errCode) => { + expect(errCode).assertEqual(SUCCESS); + flagFir = true; + checkFinish(); + }); + testProxyMultiOneway.voidVoidSecond((errCode) => { + expect(errCode).assertEqual(SUCCESS); + flagSec = true; + checkFinish(); + }); + testProxyMultiOneway.voidVoidThird((errCode) => { + expect(errCode).assertEqual(SUCCESS); + flagThi = true; + checkFinish(); + }); + }, 500); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_0200 + * @tc.name: support method attributes declaration [oneway] + * @tc.desc: [oneway] void onewayVoidVoid() + */ + it('ACTS_Zidl_Js2JsMulti_0200', 0, async function (done) { + testProxyMulti.onewayVoidVoid((errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_0300 + * @tc.name: support method result type void + * @tc.desc: void voidVoid(); + */ + it('ACTS_Zidl_Js2JsMulti_0300', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_0300 begin'); + testProxyMulti.voidVoid((errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_0400 + * @tc.name: support method result type boolean + * @tc.desc: boolean booleanVoid(); + */ + it('ACTS_Zidl_Js2JsMulti_0400', 0, async function (done) { + testProxyMulti.booleanVoid((errCode, boolean) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_0400 call return:" + boolean); + expect(errCode).assertEqual(SUCCESS); + expect(boolean).assertEqual(true); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_0500 + * @tc.name: support method result type byte + * @tc.desc: number byteVoid(); + */ + it('ACTS_Zidl_Js2JsMulti_0500', 0, async function (done) { + testProxyMulti.byteVoid((errCode, mybyte) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_0500 call return:" + mybyte); + expect(errCode).assertEqual(SUCCESS); + expect(mybyte).assertEqual(1); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_0600 + * @tc.name: support method result type short + * @tc.desc: number shortVoid(); + */ + it('ACTS_Zidl_Js2JsMulti_0600', 0, async function (done) { + testProxyMulti.shortVoid((errCode, myshort) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_0600 call return:" + myshort); + expect(errCode).assertEqual(SUCCESS); + expect(myshort).assertEqual(222); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_0700 + * @tc.name: support method result type int + * @tc.desc: number intVoid(); + */ + it('ACTS_Zidl_Js2JsMulti_0700', 0, async function (done) { + testProxyMulti.intVoid((errCode, myint) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_0700 call return:" + myint); + expect(errCode).assertEqual(SUCCESS); + expect(myint).assertEqual(333); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_0800 + * @tc.name: support method result type long + * @tc.desc: number longVoid(); + */ + it('ACTS_Zidl_Js2JsMulti_0800', 0, async function (done) { + testProxyMulti.longVoid((errCode, mylong) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_0800 call return:" + mylong); + expect(errCode).assertEqual(SUCCESS); + expect(mylong).assertEqual(4444); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_0900 + * @tc.name: support method result type float + * @tc.desc: number floatVoid(); + */ + it('ACTS_Zidl_Js2JsMulti_0900', 0, async function (done) { + testProxyMulti.floatVoid((errCode, myfloat) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_0900 call return:" + myfloat); + expect(errCode).assertEqual(SUCCESS); + expect(myfloat).assertEqual(10.1); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_1000 + * @tc.name: support method result type double + * @tc.desc: number doubleVoid(); + */ + it('ACTS_Zidl_Js2JsMulti_1000', 0, async function (done) { + testProxyMulti.doubleVoid((errCode, mydouble) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_1000 call return:" + mydouble); + expect(errCode).assertEqual(SUCCESS); + expect(mydouble).assertEqual(22.1); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_1100 + * @tc.name: support method result type String + * @tc.desc: String stringVoid(); + */ + it('ACTS_Zidl_Js2JsMulti_1100', 0, async function (done) { + testProxyMulti.stringVoid((errCode, mystring) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_1100 call return:" + mystring); + expect(errCode).assertEqual(SUCCESS); + expect(mystring).assertEqual("stringVoid"); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_1200 + * @tc.name: support method result type sequenceable + * @tc.desc: TestInfo sequenceableVoid(); + */ + it('ACTS_Zidl_Js2JsMulti_1200', 0, async function (done) { + testProxyMulti.sequenceableVoid((errCode, mysequenceable) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_1200 call return:" + JSON.stringify(mysequenceable)); + expect(errCode).assertEqual(SUCCESS); + expect(mysequenceable.getNum()).assertEqual(14); + expect(mysequenceable.getString()).assertEqual("hello"); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_1300 + * @tc.name: support method result type interface + * @tc.desc: ITest interfaceVoid(); + */ + it('ACTS_Zidl_Js2JsMulti_1300', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_1300 begin'); + + testProxyMulti.interfaceVoid((errCode, data) => { + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_1300 called"); + expect(errCode).assertEqual(SUCCESS); + let proxy = new InterfaceDeclareProxy(data); + proxy.testInterface(1500, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }); + }) + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_1400 + * @tc.name: support method result type Map container type + * @tc.desc: Map mapStringStringVoid(); + */ + it('ACTS_Zidl_Js2JsMulti_1400', 0, async function (done) { + testProxyMulti.mapStringStringVoid((errCode, mymapStringString) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_1400 call return:" + mymapStringString.get("string1")); + expect(errCode).assertEqual(SUCCESS); + expect(mymapStringString.get("string1")).assertEqual("string2"); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_1500 + * @tc.name: support method result type array type + * @tc.desc: double[] doubleArrayVoid(); + */ + it('ACTS_Zidl_Js2JsMulti_1500', 0, async function (done) { + testProxyMulti.doubleArrayVoid((errCode, mydoubleArray) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_1500 call return:" + mydoubleArray); + expect(errCode).assertEqual(SUCCESS); + expect(mydoubleArray.length).assertEqual(3); + expect(mydoubleArray[0]).assertEqual(1.1); + expect(mydoubleArray[1]).assertEqual(2.1); + expect(mydoubleArray[2]).assertEqual(3.1); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_1600 + * @tc.name: support object type formal parameter attribute in + * @tc.desc: sequenceable zidl.systemtest.TestInfo; void voidInObject([in] TestInfo param); + */ + it('ACTS_Zidl_Js2JsMulti_1600', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_1600 begin'); + var flagFir = false; + var flagSec = false; + + function checkFinish() { + if (flagFir && flagSec) { + done(); + } + } + + let myMap = new Map(); + myMap.set("string1", 1); + var strarray = ["aaa", "bbb", "ccc"]; + testProxyMulti.voidInMapStringInt(myMap, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + flagFir = true; + checkFinish(); + }); + testProxyMulti.voidInStringArray(strarray, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + flagSec = true; + checkFinish(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_1700 + * @tc.name: support object type formal parameter attribute out + * @tc.desc: sequenceable zidl.systemtest.TestInfo;void voidOutObject([out] String param); + */ + it('ACTS_Zidl_Js2JsMulti_1700', 0, async function (done) { + var flagFir = false; + var flagSec = false; + + function checkFinish() { + if (flagFir && flagSec) { + done(); + } + } + + testProxyMulti.voidOutMapStringInt((errCode, map) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_1700 call return:" + map.get("voidOutMapStringInt")); + expect(errCode).assertEqual(SUCCESS); + expect(map.get("voidOutMapStringInt")).assertEqual(1); + flagFir = true; + checkFinish(); + }); + testProxyMulti.voidOutStringArray((errCode, strArray) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_1700 call return:" + JSON.stringify(strArray)); + expect(errCode).assertEqual(SUCCESS); + expect(strArray[0]).assertEqual("aa"); + expect(strArray[1]).assertEqual("dd"); + flagSec = true; + checkFinish(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_1800 + * @tc.name: support object type formal parameter attribute in, out + * @tc.desc: sequenceable zidl.systemtest.TestInfo;void voidInOutObject([in, out] TestInfo param); + */ + it('ACTS_Zidl_Js2JsMulti_1800', 0, async function (done) { + var flagFir = false; + var flagSec = false; + + function checkFinish() { + if (flagFir && flagSec) { + done(); + } + } + + var mapIn = new Map(); + mapIn.set("voidInOutMapStringInt1", 1801); + mapIn.set("voidInOutMapStringInt2", 1802); + testProxyMulti.voidInOutMapStringInt(mapIn, (errCode, map) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_1800 call return:" + map.get("voidInOutMapStringInt")); + expect(errCode).assertEqual(SUCCESS); + expect(map.get("voidInOutMapStringInt1")).assertEqual(1802); + expect(map.get("voidInOutMapStringInt2")).assertEqual(1801); + flagFir = true; + checkFinish(); + }); + + var strArrayIn = ["ddd", "ccc"]; + testProxyMulti.voidInOutStringArray(strArrayIn, (errCode, strArray) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_1800 call return:" + JSON.stringify(strArray)); + expect(errCode).assertEqual(SUCCESS); + expect(strArray[0]).assertEqual("aaa"); + expect(strArray[1]).assertEqual("bbb"); + flagSec = true; + checkFinish(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_1900 + * @tc.name: support basic type formal parameter attribute in + * @tc.desc: void voidInInt([in] number param);void voidInString([in] String param); + */ + it('ACTS_Zidl_Js2JsMulti_1900', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_1900 begin'); + var number8 = 8888; + var str3 = "voidInString"; + var flagFir = false; + var flagSec = false; + + function checkFinish() { + if (flagFir && flagSec) { + done(); + } + } + + testProxyMulti.voidInInt(number8, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + flagFir = true; + checkFinish(); + }); + testProxyMulti.voidInString(str3, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + flagSec = true; + checkFinish(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_2000 + * @tc.name: support basic type formal parameter attribute out + * @tc.desc: void voidOutInt([out] number param);void voidOutString([out] String param); + */ + it('ACTS_Zidl_Js2JsMulti_2000', 0, async function (done) { + var flagFir = false; + var flagSec = false; + + function checkFinish() { + if (flagFir && flagSec) { + done(); + } + } + + testProxyMulti.voidOutInt((errCode, number) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_2000 call return:" + JSON.stringify(number)); + expect(errCode).assertEqual(SUCCESS); + expect(number).assertEqual(123); + flagFir = true; + checkFinish(); + }); + testProxyMulti.voidOutString((errCode, str) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_2000 call return:" + JSON.stringify(str)); + expect(str).assertEqual("voidOutString"); + expect(errCode).assertEqual(SUCCESS); + flagSec = true; + checkFinish(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_2100 + * @tc.name: support basic type formal parameter attribute in, out + * @tc.desc: void voidInOutInt([in, out] number param);void voidInOutString([in, out] String param); + */ + it('ACTS_Zidl_Js2JsMulti_2100', 0, async function (done) { + var flagFir = false; + var flagSec = false; + + function checkFinish() { + if (flagFir && flagSec) { + done(); + } + } + + console.log('ACTS_Zidl_Js2JsMulti_2100 begin'); + var number23 = 123456; + var str1 = "voidInOutString"; + testProxyMulti.voidInOutInt(number23, (errCode, number) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_2100 call return:" + JSON.stringify(number)); + expect(errCode).assertEqual(SUCCESS); + expect(number).assertEqual(456789); + flagFir = true; + checkFinish(); + }); + testProxyMulti.voidInOutString(str1, (errCode, str) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_2100 call return:" + JSON.stringify(str)); + expect(errCode).assertEqual(SUCCESS); + expect(str).assertEqual("456789"); + flagSec = true; + checkFinish(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_2200 + * @tc.name: support formal parameter type boolean + * @tc.desc: void voidBoolean([in] boolean param); + */ + it('ACTS_Zidl_Js2JsMulti_2200', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_2200 begin'); + var oBooleanTrue = true; + + testProxyMulti.voidParameterTypeBoolean(oBooleanTrue, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_2300 + * @tc.name: support formal parameter type byte + * @tc.desc: void voidByte([in] byte param); + */ + it('ACTS_Zidl_Js2JsMulti_2300', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_2300 begin'); + var number1 = 1111; + + testProxyMulti.voidParameterTypeByte(number1, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_2400 + * @tc.name: support formal parameter type short + * @tc.desc: void voidShort([in] short param); + */ + it('ACTS_Zidl_Js2JsMulti_2400', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_2400 begin'); + var number2 = 2222; + + testProxyMulti.voidParameterTypeShort(number2, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_2500 + * @tc.name: support formal parameter type int + * @tc.desc: void voidInt([in] int param); + */ + it('ACTS_Zidl_Js2JsMulti_2500', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_2500 begin'); + var number3 = 3333; + + testProxyMulti.voidParameterTypeInt(number3, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_2600 + * @tc.name: support formal parameter type long + * @tc.desc: void voidLong([in] long param); + */ + it('ACTS_Zidl_Js2JsMulti_2600', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_2600 begin'); + var number4 = 4444; + + testProxyMulti.voidParameterTypeLong(number4, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_2700 + * @tc.name: support formal parameter type float + * @tc.desc: void voidFloat([in] float param); + */ + it('ACTS_Zidl_Js2JsMulti_2700', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_2700 begin'); + var number5 = 5555.1; + + testProxyMulti.voidParameterTypeFloat(number5, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_2800 + * @tc.name: support formal parameter type double + * @tc.desc: void voidDouble([in] double param); + */ + it('ACTS_Zidl_Js2JsMulti_2800', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_2800 begin'); + var number6 = 6666.1; + + setTimeout(function () { + testProxyMulti.voidParameterTypeDouble(number6, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }, 500); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_2900 + * @tc.name: support formal parameter type String + * @tc.desc: void voidString([in] String param); + */ + it('ACTS_Zidl_Js2JsMulti_2900', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_2900 begin'); + var str2 = "voidParameterTypeString"; + + testProxyMulti.voidParameterTypeString(str2, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_3000 + * @tc.name: support formal parameter type sequenceable + * @tc.desc: void voidSequenceable([in] TestInfo param); + */ + it('ACTS_Zidl_Js2JsMulti_3000', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_3000 begin'); + let mySequence = new MySequenceable(); + + testProxyMulti.voidParameterTypeSequenceable(mySequence, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_3100 + * @tc.name: support formal parameter type interface + * @tc.desc: void voidInterface([in] ITest param); + */ + it('ACTS_Zidl_Js2JsMulti_3100', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_3100 begin'); + + class InterfaceDeclare extends InterfaceDeclareStub { + testInterface(data: number, callback: testInterfaceCallback): void { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_3100 called"); + let result = FAIL; + + if (data == 3300) { + result = SUCCESS; + } + callback(result); + } + } + + let clientInterface = new InterfaceDeclare('clientInterface'); + + testProxyMulti.voidParameterTypeInterface(clientInterface, (errCode) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_3100 clientInterface callback"); + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_3200 + * @tc.name: support formal parameter type Map + * @tc.desc: void voidMapStringString([in] Map param); + */ + it('ACTS_Zidl_Js2JsMulti_3200', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_3200 begin'); + var map = new Map(); + map.set("voidParameterTypeMapStringString", "fdhatdh"); + + testProxyMulti.voidParameterTypeMapStringString(map, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_3300 + * @tc.name: support formal parameter type array + * @tc.desc: void voidDoubleArray([in] double[] param); + */ + it('ACTS_Zidl_Js2JsMulti_3300', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsMulti_3300 begin'); + var array = [1.1, 2.1]; + + testProxyMulti.voidParameterTypeDoubleArray(array, (errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_3400 + * @tc.name: parameter order + * @tc.desc: order of parameter properties [out], [in] + */ + it('ACTS_Zidl_Js2JsMulti_3400', 0, async function (done) { + var num = 61; + testProxyMulti.voidOrderOutIn(num, (errCode, string) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_3400 call return:" + string); + expect(errCode).assertEqual(SUCCESS); + expect(string).assertEqual("hello world"); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_3500 + * @tc.name: parameter order + * @tc.desc: order of parameter properties [in, out], [in] + */ + it('ACTS_Zidl_Js2JsMulti_3500', 0, async function (done) { + var num = 62; + var str = "inputparam"; + testProxyMulti.voidOrderInOutIn(num, str, (errCode, numparam) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_3500 call return:" + numparam); + expect(errCode).assertEqual(SUCCESS); + expect(numparam).assertEqual(6); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_3600 + * @tc.name: parameter order + * @tc.desc: order of parameter properties [out], [in, out] + */ + it('ACTS_Zidl_Js2JsMulti_3600', 0, async function (done) { + var str = "param"; + testProxyMulti.voidOrderOutInOut(str, (errCode, paramI, paramS) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_3600 call return:" + paramI + " " + paramS); + expect(errCode).assertEqual(SUCCESS); + expect(paramI).assertEqual(3); + expect(paramS).assertEqual("paramcallback"); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsMulti_3700 + * @tc.name: parameter order + * @tc.desc: order of parameter properties [in], [in, out], [out] + */ + it('ACTS_Zidl_Js2JsMulti_3700', 0, async function (done) { + var str = "paramInput"; + var num = 64; + testProxyMulti.voidOrderInInOutOut(str, num, (errCode, paramI, paramS) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsMulti_3700 call return:" + paramS + " " + paramI); + expect(errCode).assertEqual(SUCCESS); + expect(paramS).assertEqual("callback"); + expect(paramI).assertEqual(4); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_0100 + * @tc.name: support method attributes declaration [oneway] + * @tc.desc: [oneway] interface zidl.systemtest.IInterfaceAttributeDeclaratoinOneway {} + */ + it('ACTS_Zidl_Js2JsSingle_0100', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_0100 begin'); + var flagFir = false; + var flagSec = false; + var flagThi = false; + + function checkFinish() { + if (flagFir && flagSec && flagThi) { + done(); + } + } + + setTimeout(function () { + testProxySingleOneway.voidVoidFirst((errCode) => { + expect(errCode).assertEqual(SUCCESS); + flagFir = true; + checkFinish(); + }); + testProxySingleOneway.voidVoidSecond((errCode) => { + expect(errCode).assertEqual(SUCCESS); + flagSec = true; + checkFinish(); + }); + testProxySingleOneway.voidVoidThird((errCode) => { + expect(errCode).assertEqual(SUCCESS); + flagThi = true; + checkFinish(); + }); + }, 500); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_0200 + * @tc.name: support method attributes declaration [oneway] + * @tc.desc: [oneway] void onewayVoidVoid() + */ + it('ACTS_Zidl_Js2JsSingle_0200', 0, async function (done) { + testProxySingle.onewayVoidVoid((errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_0300 + * @tc.name: support method result type void + * @tc.desc: void voidVoid(); + */ + it('ACTS_Zidl_Js2JsSingle_0300', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_0300 begin'); + testProxySingle.voidVoid((errCode) => { + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_0400 + * @tc.name: support method result type boolean + * @tc.desc: boolean booleanVoid(); + */ + it('ACTS_Zidl_Js2JsSingle_0400', 0, async function (done) { + testProxySingle.booleanVoid((errCode, boolean) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_0400 call return:" + boolean); + expect(errCode).assertEqual(SUCCESS); + expect(boolean).assertEqual(true); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_0500 + * @tc.name: support method result type byte + * @tc.desc: number byteVoid(); + */ + it('ACTS_Zidl_Js2JsSingle_0500', 0, async function (done) { + testProxySingle.byteVoid((errCode, mybyte) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_0500 call return:" + mybyte); + expect(errCode).assertEqual(SUCCESS); + expect(mybyte).assertEqual(1); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_0600 + * @tc.name: support method result type short + * @tc.desc: number shortVoid(); + */ + it('ACTS_Zidl_Js2JsSingle_0600', 0, async function (done) { + testProxySingle.shortVoid((errCode, myshort) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_0600 call return:" + myshort); + expect(errCode).assertEqual(SUCCESS); + expect(myshort).assertEqual(222); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_0700 + * @tc.name: support method result type int + * @tc.desc: number intVoid(); + */ + it('ACTS_Zidl_Js2JsSingle_0700', 0, async function (done) { + testProxySingle.intVoid((errCode, myint) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_0700 call return:" + myint); + expect(errCode).assertEqual(SUCCESS); + expect(myint).assertEqual(333); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_0800 + * @tc.name: support method result type long + * @tc.desc: number longVoid(); + */ + it('ACTS_Zidl_Js2JsSingle_0800', 0, async function (done) { + testProxySingle.longVoid((errCode, mylong) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_0800 call return:" + mylong); + expect(errCode).assertEqual(SUCCESS); + expect(mylong).assertEqual(4444); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_0900 + * @tc.name: support method result type float + * @tc.desc: number floatVoid(); + */ + it('ACTS_Zidl_Js2JsSingle_0900', 0, async function (done) { + testProxySingle.floatVoid((errCode, myfloat) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_0900 call return:" + myfloat); + expect(errCode).assertEqual(SUCCESS); + expect(myfloat).assertEqual(10.1); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_1000 + * @tc.name: support method result type double + * @tc.desc: number doubleVoid(); + */ + it('ACTS_Zidl_Js2JsSingle_1000', 0, async function (done) { + testProxySingle.doubleVoid((errCode, mydouble) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_1000 call return:" + mydouble); + expect(errCode).assertEqual(SUCCESS); + expect(mydouble).assertEqual(22.1); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_1100 + * @tc.name: support method result type String + * @tc.desc: String stringVoid(); + */ + it('ACTS_Zidl_Js2JsSingle_1100', 0, async function (done) { + testProxySingle.stringVoid((errCode, mystring) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_1100 call return:" + mystring); + expect(errCode).assertEqual(SUCCESS); + expect(mystring).assertEqual("stringVoid"); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_1200 + * @tc.name: support method result type sequenceable + * @tc.desc: TestInfo sequenceableVoid(); + */ + it('ACTS_Zidl_Js2JsSingle_1200', 0, async function (done) { + testProxySingle.sequenceableVoid((errCode, mysequenceable) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_1200 call return:" + JSON.stringify(mysequenceable)); + expect(errCode).assertEqual(SUCCESS); + expect(mysequenceable.getNum()).assertEqual(14); + expect(mysequenceable.getString()).assertEqual("hello"); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_1300 + * @tc.name: support method result type interface + * @tc.desc: ITest interfaceVoid(); + */ + it('ACTS_Zidl_Js2JsSingle_1300', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_1300 begin'); + + testProxySingle.interfaceVoid((errCode, data) => { + console.log("ZidlTest Server ACTS_Zidl_Js2JsSingle_1300 called"); + expect(errCode).assertEqual(SUCCESS); + let proxy = new InterfaceDeclareProxy(data); + proxy.testInterface(1500, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }); + }) + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_1400 + * @tc.name: support method result type Map container type + * @tc.desc: Map mapStringStringVoid(); + */ + it('ACTS_Zidl_Js2JsSingle_1400', 0, async function (done) { + testProxySingle.mapStringStringVoid((errCode, mymapStringString) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_1400 call return:" + mymapStringString.get("string1")); + expect(errCode).assertEqual(SUCCESS); + expect(mymapStringString.get("string1")).assertEqual("string2"); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_1500 + * @tc.name: support method result type array type + * @tc.desc: double[] doubleArrayVoid(); + */ + it('ACTS_Zidl_Js2JsSingle_1500', 0, async function (done) { + testProxySingle.doubleArrayVoid((errCode, mydoubleArray) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_1500 call return:" + mydoubleArray); + expect(errCode).assertEqual(SUCCESS); + expect(mydoubleArray.length).assertEqual(3); + expect(mydoubleArray[0]).assertEqual(1.1); + expect(mydoubleArray[1]).assertEqual(2.1); + expect(mydoubleArray[2]).assertEqual(3.1); + done(); + }) + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_1600 + * @tc.name: support object type formal parameter attribute in + * @tc.desc: sequenceable zidl.systemtest.TestInfo; void voidInObject([in] TestInfo param); + */ + it('ACTS_Zidl_Js2JsSingle_1600', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_1600 begin'); + var flagFir = false; + var flagSec = false; + + function checkFinish() { + if (flagFir && flagSec) { + done(); + } + } + + let myMap = new Map(); + myMap.set("string1", 1); + var strarray = ["aaa", "bbb", "ccc"]; + testProxySingle.voidInMapStringInt(myMap, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + flagFir = true; + checkFinish(); + }); + testProxySingle.voidInStringArray(strarray, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + flagSec = true; + checkFinish(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_1700 + * @tc.name: support object type formal parameter attribute out + * @tc.desc: sequenceable zidl.systemtest.TestInfo;void voidOutObject([out] String param); + */ + it('ACTS_Zidl_Js2JsSingle_1700', 0, async function (done) { + var flagFir = false; + var flagSec = false; + + function checkFinish() { + if (flagFir && flagSec) { + done(); + } + } + + testProxySingle.voidOutMapStringInt((errCode, map) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_1700 call return:" + map.get("voidOutMapStringInt")); + expect(errCode).assertEqual(SUCCESS); + expect(map.get("voidOutMapStringInt")).assertEqual(1); + flagFir = true; + checkFinish(); + }); + testProxySingle.voidOutStringArray((errCode, strArray) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_1700 call return:" + JSON.stringify(strArray)); + expect(errCode).assertEqual(SUCCESS); + expect(strArray[0]).assertEqual("aa"); + expect(strArray[1]).assertEqual("dd"); + flagSec = true; + checkFinish(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_1800 + * @tc.name: support object type formal parameter attribute in, out + * @tc.desc: sequenceable zidl.systemtest.TestInfo;void voidInOutObject([in, out] TestInfo param); + */ + it('ACTS_Zidl_Js2JsSingle_1800', 0, async function (done) { + var flagFir = false; + var flagSec = false; + + function checkFinish() { + if (flagFir && flagSec) { + done(); + } + } + + var mapIn = new Map(); + mapIn.set("voidInOutMapStringInt1", 1801); + mapIn.set("voidInOutMapStringInt2", 1802); + testProxySingle.voidInOutMapStringInt(mapIn, (errCode, map) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_1800 call return:" + map.get("voidInOutMapStringInt")); + expect(errCode).assertEqual(SUCCESS); + expect(map.get("voidInOutMapStringInt1")).assertEqual(1802); + expect(map.get("voidInOutMapStringInt2")).assertEqual(1801); + flagFir = true; + checkFinish(); + }); + var strArrayIn = ["ddd", "ccc"]; + testProxySingle.voidInOutStringArray(strArrayIn, (errCode, strArray) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_1800 call return:" + JSON.stringify(strArray)); + expect(errCode).assertEqual(SUCCESS); + expect(strArray[0]).assertEqual("aaa"); + expect(strArray[1]).assertEqual("bbb"); + flagSec = true; + checkFinish(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_1900 + * @tc.name: support basic type formal parameter attribute in + * @tc.desc: void voidInInt([in] number param);void voidInString([in] String param); + */ + it('ACTS_Zidl_Js2JsSingle_1900', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_1900 begin'); + var number8 = 8888; + var str3 = "voidInString"; + var flagFir = false; + var flagSec = false; + + function checkFinish() { + if (flagFir && flagSec) { + done(); + } + } + + testProxySingle.voidInInt(number8, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + flagFir = true; + checkFinish(); + }); + testProxySingle.voidInString(str3, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + flagSec = true; + checkFinish(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_2000 + * @tc.name: support basic type formal parameter attribute out + * @tc.desc: void voidOutInt([out] number param);void voidOutString([out] String param); + */ + it('ACTS_Zidl_Js2JsSingle_2000', 0, async function (done) { + var flagFir = false; + var flagSec = false; + + function checkFinish() { + if (flagFir && flagSec) { + done(); + } + } + + testProxySingle.voidOutInt((errCode, number) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_2000 call return:" + JSON.stringify(number)); + expect(errCode).assertEqual(SUCCESS); + expect(number).assertEqual(123); + flagFir = true; + checkFinish(); + }); + testProxySingle.voidOutString((errCode, str) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_2000 call return:" + JSON.stringify(str)); + expect(str).assertEqual("voidOutString"); + expect(errCode).assertEqual(SUCCESS); + flagSec = true; + checkFinish(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_2100 + * @tc.name: support basic type formal parameter attribute in, out + * @tc.desc: void voidInOutInt([in, out] number param);void voidInOutString([in, out] String param); + */ + it('ACTS_Zidl_Js2JsSingle_2100', 0, async function (done) { + var flagFir = false; + var flagSec = false; + + function checkFinish() { + if (flagFir && flagSec) { + done(); + } + } + + console.log('ACTS_Zidl_Js2JsSingle_2100 begin'); + var number23 = 123456; + var str1 = "voidInOutString"; + testProxySingle.voidInOutInt(number23, (errCode, number) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_2100 call return:" + JSON.stringify(number)); + expect(errCode).assertEqual(SUCCESS); + expect(number).assertEqual(456789); + flagFir = true; + checkFinish(); + }); + testProxySingle.voidInOutString(str1, (errCode, str) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_2100 call return:" + JSON.stringify(str)); + expect(errCode).assertEqual(SUCCESS); + expect(str).assertEqual("456789"); + flagSec = true; + checkFinish(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_2200 + * @tc.name: support formal parameter type boolean + * @tc.desc: void voidBoolean([in] boolean param); + */ + it('ACTS_Zidl_Js2JsSingle_2200', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_2200 begin'); + var oBooleanTrue = true; + + testProxySingle.voidParameterTypeBoolean(oBooleanTrue, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_2300 + * @tc.name: support formal parameter type byte + * @tc.desc: void voidByte([in] byte param); + */ + it('ACTS_Zidl_Js2JsSingle_2300', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_2300 begin'); + var number1 = 1111; + + testProxySingle.voidParameterTypeByte(number1, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_2400 + * @tc.name: support formal parameter type short + * @tc.desc: void voidShort([in] short param); + */ + it('ACTS_Zidl_Js2JsSingle_2400', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_2400 begin'); + var number2 = 2222; + + testProxySingle.voidParameterTypeShort(number2, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_2500 + * @tc.name: support formal parameter type int + * @tc.desc: void voidInt([in] int param); + */ + it('ACTS_Zidl_Js2JsSingle_2500', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_2500 begin'); + var number3 = 3333; + + testProxySingle.voidParameterTypeInt(number3, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_2600 + * @tc.name: support formal parameter type long + * @tc.desc: void voidLong([in] long param); + */ + it('ACTS_Zidl_Js2JsSingle_2600', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_2600 begin'); + var number4 = 4444; + + testProxySingle.voidParameterTypeLong(number4, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_2700 + * @tc.name: support formal parameter type float + * @tc.desc: void voidFloat([in] float param); + */ + it('ACTS_Zidl_Js2JsSingle_2700', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_2700 begin'); + var number5 = 5555.1; + + testProxySingle.voidParameterTypeFloat(number5, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_2800 + * @tc.name: support formal parameter type double + * @tc.desc: void voidDouble([in] double param); + */ + it('ACTS_Zidl_Js2JsSingle_2800', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_2800 begin'); + var number6 = 6666.1; + + setTimeout(function () { + testProxySingle.voidParameterTypeDouble(number6, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }, 500); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_2900 + * @tc.name: support formal parameter type String + * @tc.desc: void voidString([in] String param); + */ + it('ACTS_Zidl_Js2JsSingle_2900', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_2900 begin'); + var str2 = "voidParameterTypeString"; + + testProxySingle.voidParameterTypeString(str2, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_3000 + * @tc.name: support formal parameter type sequenceable + * @tc.desc: void voidSequenceable([in] TestInfo param); + */ + it('ACTS_Zidl_Js2JsSingle_3000', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_3000 begin'); + let mySequence = new MySequenceable(); + + testProxySingle.voidParameterTypeSequenceable(mySequence, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_3100 + * @tc.name: support formal parameter type interface + * @tc.desc: void voidInterface([in] ITest param); + */ + it('ACTS_Zidl_Js2JsSingle_3100', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_3100 begin'); + + class InterfaceDeclare extends InterfaceDeclareStub { + testInterface(data: number, callback: testInterfaceCallback): void{ + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_3100 called"); + let result = FAIL; + + if (data == 3300) { + result = SUCCESS; + } + callback(result); + } + } + + let clientInterface = new InterfaceDeclare('clientInterface'); + + testProxySingle.voidParameterTypeInterface(clientInterface, (errCode)=>{ + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_3100 clientInterface callback"); + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_3200 + * @tc.name: support formal parameter type Map + * @tc.desc: void voidMapStringString([in] Map param); + */ + it('ACTS_Zidl_Js2JsSingle_3200', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_3200 begin'); + var map = new Map(); + map.set("voidParameterTypeMapStringString", "fdhatdh"); + + testProxySingle.voidParameterTypeMapStringString(map, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_3300 + * @tc.name: support formal parameter type array + * @tc.desc: void voidDoubleArray([in] double[] param); + */ + it('ACTS_Zidl_Js2JsSingle_3300', 0, async function (done) { + console.log('ACTS_Zidl_Js2JsSingle_3300 begin'); + var array = [1.1, 2.1]; + + testProxySingle.voidParameterTypeDoubleArray(array, (errCode)=>{ + expect(errCode).assertEqual(SUCCESS); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_3400 + * @tc.name: parameter order + * @tc.desc: order of parameter properties [out], [in] + */ + it('ACTS_Zidl_Js2JsSingle_3400', 0, async function (done) { + var num = 61; + testProxySingle.voidOrderOutIn(num, (errCode, string) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_3400 call return:" + string); + expect(errCode).assertEqual(SUCCESS); + expect(string).assertEqual("hello world"); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_3500 + * @tc.name: parameter order + * @tc.desc: order of parameter properties [in, out], [in] + */ + it('ACTS_Zidl_Js2JsSingle_3500', 0, async function (done) { + var num = 62; + var str = "inputparam"; + testProxySingle.voidOrderInOutIn(num, str, (errCode, numparam) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_3500 call return:" + numparam); + expect(errCode).assertEqual(SUCCESS); + expect(numparam).assertEqual(6); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_3600 + * @tc.name: parameter order + * @tc.desc: order of parameter properties [out], [in, out] + */ + it('ACTS_Zidl_Js2JsSingle_3600', 0, async function (done) { + var str = "param"; + testProxySingle.voidOrderOutInOut(str, (errCode, paramI, paramS) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_3600 call return:" + paramI + " " + paramS); + expect(errCode).assertEqual(SUCCESS); + expect(paramI).assertEqual(3); + expect(paramS).assertEqual("paramcallback"); + done(); + }); + }) + + /** + * @tc.number: ACTS_Zidl_Js2JsSingle_3700 + * @tc.name: parameter order + * @tc.desc: order of parameter properties [in], [in, out], [out] + */ + it('ACTS_Zidl_Js2JsSingle_3700', 0, async function (done) { + var str = "paramInput"; + var num = 64; + testProxySingle.voidOrderInInOutOut(str, num, (errCode, paramI, paramS) => { + console.log("ZidlTest Client ACTS_Zidl_Js2JsSingle_3700 call return:" + paramS + " " + paramI); + expect(errCode).assertEqual(SUCCESS); + expect(paramS).assertEqual("callback"); + expect(paramI).assertEqual(4); + done(); + }); + }) + }) +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..882f978e77b1a8fbbf843ccb4dd73c47ed460305 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/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 './Ability.test.ets' + + +export default function testsuite(context) { + + abilityTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlTool/i_zidl_tool_test.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlTool/i_zidl_tool_test.ts new file mode 100755 index 0000000000000000000000000000000000000000..ac9da635209b8b8a170f587485ab01a1e9844fcb --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlTool/i_zidl_tool_test.ts @@ -0,0 +1,105 @@ +/* + * 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 MySequenceable from "./my_sequenceable"; +import IInterfaceDeclare from "../interfaceDeclare/i_interface_declare"; + +export default interface IZidlToolTest { + onewayVoidVoid(callback: onewayVoidVoidCallback): void; + voidVoid(callback: voidVoidCallback): void; + booleanVoid(callback: booleanVoidCallback): void; + byteVoid(callback: byteVoidCallback): void; + shortVoid(callback: shortVoidCallback): void; + intVoid(callback: intVoidCallback): void; + longVoid(callback: longVoidCallback): void; + floatVoid(callback: floatVoidCallback): void; + doubleVoid(callback: doubleVoidCallback): void; + stringVoid(callback: stringVoidCallback): void; + sequenceableVoid(callback: sequenceableVoidCallback): void; + interfaceVoid(callback: interfaceVoidCallback): void; + mapStringStringVoid(callback: mapStringStringVoidCallback): void; + doubleArrayVoid(callback: doubleArrayVoidCallback): void; + voidInMapStringInt(param: Map, callback: voidInMapStringIntCallback): void; + voidInStringArray(param: string[], callback: voidInStringArrayCallback): void; + voidOutMapStringInt(callback: voidOutMapStringIntCallback): void; + voidOutStringArray(callback: voidOutStringArrayCallback): void; + voidInOutMapStringInt(param: Map, callback: voidInOutMapStringIntCallback): void; + voidInOutStringArray(param: string[], callback: voidInOutStringArrayCallback): void; + voidInInt(param: number, callback: voidInIntCallback): void; + voidInString(param: string, callback: voidInStringCallback): void; + voidOutInt(callback: voidOutIntCallback): void; + voidOutString(callback: voidOutStringCallback): void; + voidInOutInt(param: number, callback: voidInOutIntCallback): void; + voidInOutString(param: string, callback: voidInOutStringCallback): void; + voidParameterTypeBoolean(param: boolean, callback: voidParameterTypeBooleanCallback): void; + voidParameterTypeByte(param: number, callback: voidParameterTypeByteCallback): void; + voidParameterTypeShort(param: number, callback: voidParameterTypeShortCallback): void; + voidParameterTypeInt(param: number, callback: voidParameterTypeIntCallback): void; + voidParameterTypeLong(param: number, callback: voidParameterTypeLongCallback): void; + voidParameterTypeFloat(param: number, callback: voidParameterTypeFloatCallback): void; + voidParameterTypeDouble(param: number, callback: voidParameterTypeDoubleCallback): void; + voidParameterTypeString(param: string, callback: voidParameterTypeStringCallback): void; + voidParameterTypeSequenceable(param: MySequenceable, callback: voidParameterTypeSequenceableCallback): void; + voidParameterTypeInterface(param: IInterfaceDeclare, callback: voidParameterTypeInterfaceCallback): void; + voidParameterTypeMapStringString(param: Map, callback: voidParameterTypeMapStringStringCallback): void; + voidParameterTypeDoubleArray(param: number[], callback: voidParameterTypeDoubleArrayCallback): void; + voidOrderOutIn(paramI: number, callback: voidOrderOutInCallback): void; + voidOrderInOutIn(paramI: number, paramS: string, callback: voidOrderInOutInCallback): void; + voidOrderOutInOut(paramS: string, callback: voidOrderOutInOutCallback): void; + voidOrderInInOutOut(paramS: string, paramI: number, callback: voidOrderInInOutOutCallback): void; +} +export type onewayVoidVoidCallback = (errCode: number) => void; +export type voidVoidCallback = (errCode: number) => void; +export type booleanVoidCallback = (errCode: number, returnValue: boolean) => void; +export type byteVoidCallback = (errCode: number, returnValue: number) => void; +export type shortVoidCallback = (errCode: number, returnValue: number) => void; +export type intVoidCallback = (errCode: number, returnValue: number) => void; +export type longVoidCallback = (errCode: number, returnValue: number) => void; +export type floatVoidCallback = (errCode: number, returnValue: number) => void; +export type doubleVoidCallback = (errCode: number, returnValue: number) => void; +export type stringVoidCallback = (errCode: number, returnValue: string) => void; +export type sequenceableVoidCallback = (errCode: number, returnValue: MySequenceable) => void; +export type interfaceVoidCallback = (errCode: number, returnValue: IInterfaceDeclare) => void; +export type mapStringStringVoidCallback = (errCode: number, returnValue: Map) => void; +export type doubleArrayVoidCallback = (errCode: number, returnValue: number[]) => void; +export type voidInMapStringIntCallback = (errCode: number) => void; +export type voidInStringArrayCallback = (errCode: number) => void; +export type voidOutMapStringIntCallback = (errCode: number, param: Map) => void; +export type voidOutStringArrayCallback = (errCode: number, param: string[]) => void; +export type voidInOutMapStringIntCallback = (errCode: number, param: Map) => void; +export type voidInOutStringArrayCallback = (errCode: number, param: string[]) => void; +export type voidInIntCallback = (errCode: number) => void; +export type voidInStringCallback = (errCode: number) => void; +export type voidOutIntCallback = (errCode: number, param: number) => void; +export type voidOutStringCallback = (errCode: number, param: string) => void; +export type voidInOutIntCallback = (errCode: number, param: number) => void; +export type voidInOutStringCallback = (errCode: number, param: string) => void; +export type voidParameterTypeBooleanCallback = (errCode: number) => void; +export type voidParameterTypeByteCallback = (errCode: number) => void; +export type voidParameterTypeShortCallback = (errCode: number) => void; +export type voidParameterTypeIntCallback = (errCode: number) => void; +export type voidParameterTypeLongCallback = (errCode: number) => void; +export type voidParameterTypeFloatCallback = (errCode: number) => void; +export type voidParameterTypeDoubleCallback = (errCode: number) => void; +export type voidParameterTypeStringCallback = (errCode: number) => void; +export type voidParameterTypeSequenceableCallback = (errCode: number) => void; +export type voidParameterTypeInterfaceCallback = (errCode: number) => void; +export type voidParameterTypeMapStringStringCallback = (errCode: number) => void; +export type voidParameterTypeDoubleArrayCallback = (errCode: number) => void; +export type voidOrderOutInCallback = (errCode: number, paramS: string) => void; +export type voidOrderInOutInCallback = (errCode: number, paramI: number) => void; +export type voidOrderOutInOutCallback = (errCode: number, paramI: number, paramS: string) => void; +export type voidOrderInInOutOutCallback = (errCode: number, paramI: number, paramS2: string) => void; + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlTool/my_sequenceable.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlTool/my_sequenceable.ts new file mode 100755 index 0000000000000000000000000000000000000000..7cd93c0ecc3403e8e3e8a40c1392e4a0e025b169 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlTool/my_sequenceable.ts @@ -0,0 +1,28 @@ +export default class MySequenceable { + constructor() { + this.num = 32; + this.str = "nihao"; + } + getNum() : number { + return this.num; + } + + getString() : string { + return this.str; + } + + marshalling(messageParcel) { + console.info('marshalling++++'); + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + return true; + } + unmarshalling(messageParcel) { + console.info('unmarshalling++++'); + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + return true; + } + private num; + private str; +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlTool/zidl_tool_test_proxy.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlTool/zidl_tool_test_proxy.ts new file mode 100755 index 0000000000000000000000000000000000000000..c1431ca78cc44f27500b399da5b0805a27bb4947 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlTool/zidl_tool_test_proxy.ts @@ -0,0 +1,948 @@ +/* + * 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 {onewayVoidVoidCallback} from "./i_zidl_tool_test"; +import {voidVoidCallback} from "./i_zidl_tool_test"; +import {booleanVoidCallback} from "./i_zidl_tool_test"; +import {byteVoidCallback} from "./i_zidl_tool_test"; +import {shortVoidCallback} from "./i_zidl_tool_test"; +import {intVoidCallback} from "./i_zidl_tool_test"; +import {longVoidCallback} from "./i_zidl_tool_test"; +import {floatVoidCallback} from "./i_zidl_tool_test"; +import {doubleVoidCallback} from "./i_zidl_tool_test"; +import {stringVoidCallback} from "./i_zidl_tool_test"; +import {sequenceableVoidCallback} from "./i_zidl_tool_test"; +import {interfaceVoidCallback} from "./i_zidl_tool_test"; +import {mapStringStringVoidCallback} from "./i_zidl_tool_test"; +import {doubleArrayVoidCallback} from "./i_zidl_tool_test"; +import {voidInMapStringIntCallback} from "./i_zidl_tool_test"; +import {voidInStringArrayCallback} from "./i_zidl_tool_test"; +import {voidOutMapStringIntCallback} from "./i_zidl_tool_test"; +import {voidOutStringArrayCallback} from "./i_zidl_tool_test"; +import {voidInOutMapStringIntCallback} from "./i_zidl_tool_test"; +import {voidInOutStringArrayCallback} from "./i_zidl_tool_test"; +import {voidInIntCallback} from "./i_zidl_tool_test"; +import {voidInStringCallback} from "./i_zidl_tool_test"; +import {voidOutIntCallback} from "./i_zidl_tool_test"; +import {voidOutStringCallback} from "./i_zidl_tool_test"; +import {voidInOutIntCallback} from "./i_zidl_tool_test"; +import {voidInOutStringCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeBooleanCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeByteCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeShortCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeIntCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeLongCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeFloatCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeDoubleCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeStringCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeSequenceableCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeInterfaceCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeMapStringStringCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeDoubleArrayCallback} from "./i_zidl_tool_test"; +import {voidOrderOutInCallback} from "./i_zidl_tool_test"; +import {voidOrderInOutInCallback} from "./i_zidl_tool_test"; +import {voidOrderOutInOutCallback} from "./i_zidl_tool_test"; +import {voidOrderInInOutOutCallback} from "./i_zidl_tool_test"; +import IZidlToolTest from "./i_zidl_tool_test"; +import rpc from "@ohos.rpc"; +import MySequenceable from "./my_sequenceable"; +import IInterfaceDeclare from "../interfaceDeclare/i_interface_declare"; +import InterfaceDeclareStub from "../interfaceDeclare/interface_declare_stub"; + +export default class ZidlToolTestProxy implements IZidlToolTest { + constructor(proxy) { + this.proxy = proxy; + } + + onewayVoidVoid(callback: onewayVoidVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_ASYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_ONEWAY_VOID_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidVoid(callback: voidVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + booleanVoid(callback: booleanVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_BOOLEAN_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _returnValue = undefined; + callback(_errCode, _returnValue); + return; + } + let _returnValue = result.reply.readInt() == 1 ? true : false; + callback(_errCode, _returnValue); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + byteVoid(callback: byteVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_BYTE_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _returnValue = undefined; + callback(_errCode, _returnValue); + return; + } + let _returnValue = result.reply.readInt(); + callback(_errCode, _returnValue); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + shortVoid(callback: shortVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_SHORT_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _returnValue = undefined; + callback(_errCode, _returnValue); + return; + } + let _returnValue = result.reply.readInt(); + callback(_errCode, _returnValue); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + intVoid(callback: intVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_INT_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _returnValue = undefined; + callback(_errCode, _returnValue); + return; + } + let _returnValue = result.reply.readInt(); + callback(_errCode, _returnValue); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + longVoid(callback: longVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_LONG_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _returnValue = undefined; + callback(_errCode, _returnValue); + return; + } + let _returnValue = result.reply.readLong(); + callback(_errCode, _returnValue); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + floatVoid(callback: floatVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_FLOAT_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _returnValue = undefined; + callback(_errCode, _returnValue); + return; + } + let _returnValue = result.reply.readFloat(); + callback(_errCode, _returnValue); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + doubleVoid(callback: doubleVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_DOUBLE_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _returnValue = undefined; + callback(_errCode, _returnValue); + return; + } + let _returnValue = result.reply.readDouble(); + callback(_errCode, _returnValue); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + stringVoid(callback: stringVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_STRING_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _returnValue = undefined; + callback(_errCode, _returnValue); + return; + } + let _returnValue = result.reply.readString(); + callback(_errCode, _returnValue); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + sequenceableVoid(callback: sequenceableVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_SEQUENCEABLE_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _returnValue = undefined; + callback(_errCode, _returnValue); + return; + } + let _returnValue = new MySequenceable(); + result.reply.readSequenceable(_returnValue); + callback(_errCode, _returnValue); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + interfaceVoid(callback: interfaceVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_INTERFACE_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _returnValue = undefined; + callback(_errCode, _returnValue); + return; + } + let _returnValue = result.reply.readRemoteObject(); + callback(_errCode, _returnValue); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + mapStringStringVoid(callback: mapStringStringVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_MAP_STRING_STRING_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _returnValue = undefined; + callback(_errCode, _returnValue); + return; + } + let _returnValue = new Map(); + let _returnValueSize = result.reply.readInt(); + for (let i = 0; i < _returnValueSize; ++i) { + let key = result.reply.readString(); + let value = result.reply.readString(); + _returnValue.set(key, value); + } + callback(_errCode, _returnValue); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + doubleArrayVoid(callback: doubleArrayVoidCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_DOUBLE_ARRAY_VOID, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _returnValue = undefined; + callback(_errCode, _returnValue); + return; + } + let _returnValue = result.reply.readDoubleArray(); + callback(_errCode, _returnValue); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidInMapStringInt(param: Map, callback: voidInMapStringIntCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(param.size); + for (let [key, value] of param) { + _data.writeString(key); + _data.writeInt(value); + } + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_IN_MAP_STRING_INT, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidInStringArray(param: string[], callback: voidInStringArrayCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeStringArray(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_IN_STRING_ARRAY, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidOutMapStringInt(callback: voidOutMapStringIntCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_OUT_MAP_STRING_INT, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _param = undefined; + callback(_errCode,_param); + return; + } + let _param = new Map(); + let _paramSize = result.reply.readInt(); + for (let i = 0; i < _paramSize; ++i) { + let key = result.reply.readString(); + let value = result.reply.readInt(); + _param.set(key, value); + } + callback(_errCode,_param); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidOutStringArray(callback: voidOutStringArrayCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_OUT_STRING_ARRAY, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _param = undefined; + callback(_errCode,_param); + return; + } + let _param = result.reply.readStringArray(); + callback(_errCode,_param); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidInOutMapStringInt(param: Map, callback: voidInOutMapStringIntCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(param.size); + for (let [key, value] of param) { + _data.writeString(key); + _data.writeInt(value); + } + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_IN_OUT_MAP_STRING_INT, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _param = undefined; + callback(_errCode,_param); + return; + } + let _param = new Map(); + let _paramSize = result.reply.readInt(); + for (let i = 0; i < _paramSize; ++i) { + let key = result.reply.readString(); + let value = result.reply.readInt(); + _param.set(key, value); + } + callback(_errCode,_param); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidInOutStringArray(param: string[], callback: voidInOutStringArrayCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeStringArray(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_IN_OUT_STRING_ARRAY, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _param = undefined; + callback(_errCode,_param); + return; + } + let _param = result.reply.readStringArray(); + callback(_errCode,_param); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidInInt(param: number, callback: voidInIntCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_IN_INT, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidInString(param: string, callback: voidInStringCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeString(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_IN_STRING, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidOutInt(callback: voidOutIntCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_OUT_INT, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _param = undefined; + callback(_errCode,_param); + return; + } + let _param = result.reply.readInt(); + callback(_errCode,_param); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidOutString(callback: voidOutStringCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_OUT_STRING, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _param = undefined; + callback(_errCode,_param); + return; + } + let _param = result.reply.readString(); + callback(_errCode,_param); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidInOutInt(param: number, callback: voidInOutIntCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_IN_OUT_INT, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _param = undefined; + callback(_errCode,_param); + return; + } + let _param = result.reply.readInt(); + callback(_errCode,_param); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidInOutString(param: string, callback: voidInOutStringCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeString(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_IN_OUT_STRING, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _param = undefined; + callback(_errCode,_param); + return; + } + let _param = result.reply.readString(); + callback(_errCode,_param); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidParameterTypeBoolean(param: boolean, callback: voidParameterTypeBooleanCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(param ? 1 : 0); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_PARAMETER_TYPE_BOOLEAN, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidParameterTypeByte(param: number, callback: voidParameterTypeByteCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_PARAMETER_TYPE_BYTE, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidParameterTypeShort(param: number, callback: voidParameterTypeShortCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_PARAMETER_TYPE_SHORT, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidParameterTypeInt(param: number, callback: voidParameterTypeIntCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_PARAMETER_TYPE_INT, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidParameterTypeLong(param: number, callback: voidParameterTypeLongCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeLong(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_PARAMETER_TYPE_LONG, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidParameterTypeFloat(param: number, callback: voidParameterTypeFloatCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeFloat(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_PARAMETER_TYPE_FLOAT, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidParameterTypeDouble(param: number, callback: voidParameterTypeDoubleCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeDouble(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_PARAMETER_TYPE_DOUBLE, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidParameterTypeString(param: string, callback: voidParameterTypeStringCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeString(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_PARAMETER_TYPE_STRING, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidParameterTypeSequenceable(param: MySequenceable, callback: voidParameterTypeSequenceableCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeSequenceable(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_PARAMETER_TYPE_SEQUENCEABLE, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidParameterTypeInterface(param: IInterfaceDeclare, callback: voidParameterTypeInterfaceCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeRemoteObject(param as InterfaceDeclareStub); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_PARAMETER_TYPE_INTERFACE, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidParameterTypeMapStringString(param: Map, callback: voidParameterTypeMapStringStringCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(param.size); + for (let [key, value] of param) { + _data.writeString(key); + _data.writeString(value); + } + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_PARAMETER_TYPE_MAP_STRING_STRING, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidParameterTypeDoubleArray(param: number[], callback: voidParameterTypeDoubleArrayCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeDoubleArray(param); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_PARAMETER_TYPE_DOUBLE_ARRAY, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidOrderOutIn(paramI: number, callback: voidOrderOutInCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(paramI); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_ORDER_OUT_IN, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _paramS = undefined; + callback(_errCode,_paramS); + return; + } + let _paramS = result.reply.readString(); + callback(_errCode,_paramS); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidOrderInOutIn(paramI: number, paramS: string, callback: voidOrderInOutInCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(paramI); + _data.writeString(paramS); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_ORDER_IN_OUT_IN, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _paramI = undefined; + callback(_errCode,_paramI); + return; + } + let _paramI = result.reply.readInt(); + callback(_errCode,_paramI); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidOrderOutInOut(paramS: string, callback: voidOrderOutInOutCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeString(paramS); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_ORDER_OUT_IN_OUT, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _paramI = undefined; + let _paramS = undefined; + callback(_errCode,_paramI, _paramS); + return; + } + let _paramI = result.reply.readInt(); + let _paramS = result.reply.readString(); + callback(_errCode,_paramI, _paramS); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidOrderInInOutOut(paramS: string, paramI: number, callback: voidOrderInInOutOutCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeString(paramS); + _data.writeInt(paramI); + this.proxy.sendRequest(ZidlToolTestProxy.COMMAND_VOID_ORDER_IN_IN_OUT_OUT, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + if (_errCode != 0) { + let _paramI = undefined; + let _paramS2 = undefined; + callback(_errCode,_paramI, _paramS2); + return; + } + let _paramI = result.reply.readInt(); + let _paramS2 = result.reply.readString(); + callback(_errCode,_paramI, _paramS2); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + static readonly COMMAND_ONEWAY_VOID_VOID = 1; + static readonly COMMAND_VOID_VOID = 2; + static readonly COMMAND_BOOLEAN_VOID = 3; + static readonly COMMAND_BYTE_VOID = 4; + static readonly COMMAND_SHORT_VOID = 5; + static readonly COMMAND_INT_VOID = 6; + static readonly COMMAND_LONG_VOID = 7; + static readonly COMMAND_FLOAT_VOID = 8; + static readonly COMMAND_DOUBLE_VOID = 9; + static readonly COMMAND_STRING_VOID = 10; + static readonly COMMAND_SEQUENCEABLE_VOID = 11; + static readonly COMMAND_INTERFACE_VOID = 12; + static readonly COMMAND_MAP_STRING_STRING_VOID = 13; + static readonly COMMAND_DOUBLE_ARRAY_VOID = 14; + static readonly COMMAND_VOID_IN_MAP_STRING_INT = 15; + static readonly COMMAND_VOID_IN_STRING_ARRAY = 16; + static readonly COMMAND_VOID_OUT_MAP_STRING_INT = 17; + static readonly COMMAND_VOID_OUT_STRING_ARRAY = 18; + static readonly COMMAND_VOID_IN_OUT_MAP_STRING_INT = 19; + static readonly COMMAND_VOID_IN_OUT_STRING_ARRAY = 20; + static readonly COMMAND_VOID_IN_INT = 21; + static readonly COMMAND_VOID_IN_STRING = 22; + static readonly COMMAND_VOID_OUT_INT = 23; + static readonly COMMAND_VOID_OUT_STRING = 24; + static readonly COMMAND_VOID_IN_OUT_INT = 25; + static readonly COMMAND_VOID_IN_OUT_STRING = 26; + static readonly COMMAND_VOID_PARAMETER_TYPE_BOOLEAN = 27; + static readonly COMMAND_VOID_PARAMETER_TYPE_BYTE = 28; + static readonly COMMAND_VOID_PARAMETER_TYPE_SHORT = 29; + static readonly COMMAND_VOID_PARAMETER_TYPE_INT = 30; + static readonly COMMAND_VOID_PARAMETER_TYPE_LONG = 31; + static readonly COMMAND_VOID_PARAMETER_TYPE_FLOAT = 32; + static readonly COMMAND_VOID_PARAMETER_TYPE_DOUBLE = 33; + static readonly COMMAND_VOID_PARAMETER_TYPE_STRING = 34; + static readonly COMMAND_VOID_PARAMETER_TYPE_SEQUENCEABLE = 35; + static readonly COMMAND_VOID_PARAMETER_TYPE_INTERFACE = 36; + static readonly COMMAND_VOID_PARAMETER_TYPE_MAP_STRING_STRING = 37; + static readonly COMMAND_VOID_PARAMETER_TYPE_DOUBLE_ARRAY = 38; + static readonly COMMAND_VOID_ORDER_OUT_IN = 39; + static readonly COMMAND_VOID_ORDER_IN_OUT_IN = 40; + static readonly COMMAND_VOID_ORDER_OUT_IN_OUT = 41; + static readonly COMMAND_VOID_ORDER_IN_IN_OUT_OUT = 42; + private proxy +} + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlToolOneWay/i_interface_attribute_declaratoin_oneway.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlToolOneWay/i_interface_attribute_declaratoin_oneway.ts new file mode 100755 index 0000000000000000000000000000000000000000..943d83dc857cd02cccbddfd143c4b3e504ebf825 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlToolOneWay/i_interface_attribute_declaratoin_oneway.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ + + +export default interface IInterfaceAttributeDeclaratoinOneway { + voidVoidFirst(callback: voidVoidFirstCallback): void; + voidVoidSecond(callback: voidVoidSecondCallback): void; + voidVoidThird(callback: voidVoidThirdCallback): void; +} +export type voidVoidFirstCallback = (errCode: number) => void; +export type voidVoidSecondCallback = (errCode: number) => void; +export type voidVoidThirdCallback = (errCode: number) => void; + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlToolOneWay/interface_attribute_declaratoin_oneway_proxy.ts b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlToolOneWay/interface_attribute_declaratoin_oneway_proxy.ts new file mode 100755 index 0000000000000000000000000000000000000000..b3f7e054918f4b007c75210222f4e3330b594b30 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/ets/zidlToolOneWay/interface_attribute_declaratoin_oneway_proxy.ts @@ -0,0 +1,77 @@ +/* + * 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 {voidVoidFirstCallback} from "./i_interface_attribute_declaratoin_oneway"; +import {voidVoidSecondCallback} from "./i_interface_attribute_declaratoin_oneway"; +import {voidVoidThirdCallback} from "./i_interface_attribute_declaratoin_oneway"; +import IInterfaceAttributeDeclaratoinOneway from "./i_interface_attribute_declaratoin_oneway"; +import rpc from "@ohos.rpc"; + +export default class InterfaceAttributeDeclaratoinOnewayProxy implements IInterfaceAttributeDeclaratoinOneway { + constructor(proxy) { + this.proxy = proxy; + } + + voidVoidFirst(callback: voidVoidFirstCallback): void + { + let _option = new rpc.MessageOption(1); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(InterfaceAttributeDeclaratoinOnewayProxy.COMMAND_VOID_VOID_FIRST, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidVoidSecond(callback: voidVoidSecondCallback): void + { + let _option = new rpc.MessageOption(1); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(InterfaceAttributeDeclaratoinOnewayProxy.COMMAND_VOID_VOID_SECOND, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + voidVoidThird(callback: voidVoidThirdCallback): void + { + let _option = new rpc.MessageOption(1); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + this.proxy.sendRequest(InterfaceAttributeDeclaratoinOnewayProxy.COMMAND_VOID_VOID_THIRD, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + static readonly COMMAND_VOID_VOID_FIRST = 1; + static readonly COMMAND_VOID_VOID_SECOND = 2; + static readonly COMMAND_VOID_VOID_THIRD = 3; + private proxy +} + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/module.json b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..831fb3d8118747dad4cfed307da30e4f1de0575a --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/module.json @@ -0,0 +1,100 @@ +{ + "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.zidlclienttest.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "launchType": "singleton", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "name": "com.example.zidlclienttest.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + }, + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.example.zidlclienttest.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/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/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/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/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/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/zidltest/actsamszidlclienttest/signature/openharmony_sx.p7b differ diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/AppScope/app.json b/aafwk/aafwk_standard/zidltest/actsamszidlservice/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..6fb3b00113b6a44a209002cc861e335dad5f197b --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.example.zidlservice", + "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/aafwk/aafwk_standard/zidltest/actsamszidlservice/AppScope/resources/base/element/string.json b/aafwk/aafwk_standard/zidltest/actsamszidlservice/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..0d3507c0d180557b94bc5f0071ba146b4909fe51 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ohosProject" + } + ] +} diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/AppScope/resources/base/media/app_icon.png b/aafwk/aafwk_standard/zidltest/actsamszidlservice/AppScope/resources/base/media/app_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/zidltest/actsamszidlservice/AppScope/resources/base/media/app_icon.png differ diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/BUILD.gn b/aafwk/aafwk_standard/zidltest/actsamszidlservice/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..cc8a1708e73a74539dacc88f92fbe69fe0954b72 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/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("ActsAmsZidlServiceRelyHap") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsamszidlservicerelyhap_js_assets", + ":actsamszidlservicerelyhap_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAmsZidlServiceRelyHap" +} + +ohos_app_scope("actsamszidlservicerelyhap_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsamszidlservicerelyhap_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsamszidlservicerelyhap_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsamszidlservicerelyhap_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/Test.json b/aafwk/aafwk_standard/zidltest/actsamszidlservice/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..3ec911dfc7b3a17504cd4577be5bbabaf7f97e63 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/Application/AbilityStage.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..159f48742031f407af4b1016035bf01e8e12a10a --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/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/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..7bbcfae1558870546b771fab5ab5ca1c4511a9d0 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/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("ACTS_ProcessManage VendorAppService MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("ACTS_ProcessManage VendorAppService MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("ACTS_ProcessManage VendorAppService MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("ACTS_ProcessManage VendorAppService MainAbility onWindowStageDestroy") + } + + async onForeground() { + // Ability has brought to foreground + console.log("ACTS_ProcessManage VendorAppService MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("ACTS_ProcessManage VendorAppService MainAbility onBackground") + } +}; diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..19dbaec3be48cecc39e3f115abd3f1f5baa88018 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,433 @@ +/* +* 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 {voidOutStringCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidOutIntCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidOutMapStringIntCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidOutStringArrayCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidInOutMapStringIntCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidInOutStringArrayCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidInOutIntCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidInOutStringCallback} from "./zidlTool/i_zidl_tool_test"; +import {booleanVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {byteVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {shortVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {intVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {longVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {floatVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {doubleVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {stringVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {sequenceableVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {interfaceVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {mapStringStringVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {doubleArrayVoidCallback} from "./zidlTool/i_zidl_tool_test"; +import {voidOrderOutInCallback} from "./zidlTool/i_zidl_tool_test" +import {voidOrderInOutInCallback} from "./zidlTool/i_zidl_tool_test" +import {voidOrderOutInOutCallback} from "./zidlTool/i_zidl_tool_test" +import {voidOrderInInOutOutCallback} from "./zidlTool/i_zidl_tool_test" +import {onewayVoidVoidCallback} from "./zidlTool/i_zidl_tool_test" +import {voidInMapStringIntCallback} from "./zidlTool/i_zidl_tool_test" +import {voidVoidCallback} from "./zidlTool/i_zidl_tool_test" +import {voidInStringArrayCallback} from "./zidlTool/i_zidl_tool_test" +import ZidlTestServiceStub from './zidlTool/zidl_tool_test_stub'; +import MySequenceable from "./zidlTool/my_sequenceable"; +import InterfaceDeclareProxy from './interfaceDeclare/interface_declare_proxy' +import InterfaceDeclareStub from './interfaceDeclare/interface_declare_stub' +import {voidInIntCallback} from "./zidlTool/i_zidl_tool_test" +import {voidInStringCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeBooleanCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeByteCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeShortCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeIntCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeLongCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeFloatCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeDoubleCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeStringCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeSequenceableCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeInterfaceCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeMapStringStringCallback} from "./zidlTool/i_zidl_tool_test" +import {voidParameterTypeDoubleArrayCallback} from "./zidlTool/i_zidl_tool_test" +import {testInterfaceCallback} from './interfaceDeclare/i_interface_declare' + +var SUCCESS = 0; +var FAIL = 1; + +class ZidlTestImp extends ZidlTestServiceStub { + + onewayVoidVoid(callback: onewayVoidVoidCallback) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_0200 called"); + callback(SUCCESS); + } + + voidVoid(callback: voidVoidCallback) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_0300 called"); + callback(SUCCESS); + } + + booleanVoid(callback: booleanVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_0400 called"); + var boolean = true; + callback(SUCCESS, boolean); + } + + byteVoid(callback: byteVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_0500 called"); + var mybyte = 1; + callback(SUCCESS, mybyte); + } + + shortVoid(callback: shortVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_0600 called"); + var myshort = 222; + callback(SUCCESS, myshort); + } + + intVoid(callback: intVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_0700 called"); + var myint = 333; + callback(SUCCESS, myint); + } + + longVoid(callback: longVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_0800 called"); + var mylong = 4444; + callback(SUCCESS, mylong); + } + + floatVoid(callback: floatVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_0900 called"); + var myfloat = 10.1; + callback(SUCCESS, myfloat); + } + + doubleVoid(callback: doubleVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_1000 called"); + var mydouble = 22.1; + callback(SUCCESS, mydouble); + } + + stringVoid(callback: stringVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_1100 called"); + var mystring = "stringVoid"; + callback(SUCCESS, mystring); + } + + sequenceableVoid(callback: sequenceableVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_1200 called"); + let mySequence = new MySequenceable(); + callback(SUCCESS, mySequence); + } + + interfaceVoid(callback: interfaceVoidCallback) { + class InterfaceDeclare extends InterfaceDeclareStub { + testInterface(data: number, callback: testInterfaceCallback): void{ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_1300 interfaceStub called"); + let result = FAIL; + + if (data == 1500) { + result = SUCCESS; + } + callback(result); + } + } + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_1300 toolStub called"); + let serverInterface = new InterfaceDeclare('serverInterface'); + callback(SUCCESS, serverInterface); + } + + mapStringStringVoid(callback: mapStringStringVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_1400 called"); + let myMap = new Map(); + myMap.set("string1","string2"); + callback(SUCCESS, myMap); + } + + doubleArrayVoid(callback: doubleArrayVoidCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_1500 called"); + var array = [1.1, 2.1, 3.1]; + callback(SUCCESS, array); + } + + voidInMapStringInt(myMap, callback: voidInMapStringIntCallback){ + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_1600_1 called:'+ myMap.get("string1")); + if(myMap.get("string1") == 1){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidInStringArray(strarray, callback: voidInStringArrayCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_1600_2 called:"+ JSON.stringify(strarray)); + if(strarray[0] == "aaa"&&strarray[1] == "bbb"&&strarray[2] == "ccc"){ + callback(SUCCESS); + }else { + callback(FAIL); + } + } + + voidOutMapStringInt(callback : voidOutMapStringIntCallback){ + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_1700 called'); + var map=new Map(); + map.set("voidOutMapStringInt", 1); + callback(SUCCESS, map); + } + + voidOutStringArray(callback :voidOutStringArrayCallback){ + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_1700 called'); + var strarray = ["aa", "dd"]; + callback(SUCCESS, strarray); + } + + voidInOutMapStringInt(mapIn, callback: voidInOutMapStringIntCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_1800 called'); + var errCode = FAIL; + if ((mapIn.get("voidInOutMapStringInt1") == 1801) && + (mapIn.get("voidInOutMapStringInt2") == 1802)) { + mapIn.set("voidInOutMapStringInt1", 1802); + mapIn.set("voidInOutMapStringInt2", 1801); + errCode = SUCCESS; + } + callback(errCode, mapIn); + } + + voidInOutStringArray(strArrayIn, callback: voidInOutStringArrayCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_1800 called'); + var errCode = FAIL; + if ((strArrayIn[0] == "ddd") && + (strArrayIn[1] == "ccc")) { + strArrayIn[0] = "aaa"; + strArrayIn[1] = "bbb"; + errCode = SUCCESS; + } + callback(errCode, strArrayIn); + } + + voidInInt(number, callback : voidInIntCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_1900 called:'+ JSON.stringify(number)); + if(number == 8888){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidInString(string, callback : voidInStringCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_1900 called:'+ JSON.stringify(string)); + if(string == "voidInString"){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidOutInt(callback : voidOutIntCallback){ + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2000 called'); + var number = 123; + callback(SUCCESS, number); + } + + voidOutString(callback : voidOutStringCallback){ + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2000 called'); + var string = "voidOutString"; + callback(SUCCESS, string); + } + + voidInOutInt(number, callback: voidInOutIntCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2100_1 called:'+ JSON.stringify(number)); + var num = 456789; + if(number == 123456){ + callback(SUCCESS, num); + }else{ + callback(FAIL, number); + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2100_1 Call_Fail') + } + } + voidInOutString(strinput, callback: voidInOutStringCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2100_2 called:'+ JSON.stringify(strinput)); + var str = "456789"; + if(strinput == "voidInOutString"){ + callback(SUCCESS, str); + }else{ + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2100_2 Call_Fail'); + callback(FAIL, strinput); + } + } + + voidParameterTypeBoolean(oBooleanTrue, callback : voidParameterTypeBooleanCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2200 called:'+ JSON.stringify(oBooleanTrue)); + if(oBooleanTrue == true){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeByte(number, callback : voidParameterTypeByteCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2300 called:'+ JSON.stringify(number)); + if(number == 1111){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeShort(number, callback : voidParameterTypeShortCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2400 called:'+ JSON.stringify(number)); + if(number == 2222){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeInt(number, callback : voidParameterTypeIntCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2500 called:'+ JSON.stringify(number)); + if(number == 3333){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeLong(number, callback : voidParameterTypeLongCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2600 called:'+ JSON.stringify(number)); + if(number == 4444){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeFloat(number, callback : voidParameterTypeFloatCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2700 called:'+ JSON.stringify(number)); + if(number == 5555.1){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeDouble(number, callback : voidParameterTypeDoubleCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2800 called:'+ JSON.stringify(number)); + if(number == 6666.1){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeString(string, callback : voidParameterTypeStringCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_2900 called:'+ JSON.stringify(string)); + if(string == "voidParameterTypeString"){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeSequenceable(MySequenceable, callback : voidParameterTypeSequenceableCallback) { + console.log('ZidlTest Process Server ACTS_Zidl_Js2JsMulti_3000 called:'+ JSON.stringify(MySequenceable)); + if((MySequenceable != null) && (MySequenceable.getNum() == 32) && (MySequenceable.getString() == "nihao")){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeInterface(param: InterfaceDeclareProxy, callback : voidParameterTypeInterfaceCallback) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_3100 called"); + let proxy = new InterfaceDeclareProxy(param); + proxy.testInterface(3300, (errCode)=>{ + if (errCode == SUCCESS) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_3100 callback SUCCESS"); + callback(SUCCESS); + } else { + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_3100 callback FAIL"); + callback(FAIL); + } + }); + + } + + voidParameterTypeMapStringString(map, callback : voidParameterTypeMapStringStringCallback) { + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_3200 called:'+ map.get("voidParameterTypeMapStringString")); + if(map.get("voidParameterTypeMapStringString") == "fdhatdh"){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidParameterTypeDoubleArray(array, callback : voidParameterTypeDoubleArrayCallback){ + console.log('ZidlTest Server ACTS_Zidl_Js2JsMulti_3300 called:'+ JSON.stringify(array)); + if(array.length == 2 && array[0] == 1.1 && array[1] == 2.1){ + callback(SUCCESS); + }else{ + callback(FAIL); + } + } + + voidOrderOutIn(paramI, callback: voidOrderOutInCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_3400 called" + paramI); + var mystring = "hello world"; + callback(SUCCESS, mystring); + } + + voidOrderInOutIn(paramI, paramS, callback: voidOrderInOutInCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_3500 called" + paramI + " " + paramS); + var mynumber = 6; + callback(SUCCESS, mynumber); + } + + voidOrderOutInOut(paramS, callback: voidOrderOutInOutCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_3600 called" + paramS); + var mynumber = 3; + var mystring = "paramcallback"; + callback(SUCCESS, mynumber, mystring); + } + + voidOrderInInOutOut(paramS, paramI, callback: voidOrderInInOutOutCallback){ + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_3700 called" + paramS + " " + paramI); + var mystring = "callback"; + var mynumber = 4; + callback(SUCCESS, mynumber, mystring); + } +} + +export default class ServiceAbility extends ServiceExtension { + onCreate(want,startId) { + globalThis.abilityWant = want; + console.log('ZidlService ServiceAbility onCreate, want: ' + want.abilityName); + } + + onRequest(want, startId) { + console.log('ZidlService ServiceAbility onRequest, want: ' + want.abilityName + + ', startId: ' + startId); + } + + onConnect(want) { + console.log('ZidlService ServiceAbility onConnect, want:' + want.abilityName); + return new ZidlTestImp('connect'); + } + + onDisconnect(want) { + console.log('ZidlService ServiceAbility onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('AZidlService ServiceAbility onDestroy'); + } +}; diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/interfaceDeclare/i_interface_declare.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/interfaceDeclare/i_interface_declare.ts new file mode 100755 index 0000000000000000000000000000000000000000..9c6b544fcf622de7f85f5301f307857f855f2ec6 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/interfaceDeclare/i_interface_declare.ts @@ -0,0 +1,21 @@ +/* + * 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. + */ + + +export default interface IInterfaceDeclare { + testInterface(data: number, callback: testInterfaceCallback): void; +} +export type testInterfaceCallback = (errCode: number) => void; + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/interfaceDeclare/interface_declare_proxy.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/interfaceDeclare/interface_declare_proxy.ts new file mode 100755 index 0000000000000000000000000000000000000000..fadb691def524f2745a670d6c4c9cfbb4fffd475 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/interfaceDeclare/interface_declare_proxy.ts @@ -0,0 +1,44 @@ +/* + * 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 {testInterfaceCallback} from "./i_interface_declare"; +import IInterfaceDeclare from "./i_interface_declare"; +import rpc from "@ohos.rpc"; + +export default class InterfaceDeclareProxy implements IInterfaceDeclare { + constructor(proxy) { + this.proxy = proxy; + } + + testInterface(data: number, callback: testInterfaceCallback): void + { + let _option = new rpc.MessageOption(rpc.MessageOption.TF_SYNC); + let _data = new rpc.MessageParcel(); + let _reply = new rpc.MessageParcel(); + _data.writeInt(data); + this.proxy.sendRequest(InterfaceDeclareProxy.COMMAND_TEST_INTERFACE, _data, _reply, _option).then(function(result) { + if (result.errCode === 0) { + let _errCode = result.reply.readInt(); + callback(_errCode); + } else { + console.log("sendRequest failed, errCode: " + result.errCode); + } + }) + } + + static readonly COMMAND_TEST_INTERFACE = 1; + private proxy +} + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/interfaceDeclare/interface_declare_stub.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/interfaceDeclare/interface_declare_stub.ts new file mode 100755 index 0000000000000000000000000000000000000000..fa6208b1f94fc17dd376c3495e9ceea3c317ee0b --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/interfaceDeclare/interface_declare_stub.ts @@ -0,0 +1,47 @@ +/* + * 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 {testInterfaceCallback} from "./i_interface_declare"; +import IInterfaceDeclare from "./i_interface_declare"; +import rpc from "@ohos.rpc"; + +export default class InterfaceDeclareStub extends rpc.RemoteObject implements IInterfaceDeclare { + constructor(des: string) { + super(des); + } + + onRemoteRequest(code: number, data, reply, option): boolean { + console.log("onRemoteRequest called, code = " + code); + switch(code) { + case InterfaceDeclareStub.COMMAND_TEST_INTERFACE: { + let _data = data.readInt(); + this.testInterface(_data, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + default: { + console.log("invalid request code" + code); + break; + } + } + return false; + } + + testInterface(data: number, callback: testInterfaceCallback): void{} + + static readonly COMMAND_TEST_INTERFACE = 1; +} + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..b49731a414958a281c2f0c4eab0e7fb408eb2c2f --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/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/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/zidlTool/i_zidl_tool_test.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/zidlTool/i_zidl_tool_test.ts new file mode 100755 index 0000000000000000000000000000000000000000..ac9da635209b8b8a170f587485ab01a1e9844fcb --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/zidlTool/i_zidl_tool_test.ts @@ -0,0 +1,105 @@ +/* + * 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 MySequenceable from "./my_sequenceable"; +import IInterfaceDeclare from "../interfaceDeclare/i_interface_declare"; + +export default interface IZidlToolTest { + onewayVoidVoid(callback: onewayVoidVoidCallback): void; + voidVoid(callback: voidVoidCallback): void; + booleanVoid(callback: booleanVoidCallback): void; + byteVoid(callback: byteVoidCallback): void; + shortVoid(callback: shortVoidCallback): void; + intVoid(callback: intVoidCallback): void; + longVoid(callback: longVoidCallback): void; + floatVoid(callback: floatVoidCallback): void; + doubleVoid(callback: doubleVoidCallback): void; + stringVoid(callback: stringVoidCallback): void; + sequenceableVoid(callback: sequenceableVoidCallback): void; + interfaceVoid(callback: interfaceVoidCallback): void; + mapStringStringVoid(callback: mapStringStringVoidCallback): void; + doubleArrayVoid(callback: doubleArrayVoidCallback): void; + voidInMapStringInt(param: Map, callback: voidInMapStringIntCallback): void; + voidInStringArray(param: string[], callback: voidInStringArrayCallback): void; + voidOutMapStringInt(callback: voidOutMapStringIntCallback): void; + voidOutStringArray(callback: voidOutStringArrayCallback): void; + voidInOutMapStringInt(param: Map, callback: voidInOutMapStringIntCallback): void; + voidInOutStringArray(param: string[], callback: voidInOutStringArrayCallback): void; + voidInInt(param: number, callback: voidInIntCallback): void; + voidInString(param: string, callback: voidInStringCallback): void; + voidOutInt(callback: voidOutIntCallback): void; + voidOutString(callback: voidOutStringCallback): void; + voidInOutInt(param: number, callback: voidInOutIntCallback): void; + voidInOutString(param: string, callback: voidInOutStringCallback): void; + voidParameterTypeBoolean(param: boolean, callback: voidParameterTypeBooleanCallback): void; + voidParameterTypeByte(param: number, callback: voidParameterTypeByteCallback): void; + voidParameterTypeShort(param: number, callback: voidParameterTypeShortCallback): void; + voidParameterTypeInt(param: number, callback: voidParameterTypeIntCallback): void; + voidParameterTypeLong(param: number, callback: voidParameterTypeLongCallback): void; + voidParameterTypeFloat(param: number, callback: voidParameterTypeFloatCallback): void; + voidParameterTypeDouble(param: number, callback: voidParameterTypeDoubleCallback): void; + voidParameterTypeString(param: string, callback: voidParameterTypeStringCallback): void; + voidParameterTypeSequenceable(param: MySequenceable, callback: voidParameterTypeSequenceableCallback): void; + voidParameterTypeInterface(param: IInterfaceDeclare, callback: voidParameterTypeInterfaceCallback): void; + voidParameterTypeMapStringString(param: Map, callback: voidParameterTypeMapStringStringCallback): void; + voidParameterTypeDoubleArray(param: number[], callback: voidParameterTypeDoubleArrayCallback): void; + voidOrderOutIn(paramI: number, callback: voidOrderOutInCallback): void; + voidOrderInOutIn(paramI: number, paramS: string, callback: voidOrderInOutInCallback): void; + voidOrderOutInOut(paramS: string, callback: voidOrderOutInOutCallback): void; + voidOrderInInOutOut(paramS: string, paramI: number, callback: voidOrderInInOutOutCallback): void; +} +export type onewayVoidVoidCallback = (errCode: number) => void; +export type voidVoidCallback = (errCode: number) => void; +export type booleanVoidCallback = (errCode: number, returnValue: boolean) => void; +export type byteVoidCallback = (errCode: number, returnValue: number) => void; +export type shortVoidCallback = (errCode: number, returnValue: number) => void; +export type intVoidCallback = (errCode: number, returnValue: number) => void; +export type longVoidCallback = (errCode: number, returnValue: number) => void; +export type floatVoidCallback = (errCode: number, returnValue: number) => void; +export type doubleVoidCallback = (errCode: number, returnValue: number) => void; +export type stringVoidCallback = (errCode: number, returnValue: string) => void; +export type sequenceableVoidCallback = (errCode: number, returnValue: MySequenceable) => void; +export type interfaceVoidCallback = (errCode: number, returnValue: IInterfaceDeclare) => void; +export type mapStringStringVoidCallback = (errCode: number, returnValue: Map) => void; +export type doubleArrayVoidCallback = (errCode: number, returnValue: number[]) => void; +export type voidInMapStringIntCallback = (errCode: number) => void; +export type voidInStringArrayCallback = (errCode: number) => void; +export type voidOutMapStringIntCallback = (errCode: number, param: Map) => void; +export type voidOutStringArrayCallback = (errCode: number, param: string[]) => void; +export type voidInOutMapStringIntCallback = (errCode: number, param: Map) => void; +export type voidInOutStringArrayCallback = (errCode: number, param: string[]) => void; +export type voidInIntCallback = (errCode: number) => void; +export type voidInStringCallback = (errCode: number) => void; +export type voidOutIntCallback = (errCode: number, param: number) => void; +export type voidOutStringCallback = (errCode: number, param: string) => void; +export type voidInOutIntCallback = (errCode: number, param: number) => void; +export type voidInOutStringCallback = (errCode: number, param: string) => void; +export type voidParameterTypeBooleanCallback = (errCode: number) => void; +export type voidParameterTypeByteCallback = (errCode: number) => void; +export type voidParameterTypeShortCallback = (errCode: number) => void; +export type voidParameterTypeIntCallback = (errCode: number) => void; +export type voidParameterTypeLongCallback = (errCode: number) => void; +export type voidParameterTypeFloatCallback = (errCode: number) => void; +export type voidParameterTypeDoubleCallback = (errCode: number) => void; +export type voidParameterTypeStringCallback = (errCode: number) => void; +export type voidParameterTypeSequenceableCallback = (errCode: number) => void; +export type voidParameterTypeInterfaceCallback = (errCode: number) => void; +export type voidParameterTypeMapStringStringCallback = (errCode: number) => void; +export type voidParameterTypeDoubleArrayCallback = (errCode: number) => void; +export type voidOrderOutInCallback = (errCode: number, paramS: string) => void; +export type voidOrderInOutInCallback = (errCode: number, paramI: number) => void; +export type voidOrderOutInOutCallback = (errCode: number, paramI: number, paramS: string) => void; +export type voidOrderInInOutOutCallback = (errCode: number, paramI: number, paramS2: string) => void; + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/zidlTool/my_sequenceable.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/zidlTool/my_sequenceable.ts new file mode 100755 index 0000000000000000000000000000000000000000..0030fa8fefb9f88efbb1cbefa804919da4499cc2 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/zidlTool/my_sequenceable.ts @@ -0,0 +1,28 @@ +export default class MySequenceable { + constructor() { + this.num = 14; + this.str = "hello"; + } + getNum() : number { + return this.num; + } + + getString() : string { + return this.str; + } + + marshalling(messageParcel) { + console.info('marshalling++++'); + messageParcel.writeInt(this.num); + messageParcel.writeString(this.str); + return true; + } + unmarshalling(messageParcel) { + console.info('unmarshalling++++'); + this.num = messageParcel.readInt(); + this.str = messageParcel.readString(); + return true; + } + private num; + private str; +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/zidlTool/zidl_tool_test_stub.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/zidlTool/zidl_tool_test_stub.ts new file mode 100755 index 0000000000000000000000000000000000000000..466bc3d6040a0b3c01ca401b05d96dc1a55cacb9 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility/zidlTool/zidl_tool_test_stub.ts @@ -0,0 +1,549 @@ +/* + * 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 {onewayVoidVoidCallback} from "./i_zidl_tool_test"; +import {voidVoidCallback} from "./i_zidl_tool_test"; +import {booleanVoidCallback} from "./i_zidl_tool_test"; +import {byteVoidCallback} from "./i_zidl_tool_test"; +import {shortVoidCallback} from "./i_zidl_tool_test"; +import {intVoidCallback} from "./i_zidl_tool_test"; +import {longVoidCallback} from "./i_zidl_tool_test"; +import {floatVoidCallback} from "./i_zidl_tool_test"; +import {doubleVoidCallback} from "./i_zidl_tool_test"; +import {stringVoidCallback} from "./i_zidl_tool_test"; +import {sequenceableVoidCallback} from "./i_zidl_tool_test"; +import {interfaceVoidCallback} from "./i_zidl_tool_test"; +import {mapStringStringVoidCallback} from "./i_zidl_tool_test"; +import {doubleArrayVoidCallback} from "./i_zidl_tool_test"; +import {voidInMapStringIntCallback} from "./i_zidl_tool_test"; +import {voidInStringArrayCallback} from "./i_zidl_tool_test"; +import {voidOutMapStringIntCallback} from "./i_zidl_tool_test"; +import {voidOutStringArrayCallback} from "./i_zidl_tool_test"; +import {voidInOutMapStringIntCallback} from "./i_zidl_tool_test"; +import {voidInOutStringArrayCallback} from "./i_zidl_tool_test"; +import {voidInIntCallback} from "./i_zidl_tool_test"; +import {voidInStringCallback} from "./i_zidl_tool_test"; +import {voidOutIntCallback} from "./i_zidl_tool_test"; +import {voidOutStringCallback} from "./i_zidl_tool_test"; +import {voidInOutIntCallback} from "./i_zidl_tool_test"; +import {voidInOutStringCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeBooleanCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeByteCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeShortCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeIntCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeLongCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeFloatCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeDoubleCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeStringCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeSequenceableCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeInterfaceCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeMapStringStringCallback} from "./i_zidl_tool_test"; +import {voidParameterTypeDoubleArrayCallback} from "./i_zidl_tool_test"; +import {voidOrderOutInCallback} from "./i_zidl_tool_test"; +import {voidOrderInOutInCallback} from "./i_zidl_tool_test"; +import {voidOrderOutInOutCallback} from "./i_zidl_tool_test"; +import {voidOrderInInOutOutCallback} from "./i_zidl_tool_test"; +import IZidlToolTest from "./i_zidl_tool_test"; +import rpc from "@ohos.rpc"; +import MySequenceable from "./my_sequenceable"; +import IInterfaceDeclare from "../interfaceDeclare/i_interface_declare"; +import InterfaceDeclareStub from "../interfaceDeclare/interface_declare_stub"; + +export default class ZidlToolTestStub extends rpc.RemoteObject implements IZidlToolTest { + constructor(des: string) { + super(des); + } + + onRemoteRequest(code: number, data, reply, option): boolean { + console.log("onRemoteRequest called, code = " + code); + switch(code) { + case ZidlToolTestStub.COMMAND_ONEWAY_VOID_VOID: { + this.onewayVoidVoid((errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_VOID: { + this.voidVoid((errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_BOOLEAN_VOID: { + this.booleanVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(returnValue ? 1 : 0); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_BYTE_VOID: { + this.byteVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_SHORT_VOID: { + this.shortVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_INT_VOID: { + this.intVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_LONG_VOID: { + this.longVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeLong(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_FLOAT_VOID: { + this.floatVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeFloat(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_DOUBLE_VOID: { + this.doubleVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeDouble(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_STRING_VOID: { + this.stringVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeString(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_SEQUENCEABLE_VOID: { + this.sequenceableVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeSequenceable(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_INTERFACE_VOID: { + this.interfaceVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeRemoteObject(returnValue as InterfaceDeclareStub); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_MAP_STRING_STRING_VOID: { + this.mapStringStringVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(returnValue.size); + for (let [key, value] of returnValue) { + reply.writeString(key); + reply.writeString(value); + } + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_DOUBLE_ARRAY_VOID: { + this.doubleArrayVoid((errCode, returnValue) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeDoubleArray(returnValue); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_MAP_STRING_INT: { + let _param = new Map(); + let _paramSize = data.readInt(); + for (let i = 0; i < _paramSize; ++i) { + let key = data.readString(); + let value = data.readInt(); + _param.set(key, value); + } + this.voidInMapStringInt(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_STRING_ARRAY: { + let _param = data.readStringArray(); + this.voidInStringArray(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_OUT_MAP_STRING_INT: { + this.voidOutMapStringInt((errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(param.size); + for (let [key, value] of param) { + reply.writeString(key); + reply.writeInt(value); + } + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_OUT_STRING_ARRAY: { + this.voidOutStringArray((errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeStringArray(param); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_OUT_MAP_STRING_INT: { + let _param = new Map(); + let _paramSize = data.readInt(); + for (let i = 0; i < _paramSize; ++i) { + let key = data.readString(); + let value = data.readInt(); + _param.set(key, value); + } + this.voidInOutMapStringInt(_param, (errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(param.size); + for (let [key, value] of param) { + reply.writeString(key); + reply.writeInt(value); + } + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_OUT_STRING_ARRAY: { + let _param = data.readStringArray(); + this.voidInOutStringArray(_param, (errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeStringArray(param); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_INT: { + let _param = data.readInt(); + this.voidInInt(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_STRING: { + let _param = data.readString(); + this.voidInString(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_OUT_INT: { + this.voidOutInt((errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(param); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_OUT_STRING: { + this.voidOutString((errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeString(param); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_OUT_INT: { + let _param = data.readInt(); + this.voidInOutInt(_param, (errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(param); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_IN_OUT_STRING: { + let _param = data.readString(); + this.voidInOutString(_param, (errCode, param) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeString(param); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_BOOLEAN: { + let _param = data.readInt() == 1 ? true : false; + this.voidParameterTypeBoolean(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_BYTE: { + let _param = data.readInt(); + this.voidParameterTypeByte(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_SHORT: { + let _param = data.readInt(); + this.voidParameterTypeShort(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_INT: { + let _param = data.readInt(); + this.voidParameterTypeInt(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_LONG: { + let _param = data.readLong(); + this.voidParameterTypeLong(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_FLOAT: { + let _param = data.readFloat(); + this.voidParameterTypeFloat(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_DOUBLE: { + let _param = data.readDouble(); + this.voidParameterTypeDouble(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_STRING: { + let _param = data.readString(); + this.voidParameterTypeString(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_SEQUENCEABLE: { + let _param = new MySequenceable(); + data.readSequenceable(_param); + this.voidParameterTypeSequenceable(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_INTERFACE: { + let _param = data.readRemoteObject(); + this.voidParameterTypeInterface(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_MAP_STRING_STRING: { + let _param = new Map(); + let _paramSize = data.readInt(); + for (let i = 0; i < _paramSize; ++i) { + let key = data.readString(); + let value = data.readString(); + _param.set(key, value); + } + this.voidParameterTypeMapStringString(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_PARAMETER_TYPE_DOUBLE_ARRAY: { + let _param = data.readDoubleArray(); + this.voidParameterTypeDoubleArray(_param, (errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_ORDER_OUT_IN: { + let _paramI = data.readInt(); + this.voidOrderOutIn(_paramI, (errCode, paramS) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeString(paramS); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_ORDER_IN_OUT_IN: { + let _paramI = data.readInt(); + let _paramS = data.readString(); + this.voidOrderInOutIn(_paramI, _paramS, (errCode, paramI) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(paramI); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_ORDER_OUT_IN_OUT: { + let _paramS = data.readString(); + this.voidOrderOutInOut(_paramS, (errCode, paramI, paramS) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(paramI); + reply.writeString(paramS); + } + }); + return true; + } + case ZidlToolTestStub.COMMAND_VOID_ORDER_IN_IN_OUT_OUT: { + let _paramS = data.readString(); + let _paramI = data.readInt(); + this.voidOrderInInOutOut(_paramS, _paramI, (errCode, paramI, paramS2) => { + reply.writeInt(errCode); + if (errCode == 0) { + reply.writeInt(paramI); + reply.writeString(paramS2); + } + }); + return true; + } + default: { + console.log("invalid request code" + code); + break; + } + } + return false; + } + + onewayVoidVoid(callback: onewayVoidVoidCallback): void{} + voidVoid(callback: voidVoidCallback): void{} + booleanVoid(callback: booleanVoidCallback): void{} + byteVoid(callback: byteVoidCallback): void{} + shortVoid(callback: shortVoidCallback): void{} + intVoid(callback: intVoidCallback): void{} + longVoid(callback: longVoidCallback): void{} + floatVoid(callback: floatVoidCallback): void{} + doubleVoid(callback: doubleVoidCallback): void{} + stringVoid(callback: stringVoidCallback): void{} + sequenceableVoid(callback: sequenceableVoidCallback): void{} + interfaceVoid(callback: interfaceVoidCallback): void{} + mapStringStringVoid(callback: mapStringStringVoidCallback): void{} + doubleArrayVoid(callback: doubleArrayVoidCallback): void{} + voidInMapStringInt(param: Map, callback: voidInMapStringIntCallback): void{} + voidInStringArray(param: string[], callback: voidInStringArrayCallback): void{} + voidOutMapStringInt(callback: voidOutMapStringIntCallback): void{} + voidOutStringArray(callback: voidOutStringArrayCallback): void{} + voidInOutMapStringInt(param: Map, callback: voidInOutMapStringIntCallback): void{} + voidInOutStringArray(param: string[], callback: voidInOutStringArrayCallback): void{} + voidInInt(param: number, callback: voidInIntCallback): void{} + voidInString(param: string, callback: voidInStringCallback): void{} + voidOutInt(callback: voidOutIntCallback): void{} + voidOutString(callback: voidOutStringCallback): void{} + voidInOutInt(param: number, callback: voidInOutIntCallback): void{} + voidInOutString(param: string, callback: voidInOutStringCallback): void{} + voidParameterTypeBoolean(param: boolean, callback: voidParameterTypeBooleanCallback): void{} + voidParameterTypeByte(param: number, callback: voidParameterTypeByteCallback): void{} + voidParameterTypeShort(param: number, callback: voidParameterTypeShortCallback): void{} + voidParameterTypeInt(param: number, callback: voidParameterTypeIntCallback): void{} + voidParameterTypeLong(param: number, callback: voidParameterTypeLongCallback): void{} + voidParameterTypeFloat(param: number, callback: voidParameterTypeFloatCallback): void{} + voidParameterTypeDouble(param: number, callback: voidParameterTypeDoubleCallback): void{} + voidParameterTypeString(param: string, callback: voidParameterTypeStringCallback): void{} + voidParameterTypeSequenceable(param: MySequenceable, callback: voidParameterTypeSequenceableCallback): void{} + voidParameterTypeInterface(param: IInterfaceDeclare, callback: voidParameterTypeInterfaceCallback): void{} + voidParameterTypeMapStringString(param: Map, callback: voidParameterTypeMapStringStringCallback): void{} + voidParameterTypeDoubleArray(param: number[], callback: voidParameterTypeDoubleArrayCallback): void{} + voidOrderOutIn(paramI: number, callback: voidOrderOutInCallback): void{} + voidOrderInOutIn(paramI: number, paramS: string, callback: voidOrderInOutInCallback): void{} + voidOrderOutInOut(paramS: string, callback: voidOrderOutInOutCallback): void{} + voidOrderInInOutOut(paramS: string, paramI: number, callback: voidOrderInInOutOutCallback): void{} + + static readonly COMMAND_ONEWAY_VOID_VOID = 1; + static readonly COMMAND_VOID_VOID = 2; + static readonly COMMAND_BOOLEAN_VOID = 3; + static readonly COMMAND_BYTE_VOID = 4; + static readonly COMMAND_SHORT_VOID = 5; + static readonly COMMAND_INT_VOID = 6; + static readonly COMMAND_LONG_VOID = 7; + static readonly COMMAND_FLOAT_VOID = 8; + static readonly COMMAND_DOUBLE_VOID = 9; + static readonly COMMAND_STRING_VOID = 10; + static readonly COMMAND_SEQUENCEABLE_VOID = 11; + static readonly COMMAND_INTERFACE_VOID = 12; + static readonly COMMAND_MAP_STRING_STRING_VOID = 13; + static readonly COMMAND_DOUBLE_ARRAY_VOID = 14; + static readonly COMMAND_VOID_IN_MAP_STRING_INT = 15; + static readonly COMMAND_VOID_IN_STRING_ARRAY = 16; + static readonly COMMAND_VOID_OUT_MAP_STRING_INT = 17; + static readonly COMMAND_VOID_OUT_STRING_ARRAY = 18; + static readonly COMMAND_VOID_IN_OUT_MAP_STRING_INT = 19; + static readonly COMMAND_VOID_IN_OUT_STRING_ARRAY = 20; + static readonly COMMAND_VOID_IN_INT = 21; + static readonly COMMAND_VOID_IN_STRING = 22; + static readonly COMMAND_VOID_OUT_INT = 23; + static readonly COMMAND_VOID_OUT_STRING = 24; + static readonly COMMAND_VOID_IN_OUT_INT = 25; + static readonly COMMAND_VOID_IN_OUT_STRING = 26; + static readonly COMMAND_VOID_PARAMETER_TYPE_BOOLEAN = 27; + static readonly COMMAND_VOID_PARAMETER_TYPE_BYTE = 28; + static readonly COMMAND_VOID_PARAMETER_TYPE_SHORT = 29; + static readonly COMMAND_VOID_PARAMETER_TYPE_INT = 30; + static readonly COMMAND_VOID_PARAMETER_TYPE_LONG = 31; + static readonly COMMAND_VOID_PARAMETER_TYPE_FLOAT = 32; + static readonly COMMAND_VOID_PARAMETER_TYPE_DOUBLE = 33; + static readonly COMMAND_VOID_PARAMETER_TYPE_STRING = 34; + static readonly COMMAND_VOID_PARAMETER_TYPE_SEQUENCEABLE = 35; + static readonly COMMAND_VOID_PARAMETER_TYPE_INTERFACE = 36; + static readonly COMMAND_VOID_PARAMETER_TYPE_MAP_STRING_STRING = 37; + static readonly COMMAND_VOID_PARAMETER_TYPE_DOUBLE_ARRAY = 38; + static readonly COMMAND_VOID_ORDER_OUT_IN = 39; + static readonly COMMAND_VOID_ORDER_IN_OUT_IN = 40; + static readonly COMMAND_VOID_ORDER_OUT_IN_OUT = 41; + static readonly COMMAND_VOID_ORDER_IN_IN_OUT_OUT = 42; +} + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..79f54ac14eeb5a62fc54b4e4cec2eee5c53d5c75 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -0,0 +1,64 @@ +/* +* 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 ZidlTestServiceStubOneway from './zidlToolOneWay/interface_attribute_declaratoin_oneway_stub'; +import {voidVoidFirstCallback} from './zidlToolOneWay/i_interface_attribute_declaratoin_oneway' +import {voidVoidSecondCallback} from './zidlToolOneWay/i_interface_attribute_declaratoin_oneway' +import {voidVoidThirdCallback} from './zidlToolOneWay/i_interface_attribute_declaratoin_oneway' + +const SUCCESS = 0; +const FAIL = 1; + +class ZidlTestImpOneway extends ZidlTestServiceStubOneway { + voidVoidFirst(callback: voidVoidFirstCallback) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_0100_1 called"); + callback(SUCCESS); + } + + voidVoidSecond(callback: voidVoidSecondCallback) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_0100_2 called"); + callback(SUCCESS); + } + + voidVoidThird(callback: voidVoidThirdCallback) { + console.log("ZidlTest Server ACTS_Zidl_Js2JsMulti_0100_3 called"); + callback(SUCCESS); + } +} + +export default class ServiceAbility2 extends ServiceExtension { + onCreate(want,startId) { + globalThis.abilityWant = want; + console.log('ZidlService ServiceAbility2 onCreate, want: ' + want.abilityName); + } + + onRequest(want, startId) { + console.log('ZidlService ServiceAbility2 onRequest, want: ' + want.abilityName + + ', startId: ' + startId); + } + + onConnect(want) { + console.log('ZidlService ServiceAbility2 onConnect, want:' + want.abilityName); + return new ZidlTestImpOneway('connect'); + } + + onDisconnect(want) { + console.log('ZidlService ServiceAbility2 onDisconnect, want:' + want.abilityName); + } + + onDestroy() { + console.log('AZidlService ServiceAbility2 onDestroy'); + } +}; diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility2/service.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..b49731a414958a281c2f0c4eab0e7fb408eb2c2f --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/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/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility2/zidlToolOneWay/i_interface_attribute_declaratoin_oneway.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility2/zidlToolOneWay/i_interface_attribute_declaratoin_oneway.ts new file mode 100755 index 0000000000000000000000000000000000000000..943d83dc857cd02cccbddfd143c4b3e504ebf825 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility2/zidlToolOneWay/i_interface_attribute_declaratoin_oneway.ts @@ -0,0 +1,25 @@ +/* + * 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. + */ + + +export default interface IInterfaceAttributeDeclaratoinOneway { + voidVoidFirst(callback: voidVoidFirstCallback): void; + voidVoidSecond(callback: voidVoidSecondCallback): void; + voidVoidThird(callback: voidVoidThirdCallback): void; +} +export type voidVoidFirstCallback = (errCode: number) => void; +export type voidVoidSecondCallback = (errCode: number) => void; +export type voidVoidThirdCallback = (errCode: number) => void; + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility2/zidlToolOneWay/interface_attribute_declaratoin_oneway_stub.ts b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility2/zidlToolOneWay/interface_attribute_declaratoin_oneway_stub.ts new file mode 100755 index 0000000000000000000000000000000000000000..a2b75c5f4d97885876f91ef457802e77e20914e2 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/ServiceAbility2/zidlToolOneWay/interface_attribute_declaratoin_oneway_stub.ts @@ -0,0 +1,64 @@ +/* + * 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 {voidVoidFirstCallback} from "./i_interface_attribute_declaratoin_oneway"; +import {voidVoidSecondCallback} from "./i_interface_attribute_declaratoin_oneway"; +import {voidVoidThirdCallback} from "./i_interface_attribute_declaratoin_oneway"; +import IInterfaceAttributeDeclaratoinOneway from "./i_interface_attribute_declaratoin_oneway"; +import rpc from "@ohos.rpc"; + +export default class InterfaceAttributeDeclaratoinOnewayStub extends rpc.RemoteObject implements IInterfaceAttributeDeclaratoinOneway { + constructor(des: string) { + super(des); + } + + onRemoteRequest(code: number, data, reply, option): boolean { + console.log("onRemoteRequest called, code = " + code); + switch(code) { + case InterfaceAttributeDeclaratoinOnewayStub.COMMAND_VOID_VOID_FIRST: { + this.voidVoidFirst((errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case InterfaceAttributeDeclaratoinOnewayStub.COMMAND_VOID_VOID_SECOND: { + this.voidVoidSecond((errCode) => { + reply.writeInt(errCode); + }); + return true; + } + case InterfaceAttributeDeclaratoinOnewayStub.COMMAND_VOID_VOID_THIRD: { + this.voidVoidThird((errCode) => { + reply.writeInt(errCode); + }); + return true; + } + default: { + console.log("invalid request code" + code); + break; + } + } + return false; + } + + voidVoidFirst(callback: voidVoidFirstCallback): void{} + voidVoidSecond(callback: voidVoidSecondCallback): void{} + voidVoidThird(callback: voidVoidThirdCallback): void{} + + static readonly COMMAND_VOID_VOID_FIRST = 1; + static readonly COMMAND_VOID_VOID_SECOND = 2; + static readonly COMMAND_VOID_VOID_THIRD = 3; +} + diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/pages/index/index.ets b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..16e1531e48430510168d31c9f8d8c595c3b62ab9 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,37 @@ +/* +* 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'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + console.info("start run testcase!!!!") + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('pmsystemappa') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .margin({ + top: 20 + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/pages/second/second.ets b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/ets/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..2c768edb999b1b54fef3268922817734b1f1c954 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/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/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/module.json b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..40f140623e5cc80a03e81bf0cac2b923443daea4 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/module.json @@ -0,0 +1,99 @@ +{ + "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.zidlservice.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.zidlservice.ServiceAbility", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:phone_entry_main", + "type": "service", + "visible": true + }, + { + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "name": "com.example.zidlservice.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/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..376647878b379044fa3300dfa4662c98a4c3efbc --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/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/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/resources/base/profile/main_pages.json b/aafwk/aafwk_standard/zidltest/actsamszidlservice/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4 --- /dev/null +++ b/aafwk/aafwk_standard/zidltest/actsamszidlservice/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/aafwk/aafwk_standard/zidltest/actsamszidlservice/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/zidltest/actsamszidlservice/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..cc53179a48f88f20acc379c138a001e9a15838f6 Binary files /dev/null and b/aafwk/aafwk_standard/zidltest/actsamszidlservice/signature/openharmony_sx.p7b differ