diff --git a/ability/ability_runtime/stage/BUILD.gn b/ability/ability_runtime/stage/BUILD.gn index 59ca123d04673baa99c07bf408129675f7f84469..0e66fde190d6f272a817f11b998cb63eb54cdf43 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 0000000000000000000000000000000000000000..0c7f062bd3027212acee62505a71a84f05f37b43 --- /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:ActsStartUpAssistant", + "StartUpRuleTest:ActsStartUpRuleTest", + ] + } +} 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 0000000000000000000000000000000000000000..c2ff8cadea06f49024d4c4c4595b52891616a202 --- /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 0000000000000000000000000000000000000000..12d9f1b26690ec47d1d3e99597c348a2e5a9469b --- /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 Binary files /dev/null and b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/BUILD.gn b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f04a93b42b64a9ec5e76b652653abd3ffde0a778 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/BUILD.gn @@ -0,0 +1,46 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_hap_assist_suite("ActsStartUpAssistant") { + hap_name = "ActsStartUpAssistant" + js_build_mode = "debug" + + testonly = true + hap_profile = "entry/src/main/module.json" + deps = [ + ":actsstartupassistant_js_assets", + ":actsstartupassistant_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_app_scope("actsstartupassistant_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsstartupassistant_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsstartupassistant_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsstartupassistant_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/ets/calleeability/CalleeAbility.ts b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/ets/calleeability/CalleeAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..d81e0e112ba2241dcf90158c24397bc35fd5eda8 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/ets/calleeability/CalleeAbility.ts @@ -0,0 +1,81 @@ +/* + * 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 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 0000000000000000000000000000000000000000..cccbead40dca627f8b71c193e4275881a283475c --- /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 0000000000000000000000000000000000000000..a7c665620e7b0c34fb2d1d42821d92c4cc521b5b --- /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 0000000000000000000000000000000000000000..46aeb288d98c1d7061d21ac9ede84797804d5d59 --- /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 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /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 0000000000000000000000000000000000000000..71875d77bfd4390e107e9af45e640bdd0a9c00ed --- /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 Binary files /dev/null and b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/en_US/element/string.json b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..71875d77bfd4390e107e9af45e640bdd0a9c00ed --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/en_US/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/zh_CN/element/string.json b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..98171ead8506fd4d3ebebf85ba7459212f80ec3b --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "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/signature/openharmony_sx.p7b b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..680fec44ed8f18eaa606bc2de8dbcb11a2448602 Binary files /dev/null and b/ability/ability_runtime/stage/actsstartuptest/StartUpAssistant/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/AppScope/app.json b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..7d8fc3ce6626acf0d67092807a53fe251b8ebaf3 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/AppScope/app.json @@ -0,0 +1,19 @@ +{ + "app": { + "bundleName": "com.acts.startuptest", + "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/StartUpRuleTest/AppScope/resources/base/element/string.json b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1bceac5cf3112166038a27ad1b7c1bde702d6d66 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "startuptest" + } + ] +} diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/BUILD.gn b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fa970b859b87b0256d54f67daae91a879b255c69 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/BUILD.gn @@ -0,0 +1,43 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsStartUpRuleTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":actsstartupruletest_js_assets", + ":actsstartupruletest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsStartUpRuleTest" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_app_scope("actsstartupruletest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actsstartupruletest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actsstartupruletest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actsstartupruletest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/Test.json b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..28a0d467e18fc939402a395b2d7ebf1362343197 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/Test.json @@ -0,0 +1,29 @@ +{ + "description": "Configuration for startuprule demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "com.acts.startuptest", + "module-name": "entry", + "shell-timeout": "600000", + "testcase-timeout": 15000 + }, + "kits": [ + { + "test-file-name": [ + "ActsStartUpRuleTest.hap", + "ActsStartUpAssistant.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "power-shell wakeup", + "power-shell setmode 602", + "uinput -T -d 300 600 -m 300 600 300 100 -u 300 100" + ] + } + ] +} diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/DataShareExtAbility/DataShareExtAbility.ts b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/DataShareExtAbility/DataShareExtAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8ed4d95a7646e65e27f6de1a7c99a7c01fb1381e --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/DataShareExtAbility/DataShareExtAbility.ts @@ -0,0 +1,25 @@ +/* + * 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 DataShareExtensionAbility from '@ohos.application.DataShareExtensionAbility'; + +export default class DataShareExtAbility extends DataShareExtensionAbility { + onCreate(want) { + console.log(`DataShareExtAbility onCreate: ${JSON.stringify(want)}`); + } + onDestroy() { + console.log('DataShareExtAbility onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..84ab10531dbc2c72cd567ec8d190afb6880e8508 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/ServiceExtAbility/ServiceExtAbility.ts @@ -0,0 +1,45 @@ +/* + * 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 ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'; +import rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des); + } + onRemoteRequest(code, data, reply, option) { + return true; + } +} + +export default class ServiceExtAbility extends ServiceExtensionAbility { + onCreate(want) { + console.log(`onCreate: ${JSON.stringify(want)}`); + } + onRequest(want, startId) { + console.log(`onRequest: ${JSON.stringify(want)}`); + } + onConnect(want) { + console.log('onConnect END'); + return new StubTest('stub'); + } + onDisconnect(want): void { + console.log(`HXW onDisconnect: ${JSON.stringify(want)}`); + } + onDestroy() { + console.log('onDestroy'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..0add92b10a810393400bb6934b447f427a6f86d5 --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -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 hilog from '@ohos.hilog'; +import TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +let abilityDelegator = undefined; +let abilityDelegatorArguments = undefined; + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments(); + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'; + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback); + let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName; + let debug = abilityDelegatorArguments.parameters['-D']; + if (debug === 'true') + { + cmd += ' -D'; + } + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err, d) => { + 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 0000000000000000000000000000000000000000..8006ddcd353312e5c2114029e2c0044ced3ec38d --- /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 0000000000000000000000000000000000000000..b2a81f176ee853206c85474d92eb8ad50ca560db --- /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 0000000000000000000000000000000000000000..d86d162ddd381c27554e2b2b8192c60740e001c6 --- /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 0000000000000000000000000000000000000000..c798d8d3d9c911f5de63f35e1350c537ff2b6257 --- /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 0000000000000000000000000000000000000000..1c37f8586044535d46be7ae1379c69025ca994b0 --- /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 0000000000000000000000000000000000000000..f5935328aaeaa4b78df44f15fa2dd55bd7ab075b --- /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 0000000000000000000000000000000000000000..a5e3901b158ee41800d1352a723099f852f4e5ef --- /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 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /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 0000000000000000000000000000000000000000..3ad471059305b990b8ca8a524362da7c2427563f --- /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 Binary files /dev/null and b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..10dccbd390c0448e31f3cce55923c05595a711aa --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/Index", + "testability/pages/Index" + ] +} diff --git a/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/en_US/element/string.json b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3ad471059305b990b8ca8a524362da7c2427563f --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/en_US/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/zh_CN/element/string.json b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..015a23c1ac44e12ceff8a453097c98687906ab8c --- /dev/null +++ b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "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/signature/openharmony_sx.p7b b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..01ab67bb8bfe41125f6ca2940dc7bc621efa9192 Binary files /dev/null and b/ability/ability_runtime/stage/actsstartuptest/StartUpRuleTest/signature/openharmony_sx.p7b differ