diff --git a/bundlemanager/bundle_standard/bundlemanager/BUILD.gn b/bundlemanager/bundle_standard/bundlemanager/BUILD.gn index 4e2522cf95cf6c95fea892ad87937842e8fd0025..40d32a820e3c3a5e01681452f3fb0e1f6daeabaa 100644 --- a/bundlemanager/bundle_standard/bundlemanager/BUILD.gn +++ b/bundlemanager/bundle_standard/bundlemanager/BUILD.gn @@ -29,6 +29,7 @@ group("bundlemanager") { "actsbundlemanagerstagetest:ActsBundleMgrStageEtsTest", "actsbundlemanagertest:ActsBundleManagerTest", "actsbundlenativetest:ActsBundleNativeTest", + "actsbundlemanageroverlaytest:ActsBundleMgrOverlayEtsTest", "sceneProject/bmsaccesstokenfive:bmsAccessTokenTest5", "sceneProject/bmsaccesstokenfour:bmsAccessTokenTest4", "sceneProject/bmsaccesstokenone:bmsAccessTokenTest1", @@ -61,6 +62,7 @@ group("bundlemanager") { "sceneProject/bmssecondright:second_right", "sceneProject/bmsstagedemoone:bmsStageDemo1", "sceneProject/bmsstagedemotwo:bmsStageDemo2", + "sceneProject/bmsoverlaydemo:bmsOverlayDemo" ] } } diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/AppScope/app.json b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..47c9f3c90c57d929853ed842805ea0c5f704a440 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"ohos.acts.bundle.overlay.test", + "vendor":"huawei", + "versionCode":1000000, + "versionName":"1.0.0", + "debug":false, + "icon":"$media:icon", + "label":"$string:app_name", + "description":"$string:description_application", + "distributedNotificationEnabled":true, + "keepAlive":true, + "singleUser":true, + "minAPIVersion":9, + "targetAPIVersion":9, + "car":{ + "apiCompatibleVersion":9, + "singleUser":false + } + } +} diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/AppScope/resources/base/element/string.json b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/BUILD.gn b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8f3b7612dcdff57b62dccc01c0c774c2c4479c60 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/BUILD.gn @@ -0,0 +1,42 @@ +# Copyright (c) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES 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("ActsBundleMgrOverlayEtsTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actbmsoverlayetstest_js_assets", + ":actbmsoverlayetstest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsBundleMgrOverlayEtsTest" + subsystem_name = "bundlemanager" + part_name = "bundle_framework" +} + +ohos_app_scope("actbmsoverlayetstest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("actbmsoverlayetstest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("actbmsoverlayetstest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actbmsoverlayetstest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/Test.json b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..3519e2fe78cee8c1dec37f1f301396de02bf0171 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/Test.json @@ -0,0 +1,42 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.bundle.overlay.test", + "module-name": "testModule", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [ + { + "test-file-name": [ + "ActsBundleMgrStageEtsTest.hap", + "bmsOverlayDemo.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command":[ + "remount", + "mkdir /data/test/" + ] + }, + { + "type": "PushKit", + "push": [ + "bmsOverlayDemo.hap -> /data/test/bmsOverlayDemo.hap" + ] + }, + { + "type": "ShellKit", + "teardown-command":[ + "bm uninstall -n ohos.acts.bundle.overlay.test", + "rm -rf /data/test/" + ] + } + ] +} + diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/Application/AbilityStage.ts b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..cbcc939ff5d038c8e22947c2f0186d3407e691bc --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,9 @@ +import AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/FormAbility/FormAbility.ts b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/FormAbility/FormAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..d443631109f5f73817ec907b36c1b7a3d353d357 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/FormAbility/FormAbility.ts @@ -0,0 +1,37 @@ +import FormExtension from '@ohos.app.form.FormExtensionAbility'; +import formBindingData from '@ohos.application.formBindingData'; +import formInfo from '@ohos.application.formInfo'; + +export default class FormAbility extends FormExtension { + onCreate(want) { + // Called to return a FormBindingData object. + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormal(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + + onUpdate(formId) { + // Called to notify the form provider to update a specified form. + } + + onVisibilityChange(newStatus) { + // Called when the form provider receives form events from the system. + } + + onEvent(formId, message) { + // Called when a specified message event defined by the form provider is triggered. + } + + onDestroy(formId) { + // Called to notify the form provider that a specified form has been destroyed. + } + + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } +}; \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/MainAbility/MainAbility.ts b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..2fb66add2d57337f9e6a8d6367842b895b573afc --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,36 @@ +import Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + onCreate(want,launchParam){ + // Ability is creating, initialize resources for this ability + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/MainAbility/pages/index/index.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f172d89b07521c2a1991ab441e99479f72823209 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/MainAbility/pages/index/index.ets @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; + +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from '@ohos/hypium' +import testsuite from '../../../test/List.test' + + +@Entry +@Component +struct Index { + + aboutToAppear(){ + console.info("start run testcase!!!!") + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/MainAbility/pages/second/second.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/MainAbility/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/MainAbility/pages/second/second.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/ServiceAbility/FormAbility.ts b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/ServiceAbility/FormAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..d443631109f5f73817ec907b36c1b7a3d353d357 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/ServiceAbility/FormAbility.ts @@ -0,0 +1,37 @@ +import FormExtension from '@ohos.app.form.FormExtensionAbility'; +import formBindingData from '@ohos.application.formBindingData'; +import formInfo from '@ohos.application.formInfo'; + +export default class FormAbility extends FormExtension { + onCreate(want) { + // Called to return a FormBindingData object. + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormal(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + + onUpdate(formId) { + // Called to notify the form provider to update a specified form. + } + + onVisibilityChange(newStatus) { + // Called when the form provider receives form events from the system. + } + + onEvent(formId, message) { + // Called when a specified message event defined by the form provider is triggered. + } + + onDestroy(formId) { + // Called to notify the form provider that a specified form has been destroyed. + } + + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } +}; \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/TestAbility/TestAbility.ts b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..3e2d601de1553cc7d790ee83b23414b26a47913b --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,30 @@ +import Ability from '@ohos.app.ability.UIAbility' + +export default class TestAbility extends Ability { + onCreate(want, launchParam) { + console.log('TestAbility onCreate') + } + + onDestroy() { + console.log('TestAbility onDestroy') + } + + onWindowStageCreate(windowStage) { + console.log('TestAbility onWindowStageCreate') + windowStage.setUIContent(this.context, 'TestAbility/pages/index', null) + + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + console.log('TestAbility onWindowStageDestroy') + } + + onForeground() { + console.log('TestAbility onForeground') + } + + onBackground() { + console.log('TestAbility onBackground') + } +}; \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/TestAbility/pages/index.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@ohos.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + @State message: string = 'Hello World' + 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/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..258481fbf031910495016da7ed433d2fb5b01a7e --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,58 @@ +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' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ohos.acts.bundle.overlay.test.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/GetOverlayModuleInfo.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/GetOverlayModuleInfo.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0cbd772d3a45b1dcb20e78c2eacdcb82ab165333 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/GetOverlayModuleInfo.test.ets @@ -0,0 +1,138 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impligetProfileByAbilityEmptyAbilityCalled. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import overlay from '@ohos.bundle.overlay'; +import Utils from "./Utils"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" + +const MODULE_NAME = "testModule"; +const MODULE_NAME1 = "test1"; +const MODULE_NAME2 = "stage1"; +const ERROR_INCOMING_MODULE_NAME_NOT_INSTALL = 17700002; +const ERROR_INCOMING_MODULE_NAME_NOT_OVERLAY = 17700033; +const ERROR_CODE = 401; + +export default function getOverlayModuleInfo() { + describe('getOverlayModuleInfo', function () { + /* + * @tc.number: SUB_BMS_APPINFO_OVERLAY_0001 + * @tc.name: GetOverlayModuleInfoModuleNameIsNull + * @tc.desc: The query fails when the incoming moduleName is empty + */ + it('GetOverlayModuleInfoModuleNameIsNull', 0, async function (done) { + try { + await overlay.getOverlayModuleInfo("").then(data => { + Utils.info("GetOverlayModuleInfoModuleNameIsNull result" + JSON.stringify(data)); + expect().assertFail(); + }).catch(err => { + Utils.info("GetOverlayModuleInfoModuleNameIsNull fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_CODE); + }); + } catch (e) { + Utils.info("GetOverlayModuleInfoModuleNameIsNull catch" + JSON.stringify(e)); + expect(e.code).assertEqual(ERROR_CODE); + } + + try { + overlay.getOverlayModuleInfo("", (err,data) => { + Utils.info("GetOverlayModuleInfoModuleNameIsNull result" + JSON.stringify(data)); + Utils.info("GetOverlayModuleInfoModuleNameIsNull fail" + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + } catch (e) { + Utils.info("GetOverlayModuleInfoModuleNameIsNull callback catch" + JSON.stringify(e)); + expect(e.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /* + * @tc.number: SUB_BMS_APPINFO_OVERLAY_0003 + * @tc.name: GetOverlayModuleInfoModuleNameNotInstall + * @tc.desc: The query fails when the incoming moduleName is not installed + */ + it('GetOverlayModuleInfoModuleNameNotInstall', 0, async function (done) { + await overlay.getOverlayModuleInfo(MODULE_NAME1).then(data => { + Utils.info("GetOverlayModuleInfoModuleNameNotInstall result" + JSON.stringify(data)); + expect().assertFail(); + }).catch(err => { + Utils.info("GetOverlayModuleInfoModuleNameNotInstall fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_INSTALL); + }); + + overlay.getOverlayModuleInfo(MODULE_NAME1, (err,data) => { + Utils.info("GetOverlayModuleInfoModuleNameNotInstall result" + JSON.stringify(data)); + Utils.info("GetOverlayModuleInfoModuleNameNotInstall fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_INSTALL); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_OVERLAY_0004 + * @tc.name: GetOverlayModuleInfoModuleNameNotOverlay + * @tc.desc: Failed to set when the incoming moduleName is not overlay + */ + it('GetOverlayModuleInfoModuleNameNotOverlay', 0, async function (done) { + await overlay.getOverlayModuleInfo(MODULE_NAME).then(data => { + Utils.info("GetOverlayModuleInfoModuleNameNotOverlay result" + JSON.stringify(data)); + expect().assertFail(); + }).catch(err => { + Utils.info("GetOverlayModuleInfoModuleNameNotOverlay fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_OVERLAY); + }); + + overlay.getOverlayModuleInfo(MODULE_NAME, (err,data) => { + Utils.info("GetOverlayModuleInfoModuleNameNotOverlay result" + JSON.stringify(data)); + Utils.info("GetOverlayModuleInfoModuleNameNotOverlay fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_OVERLAY); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_OVERLAY_000X + * @tc.name: GetOverlayModuleInfoModuleNameIsOverlay + * @tc.desc: Query succeeded when the moduleName passed in is overlay + */ + it('GetOverlayModuleInfoModuleNameIsOverlay', 0, async function (done) { + await overlay.getOverlayModuleInfo(MODULE_NAME2).then(data => { + Utils.info("GetOverlayModuleInfoModuleNameIsOverlay result" + JSON.stringify(data)); + expect(data.bundleName).assertEqual("ohos.acts.bundle.overlay.test"); + expect(data.moduleName).assertEqual("stage1"); + expect(data.targetModuleName).assertEqual("entry1"); + expect(data.priority).assertEqual(1); + expect(data.state).assertEqual(2); + }).catch(err => { + Utils.info("GetOverlayModuleInfoModuleNameIsOverlay fail" + JSON.stringify(err)); + expect().assertFail() + }); + + overlay.getOverlayModuleInfo(MODULE_NAME2, (err,data) => { + // "bundleName":"ohos.acts.bundle.overlay.test","moduleName":"stage1","targetModuleName":"entry1","priority":1,"state":2 + Utils.info("GetOverlayModuleInfoModuleNameIsOverlay result" + JSON.stringify(data)); + Utils.info("GetOverlayModuleInfoModuleNameIsOverlay fail" + JSON.stringify(err)); + expect(data.bundleName).assertEqual("ohos.acts.bundle.overlay.test"); + expect(data.moduleName).assertEqual("stage1"); + expect(data.targetModuleName).assertEqual("entry1"); + expect(data.priority).assertEqual(1); + expect(data.state).assertEqual(2); + expect(err).assertNull(); + done(); + }); + }) + }) +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/GetTargetOverlayModuleInfos.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/GetTargetOverlayModuleInfos.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf421f81c56a75921e161e420b79162ede959d91 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/GetTargetOverlayModuleInfos.test.ets @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impligetProfileByAbilityEmptyAbilityCalled. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import overlay from '@ohos.bundle.overlay'; +import Utils from "./Utils"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" + +const MODULE_NAME = "testModule"; +const MODULE_NAME1 = "test1"; +const MODULE_NAME2 = "stage1"; +const ERROR_INCOMING_MODULE_NAME_NOT_INSTALL = 17700002; +const ERROR_INCOMING_MODULE_NAME_IS_OVERLAY = 17700034; +const ERROR_CODE = 401; + +export default function getTargetOverlayModuleInfos() { + describe('getTargetOverlayModuleInfos', function () { + /* + * @tc.number: SUB_BMS_APPINFO_OVERLAY_0006 + * @tc.name: GetTargetOverlayModuleInfosModuleNameIsNull + * @tc.desc: The query fails when the incoming moduleName is empty + */ + it('GetTargetOverlayModuleInfosModuleNameIsNull', 0, async function (done) { + try { + await overlay.getTargetOverlayModuleInfos("").then(data => { + Utils.info("GetTargetOverlayModuleInfosModuleNameIsNull result" + JSON.stringify(data)); + expect().assertFail(); + }).catch(err => { + Utils.info("GetTargetOverlayModuleInfosModuleNameIsNull fail" + JSON.stringify(err)); + expect().assertFail(); + }); + } catch (e) { + Utils.info("GetTargetOverlayModuleInfosModuleNameIsNull catch" + JSON.stringify(e)); + expect(e.code).assertEqual(ERROR_CODE); + } + + try { + overlay.getTargetOverlayModuleInfos("", (err,data) => { + Utils.info("GetTargetOverlayModuleInfosModuleNameIsNull result" + JSON.stringify(data)); + Utils.info("GetTargetOverlayModuleInfosModuleNameIsNull fail" + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + } catch (e) { + Utils.info("SetOverlayEnabledModuleNameIsNull callback catch" + JSON.stringify(e)); + expect(e.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /* + * @tc.number: SUB_BMS_APPINFO_OVERLAY_0008 + * @tc.name: GetTargetOverlayModuleInfosModuleNameNotInstall + * @tc.desc: The query fails when the incoming moduleName is not installed + */ + it('GetTargetOverlayModuleInfosModuleNameNotInstall', 0, async function (done) { + await overlay.getTargetOverlayModuleInfos(MODULE_NAME1).then(data => { + Utils.info("GetTargetOverlayModuleInfosModuleNameNotInstall result" + JSON.stringify(data)); + expect().assertFail(); + }).catch(err => { + Utils.info("GetTargetOverlayModuleInfosModuleNameNotInstall fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_INSTALL); + }); + + overlay.getTargetOverlayModuleInfos(MODULE_NAME1, (err,data) => { + Utils.info("GetTargetOverlayModuleInfosModuleNameNotInstall result" + JSON.stringify(data)); + Utils.info("GetTargetOverlayModuleInfosModuleNameNotInstall fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_INSTALL); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_OVERLAY_0009 + * @tc.name: GetTargetOverlayModuleInfosModuleNameIsOverlay + * @tc.desc: Failed to set when the incoming moduleName is overlay + */ + it('GetTargetOverlayModuleInfosModuleNameIsOverlay', 0, async function (done) { + await overlay.getTargetOverlayModuleInfos(MODULE_NAME2).then(data => { + Utils.info("GetTargetOverlayModuleInfosModuleNameIsOverlay result" + JSON.stringify(data)); + expect().assertFail(); + }).catch(err => { + Utils.info("GetTargetOverlayModuleInfosModuleNameIsOverlay fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_IS_OVERLAY); + }); + + overlay.getTargetOverlayModuleInfos(MODULE_NAME2, (err,data) => { + Utils.info("GetTargetOverlayModuleInfosModuleNameIsOverlay result" + JSON.stringify(data)); + Utils.info("GetTargetOverlayModuleInfosModuleNameIsOverlay fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_IS_OVERLAY); + done(); + }); + }) + }) +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/List.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2803b3d08f99a359be31591bfe4dfc479d21051c --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import SetOverlayEnabled from './SetOverlayEnabled.test.ets'; +import GetOverlayModuleInfo from './GetOverlayModuleInfo.test.ets'; +import GetTargetOverlayModuleInfos from './GetTargetOverlayModuleInfos.test.ets'; + +export default function testsuite() { + SetOverlayEnabled(); + GetOverlayModuleInfo(); + GetTargetOverlayModuleInfos(); +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/SetOverlayEnabled.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/SetOverlayEnabled.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..69a21441d6ca173e9e5bbb33fcf2a3bbc517bf12 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/SetOverlayEnabled.test.ets @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impligetProfileByAbilityEmptyAbilityCalled. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import overlay from '@ohos.bundle.overlay'; +import Utils from "./Utils"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" + +const MODULE_NAME = "testModule"; +const MODULE_NAME1 = "test1"; +const ERROR_INCOMING_MODULE_NAME_NOT_INSTALL = 17700002; +const ERROR_INCOMING_MODULE_NAME_NOT_OVERLAY = 17700033; +const ERROR_CODE = 401; + +export default function setOverlayEnabled() { + describe('setOverlayEnabled', function () { + /* + * @tc.number: SUB_BMS_OVERLAY_ENABLED_0001 + * @tc.name: SetOverlayEnabledModuleNameIsNull + * @tc.desc: Failed to set when the incoming moduleName is empty + */ + it('SetOverlayEnabledModuleNameIsNull', 0, async function (done) { + try { + await overlay.setOverlayEnabled("", true).then(data => { + console.info("SetOverlayEnabledModuleNameIsNull result1111" + JSON.stringify(data)) + Utils.info("SetOverlayEnabledModuleNameIsNull result" + JSON.stringify(data)); + expect().assertFail(); + }).catch(err => { + Utils.info("SetOverlayEnabledModuleNameIsNull fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_CODE); + }); + } catch (e) { + Utils.info("SetOverlayEnabledModuleNameIsNull catch" + JSON.stringify(e)); + expect(e.code).assertEqual(ERROR_CODE); + } + + try { + overlay.setOverlayEnabled("", true, (err,data) => { + Utils.info("SetOverlayEnabledModuleNameIsNull result" + JSON.stringify(data)); + Utils.info("SetOverlayEnabledModuleNameIsNull fail" + JSON.stringify(err)); + expect().assertFail(); + done(); + }); + } catch (e) { + Utils.info("SetOverlayEnabledModuleNameIsNull callback catch" + JSON.stringify(e)); + expect(e.code).assertEqual(ERROR_CODE); + done(); + } + }) + + /* + * @tc.number: SUB_BMS_OVERLAY_ENABLED_0005 + * @tc.name: SetOverlayEnabledModuleNameNotInstall + * @tc.desc: Failed to set when the incoming moduleName is not installed + */ + it('SetOverlayEnabledModuleNameNotInstall', 0, async function (done) { + await overlay.setOverlayEnabled(MODULE_NAME1, true).then(data => { + Utils.info("SetOverlayEnabledModuleNameNotInstall result" + JSON.stringify(data)); + expect().assertFail(); + }).catch(err => { + Utils.info("SetOverlayEnabledModuleNameNotInstall fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_INSTALL); + }); + + overlay.setOverlayEnabled(MODULE_NAME1, true, (err,data) => { + Utils.info("SetOverlayEnabledModuleNameNotInstall result" + JSON.stringify(data)); + Utils.info("SetOverlayEnabledModuleNameNotInstall fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_INSTALL); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_OVERLAY_ENABLED_0006 + * @tc.name: SetOverlayEnabledModuleNameIsNotOverlay + * @tc.desc: Failed to set when the incoming moduleName is not overlay + */ + it('SetOverlayEnabledModuleNameIsNotOverlay', 0, async function (done) { + await overlay.setOverlayEnabled(MODULE_NAME, true).then(data => { + Utils.info("SetOverlayEnabledModuleNameIsNotOverlay result" + JSON.stringify(data)); + expect().assertFail(); + }).catch(err => { + Utils.info("SetOverlayEnabledModuleNameIsNotOverlay fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_OVERLAY); + }); + + overlay.setOverlayEnabled(MODULE_NAME, true, (err,data) => { + Utils.info("SetOverlayEnabledModuleNameIsNotOverlay result" + JSON.stringify(data)); + Utils.info("SetOverlayEnabledModuleNameIsNotOverlay fail" + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_INCOMING_MODULE_NAME_NOT_OVERLAY); + done(); + }); + }) + }) +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/Utils.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..7609914ba8e464d002f847ee3f7d3cc0f339250d --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/ets/test/Utils.ets @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import hiLog from '@ohos.hilog'; + +export default class Utils { + + static info(str) { + hiLog.info(0 , "BMSTEST" , str); + } + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout((data) => { + resolve(data) + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } +} + + + + diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/module.json b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..8fa31f274747ef1c9f6cf39dad893ed7346ce908 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/module.json @@ -0,0 +1,379 @@ +{ + "module": { + "name": "testModule", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:testModule_entry_dsc", + "mainElement": "ohos.acts.bundle.overlay.test.MainAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ], + "abilities": [ + { + "name": "ohos.acts.bundle.overlay.test.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "singleton", + "orientation": "portrait", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ], + "metadata": [ + { + "name": "ohos.ability.form", + "value": "", + "resource": "$profile:shortcuts_config" + }, + { + "name": "ohos.ability.form1", + "value": "", + "resource": "$profile:form_config" + }, + { + "name": "ohos.ability.form2", + "value": "", + "resource": "@profile:form_config" + }, + { + "name": "ohos.ability.form3", + "value": "", + "resource": "$profile:form_config1" + }, + { + "name": "ohos.ability.form4", + "value": "", + "resource": "$profile:invalid" + } + ] + }, + { + "name": "ohos.acts.bundle.overlay.test.MainAbility1", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "standard", + "orientation": "landscape", + "skills": [] + }, + { + "name": "ohos.acts.bundle.overlay.test.MainAbility2", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "landscape_inverted", + "skills": [] + }, + { + "name": "ohos.acts.bundle.overlay.test.MainAbility3", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "portrait_inverted", + "skills": [] + }, + { + "name": "ohos.acts.bundle.overlay.test.MainAbility4", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "auto_rotation", + "skills": [] + }, + { + "name": "ohos.acts.bundle.overlay.test.MainAbility5", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "auto_rotation_landscape", + "skills": [] + }, + { + "name": "ohos.acts.bundle.overlay.test.MainAbility6", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "auto_rotation_portrait", + "skills": [] + }, + { + "name": "ohos.acts.bundle.overlay.test.MainAbility7", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "auto_rotation_restricted", + "skills": [] + }, + { + "name": "ohos.acts.bundle.overlay.test.MainAbility8", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "auto_rotation_landscape_restricted", + "skills": [] + }, + { + "name": "ohos.acts.bundle.overlay.test.MainAbility9", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "auto_rotation_portrait_restricted", + "skills": [] + }, + { + "name": "ohos.acts.bundle.overlay.test.MainAbility10", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:testModule_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "launchType": "specified", + "orientation": "locked", + "skills": [] + } + ], + "extensionAbilities": [ + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "metadata": [ + { + "name": "ohos.extension.form", + "value": "", + "resource": "$profile:shortcuts_config" + }, + { + "name": "ohos.extension.form1", + "value": "", + "resource": "$profile:form_config" + }, + { + "name": "ohos.extension.form2", + "value": "", + "resource": "@profile:form_config" + }, + { + "name": "ohos.extension.form3", + "value": "", + "resource": "$profile:form_config1" + }, + { + "name": "ohos.extension.form4", + "value": "", + "resource": "$profile:invalid" + } + ], + "name": "Form", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "form", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "Form1", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "form", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "workScheduler", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "workScheduler", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "inputMethod", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "inputMethod", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "accessibility", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "accessibility", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "fileShare", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "fileShare", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "staticSubscriber", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "staticSubscriber", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "wallpaper", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "wallpaper", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "backup", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "backup", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "window", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "window", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "enterpriseAdmin", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "enterpriseAdmin", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "thumbnail", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "thumbnail", + "visible": true + }, + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "label": "$string:entry_label", + "name": "preview", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "preview", + "visible": true + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO", + "reason": "$string:permission_reason", + "usedScene": { + "abilities": ["MainAbility"], + "when": "always" + } + }, + { + "name": "ohos.permission.READ_CALENDAR", + "reason": "$string:permission_reason", + "usedScene": { + "abilities": ["MainAbility"], + "when": "inuse" + } + } + ], + "metadata": [ + { + "name": "MetaData1", + "value": "MetaDataValue", + "resource": "$profile:shortcuts_config" + } + ] + } +} diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/element/string.json b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a4e9ba5b8d282aa4e86eb9389bf7c535226fd1c4 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,44 @@ +{ + "string": [ + { + "name": "testModule_entry_dsc", + "value": "i am an entry for testModule" + }, + { + "name": "testModule_entry_main", + "value": "the testModule entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + }, + { + "name": "form_FormAbility_desc", + "value": "form_description" + }, + { + "name": "form_FormAbility_label", + "value": "form_label" + }, + { + "name": "permission_reason", + "value": "Need permission" + } + ] +} diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/media/icon.png b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/media/icon.png differ diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/form_config.json b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/form_config.json new file mode 100644 index 0000000000000000000000000000000000000000..e892d44722d9e5b09ff78cb069ccc15d1fac872e --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/form_config.json @@ -0,0 +1,6 @@ +{ + "src": [ + "MainAbility/pages/index/index", + "MainAbility/pages/second/second" + ] +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/form_config1.txt b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/form_config1.txt new file mode 100644 index 0000000000000000000000000000000000000000..32f9ff7dc213b28017875b2e4679071350a74d1d --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/form_config1.txt @@ -0,0 +1 @@ +{"src": ["MainAbility/pages/index/index","MainAbility/pages/second/second"]} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/invalid.txt b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/invalid.txt new file mode 100644 index 0000000000000000000000000000000000000000..cdca51a17bcbc5128c3b424ef9467ecd68b98737 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/invalid.txt @@ -0,0 +1,5 @@ +{ + "src": [ + "MainAbility/pages/index/index", + "MainAbility/pages/second/second" +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/main_pages.json b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..02221db61d317863114ff0ca4dd2b33586abff12 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "MainAbility/pages/index/index", + "MainAbility/pages/second/second" + ] +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/shortcuts_config.json b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/shortcuts_config.json new file mode 100644 index 0000000000000000000000000000000000000000..02221db61d317863114ff0ca4dd2b33586abff12 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/entry/src/main/resources/base/profile/shortcuts_config.json @@ -0,0 +1,6 @@ +{ + "src": [ + "MainAbility/pages/index/index", + "MainAbility/pages/second/second" + ] +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/signature/openharmony_sx.p7b b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..8da769dd128eb963811a16a46f1168eb500cf789 Binary files /dev/null and b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanageroverlaytest/signature/openharmony_sx.p7b differ diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets index 684f45db07b845a6e7fcf5835533eb5c33b47e1c..e94ffbcc20b186c587158dc0281f9f9bfb091365 100755 --- a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets @@ -19,6 +19,7 @@ import getBundleInfoForSelf from './GetBundleInfoForSelf.test.ets'; import getSecondModuleTest from './GetSecondModule.test.ets'; import isDefaultApplicationTest from './IsDefaultApplication.test.ets'; import PublicApiEightTest from './PublicApiEightTest.test.ets'; +import PublicApiNineTest from './PublicApiNineTest.test.ets'; export default function testsuite() { getProfileByAbility(); @@ -27,4 +28,5 @@ export default function testsuite() { getSecondModuleTest(); isDefaultApplicationTest(); PublicApiEightTest(); + PublicApiNineTest(); } \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/PublicApiNineTest.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/PublicApiNineTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..701935567f8cc42cfb56871b233f699d7cca6663 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbundlemanagerstagetest/entry/src/main/ets/test/PublicApiNineTest.test.ets @@ -0,0 +1,113 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or impligetProfileByAbilityEmptyAbilityCalled. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import bundle from '@ohos.bundle.bundleManager'; +import defaultAppMgr from '@ohos.bundle.defaultAppManager'; +import util from "./Utils"; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium"; + +const BUNDLE_NAME = "ohos.acts.bundle.stage.test"; +const MODULE_NAME = "testModule"; +const METADATA_NAME = "ohos.ability.form"; +const METADATA_NAME1 = "ohos.extension.form1"; +const ABILITY_NAME = "ohos.acts.bundle.stage.test.MainAbility"; +const ABILITY_NAME1 = "Form"; +const PROFILE_JSON_STRING = "{\"src\":[\"MainAbility/pages/index/index\",\"MainAbility/pages/second/second\"]}"; + +export default function PublicApiNineTest() { + describe('PublicApiNineTest', function () { + + /* + * @tc.number: SUB_BMS_SYSTEMAPI_RUNNIING_0069 + * @tc.name: getBundleInfoForSelfProTest + * @tc.desc: Test getBundleInfoForSelf of API9 in version9 normal project + */ + it('getBundleInfoForSelfProTest', 0, async function (done) { + await bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_DEFAULT).then(data => { + util.info("getBundleInfoForSelfPro" + JSON.stringify(data)); + expect(data.name).assertEqual(BUNDLE_NAME); + }).catch(err => { + util.info("getBundleInfoForSelf fail" + JSON.stringify(err)); + expect(err).assertFail(); + }) + bundle.getBundleInfoForSelf(bundle.BundleFlag.GET_BUNDLE_INFO_DEFAULT, (err, data) => { + expect(data.name).assertEqual(BUNDLE_NAME); + expect(err).assertEqual(null); + done(); + }) + }); + + /* + * @tc.number: SUB_BMS_SYSTEMAPI_RUNNIING_0070 + * @tc.name: getProfileByAbilityTest + * @tc.desc: Test getProfileByAbility of API9 in version9 normal project + */ + it('getProfileByAbilityTest', 0, async function (done) { + await bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME).then(data => { + util.info('getProfileByAbility promise data is: ' + JSON.stringify(data)); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + }).catch(err => { + util.info('getProfileByAbility failed. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + }) + bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME, (err, data) => { + util.info('getProfileByAbility failed. Cause: ' + JSON.stringify(err)); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + done(); + }) + }); + + /* + * @tc.number: SUB_BMS_SYSTEMAPI_RUNNIING_0071 + * @tc.name: getProfileByExtensionAbilityTest + * @tc.desc: Test getProfileByExtensionAbility of API9 in version9 normal project + */ + it('getProfileByExtensionAbilityPromise', 0, async function (done) { + await bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME1, METADATA_NAME1).then(data => { + util.info('getProfileByExtensionAbility promise data is: ' + JSON.stringify(data)); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + }).catch(err => { + util.info('getProfileByExtensionAbility failed. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + }) + bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME1, METADATA_NAME1, (err, data) => { + util.info('getProfileByExtensionAbility failed. Cause: ' + JSON.stringify(err)); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + done(); + }) + }); + + /** + * @tc.number: SUB_BMS_SYSTEMAPI_RUNNIING_0072 + * @tc.name: isDefaultApplicationTest + * @tc.desc: Test isDefaultApplication of API9 in version9 normal project + */ + it('isDefaultApplication_0100', 0, async function (done) { + await defaultAppMgr.isDefaultApplication(defaultAppMgr.ApplicationType.IMAGE).then(data => { + expect(data).assertFalse() + }).catch(err => { + expect().assertFail(); + }) + defaultAppMgr.isDefaultApplication(defaultAppMgr.ApplicationType.IMAGE, (err, data) => { + util.info("isDefaultApplication_0100 data--- " + data) + util.info("isDefaultApplication_0100 err--- " + err) + expect(data).assertFalse() + expect(err).assertEqual(null) + done() + }) + }); + + }) +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/AppScope/app.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..c0f0ddca54d89596fc019a45040b528314a39ca7 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"ohos.acts.bundle.overlay.test", + "vendor":"huawei", + "versionCode":1000000, + "versionName":"1.0.0", + "debug":false, + "icon":"$media:icon", + "label":"$string:app_name", + "description":"$string:description_application", + "distributedNotificationEnabled":true, + "keepAlive":true, + "singleUser":true, + "minAPIVersion":9, + "targetAPIVersion":9, + "car":{ + "apiCompatibleVersion":9, + "singleUser":false + } + } +} diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/AppScope/resources/base/element/string.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/BUILD.gn b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f9b25070e3c01cc9eea89b87d4fdce1b246cb96e --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/BUILD.gn @@ -0,0 +1,42 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_hap_assist_suite("bmsOverlayDemo") { + hap_profile = "entry/src/main/module.json" + hap_name = "bmsOverlayDemo" + subsystem_name = "bundlemanager" + part_name = "bundle_framework" + testonly = true + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" +} + +ohos_app_scope("bmsoverlaydemo_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("hjs_demo_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":bmsoverlaydemo_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/Test.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..26909f2889de98a479f076f87725fed805c7a343 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/Test.json @@ -0,0 +1,4 @@ +{ + "description": "Configuration for hjunit demo Tests", +} + diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/Application/AbilityStage.ts b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..cbcc939ff5d038c8e22947c2f0186d3407e691bc --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,9 @@ +import AbilityStage from "@ohos.app.ability.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/FormAbility/FormAbility.ts b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/FormAbility/FormAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..d443631109f5f73817ec907b36c1b7a3d353d357 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/FormAbility/FormAbility.ts @@ -0,0 +1,37 @@ +import FormExtension from '@ohos.app.form.FormExtensionAbility'; +import formBindingData from '@ohos.application.formBindingData'; +import formInfo from '@ohos.application.formInfo'; + +export default class FormAbility extends FormExtension { + onCreate(want) { + // Called to return a FormBindingData object. + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormal(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + + onUpdate(formId) { + // Called to notify the form provider to update a specified form. + } + + onVisibilityChange(newStatus) { + // Called when the form provider receives form events from the system. + } + + onEvent(formId, message) { + // Called when a specified message event defined by the form provider is triggered. + } + + onDestroy(formId) { + // Called to notify the form provider that a specified form has been destroyed. + } + + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } +}; \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/MainAbility/MainAbility.ts b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..266fcd85946409e0f8652dbb84fe4830200f35bc --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,36 @@ +import Ability from '@ohos.app.ability.UIAbility' + +export default class MainAbility extends Ability { + onCreate(want,launchParam){ + // Ability is creating, initialize resources for this ability + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/ServiceAbility/FormAbility.ts b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/ServiceAbility/FormAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..d443631109f5f73817ec907b36c1b7a3d353d357 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/ServiceAbility/FormAbility.ts @@ -0,0 +1,37 @@ +import FormExtension from '@ohos.app.form.FormExtensionAbility'; +import formBindingData from '@ohos.application.formBindingData'; +import formInfo from '@ohos.application.formInfo'; + +export default class FormAbility extends FormExtension { + onCreate(want) { + // Called to return a FormBindingData object. + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormal(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + + onUpdate(formId) { + // Called to notify the form provider to update a specified form. + } + + onVisibilityChange(newStatus) { + // Called when the form provider receives form events from the system. + } + + onEvent(formId, message) { + // Called when a specified message event defined by the form provider is triggered. + } + + onDestroy(formId) { + // Called to notify the form provider that a specified form has been destroyed. + } + + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } +}; \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/pages/index/index.ets b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7974e5d93b5154d6fdf9609f18c2168ff4fd7d60 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import file from '@system.file'; + +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" +import testsuite from "../../test/List.test.ets" + + +@Entry +@Component +struct Index { + + aboutToAppear(){ + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/pages/second/second.ets b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..1c1c727ff11ecc97909f482c35268db87ae23bb4 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/pages/second/second.ets @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/test/List.test.ets b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..193419242c9869f76b7cb16e2999f5d76ec6da9c --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +export default function testsuite(context) { + + +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/module.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..d0bc5fa85a75b04cbb2ef63125a5f927e8e014e6 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/module.json @@ -0,0 +1,25 @@ +{ + "module": { + "name": "stage1", + "type": "feature", + "targetModuleName": "entry1", + "targetPriority": 1, + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "metadata": [ + { + "name": "ArkTSPartialUpdate", + "value": "false" + } + ] + } +} diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/resources/base/element/string.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c9962d9e060b2701436e65408ad934b871cd1867 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/resources/base/element/string.json @@ -0,0 +1,40 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + }, + { + "name": "form_FormAbility_desc", + "value": "form_description" + }, + { + "name": "form_FormAbility_label", + "value": "form_label" + } + ] +} diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/resources/base/media/icon.png b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/resources/base/media/icon.png differ diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/resources/base/profile/form_config.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/resources/base/profile/form_config.json new file mode 100644 index 0000000000000000000000000000000000000000..4dfa0a89fba365ef2240e563cef1f6b1b884c937 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/resources/base/profile/form_config.json @@ -0,0 +1,77 @@ +{ + "forms": [ + { + "isDefault": true, + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "widget", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "isDefault": true, + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "widget1", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "1*2", + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "isDefault": true, + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "widget2", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "isDefault": true, + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "widget3", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + } + ] +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/resources/base/profile/main_pages.json b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/signature/openharmony_sx.p7b b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..8da769dd128eb963811a16a46f1168eb500cf789 Binary files /dev/null and b/bundlemanager/bundle_standard/bundlemanager/sceneProject/bmsoverlaydemo/signature/openharmony_sx.p7b differ