diff --git a/aafwk/aafwk_standard/BUILD.gn b/aafwk/aafwk_standard/BUILD.gn index ac351e87265257865b3be3beca743a0ae5e89d52..c0764c8bcb36b2aa2f6bc1f9fd588d9c0fc87269 100755 --- a/aafwk/aafwk_standard/BUILD.gn +++ b/aafwk/aafwk_standard/BUILD.gn @@ -51,6 +51,7 @@ group("aafwk_standard") { "serviceability/stserviceabilityserver:amsStServiceAilityServer", "serviceability/stserviceabilityserversecond:ActsAmsStServiceAilityServerSecondTest", "setshowonlockscreen:setshowonlockscreen", + "stage:stage", "want:want", ] } diff --git a/aafwk/aafwk_standard/stage/BUILD.gn b/aafwk/aafwk_standard/stage/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..798bacf751a47691f78ced3337e0f8dcdb2b2689 --- /dev/null +++ b/aafwk/aafwk_standard/stage/BUILD.gn @@ -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. + +import("//test/xts/tools/build/suite.gni") + +group("stage") { + testonly = true + if (is_standard_system) { + deps = [ "stage_extension_service:StageExtensionServiceTest" ] + } +} diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/BUILD.gn b/aafwk/aafwk_standard/stage/stage_extension_service/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..8317e362b10d7468743b903495f5885bdd969544 --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/BUILD.gn @@ -0,0 +1,32 @@ +# 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") + +ohos_js_hap_suite("StageExtensionServiceTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":stage_extension_service_assets", + ":stage_extension_service_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "StageExtensionServiceTest" +} +ohos_js_assets("stage_extension_service_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("stage_extension_service_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/Test.json b/aafwk/aafwk_standard/stage/stage_extension_service/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..83f5b926b3070399ae12f63451cda070d7948015 --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for serviceExtension Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "600000", + "package": "com.example.serviceextension", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "StageExtensionServiceTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/config.json b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/config.json new file mode 100755 index 0000000000000000000000000000000000000000..f041e67499333748c4aab53b14b37119d8b634f5 --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/config.json @@ -0,0 +1,84 @@ +{ + "app": { + "bundleName": "com.example.serviceextension", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.serviceextension", + "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", + "type": "service" + }, + { + "srcPath": "ServiceAbility2", + "name": ".ServiceAbility2", + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:description_serviceability2", + "type": "service" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/AbilityStage.ts b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..fd1f27a591d899e2a0727dc333cadae18fff44a4 --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/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.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + globalThis.lifeCycleList = []; + } +} diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/MainAbility/MainAbility.ts b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..ec696dd399c1e38f0fc97b697bed7a5a43f494dc --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/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; + } + + 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", 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/stage/stage_extension_service/entry/src/main/ets/MainAbility/app.ets b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/MainAbility/app.ets new file mode 100755 index 0000000000000000000000000000000000000000..8fa46789d26d2239baaaf1d63b92d076a8a696c8 --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,22 @@ +/** + * 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('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/MainAbility/pages/index.ets b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..b31be6a500ac958b918d2acc271ed6fa1837d475 --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,66 @@ +/** + * 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) + 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 111!') + .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%') + } +} diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/MainAbility/pages/second.ets b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..23efeed6ee4ed4854293a5f798b136c2b519280b --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/MainAbility/pages/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%') + } +} diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..058b3eb63e05e6e19ec71288bb89365d0f0f86c0 --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -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 ServiceExtension from "@ohos.application.ServiceExtension" + +export default class MyServiceAbility extends ServiceExtension { + + onCreate(want){ + console.log('MyApplication.MyServiceExtension onCreate' + JSON.stringify(want)); + globalThis.extensionContext = this.context; + } + + onDestroy(){ + console.log('[MyApplication] MyServiceExtension onDestroy'); + } + + onRequest(want,startId){ + console.log('[MyApplication] MyServiceExtension onRequest' + JSON.stringify(want) + JSON.stringify(startId)); + } + + onConnect(want){ + console.log('[MyApplication] MyServiceExtension onConnect' + JSON.stringify(want)); + } + + onDisconnect(want){ + console.log('[MyApplication] MyServiceExtension onConnect' + JSON.stringify(want)); + } + + onReconnect(want){ + console.log('[MyApplication] MyServiceExtension onConnect' + JSON.stringify(want)); + } +} diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/ServiceAbility/service.ts b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/ServiceAbility/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..f4fcb0ca614fd52b23fe164125a4b054c5b0b002 --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/ServiceAbility/service.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 { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100755 index 0000000000000000000000000000000000000000..63a71d43aebe198a602877d15c9b5542c1d1e334 --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -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 ServiceExtension from "@ohos.application.ServiceExtension" + +export default class MyServiceAbility extends ServiceExtension { + + onCreate(want){ + console.log('ServiceAbility2 onCreate' + JSON.stringify(want)); + globalThis.extensionContext2 = this.context; + globalThis.lifeCycleList.push('ServiceAbility2_onCreate'); + console.log('ServiceAbility2 lifeCycleList is' + JSON.stringify(globalThis.lifeCycleList)); + } + + onDestroy(){ + console.log('ServiceAbility2 onDestroy'); + globalThis.lifeCycleList.push('ServiceAbility2_onDestroy'); + console.log('ServiceAbility2 lifeCycleList is' + JSON.stringify(globalThis.lifeCycleList)); + } + + onRequest(want,startId){ + console.log('ServiceAbility2 onRequest' + JSON.stringify(want) + JSON.stringify(startId)); + globalThis.lifeCycleList.push('ServiceAbility2_onRequest'); + globalThis.startId2 = startId; + globalThis.serviceWant2 = want; + console.log("ServiceAbility2 serviceWant2 is " + JSON.stringify(globalThis.serviceWant2)); + console.log('ServiceAbility2 lifeCycleList is' + JSON.stringify(globalThis.lifeCycleList)); + setTimeout(()=>{ + this.context.terminateSelf().then((data) => { + console.log("ServiceAbility2 terminateSelf data: " + JSON.stringify(data)) + }).catch((error) => { + console.log("ServiceAbility2 terminateSelf error: " + JSON.stringify(error)) + }); + }, 1000); + } + + onConnect(want){ + console.log('ServiceAbility2 onConnect' + JSON.stringify(want)); + globalThis.lifeCycleList.push('ServiceAbility2_onConnect'); + console.log('ServiceAbility2 lifeCycleList is' + JSON.stringify(globalThis.lifeCycleList)); + } + + onDisconnect(want){ + console.log('ServiceAbility2 onDisconnect' + JSON.stringify(want)); + globalThis.lifeCycleList.push('ServiceAbility2_onDisconnect'); + console.log('ServiceAbility2 lifeCycleList is' + JSON.stringify(globalThis.lifeCycleList)); + } + + onReconnect(want){ + console.log('ServiceAbility2 onReconnect' + JSON.stringify(want)); + globalThis.lifeCycleList.push('ServiceAbility2_onReconnect'); + console.log('ServiceAbility2 lifeCycleList is' + JSON.stringify(globalThis.lifeCycleList)); + } +} diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/ServiceAbility2/service.ts b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100755 index 0000000000000000000000000000000000000000..f4fcb0ca614fd52b23fe164125a4b054c5b0b002 --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/ServiceAbility2/service.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 { + onStart() { + console.info('ServiceAbility onStart'); + }, + onStop() { + console.info('ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility onCommand'); + } +}; diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/test/ExtensionTest.test.ets b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/test/ExtensionTest.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..536574dfdd003a02a0ede4448d6f023c63551c98 --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/test/ExtensionTest.test.ets @@ -0,0 +1,913 @@ +/** + * 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" + +export default function ExtensionTest(abilityContext) { + describe('ServiceExtensionTest', function () { + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_6600 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_6600', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_6600"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + deviceId: undefined, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000) + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_6700 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_6700', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_6700"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + uri: "abcdefxxxx", + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var actualValue = globalThis.serviceWant2.uri; + checkParametersValue(actualValue, "abcdefxxxx", TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000) + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_6800 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_6800', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_6800"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + flags: 0x0001, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var actualValue = globalThis.serviceWant2.flags; + checkParametersValue(actualValue, 1, TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000) + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_6900 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_6900', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_6900"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + flags: 0x0001|0x0002, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var actualValue = globalThis.serviceWant2.flags; + checkParametersValue(actualValue, 3, TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000) + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_7000 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_7000', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_7000"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + flags: 1.33, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var actualValue = globalThis.serviceWant2.flags; + checkParametersValue(actualValue, 1, TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000) + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_7100 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_7100', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_7100"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + flags: "2", + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var actualValue = globalThis.serviceWant2.flags; + checkParametersValue(actualValue, 0, TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000) + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_7200 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_7200', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_7200"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + flags: "aa", + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var actualValue = globalThis.serviceWant2.flags; + checkParametersValue(actualValue, 0, TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000) + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_7300 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_7300', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_7300"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + parameters: { + "test": 666 + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var actualValue = globalThis.serviceWant2.parameters.test; + checkParametersValue(actualValue, 666, TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000) + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_7400 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_7400', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_7400"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + parameters: { + "test": 1231564215648115648203065413 + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var actualValue = globalThis.serviceWant2.parameters.test + checkParametersValue(actualValue, 1.2315642156481157e+27, TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000) + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_7500 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_7500', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_7500"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + parameters: { + "test": 66.66 + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var actualValue = globalThis.serviceWant2.parameters.test; + checkParametersValue(actualValue, 66.66, TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000) + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_7600 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_7600', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_7600"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + parameters: { + "test": 66.66666666666666 + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var actualValue = globalThis.serviceWant2.parameters.test; + checkParametersValue(actualValue, 66.66666666666666, TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000) + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_7700 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_7700', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_7700"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + parameters: { + "test": 66.66666666666666666 + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var actualValue = globalThis.serviceWant2.parameters.test; + checkParametersValue(actualValue, 66.66666666666667, TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000) + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_7800 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_7800', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_7800"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + parameters: { + "test": 9223372036854776088 + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var actualValue = globalThis.serviceWant2.parameters.test; + checkParametersValue(actualValue, 9223372036854776000, TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000) + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_7900 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_7900', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_7900"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + parameters: { + "test": "testString" + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var actualValue = globalThis.serviceWant2.parameters.test; + checkParametersValue(actualValue, "testString", TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000); + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_8000 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_8000', 0, async function (done){ + var TAG = "SUB_AA_Extension_ServiceExtensionContext_8000"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function() { + await globalThis.extensionContext.startAbility({ + parameters: { + "test": true + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function() { + var expectValue = globalThis.serviceWant2.parameters.test; + console.log(TAG + " expectValue = " + JSON.stringify(expectValue)); + expect(expectValue).assertTrue(); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000); + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_8100 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_8100', 0, async function (done) { + var TAG = "SUB_AA_Extension_ServiceExtensionContext_8100"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function () { + var testStr = [1, 2, 3]; + await globalThis.extensionContext.startAbility({ + parameters: { + "test": testStr + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function () { + var actualValue = globalThis.serviceWant2.parameters.test; + checkParametersArrayValue(actualValue, testStr, TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000); + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_8200 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_8200', 0, async function (done) { + var TAG = "SUB_AA_Extension_ServiceExtensionContext_8200"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function () { + const testStr = ["string1", "string2"]; + await globalThis.extensionContext.startAbility({ + parameters: { + "test": testStr + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function () { + var actualValue = globalThis.serviceWant2.parameters.test; + checkParametersArrayValue(actualValue, testStr, TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000); + }, 2000); + }); + + + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_8400 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_8400', 0, async function (done) { + var TAG = "SUB_AA_Extension_ServiceExtensionContext_8400"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function () { + await globalThis.extensionContext.startAbility({ + parameters: { + "test": 'a' + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function () { + var actualValue = globalThis.serviceWant2.parameters.test; + checkParametersValue(actualValue, 'a', TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000); + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_8500 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_8500', 0, async function (done) { + var TAG = "SUB_AA_Extension_ServiceExtensionContext_8500"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function () { + await globalThis.extensionContext.startAbility({ + parameters: { + "test": {"testjson":"testjsonvalue"} + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function () { + var actualValue = globalThis.serviceWant2.parameters.test.testjson; + checkParametersValue(actualValue, 'testjsonvalue', TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000); + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_8600 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_8600', 0, async function (done) { + var TAG = "SUB_AA_Extension_ServiceExtensionContext_8600"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function () { + await globalThis.extensionContext.startAbility({ + parameters: { + "ability.want.params.TITLE" : "test" + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function () { + var actualValue = globalThis.serviceWant2.parameters["ability.want.params.TITLE"]; + checkParametersValue(actualValue, "test", TAG) + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000); + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_8700 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_8700', 0, async function (done) { + var TAG = "SUB_AA_Extension_ServiceExtensionContext_8700"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function () { + await globalThis.extensionContext.startAbility({ + parameters: { + "ability.want.params.TITLE" : {"key": "one", "value": "test"} + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function () { + var actualValue = globalThis.serviceWant2.parameters["ability.want.params.TITLE"]; + console.log(TAG + " actualValue = " + JSON.stringify(actualValue)); + expect(actualValue.key == "one").assertTrue(); + expect(actualValue.value == "test").assertTrue(); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000); + }, 2000); + }); + + /** + * @tc.number: SUB_AA_Extension_ServiceExtensionContext_8800 + * @tc.name: + * @tc.desc: + */ + it('SUB_AA_Extension_ServiceExtensionContext_8800', 0, async function (done) { + var TAG = "SUB_AA_Extension_ServiceExtensionContext_8800"; + console.log(TAG + " --- start"); + globalThis.lifeCycleList = []; + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + + abilityContext.startAbility({ + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility" + }, (error, data) => { + console.log(TAG + '-- startAbility(ServiceAbility): ' + JSON.stringify(error) + ", " + JSON.stringify(data)); + }); + setTimeout(async function () { + var testStr = [1, 2, 3]; + await globalThis.extensionContext.startAbility({ + parameters: { + "test1" : "test1", + "test2" : 12345, + "test3" : 'a', + "test4" : testStr, + "test5" : {"testjson":"testjsonvalue"} + }, + bundleName: "com.example.serviceextension", + abilityName: "com.example.serviceextension.ServiceAbility2" + }, (err, data) => { + console.log(TAG + '-- startAbility(ServiceAbility2): ' + JSON.stringify(err) + ", " + JSON.stringify(data)); + }); + setTimeout(function () { + var actualValue1 = globalThis.serviceWant2.parameters.test1; + checkParametersValue(actualValue1, "test1", TAG); + + var actualValue2 = globalThis.serviceWant2.parameters.test2; + checkParametersValue(actualValue2, 12345, TAG); + + var actualValue3 = globalThis.serviceWant2.parameters.test3; + checkParametersValue(actualValue3, 'a', TAG); + + var actualValue4 = globalThis.serviceWant2.parameters.test4; + checkParametersArrayValue(actualValue4, testStr, TAG); + + var actualValue5 = globalThis.serviceWant2.parameters.test5.testjson; + checkParametersValue(actualValue5, 'testjsonvalue', TAG); + + console.log(TAG + " lifeCycleList = " + JSON.stringify(globalThis.lifeCycleList)); + var findTarget = ["ServiceAbility2_onCreate", "ServiceAbility2_onRequest"]; + checkLifeCycle(globalThis.lifeCycleList, findTarget, TAG); + done(); + }, 2000); + }, 2000); + }); + + function checkLifeCycle(lifeCycle, findTarget, TAG) { + var a = 0; + console.log(TAG + " findTarget.length = " + findTarget.length); + for(var i = 0; i < findTarget.length; i++) { + var targetValue = findTarget[i]; + for(var j = 0; j < lifeCycle.length; j++) { + if(lifeCycle[j] == targetValue) { + a++; + } + } + } + console.log(TAG + " a = " + a.toString()); + expect(a == findTarget.length).assertTrue(); + } + + function checkParametersValue(actualValue, expectValue, TAG) { + console.log(TAG + " actualValue = " + JSON.stringify(actualValue)); + expect(actualValue == expectValue).assertTrue(); + } + + function checkParametersArrayValue(actualArray, expectArray, TAG) { + console.log(TAG + " actualArray = " + JSON.stringify(actualArray)); + for (var i = 0; i < actualArray.length; i++) { + expect(actualArray[i] == expectArray[i]).assertTrue(); + } + } + + }) +} diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/test/List.test.ets b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..81737fc7873fb2a154267a1a9867f918e9daa2ec --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,22 @@ +/* + * 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 permisrsions and + * limitations under the License. + */ +import ExtensionTest from './ExtensionTest.test.ets' + + +export default function testsuite(context) { + + ExtensionTest(context) + +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/resources/base/element/string.json b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..daaa017c9efe96e9a12e24eb1483ea5ca2bc56de --- /dev/null +++ b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "description_serviceability", + "value": "hap sample empty service" + }, + { + "name": "description_serviceability2", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/resources/base/media/icon.png b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/aafwk/aafwk_standard/stage/stage_extension_service/entry/src/main/resources/base/media/icon.png differ diff --git a/aafwk/aafwk_standard/stage/stage_extension_service/signature/openharmony_sx.p7b b/aafwk/aafwk_standard/stage/stage_extension_service/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/aafwk/aafwk_standard/stage/stage_extension_service/signature/openharmony_sx.p7b differ