diff --git a/bundle.json b/bundle.json index e70d171211f4f99e298f811f734ed1e713197bb0..856987ee524e4e0148ec34b78e48a356bb7496e2 100644 --- a/bundle.json +++ b/bundle.json @@ -33,7 +33,8 @@ "//test/testfwk/developer_test/examples/calculator/test:benchmarktest", "//test/testfwk/developer_test/examples/detector/test:unittest", "//test/testfwk/developer_test/examples/sleep/test:performance", - "//test/testfwk/developer_test/examples/distributedb/test:distributedtest" + "//test/testfwk/developer_test/examples/distributedb/test:distributedtest", + "//test/testfwk/developer_test/examples/stagetest/actsbundlemanagerstagetest:unittest" ] } } diff --git a/examples/stagetest/actsbundlemanagerstagetest/AppScope/app.json b/examples/stagetest/actsbundlemanagerstagetest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..c971f6f40d542a5a68b731f3f660028606322dce --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"ohos.acts.bundle.stage.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":8, + "targetAPIVersion":8, + "car":{ + "apiCompatibleVersion":8, + "singleUser":false + } + } +} diff --git a/examples/stagetest/actsbundlemanagerstagetest/AppScope/resources/base/element/string.json b/examples/stagetest/actsbundlemanagerstagetest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/BUILD.gn b/examples/stagetest/actsbundlemanagerstagetest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ea32b94ca0531dece4325141fbd840c21a86ea50 --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/BUILD.gn @@ -0,0 +1,47 @@ +# 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("//build/test.gni") + +want_output_path = "developertest/stage_test" + +ohos_js_stage_unittest("ActsBundleMgrStageEtsTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actbmsstageetstest_js_assets", + ":actbmsstageetstest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsBundleMgrStageEtsTest" + subsystem_name = "developertest" + part_name = "stage_test" + module_out_path = want_output_path +} +ohos_app_scope("actbmsstageetstest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} +ohos_js_assets("actbmsstageetstest_js_assets") { + source_dir = "entry/src/main/ets" +} +ohos_resources("actbmsstageetstest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":actbmsstageetstest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} +group("unittest") { + testonly = true + deps = [] + deps += [ ":ActsBundleMgrStageEtsTest" ] +} diff --git a/examples/stagetest/actsbundlemanagerstagetest/Test.json b/examples/stagetest/actsbundlemanagerstagetest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..1b848ca2d81e2411245eab11aebda1c40c2a49e4 --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/Test.json @@ -0,0 +1,27 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "180000", + "bundle-name": "ohos.acts.bundle.stage.test", + "module-name": "testModule", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [ + { + "test-file-name": [ + "ActsBundleMgrStageEtsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "teardown-command":[ + "bm uninstall -n ohos.acts.bundle.stage.test" + ] + } + ] +} + diff --git a/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/Application/AbilityStage.ts b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..cbcc939ff5d038c8e22947c2f0186d3407e691bc --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/FormAbility/FormAbility.ts b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/FormAbility/FormAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..d443631109f5f73817ec907b36c1b7a3d353d357 --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/MainAbility/MainAbility.ts b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..2fb66add2d57337f9e6a8d6367842b895b573afc --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/MainAbility/pages/index/index.ets b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..f172d89b07521c2a1991ab441e99479f72823209 --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/MainAbility/pages/second/second.ets b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/MainAbility/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/ServiceAbility/FormAbility.ts b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/ServiceAbility/FormAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..d443631109f5f73817ec907b36c1b7a3d353d357 --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/TestAbility/TestAbility.ts b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..3e2d601de1553cc7d790ee83b23414b26a47913b --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/TestAbility/pages/index.ets b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..3149248aff33bcf98aa3bd3c3f65c003ab80df38 --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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.stage.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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/test/GetProfileByAbility.test.ets b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/test/GetProfileByAbility.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8a217ef8855145542c201c81f071b03397ee634c --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/test/GetProfileByAbility.test.ets @@ -0,0 +1,73 @@ +/** + * 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 manager from '@ohos.bundle.bundleManager'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" + +const MODULE_NAME = "testModule" +const MODULE_NAME_TEST = "testModule1" +const ABILITY_NAME = "ohos.acts.bundle.stage.test.MainAbility" +const ABILITY_NAME1 = "ohos.acts.bundle.stage.test.MainAbility1" +const ABILITY_NAME_TEST = "ohos.acts.bundle.stage.test.MainAbilityTest" +const METADATA_NAME = "ohos.ability.form" +const METADATA_NAME1 = "ohos.ability.form1" +const METADATA_NAME2 = "ohos.ability.form2" +const METADATA_NAME3 = "ohos.ability.form3" +const METADATA_NAME4 = "ohos.ability.form4" +const METADATA_NAME_TEST = "ohos.test.form" +const PROFILE_JSON_STRING = "{\"src\":[\"MainAbility/pages/index/index\",\"MainAbility/pages/second/second\"]}" +const ERROR_ABILITY_NOT_EXIST = 17700003 +const ERROR_PROFILE_NOT_EXIST = 17700024 +const ERROR_MODULE_NOT_EXIST = 17700002 + +export default function getProfileByAbility() { + describe('getProfileByAbility', function () { + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0011 + * @tc.name: getProfileByAbilityInvalidModulePro + * @tc.desc: Check the invalid moduleName (by promise) + * @tc.level 0 + */ + it('getProfileByAbilityInvalidModulePro', 0, async function (done) { + await manager.getProfileByAbility(MODULE_NAME_TEST, ABILITY_NAME, METADATA_NAME).then(data => { + console.info("getProfileByAbilityInvalidModulePro success" + JSON.stringify(data)) + expect(data).assertFail() + done() + }).catch(err => { + console.info("getProfileByAbilityInvalidModulePro failed" + JSON.stringify(err)) + expect(err.code).assertEqual(ERROR_ABILITY_NOT_EXIST) + done() + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0015 + * @tc.name: getProfileByAbilityEmptyModulePro + * @tc.desc: Check the empty moduleName (by promise) + * @tc.level 0 + */ + it('getProfileByAbilityEmptyModulePro', 0, async function (done) { + await manager.getProfileByAbility('', ABILITY_NAME, METADATA_NAME).then(data => { + console.info("getProfileByAbilityEmptyModulePro success" + JSON.stringify(data)) + expect(data).assertFail() + done() + }).catch(err => { + console.info("getProfileByAbilityEmptyModulePro failed" + JSON.stringify(err)) + expect(err.code).assertEqual(ERROR_MODULE_NOT_EXIST) + done() + }) + }) + }) +} \ No newline at end of file diff --git a/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..01f76813bb25dcbfd29e71b625b399d9fa74cbcd --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,23 @@ +/* + * 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 getProfileByAbility from './GetProfileByAbility.test.ets'; +import getProfileByExtensionAbility from './GetProfileByExtensionAbility.test.ets'; +import getBundleInfoForSelf from './GetBundleInfoForSelf.test.ets'; +import getSecondModuleTest from './GetSecondModule.test.ets'; + +export default function testsuite() { + getProfileByAbility(); +} \ No newline at end of file diff --git a/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/test/Utils.ets b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..f3b5fe7f6934788d3560d3170931643879f18d4c --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/ets/test/Utils.ets @@ -0,0 +1,30 @@ +/** + * 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 class Utils { + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout((data) => { + resolve(data) + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } +} + + + + diff --git a/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/module.json b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..b514f056d5ddad6cd78356f1d655e0e58c7c6ef9 --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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.stage.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.stage.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.stage.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.stage.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.stage.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.stage.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.stage.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.stage.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.stage.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.stage.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.stage.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.stage.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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/element/string.json b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a4e9ba5b8d282aa4e86eb9389bf7c535226fd1c4 --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/media/icon.png b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/media/icon.png differ diff --git a/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/profile/form_config.json b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/profile/form_config.json new file mode 100644 index 0000000000000000000000000000000000000000..e892d44722d9e5b09ff78cb069ccc15d1fac872e --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/profile/form_config1.txt b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/profile/form_config1.txt new file mode 100644 index 0000000000000000000000000000000000000000..32f9ff7dc213b28017875b2e4679071350a74d1d --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/profile/invalid.txt b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/profile/invalid.txt new file mode 100644 index 0000000000000000000000000000000000000000..cdca51a17bcbc5128c3b424ef9467ecd68b98737 --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/profile/main_pages.json b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..02221db61d317863114ff0ca4dd2b33586abff12 --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/profile/shortcuts_config.json b/examples/stagetest/actsbundlemanagerstagetest/entry/src/main/resources/base/profile/shortcuts_config.json new file mode 100644 index 0000000000000000000000000000000000000000..02221db61d317863114ff0ca4dd2b33586abff12 --- /dev/null +++ b/examples/stagetest/actsbundlemanagerstagetest/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/examples/stagetest/actsbundlemanagerstagetest/signature/openharmony_sx.p7b b/examples/stagetest/actsbundlemanagerstagetest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..c4fcd77fde1e40461902b9c5cea99c1b1e1d1851 Binary files /dev/null and b/examples/stagetest/actsbundlemanagerstagetest/signature/openharmony_sx.p7b differ