diff --git a/ability/ability_runtime/BUILD.gn b/ability/ability_runtime/BUILD.gn index df8cea63aacd881ecf8e22e32f4e7ec4f9f26a2a..e9a07ecd1c588b8bdb9d103f825f8a52bf0a34b0 100644 --- a/ability/ability_runtime/BUILD.gn +++ b/ability/ability_runtime/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# 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 @@ -40,6 +40,7 @@ group("ability_runtime") { "actsstserviceabilityclientcase:ActsStServiceAbilityClientCaseTest", "actssupportfunction:actssupportfunction", "actssystemapitest:ActsSystemAPITest", + "actsuiextensiontest:actsuiextensiontest", "actsusers:actsusers", "amscontextualinforquery:amscontextualinforquery", "amsdatauriutils:ActsAmsDataUriUtilsTest", diff --git a/ability/ability_runtime/actsuiextensiontest/BUILD.gn b/ability/ability_runtime/actsuiextensiontest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..6d93bd1f189249b5959035ef3ba1383639f6250e --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/BUILD.gn @@ -0,0 +1,24 @@ +# 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") + +group("actsuiextensiontest") { + testonly = true + if (is_standard_system) { + deps = [ + "uiextensionprovider:UIExtensionProvider", + "uiextensiontest:UIExtensionTest", + ] + } +} diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/AppScope/app.json b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..29de622dbd0232104fd2e9525b9fbdbac8ab925c --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/AppScope/app.json @@ -0,0 +1,13 @@ +{ + "app": { + "bundleName": "com.example.uiextensionprovider", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "minAPIVersion": 10, + "targetAPIVersion": 10 + } +} diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..bea9602bcd5daba3cffbb2b9cf8e8d66a15fb01c --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "UIExtensionProvider" + } + ] +} diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/BUILD.gn b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f176d2741db2e6651e66b34dcf3aeb43758dafb5 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/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_hap_assist_suite("UIExtensionProvider") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":uiextensionprovider_js_assets", + ":uiextensionprovider_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "UIExtensionProvider" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_app_scope("uiextensionprovider_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("uiextensionprovider_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("uiextensionprovider_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":uiextensionprovider_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/Application/MyAbilityStage.ts b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/Application/MyAbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae48946469822fb87b65805884870193349d1905 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/Application/MyAbilityStage.ts @@ -0,0 +1,24 @@ +/* + * 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 AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'AbilityStage onCreate'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..a8b47cb7ff1bd23206698e24d48adfe493f61520 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,66 @@ +/* + * 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 Ability from '@ohos.app.ability.UIAbility' +import Window from '@ohos.window' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); + } + + onDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: Window.WindowStage) { + // Main window is created, set main page for this ability + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/index', (err, data) => { + if (err.code) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + 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.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground() { + // Ability has brought to foreground + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground() { + // Ability has back to background + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6babb94a4e64c5aa266f403b10cbe5f1c3553f9 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts @@ -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 UIExtensionAbility from '@ohos.app.ability.UIExtensionAbility' +import Logger from '../model/Logger' + +const TAG: string = '[UIExtAbility]' + +export default class UIExtAbility extends UIExtensionAbility { + onCreate() { + Logger.log(TAG, `UIExtAbility onCreate`) + } + + onForeground() { + Logger.log(TAG, `UIExtAbility onForeground`) + } + + onBackground() { + Logger.log(TAG, `UIExtAbility onBackground`) + } + + onDestroy() { + Logger.log(TAG, `UIExtAbility onDestroy`) + } + + onSessionCreate(want, session) { + Logger.log(TAG, `UIExtAbility onSessionCreate, want: ${JSON.stringify(want)}`) + let storage: LocalStorage = new LocalStorage({ + 'session': session + }); + session.loadContent('pages/index', storage); + } + + onSessionDestroy(session) { + Logger.log(TAG, `UIExtAbility onSessionDestroy`) + } +}; diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/model/Logger.ts b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/model/Logger.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9a67d309cd37ae6ec6669b16aab1518326015ca --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/model/Logger.ts @@ -0,0 +1,38 @@ +/* + * 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. + */ + +const TAG: string = '=== Stage AMS ===' + +export default class Logger { + public static log(tag, ...args: any[]) { + console.log(`${TAG}.${tag}: ${args.join('')}`) + } + + public static info(tag, ...args: any[]) { + console.info(`${TAG}.${tag}: ${args.join('')}`) + } + + public static debug(tag, ...args: any[]) { + console.debug(`${TAG}.${tag}: ${args.join('')}`) + } + + public static warn(tag, ...args: any[]) { + console.warn(`${TAG}.${tag}: ${args.join('')}`) + } + + public static error(tag, ...args: any[]) { + console.error(`${TAG}.${tag}: ${args.join('')}`) + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6320394ecc1b8e0bba7c2c17a8af458454bac391 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/ets/pages/index.ets @@ -0,0 +1,92 @@ +/* + * 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 UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession' +import commonEventManager from '@ohos.commonEventManager' +import Logger from '../model/Logger' + +const TAG: string = '[UIExtAbility]' +const sleepTimeOne = 1000; + +let storage = LocalStorage.GetShared() + +@Entry(storage) +@Component +struct Index { + @State message: string = 'UIExtension' + private session: UIExtensionContentSession = storage.get('session'); + + aboutToAppear() { + let appearEvent = 'ACTS_UIExtension_AboutToAppear'; + let terminateSelfWithResultEvent = 'ACTS_UIExtension_TerminateSelfWithResult'; + let sendDataEvent = 'ACTS_UIExtension_SendData'; + + var subscriber; + var subscribeInfo = { + events: [terminateSelfWithResultEvent, sendDataEvent] + } + commonEventManager.createSubscriber(subscribeInfo).then(async (data) => { + console.log(TAG + "createSubscriber data : " + JSON.stringify(data)); + subscriber = data; + + commonEventManager.subscribe(subscriber, async (err, data) => { + console.log(TAG + "SubscribeInfoCallback : " + JSON.stringify(data)); + if (data.event == terminateSelfWithResultEvent) { + this.session.terminateSelfWithResult({ + "resultCode": 0, + "want": { + "bundleName": "test" + } + }); + commonEventManager.unsubscribe(subscriber, async (err, data) => { + console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data)); + }); + } else if (data.event == sendDataEvent) { + this.session.sendData({ + name: { + last: 'King' + } + }); + commonEventManager.unsubscribe(subscriber, async (err, data) => { + console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data)); + }); + } + }); + }).catch((error) => { + console.log(TAG + "createSubscriber error : " + JSON.stringify(error)); + }) + setTimeout(async () => { + commonEventManager.publish(appearEvent, (err) => { + if (err) { + Logger.log(TAG + `publish ACTS_UIExtension_AboutToAppear failed, code is ${err.code}, message is ${err.message}`); + } else { + Logger.log(TAG + 'publish ACTS_UIExtension_AboutToAppear success'); + } + }); + }, sleepTimeOne); + } + + 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/actsuiextensiontest/uiextensionprovider/entry/src/main/module.json b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..bfd921858c7a8c3d6728e82d26a2361ea7d41482 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/module.json @@ -0,0 +1,54 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/MyAbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "UIExtAbility", + "icon": "$media:icon", + "description": "UIExtAbility", + "type": "ui", + "visible": true, + "srcEntrance": "./ets/UIExtensionAbility/UIExtAbility.ts", + "metadata": [ + { + "name": "ohos.extension.servicetype", + "value": "share" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/resources/base/element/color.json b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..62a137a61b90c14f109ed8c81d9d551ea0a5888a --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..dddf9123aec0b6c9500eeacf289ac1bc58ff7a6a --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/signature/openharmony_sx.p7b b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..b9cf717e61ad6d32cba0f0487609b2babcb1c058 Binary files /dev/null and b/ability/ability_runtime/actsuiextensiontest/uiextensionprovider/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/AppScope/app.json b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..c133a0b12c874ea8b295e46f884e37eb4e4a2ca1 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/AppScope/app.json @@ -0,0 +1,13 @@ +{ + "app": { + "bundleName": "com.example.uiextensiontest", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "distributedNotificationEnabled": true, + "minAPIVersion": 10, + "targetAPIVersion": 10 + } +} diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/AppScope/resources/base/element/string.json b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..85cd1d6d2e2c6ee974ba291ec50203333c836223 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "UIExtensionTest" + } + ] +} diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/BUILD.gn b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d43204c76652b72e0684d1a865e50d5fd2d5ec5f --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/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("UIExtensionTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":uiextensiontest_js_assets", + ":uiextensiontest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "UIExtensionTest" + subsystem_name = "ability" + part_name = "ability_runtime" +} + +ohos_app_scope("uiextensiontest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("uiextensiontest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("uiextensiontest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":uiextensiontest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/Test.json b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3c8a08595653cfd59b650c895caef8566c0ab70a --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/Test.json @@ -0,0 +1,22 @@ +{ + "description": "Configuration for aceceshi Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.uiextensiontest", + "module-name": "entry", + "shell-timeout": "600000", + "testcase-timeout":"30000" + }, + "kits": [ + { + "test-file-name": [ + "UIExtensionTest.hap", + "UIextensionProvider.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} + diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/Application/TestAbilityStage.ts b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/Application/TestAbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..0654cee59e211322e4f0529b6d3006e31268e201 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/Application/TestAbilityStage.ts @@ -0,0 +1,24 @@ +/* + * 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 AbilityStage from "@ohos.app.ability.UIAbility" + +export default class TestAbilityStage extends AbilityStage { + onCreate() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbilityStage onCreate'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/TestAbility/TestAbility.ets b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/TestAbility/TestAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..b86e86f3b7a489e125d05621d361ed714fd2d09d --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/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 hilog from '@ohos.hilog'; +import Ability from '@ohos.app.ability.UIAbility' +import Window from '@ohos.window' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{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) ?? ''); + } + + onDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: Window.WindowStage) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); + windowStage.loadContent('TestAbility/pages/index', (err, data) => { + if (err.code) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', + JSON.stringify(data) ?? ''); + }); + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/TestAbility/pages/index.ets b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..35f9b9b5eb34a6eef4ffb7c95a3691680abff3d3 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,47 @@ +/* + * 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../test/List.test' + +@Entry +@Component +struct Index { + @State message: string = 'Index' + aboutToAppear() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + 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/actsuiextensiontest/uiextensiontest/entry/src/main/ets/TestAbility/pages/p1.ets b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/TestAbility/pages/p1.ets new file mode 100644 index 0000000000000000000000000000000000000000..64389662c36b750a04addd4ccbe3c35306c94854 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/TestAbility/pages/p1.ets @@ -0,0 +1,62 @@ +/* + * 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 commonEventManager from '@ohos.commonEventManager' + +const TAG: string = '[P1]' + +@Entry +@Component +struct P1 { + aboutToAppear() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); + } + build() { + Row() { + Column() { + UIExtensionComponent({ + bundleName: 'com.example.uiextensionprovider', + abilityName: 'UIExtAbility' + }).width('100%').height('35%') + .onResult((data)=>{ + let onResultEvent = 'ACTS_UIExtension_OnResult'; + let options = { + parameters: { + 'result': data + } + } + commonEventManager.publish(onResultEvent, options, (err) => { + console.log(TAG + 'ACTS_UIExtension_OnResult'); + }); + }) + .onReceive((data)=>{ + let onReceiveEvent = 'ACTS_UIExtension_OnReceive'; + let options = { + parameters: { + 'result': data + } + } + commonEventManager.publish(onReceiveEvent, options, (err) => { + console.log(TAG + 'ACTS_UIExtension_OnReceive'); + }); + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..13f3712e7b1ee891bb5dee9917cface15fc4a547 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,86 @@ +/* + * 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.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters['-D'] + if (debug == 'true') + { + cmd += ' -D' + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + 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/actsuiextensiontest/uiextensiontest/entry/src/main/ets/test/Ability.test.ets b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a4a7ac8f73c8e38229687a2e41e5c9ba86c8c764 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/test/Ability.test.ets @@ -0,0 +1,148 @@ +/* + * 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 commonEventManager from '@ohos.commonEventManager' +import router from '@ohos.router' +import Utils from './Utils' + +export default function abilityTest() { + describe('ACTS_UIExtension', function () { + let TAG = ""; + let sleepTimeOne = 1000; + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(function () { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(async function (done) { + console.info("ACTS_UIExtension beforeEach start"); + let options = { + url: 'TestAbility/pages/p1', + } + let result; + try { + result = await router.pushUrl(options); + await Utils.sleep(500); + console.info("ACTS_UIExtension push page result: " + JSON.stringify(result)); + } catch (err) { + console.error("ACTS_UIExtension push page error: " + err); + } + done() + }); + afterEach(async function (done) { + router.back() + await Utils.sleep(500); + done() + }) + afterAll(function () { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('ACTS_UIExtension_TerminateSelfWithResult_001',0, async function (done) { + TAG = 'ACTS_UIExtension_TerminateSelfWithResult_001 == '; + console.log(TAG + "begin"); + + let appearEvent = 'ACTS_UIExtension_AboutToAppear'; + let onResultEvent = 'ACTS_UIExtension_OnResult'; + let terminateSelfWithResultEvent = 'ACTS_UIExtension_TerminateSelfWithResult'; + + var subscriber; + var subscribeInfo = { + events: [appearEvent, onResultEvent] + } + await commonEventManager.createSubscriber(subscribeInfo).then(async (data) => { + console.log(TAG + "createSubscriber data : " + JSON.stringify(data)); + subscriber = data; + + commonEventManager.subscribe(subscriber, async (err, data) => { + console.log(TAG + "SubscribeInfoCallback : " + JSON.stringify(data)); + + if (data.event == appearEvent) { + commonEventManager.publish(terminateSelfWithResultEvent, (err) => { + if (err) { + console.log(TAG + `publish ACTS_UIExtension_TerminateSelfWithResult failed, code is ${err.code}, message is ${err.message}`); + } else { + console.log(TAG + 'publish ACTS_UIExtension_TerminateSelfWithResult success'); + } + }); + } else if (data.event == onResultEvent) { + let result = data.parameters.result; + setTimeout(async () => { + commonEventManager.unsubscribe(subscriber, async (err, data) => { + console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data)); + expect(result.want.bundleName).assertEqual('test'); + done(); + }); + }, sleepTimeOne); + } + }); + }).catch((error) => { + console.log(TAG + "createSubscriber err : " + JSON.stringify(error)); + expect().assertFail(); + done(); + }) + }) + it('ACTS_UIExtension_UIExtensionSendData_001',0, async function (done) { + TAG = 'ACTS_UIExtension_UIExtensionSendData_001 == '; + console.log(TAG + "begin"); + + let appearEvent = 'ACTS_UIExtension_AboutToAppear'; + let onReceiveEvent = 'ACTS_UIExtension_OnReceive'; + let sendDataEvent = 'ACTS_UIExtension_SendData'; + + var subscriber; + var subscribeInfo = { + events: [appearEvent, onReceiveEvent] + } + await commonEventManager.createSubscriber(subscribeInfo).then(async (data) => { + console.log(TAG + "createSubscriber data : " + JSON.stringify(data)); + subscriber = data; + + commonEventManager.subscribe(subscriber, async (err, data) => { + console.log(TAG + "SubscribeInfoCallback : " + JSON.stringify(data)); + + if (data.event == appearEvent) { + commonEventManager.publish(sendDataEvent, (err) => { + if (err) { + console.log(TAG + `publish ACTS_UIExtension_SendData failed, code is ${err.code}, message is ${err.message}`); + } else { + console.log(TAG + 'publish ACTS_UIExtension_SendData success'); + } + }); + } else if (data.event == onReceiveEvent) { + let result = data.parameters.result; + let resultCheck = { + name: { + last: 'King' + } + }; + setTimeout(async () => { + commonEventManager.unsubscribe(subscriber, async (err, data) => { + console.log(TAG + "UnSubscribeInfoCallback : " + JSON.stringify(data)); + expect(JSON.stringify(result)).assertEqual(JSON.stringify(resultCheck)); + done(); + }); + }, sleepTimeOne); + } + }); + }).catch((error) => { + console.log(TAG + "createSubscriber err : " + JSON.stringify(error)); + expect().assertFail(); + done(); + }) + }) + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/test/List.test.ets b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..27c07a1a174f6862ea84c4bb5f45bc1789234441 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/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/actsuiextensiontest/uiextensiontest/entry/src/main/ets/test/Utils.ets b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..688bd4c25d9889ceac76922a073bb4d8d2c46cfe --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/ets/test/Utils.ets @@ -0,0 +1,26 @@ +/* + * 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. + */ + +export default class Utils { + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + } \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/module.json b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..7f4a1754c03a0e0836966c3ee39e4b2596ed801c --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/module.json @@ -0,0 +1,38 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/TestAbilityStage.ts", + "description": "$string:entry_test_desc", + "mainElement": "TestAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:test_pages", + "abilities": [ + { + "name": "TestAbility", + "srcEntrance": "./ets/TestAbility/TestAbility.ets", + "description": "$string:TestAbility_desc", + "icon": "$media:icon", + "label": "$string:TestAbility_label", + "visible": true, + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:white", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ] + } + ] + } +} diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/resources/base/element/color.json b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..1bbc9aa9617e97c45440e1d3d66afc1154837012 --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "white", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..36d4230c53e9f5a07ae343ad8dc9808341975e3b --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_test_desc", + "value": "test ability description" + }, + { + "name": "TestAbility_desc", + "value": "the test ability" + }, + { + "name": "TestAbility_label", + "value": "test label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/resources/base/profile/test_pages.json b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/resources/base/profile/test_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..5309b228c2b3674e3f42edbe766f2a764064b90a --- /dev/null +++ b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/entry/src/main/resources/base/profile/test_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "TestAbility/pages/index", + "TestAbility/pages/p1" + ] +} diff --git a/ability/ability_runtime/actsuiextensiontest/uiextensiontest/signature/openharmony_sx.p7b b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..288af57feb40b7e8f879823369d6173716356d5a Binary files /dev/null and b/ability/ability_runtime/actsuiextensiontest/uiextensiontest/signature/openharmony_sx.p7b differ