From f9ff5586937b82711d71ef5981c9164cbd3fba84 Mon Sep 17 00:00:00 2001 From: kirl75 Date: Wed, 2 Aug 2023 19:53:26 +0800 Subject: [PATCH] =?UTF-8?q?AMS=E5=90=AF=E5=8A=A8=E8=A7=84=E5=88=99?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: kirl75 --- ability/ability_runtime/stage/BUILD.gn | 1 + .../stage/actsstartuptest/BUILD.gn | 24 + .../StartUpAssistant/AppScope/app.json | 19 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin 0 -> 6790 bytes .../actsstartuptest/StartUpAssistant/BUILD.gn | 46 + .../main/ets/calleeability/CalleeAbility.ts | 81 ++ .../src/main/ets/entryability/EntryAbility.ts | 80 ++ .../entry/src/main/ets/pages/Index.ets | 32 + .../entry/src/main/module.json | 48 ++ .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 24 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/main_pages.json | 5 + .../main/resources/en_US/element/string.json | 24 + .../main/resources/zh_CN/element/string.json | 24 + .../signature/openharmony_sx.p7b | Bin 0 -> 3498 bytes .../StartUpRuleTest/AppScope/app.json | 19 + .../resources/base/element/string.json | 8 + .../resources/base/media/app_icon.png | Bin 0 -> 6790 bytes .../actsstartuptest/StartUpRuleTest/BUILD.gn | 43 + .../actsstartuptest/StartUpRuleTest/Test.json | 33 + .../DataShareExtAbility.ts | 25 + .../ServiceExtAbility/ServiceExtAbility.ts | 45 + .../ets/TestRunner/OpenHarmonyTestRunner.ts | 64 ++ .../src/main/ets/entryability/EntryAbility.ts | 56 ++ .../entry/src/main/ets/pages/Index.ets | 32 + .../entry/src/main/ets/test/Ability.test.ets | 814 ++++++++++++++++++ .../entry/src/main/ets/test/List.test.ets | 20 + .../src/main/ets/testability/TestAbility.ets | 64 ++ .../src/main/ets/testability/pages/Index.ets | 49 ++ .../entry/src/main/module.json | 86 ++ .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 32 + .../src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/main_pages.json | 6 + .../main/resources/en_US/element/string.json | 32 + .../main/resources/zh_CN/element/string.json | 32 + .../signature/openharmony_sx.p7b | Bin 0 -> 3492 bytes 39 files changed, 1892 insertions(+) create mode 100644 ability/ability_runtime/stage/actsstartuptest/BUILD.gn create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/AppScope/app.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/AppScope/resources/base/element/string.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/AppScope/resources/base/media/app_icon.png create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/BUILD.gn create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/ets/calleeability/CalleeAbility.ts create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/ets/entryability/EntryAbility.ts create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/ets/pages/Index.ets create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/module.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/element/color.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/element/string.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/media/icon.png create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/profile/main_pages.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/en_US/element/string.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/zh_CN/element/string.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/signature/openharmony_sx.p7b create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/AppScope/app.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/AppScope/resources/base/element/string.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/AppScope/resources/base/media/app_icon.png create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/BUILD.gn create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/Test.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/DataShareExtAbility/DataShareExtAbility.ts create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/entryability/EntryAbility.ts create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/pages/Index.ets create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/test/Ability.test.ets create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/test/List.test.ets create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/testability/TestAbility.ets create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/testability/pages/Index.ets create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/module.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/element/color.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/element/string.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/media/icon.png create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/profile/main_pages.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/en_US/element/string.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/zh_CN/element/string.json create mode 100644 ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/signature/openharmony_sx.p7b diff --git a/ability/ability_runtime/stage/BUILD.gn b/ability/ability_runtime/stage/BUILD.gn index 59ca123d0..0e66fde19 100644 --- a/ability/ability_runtime/stage/BUILD.gn +++ b/ability/ability_runtime/stage/BUILD.gn @@ -23,6 +23,7 @@ group("stage") { "actslifecyclemultihap3:ActsLifecycleMultiHap3", "actslifecyclemultihaptest:ActsLifecycleMultiHapTest", "actslifecyclesinglehaptest:ActsLifecycleSingleHapTest", + "actsstartuptest:startuptest", "actsuripermission:ActsUriPermission", "actswindowstagelifecyclemultihaptest:ActsWindowStageLifecycleMultiHapTest", "actswindowstagelifecyclesinglehaptest:ActsWindowStageLifecycleSingleHapTest", diff --git a/ability/ability_runtime/stage/actsstartuptest/BUILD.gn b/ability/ability_runtime/stage/actsstartuptest/BUILD.gn new file mode 100644 index 000000000..0cedcea33 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/BUILD.gn @@ -0,0 +1,24 @@ +# Copyright (c) 2021-2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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("startuptest") { + testonly = true + if (is_standard_system) { + deps = [ + "StartUpAssistant:StartUpAssistant", + "StartUpRuleTest:StartUpRuleTest", + ] + } +} diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/AppScope/app.json b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/AppScope/app.json new file mode 100644 index 000000000..c2ff8cade --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/AppScope/app.json @@ -0,0 +1,19 @@ +{ + "app": { + "bundleName": "com.acts.startupassistant", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 10, + "targetAPIVersion": 10, + "car": { + "apiCompatibleVersion": 10, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/AppScope/resources/base/element/string.json b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/AppScope/resources/base/element/string.json new file mode 100644 index 000000000..12d9f1b26 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "StartUpAssistant" + } + ] +} diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtg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O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y { + console.debug('=ACTS_unsubscribe (err,data)=======>'); + }); +} + +export default class CalleeAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'CalleeAbility onCreate'); + let subscriber = null; + let terminateSelfEvent = { + events: [ + 'terminateAssistantAbility', + ], + }; + commonEvent.createSubscriber(terminateSelfEvent).then((data) => { + console.log('createSubscriber'); + subscriber = data; + commonEvent.subscribe(subscriber, (err, data) => { + console.log('ACTS_StartUpRuleOptimizeTest terminateSelfWithResult CalleeAbility'); + let result = { + resultCode: 0 + }; + this.context.terminateSelfWithResult(result, () => {}); + unsubscribe(subscriber); + }); + }) + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/ets/entryability/EntryAbility.ts b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/ets/entryability/EntryAbility.ts new file mode 100644 index 000000000..cccbead40 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/ets/entryability/EntryAbility.ts @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; +import commonEvent from '@ohos.commonEventManager'; + +function unsubscribe(subscriber) { + commonEvent.unsubscribe(subscriber, (err, data) => { + console.debug('=ACTS_unsubscribe (err,data)=======>'); + }); +} + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'ACTS_StartUpRuleOptimizeTest', '%{public}s', 'AssistantAbility onCreate'); + let subscriber = null; + let terminateSelfEvent = { + events: [ + 'terminateAssistantAbility', + ], + }; + commonEvent.createSubscriber(terminateSelfEvent).then((data) => { + console.log('createSubscriber'); + subscriber = data; + commonEvent.subscribe(subscriber, (err, data) => { + console.log('ACTS_StartUpRuleOptimizeTest terminateSelfWithResult AssistantAbility'); + let result = { + resultCode: 0 + } + this.context.terminateSelfWithResult(result, () => {}); + }); + }) + } + + onDestroy() { + hilog.info(0x0000, 'ACTS_StartUpRuleOptimizeTest', '%{public}s', 'AssistantAbility onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'ACTS_StartUpRuleOptimizeTest', '%{public}s', 'AssistantAbility onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'ACTS_StartUpRuleOptimizeTest', '%{public}s', 'AssistantAbility onBackground'); + } +} diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/ets/pages/Index.ets b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/ets/pages/Index.ets new file mode 100644 index 000000000..a7c665620 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct Index { + @State message: string = 'StartUpTest AssistantApp'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/module.json b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/module.json new file mode 100644 index 000000000..46aeb288d --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/module.json @@ -0,0 +1,48 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "CalleeAbility", + "srcEntry": "./ets/calleeability/CalleeAbility.ts", + "description": "$string:CalleeAbility_desc", + "icon": "$media:icon", + "label": "$string:CalleeAbility_label", + "startWindowIcon": "$media:icon", + "exported": true, + "launchType": "singleton", + "startWindowBackground": "$color:start_window_background" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/element/color.json b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/element/color.json new file mode 100644 index 000000000..3c712962d --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..71875d77b --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "CalleeAbility_desc", + "value": "description" + }, + { + "name": "CalleeAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K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ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y { + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/entryability/EntryAbility.ts b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/entryability/EntryAbility.ts new file mode 100644 index 000000000..8006ddcd3 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/entryability/EntryAbility.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import UIAbility from '@ohos.app.ability.UIAbility'; +import hilog from '@ohos.hilog'; +import window from '@ohos.window'; + +export default class EntryAbility extends UIAbility { + onCreate(want, launchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/pages/Index.ets b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/pages/Index.ets new file mode 100644 index 000000000..b2a81f176 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 000000000..d86d162dd --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,814 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES 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 '@ohos/hypium' +import backgroundTaskManager from '@ohos.resourceschedule.backgroundTaskManager'; +import wantAgent from '@ohos.app.ability.wantAgent'; +import commonEvent from '@ohos.commonEventManager'; +import dataShare from '@ohos.data.dataShare'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +let ERROR_START_ABILITY_WAITTING = 16000017; +let ERROR_NO_PERMISSION = 201; +let dataShareUri = "datashare:///startuptest"; +let context = null; +let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + +function sleep(time) { + return new Promise((resolve)=>setTimeout(resolve,time)); +} + +// start continuous task +async function startContinuousTask(TAG): Promise { + let wantAgentInfo = { + wants: [ + { + bundleName: 'com.acts.startuptest', + abilityName: 'TestAbility', + } + ], + operationType: wantAgent.OperationType.START_ABILITY, + requestCode: 0, + wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG] + } + try { + let wantAgentObject = await wantAgent.getWantAgent(wantAgentInfo); + await backgroundTaskManager.startBackgroundRunning(context, + backgroundTaskManager.BackgroundMode.DATA_TRANSFER, wantAgentObject); + } catch (error) { + console.log(TAG + ` Operation startBackgroundRunning failed. code is ${error.code} message is ${error.message}`); + } +} + +// cancel continuous task +async function stopContinuousTask(TAG): Promise { + try { + await backgroundTaskManager.stopBackgroundRunning(context) + } catch (error) { + console.log(TAG + ` Operation stopBackgroundRunning failed. code is ${error.code} message is ${error.message}`); + } +} + +export default function abilityTest() { + describe('ActsAbilityTest', function () { + beforeAll(async function () { + context = globalThis.testContext; + await abilityDelegator.executeShellCommand('killall com.acts.startupassistant'); + }) + beforeEach(async function () { + //globalThis.onForegroundFlag = false; + commonEvent.publish('terminateAssistantAbility', () => {}); + }) + afterEach(async function () { + await stopContinuousTask('afterEach SUB_AA_StartUpRuleOptimizeTest'); + await sleep(200); + }) + afterAll(async function () { + commonEvent.publish('terminateAssistantAbility', () => {}); + await abilityDelegator.executeShellCommand('killall com.acts.startupassistant'); + }) + + /** + * @tc.number SUB_AA_StartUpRuleOptimizeTest_0100 + * @tc.name Prohibit background startAbility test + * @tc.desc Ability can not be started during a non-long-term task or non-scheduling foreground + */ + it('SUB_AA_StartUpRuleOptimizeTest_0100',0, async function (done) { + let TAG = 'SUB_AA_StartUpRuleOptimizeTest_0100 '; + + function startAbilityWithBgTask() { + let want = { + abilityName: 'EntryAbility', + bundleName:'com.acts.startuptest' + } + context.startAbility(want, (err) => { + console.log(TAG + ' startAbility error: ' + err.code + ' ' + err.message); + if (err && err.code) { + expect(err.code).assertEqual(ERROR_NO_PERMISSION); + setTimeout(() => { + console.log(TAG + " publish terminateAssistantAbility event"); + commonEvent.publish('terminateAssistantAbility', () => { console.log(TAG + 'publish terminate event') }); + }, 100); + } else { + expect().assertFail(); + done(); + } + }) + } + + let callbackId; + let testDone = false; + let AbilityLifecycleCallback = { + onAbilityForeground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityForeground") + if (abilityName === 'TestAbility') { + if (testDone === true) { + console.log(TAG + 'testDone'); + globalThis.ApplicationContext.off('abilityLifecycle', callbackId) + done(); + } + } + }, + onAbilityBackground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityBackground") + if (abilityName === 'TestAbility') { + setTimeout(startAbilityWithBgTask, 100); + } + } + } + callbackId = globalThis.ApplicationContext.on('abilityLifecycle', AbilityLifecycleCallback); + + // Start another ability, ensure testAbility is background + let want = { + abilityName: 'EntryAbility', + bundleName:'com.acts.startupassistant' + }; + console.log(TAG + 'startAbilityForResult'); + context.startAbilityForResult(want, (err, data) => { + console.log(TAG + ' assistantAbility is terminated'); + expect(err.code).assertEqual(0); + testDone = true; + }); + }) + + /** + * @tc.number SUB_AA_StartUpRuleOptimizeTest_0200 + * @tc.name Allow background startAbility for background running ContinuousTask + * @tc.desc Test the startAbility of a background running ContinuousTask. + */ + it('SUB_AA_StartUpRuleOptimizeTest_0200',0, async function (done) { + let TAG = 'SUB_AA_StartUpRuleOptimizeTest_0200 '; + + function startAbilityWithBgTask() { + console.log(TAG + 'startAbilityWithBgTask'); + let want = { + abilityName: 'TestAbility', + bundleName:'com.acts.startuptest' + }; + // test startAbility + context.startAbility(want).then(() => { + console.log(TAG + ' startAbility success'); + if (testDone === true) { + console.log(TAG + 'testDone'); + globalThis.ApplicationContext.off('abilityLifecycle', callbackId); + done(); + } else { + testDone = true; + } + }).catch((err) => { + console.log(TAG + ' startAbility error: ' + err.code + ' ' + err.message); + if (err.code === ERROR_START_ABILITY_WAITTING) { + testDone = true; + return; + } + expect().assertFail(); + done(); + }) + } + + let callbackId; + let testDone = false; + let AbilityLifecycleCallback = { + onAbilityForeground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityForeground"); + if (abilityName === 'TestAbility') { + if (testDone === true) { + console.log(TAG + 'testDone'); + globalThis.ApplicationContext.off('abilityLifecycle', callbackId); + done(); + } + } + }, + onAbilityBackground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityBackground") + if (abilityName === 'TestAbility') { + startAbilityWithBgTask(); + } + } + } + callbackId = globalThis.ApplicationContext.on('abilityLifecycle', AbilityLifecycleCallback); + + await startContinuousTask(TAG); + // Start another ability, ensure testAbility is background + let want = { + abilityName: 'EntryAbility', + bundleName:'com.acts.startupassistant' + }; + console.log(TAG + 'startAbility'); + context.startAbility(want, (err, data) => { + console.log(TAG + 'startAbility callback ' + err.code); + if (err.code && err.code != ERROR_START_ABILITY_WAITTING) { + expect().assertFail(); + done(); + } + }); + }) + + /** + * @tc.number SUB_AA_StartUpRuleOptimizeTest_0300 + * @tc.name Allow background startAbilityByCall for background running ContinuousTask + * @tc.desc Test the startAbilityByCall of a background running ContinuousTask. + */ + it('SUB_AA_StartUpRuleOptimizeTest_0300',0, async function (done) { + let TAG = 'SUB_AA_StartUpRuleOptimizeTest_0300 '; + + function startAbilityWithBgTask() { + let want = { + abilityName: 'CalleeAbility', + bundleName:'com.acts.startupassistant' + }; + // test startAbilityByCall + context.startAbilityByCall(want).then(async () => { + console.log(TAG + ' startAbilityByCall success'); + setTimeout(() => { + console.log(TAG + " publish terminateAssistantAbility event"); + commonEvent.publish('terminateAssistantAbility', () => { console.log(TAG + 'publish done') }); + }, 100); + }).catch((err) => { + console.log(TAG + ' startAbilityByCall error: ' + err.code + ' ' + err.message); + expect().assertFail(); + done(); + }) + } + + let callbackId; + let testDone = false; + let AbilityLifecycleCallback = { + onAbilityForeground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityForeground"); + if (abilityName === 'TestAbility') { + if (testDone === true) { + console.log(TAG + 'testDone'); + globalThis.ApplicationContext.off('abilityLifecycle', callbackId); + done(); + } + } + }, + onAbilityBackground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityBackground"); + if (abilityName === 'TestAbility') { + startAbilityWithBgTask(); + } + } + } + callbackId = globalThis.ApplicationContext.on('abilityLifecycle', AbilityLifecycleCallback); + + await startContinuousTask(TAG); + // Start another ability, ensure testAbility is background + let want = { + abilityName: 'EntryAbility', + bundleName:'com.acts.startupassistant' + }; + console.log(TAG + 'startAbilityForResult'); + context.startAbilityForResult(want, (err, data) => { + console.log(TAG + ' assistantAbility is terminated err.code ' + err.code); + expect(err.code).assertEqual(0); + testDone = true; + }); + }) + + /** + * @tc.number SUB_AA_StartUpRuleOptimizeTest_0400 + * @tc.name Allow background connectServiceExtensionAbility for background running ContinuousTask + * @tc.desc Test the connectServiceExtensionAbility of a background running ContinuousTask. + */ + it('SUB_AA_StartUpRuleOptimizeTest_0400',0, async function (done) { + let TAG = 'SUB_AA_StartUpRuleOptimizeTest_0400 '; + let connectId; + let connection = { + onConnect: function (elementName, proxy) { + console.log(TAG + ' onConnect'); + setTimeout(() => { + console.log(TAG + " publish terminateAssistantAbility event"); + commonEvent.publish('terminateAssistantAbility', () => {console.log(TAG + 'send terminate event')}); + context.disconnectServiceExtensionAbility(connectId); + }, 100); + }, + onDisconnect: function () { + console.log(TAG + 'onDisconnect'); + }, + onFailed: function (code) { + console.log(TAG + `onFailed ${code}`); + expect().assertFail(); + done(); + } + } + + function startAbilityWithBgTask() { + console.log(TAG + 'startAbilityWithBgTask'); + let want = { + abilityName: 'ServiceExtAbility', + bundleName:'com.acts.startuptest' + }; + // test connectServiceExtensionAbility + connectId = context.connectServiceExtensionAbility(want, connection); + } + + let callbackId; + let testDone = false; + let AbilityLifecycleCallback = { + onAbilityForeground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityForeground") + if (abilityName === 'TestAbility') { + if (testDone === true) { + console.log(TAG + 'testDone'); + globalThis.ApplicationContext.off('abilityLifecycle', callbackId) + done(); + } + } + }, + onAbilityBackground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityBackground") + if (abilityName === 'TestAbility') { + startAbilityWithBgTask(); + } + } + } + callbackId = globalThis.ApplicationContext.on('abilityLifecycle', AbilityLifecycleCallback); + + await startContinuousTask(TAG); + // Start another ability, ensure testAbility is background + let want = { + abilityName: 'EntryAbility', + bundleName:'com.acts.startupassistant' + }; + console.log(TAG + 'startAbilityForResult'); + context.startAbilityForResult(want, (err, data) => { + console.log(TAG + ' assistantAbility is terminated'); + expect(err.code).assertEqual(0); + testDone = true; + }); + }) + + /** + * @tc.number SUB_AA_StartUpRuleOptimizeTest_0500 + * @tc.name Allow background startServiceExtensionAbility for background running ContinuousTask + * @tc.desc Test the startServiceExtensionAbility of a background running ContinuousTask. + */ + it('SUB_AA_StartUpRuleOptimizeTest_0500',0, async function (done) { + let TAG = 'SUB_AA_StartUpRuleOptimizeTest_0500 '; + + function startAbilityWithBgTask() { + let want = { + abilityName: 'ServiceExtAbility', + bundleName:'com.acts.startuptest' + }; + // test startServiceExtensionAbility + context.startServiceExtensionAbility(want).then(() => { + console.log(TAG + ' startServiceExtensionAbility success'); + setTimeout(() => { + console.log(TAG + " publish terminateAssistantAbility event"); + commonEvent.publish('terminateAssistantAbility', () => { console.log(TAG + 'publish done') }); + }, 100); + }).catch((err) => { + console.log(TAG + ' startServiceExtensionAbility error: ' + err.code + ' ' + err.message); + expect().assertFail(); + done(); + }); + } + + let callbackId; + let testDone = false; + let AbilityLifecycleCallback = { + onAbilityForeground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityForeground"); + if (abilityName === 'TestAbility') { + if (testDone === true) { + console.log(TAG + 'testDone'); + globalThis.ApplicationContext.off('abilityLifecycle', callbackId); + done(); + } + } + }, + onAbilityBackground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityBackground"); + if (abilityName === 'TestAbility') { + startAbilityWithBgTask(); + } + } + } + callbackId = globalThis.ApplicationContext.on('abilityLifecycle', AbilityLifecycleCallback); + + await startContinuousTask(TAG); + // Start another ability, ensure testAbility is background + let want = { + abilityName: 'EntryAbility', + bundleName:'com.acts.startupassistant' + }; + console.log(TAG + 'startAbilityForResult'); + context.startAbilityForResult(want, (err, data) => { + console.log(TAG + ' assistantAbility is terminated'); + expect(err.code).assertEqual(0); + testDone = true; + }); + }) + + /** + * @tc.number SUB_AA_StartUpRuleOptimizeTest_0600 + * @tc.name Allow background createDataShareHelper for background running ContinuousTask + * @tc.desc Test the createDataShareHelper of a background running ContinuousTask. + */ + it('SUB_AA_StartUpRuleOptimizeTest_0600',0, async function (done) { + let TAG = 'SUB_AA_StartUpRuleOptimizeTest_0600 '; + + function startAbilityWithBgTask() { + // Test connect dataShare + dataShare.createDataShareHelper(context, dataShareUri, (err, dataShareHelper) => { + console.log(TAG + ' createDataShareHelper callback'); + if (err && err.code) { + console.log(TAG + ' createDataShareHelper failed ' + err.code + ' ' + err.message); + expect().assertFail(); + done(); + } else { + console.log(TAG + ' createDataShareHelper success'); + setTimeout(() => { + console.log(TAG + " publish terminateAssistantAbility event"); + commonEvent.publish('terminateAssistantAbility', () => { console.log(TAG + 'publish done') }); + }, 100); + } + }) + } + + let callbackId; + let testDone = false; + let AbilityLifecycleCallback = { + onAbilityForeground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityForeground") + if (abilityName === 'TestAbility') { + if (testDone === true) { + console.log(TAG + 'testDone'); + globalThis.ApplicationContext.off('abilityLifecycle', callbackId) + done(); + } + } + }, + onAbilityBackground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityBackground") + if (abilityName === 'TestAbility') { + startAbilityWithBgTask(); + } + } + } + callbackId = globalThis.ApplicationContext.on('abilityLifecycle', AbilityLifecycleCallback); + + await startContinuousTask(TAG); + // Start another ability, ensure testAbility is background + let want = { + abilityName: 'EntryAbility', + bundleName:'com.acts.startupassistant' + } + console.log(TAG + 'startAbilityForResult'); + context.startAbilityForResult(want, (err, data) => { + console.log(TAG + ' assistantAbility is terminated err.code ' + err.code); + expect(err.code).assertEqual(0); + testDone = true; + }); + }) + + /** + * @tc.number SUB_AA_StartUpRuleOptimizeTest_0700 + * @tc.name Allow background startAbility when the ability is moving to foreground + * @tc.desc Test the startAbility call when the ability is moving to foreground. + */ + it('SUB_AA_StartUpRuleOptimizeTest_0700',0, async function (done) { + let TAG = 'SUB_AA_StartUpRuleOptimizeTest_0700 '; + + function startAbilityWithMoveToForeground() { + let want = { + abilityName: 'TestAbility', + bundleName:'com.acts.startuptest' + } + // test startAbility + context.startAbility(want).then(() => { + console.log(TAG + ' startAbility success'); + }).catch((err) => { + console.log(TAG + ' startAbility error: ' + err.code + ' ' + err.message); + if (err.code != ERROR_START_ABILITY_WAITTING) { + expect().assertFail(); + done(); + } + }) + } + + let callbackId; + let onForeground = false; + let AbilityLifecycleCallback = { + onAbilityForeground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityForeground") + if (abilityName === 'TestAbility' && !onForeground) { + onForeground = true; + globalThis.ApplicationContext.off('abilityLifecycle', callbackId) + done(); + } + }, + onAbilityBackground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityBackground"); + if (abilityName === 'TestAbility') { + setTimeout(() => { + console.log(TAG + " publish terminateAssistantAbility event"); + commonEvent.publish('terminateAssistantAbility', () => { console.log(TAG + 'publish done')}); + }, 100); + } + } + } + callbackId = globalThis.ApplicationContext.on('abilityLifecycle', AbilityLifecycleCallback); + + // Start another ability, ensure testAbility is background + let want = { + abilityName: 'EntryAbility', + bundleName:'com.acts.startupassistant' + } + console.log(TAG + 'startAbilityForResult'); + globalThis.onForegroundFlag = false; + context.startAbilityForResult(want, (err, data) => { + console.log(TAG + ' assistantAbility is terminated SUB_AA_StartUpRuleOptimizeTest'); + expect(onForeground).assertEqual(false); + expect(err.code).assertEqual(0); + startAbilityWithMoveToForeground(); + }); + }) + + /** + * @tc.number SUB_AA_StartUpRuleOptimizeTest_0800 + * @tc.name Allow background startAbilityByCall when the ability is moving to foreground + * @tc.desc Test the startAbilityByCall call when the ability is moving to foreground. + */ + it('SUB_AA_StartUpRuleOptimizeTest_0800',0, async function (done) { + let TAG = 'SUB_AA_StartUpRuleOptimizeTest_0800 '; + + function startAbilityWithMoveToForeground() { + let want = { + abilityName: 'CalleeAbility', + bundleName:'com.acts.startupassistant' + } + // test startAbilityByCall + context.startAbilityByCall(want).then(() => { + console.log(TAG + ' startAbilityByCall success'); + done(); + }).catch((err) => { + console.log(TAG + ' startAbilityByCall error: ' + err.code + ' ' + err.message); + expect().assertFail(); + done(); + }) + } + + let callbackId; + let onForeground = false; + let AbilityLifecycleCallback = { + onAbilityForeground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityForeground") + if (abilityName === 'TestAbility' && !onForeground) { + onForeground = true; + globalThis.ApplicationContext.off('abilityLifecycle', callbackId) + } + }, + async onAbilityBackground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityBackground"); + if (abilityName === 'TestAbility') { + await sleep(100); + console.log(TAG + " publish terminateAssistantAbility event"); + commonEvent.publish('terminateAssistantAbility', () => { console.log(TAG + 'publish done')}); + } + } + } + callbackId = globalThis.ApplicationContext.on('abilityLifecycle', AbilityLifecycleCallback); + + // Start another ability, ensure testAbility is background + let want = { + abilityName: 'EntryAbility', + bundleName:'com.acts.startupassistant' + } + console.log(TAG + 'startAbilityForResult'); + let option = { + windowMode: 1 + } + context.startAbilityForResult(want, option, (err, data) => { + console.log(TAG + ' assistantAbility is terminated'); + expect(onForeground).assertEqual(false); + expect(err.code).assertEqual(0); + startAbilityWithMoveToForeground(); + }); + }) + + /** + * @tc.number SUB_AA_StartUpRuleOptimizeTest_0900 + * @tc.name Allow background connectServiceExtensionAbility when the ability is moving to foreground + * @tc.desc Test the connectServiceExtensionAbility call when the ability is moving to foreground. + */ + it('SUB_AA_StartUpRuleOptimizeTest_0900',0, async function (done) { + let TAG = 'SUB_AA_StartUpRuleOptimizeTest_0900 '; + let connectId; + let connection = { + onConnect: function (elementName, proxy) { + console.log(TAG + ' onConnect'); + context.disconnectServiceExtensionAbility(connectId); + }, + onDisconnect: function () { + console.log(TAG + 'onDisconnect'); + done(); + }, + onFailed: function (code) { + console.log(TAG + `onFailed ${code}`); + expect().assertFail(); + done(); + } + } + + function startAbilityWithMoveToForeground() { + let want = { + abilityName: 'ServiceExtAbility', + bundleName:'com.acts.startuptest' + } + // test connectServiceExtensionAbility + connectId = context.connectServiceExtensionAbility(want, connection); + } + + let callbackId; + let onForeground = false; + let AbilityLifecycleCallback = { + onAbilityForeground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityForeground") + if (abilityName === 'TestAbility' && !onForeground) { + onForeground = true; + globalThis.ApplicationContext.off('abilityLifecycle', callbackId); + } + }, + async onAbilityBackground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityBackground") + if (abilityName === 'TestAbility') { + await sleep(100); + console.log(TAG + " publish terminateAssistantAbility event"); + commonEvent.publish('terminateAssistantAbility', () => { console.log(TAG + 'publish done')}); + } + } + } + callbackId = globalThis.ApplicationContext.on('abilityLifecycle', AbilityLifecycleCallback); + + // Start another ability, ensure testAbility is background + let want = { + abilityName: 'EntryAbility', + bundleName:'com.acts.startupassistant' + } + console.log(TAG + 'startAbilityForResult'); + context.startAbilityForResult(want, (err, data) => { + console.log(TAG + ' assistantAbility is terminated'); + expect(onForeground).assertEqual(false); + expect(err.code).assertEqual(0); + startAbilityWithMoveToForeground(); + }); + }) + + + /** + * @tc.number SUB_AA_StartUpRuleOptimizeTest_1000 + * @tc.name Allow background startServiceExtensionAbility when the ability is moving to foreground + * @tc.desc Test the startServiceExtensionAbility call when the ability is moving to foreground. + */ + it('SUB_AA_StartUpRuleOptimizeTest_1000',0, async function (done) { + let TAG = 'SUB_AA_StartUpRuleOptimizeTest_1000 '; + + function startAbilityWithMoveToForeground() { + let want = { + abilityName: 'ServiceExtAbility', + bundleName:'com.acts.startuptest' + } + // test startServiceExtensionAbility + context.startServiceExtensionAbility(want).then(() => { + console.log(TAG + ' startServiceExtensionAbility success'); + }).catch((err) => { + console.log(TAG + ' startServiceExtensionAbility error: ' + err.code + ' ' + err.message); + expect().assertFail(); + done(); + }) + } + + let callbackId; + let onForeground = false; + let AbilityLifecycleCallback = { + onAbilityForeground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityForeground") + if (abilityName === 'TestAbility' && !onForeground) { + onForeground = true; + globalThis.ApplicationContext.off('abilityLifecycle', callbackId); + done(); + } + }, + async onAbilityBackground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityBackground") + if (abilityName === 'TestAbility') { + await sleep(100); + console.log(TAG + " publish terminateAssistantAbility event"); + commonEvent.publish('terminateAssistantAbility', () => { console.log(TAG + 'publish done')}); + } + } + } + callbackId = globalThis.ApplicationContext.on('abilityLifecycle', AbilityLifecycleCallback); + + // Start another ability, ensure testAbility is background + let want = { + abilityName: 'EntryAbility', + bundleName:'com.acts.startupassistant' + } + console.log(TAG + 'startAbilityForResult'); + context.startAbilityForResult(want, (err, data) => { + console.log(TAG + ' assistantAbility is terminated'); + expect(onForeground).assertEqual(false); + expect(err.code).assertEqual(0); + startAbilityWithMoveToForeground(); + }); + }) + + /** + * @tc.number SUB_AA_StartUpRuleOptimizeTest_1100 + * @tc.name Allow background createDataShareHelper when the ability is moving to foreground + * @tc.desc Test the createDataShareHelper call when the ability is moving to foreground. + */ + it('SUB_AA_StartUpRuleOptimizeTest_1100',0, async function (done) { + let TAG = 'SUB_AA_StartUpRuleOptimizeTest_1100 '; + + function startAbilityWithMoveToForeground() { + // Test connect dataShare + dataShare.createDataShareHelper(context, dataShareUri, (err, dataShareHelper) => { + console.log(TAG + ' createDataShareHelper callback'); + if (err && err.code) { + console.log(TAG + ' createDataShareHelper failed ' + err.code + ' ' + err.message); + expect().assertFail(); + done(); + } else { + console.log(TAG + ' createDataShareHelper success'); + done(); + } + }) + } + + let callbackId; + let onForeground = false; + let AbilityLifecycleCallback = { + onAbilityForeground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityForeground") + if (abilityName === 'TestAbility' && !onForeground) { + onForeground = true; + globalThis.ApplicationContext.off('abilityLifecycle', callbackId); + } + }, + onAbilityBackground(ability) { + let abilityName = ability.context.abilityInfo.name; + console.log(TAG + abilityName + " onAbilityBackground"); + if (abilityName === 'TestAbility') { + setTimeout(() => { + console.log(TAG + " publish terminateAssistantAbility event"); + commonEvent.publish('terminateAssistantAbility', () => { console.log(TAG + 'publish done')}); + }, 100); + } + } + } + callbackId = globalThis.ApplicationContext.on('abilityLifecycle', AbilityLifecycleCallback); + + // Start another ability, ensure testAbility is background + let want = { + abilityName: 'EntryAbility', + bundleName:'com.acts.startupassistant' + } + console.log(TAG + 'startAbilityForResult'); + context.startAbilityForResult(want, (err, data) => { + console.log(TAG + ' assistantAbility is terminated'); + expect(onForeground).assertEqual(false); + expect(err.code).assertEqual(0); + startAbilityWithMoveToForeground(); + }); + }) + }) +} diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 000000000..c798d8d3d --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES 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'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/testability/TestAbility.ets b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/testability/TestAbility.ets new file mode 100644 index 000000000..1c37f8586 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/testability/TestAbility.ets @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import UIAbility from '@ohos.app.ability.UIAbility'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import hilog from '@ohos.hilog'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test'; +import window from '@ohos.window'; + +export default class TestAbility extends UIAbility { + onCreate(want, launchParam) { + globalThis.onForegroundFlag = false; + globalThis.testContext = this.context; + globalThis.ApplicationContext = this.context.getApplicationContext(); + hilog.info(0x0000, 'ACTS_StartUpRuleOptimizeTest', '%{public}s', 'TestAbility onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? ''); + let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite); + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); + windowStage.loadContent('testability/pages/Index', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', + JSON.stringify(data) ?? ''); + }); + } + + onWindowStageDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.info(0x01300, 'HXWACTS_StartUpRuleOptimizeTest', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.info(0x0000, 'ACTS_StartUpRuleOptimizeTest', '%{public}s', 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/testability/pages/Index.ets b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/testability/pages/Index.ets new file mode 100644 index 000000000..f5935328a --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/testability/pages/Index.ets @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hilog from '@ohos.hilog'; + +@Entry +@Component +struct Index { + + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + + @State message: string = 'Hello TestAbility'; + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + }.width('100%') + }.height('100%') + } + } \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/module.json b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/module.json new file mode 100644 index 000000000..a5e3901b1 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/module.json @@ -0,0 +1,86 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "car", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "TestAbility", + "srcEntry": "./ets/testability/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "exported": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "backgroundModes": [ + "dataTransfer" + ] + } + ], + "extensionAbilities": [ + { + "name": "ServiceExtAbility", + "description": "service", + "type": "service", + "exported": true, + "srcEntry": "./ets/ServiceExtAbility/ServiceExtAbility.ts" + }, + { + "name": "DataShareExtAbility", + "description": "dataShare", + "type": "dataShare", + "uri": "datashare://startuptest", + "exported": true, + "srcEntry": "./ets/DataShareExtAbility/DataShareExtAbility.ts" + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING", + "reason": "$string:keep_running", + "usedScene": { + "abilities": [ + "TestAbility" + ], + "when": "always" + } + }, + { + "name": "ohos.permission.ABILITY_BACKGROUND_COMMUNICATION" + }, + { + "name": "ohos.permission.CLEAN_BACKGROUND_PROCESSES" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/element/color.json b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/element/color.json new file mode 100644 index 000000000..3c712962d --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/element/string.json new file mode 100644 index 000000000..3ad471059 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "module_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + }, + { + "name": "keep_running", + "value": "长时任务权限" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r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