diff --git a/bundlemanager/bundle_standard/bundlemanager/BUILD.gn b/bundlemanager/bundle_standard/bundlemanager/BUILD.gn index d8e793c9bab5190260fb156f02e1e27f3b42548b..cbe48a1040a3453f31bea2826489612f6c88a2a0 100644 --- a/bundlemanager/bundle_standard/bundlemanager/BUILD.gn +++ b/bundlemanager/bundle_standard/bundlemanager/BUILD.gn @@ -18,6 +18,7 @@ group("bundlemanager") { if (is_standard_system) { deps = [ "actsbmsaccesstokentest:ActsBmsAccessTokenTest", + "actsbmsbundlemanagerstagetest:ActsBmsBundleMgrStageEtsTest", "actsbmsetsmodulenametest:ActsBmsEtsModuleNameTest", "actsbmsetsunpermissiontest:ActsBmsEtsUnPermissionTest", "actsbmsgetinfostest:ActsBmsGetInfosTest", diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/AppScope/app.json b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/AppScope/app.json new file mode 100755 index 0000000000000000000000000000000000000000..c971f6f40d542a5a68b731f3f660028606322dce --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/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/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/AppScope/resources/base/element/string.json b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/AppScope/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/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/actsbmsbundlemanagerstagetest/BUILD.gn b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..47bb7942b687c6bb766773e92bec47f8389cef7f --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/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("ActsBmsBundleMgrStageEtsTest") { + hap_profile = "entry/src/main/module.json" + deps = [ + ":actbmsstageetstest_js_assets", + ":actbmsstageetstest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsBmsBundleMgrStageEtsTest" + subsystem_name = "bundlemanager" + part_name = "bundle_framework" +} + +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" +} diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/Test.json b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/Test.json new file mode 100755 index 0000000000000000000000000000000000000000..4de66a324433f172674158898e02da427b61b356 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/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": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [ + { + "test-file-name": [ + "ActsBmsBundleMgrStageEtsTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "teardown-command":[ + "bm uninstall -n ohos.acts.bundle.stage.test" + ] + } + ] +} + diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/Application/AbilityStage.ts b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100755 index 0000000000000000000000000000000000000000..51cb02ba3f5c7011c1cd433d07deebd47a195704 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,9 @@ +import AbilityStage from "@ohos.application.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/actsbmsbundlemanagerstagetest/entry/src/main/ets/FormAbility/FormAbility.ts b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/FormAbility/FormAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..2f94ce17654ff7562d7bc9878961bbab2219fe92 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/FormAbility/FormAbility.ts @@ -0,0 +1,37 @@ +import FormExtension from '@ohos.application.FormExtension'; +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/actsbmsbundlemanagerstagetest/entry/src/main/ets/MainAbility/MainAbility.ts b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..87b6463a2283b59f971ffea6a3011377c55bc1f3 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,36 @@ +import Ability from '@ohos.application.Ability' + +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/actsbmsbundlemanagerstagetest/entry/src/main/ets/MainAbility/pages/index/index.ets b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/MainAbility/pages/index/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..f172d89b07521c2a1991ab441e99479f72823209 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/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/actsbmsbundlemanagerstagetest/entry/src/main/ets/MainAbility/pages/second/second.ets b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/MainAbility/pages/second/second.ets new file mode 100755 index 0000000000000000000000000000000000000000..f9009a3e8567d1f4557ebc11dded54c7e27c0b0d --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/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/actsbmsbundlemanagerstagetest/entry/src/main/ets/ServiceAbility/FormAbility.ts b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/ServiceAbility/FormAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..2f94ce17654ff7562d7bc9878961bbab2219fe92 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/ServiceAbility/FormAbility.ts @@ -0,0 +1,37 @@ +import FormExtension from '@ohos.application.FormExtension'; +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/actsbmsbundlemanagerstagetest/entry/src/main/ets/TestAbility/TestAbility.ts b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/TestAbility/TestAbility.ts new file mode 100755 index 0000000000000000000000000000000000000000..fb7ef2b1e9e7573f5679e287d371c8acab61d2e8 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/TestAbility/TestAbility.ts @@ -0,0 +1,30 @@ +import Ability from '@ohos.application.Ability' + +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/actsbmsbundlemanagerstagetest/entry/src/main/ets/TestAbility/pages/index.ets b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100755 index 0000000000000000000000000000000000000000..b93567f962921124b282f78c8ef123965d1460c9 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/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/actsbmsbundlemanagerstagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100755 index 0000000000000000000000000000000000000000..3149248aff33bcf98aa3bd3c3f65c003ab80df38 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/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/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/test/GetProfileByAbility.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/test/GetProfileByAbility.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..5b84529d1b4722954c904f41551ab1e66c0de5e7 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/test/GetProfileByAbility.test.ets @@ -0,0 +1,410 @@ +/** + * 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 manager from '@ohos.bundle.bundleManager'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" + +const MODULE_NAME = "phone" +const MODULE_NAME_TEST = "phone1" +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() + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0017 + * @tc.name: getProfileByAbilityInvalidModuleCall + * @tc.desc: Check the invalid moduleName (by callback) + * @tc.level 0 + */ + it('getProfileByAbilityInvalidModuleCall', 0, async function (done) { + manager.getProfileByAbility(MODULE_NAME_TEST, ABILITY_NAME, METADATA_NAME, (err, data) => { + expect(err.code).assertEqual(ERROR_ABILITY_NOT_EXIST); + console.error('[getProfileByAbilityInvalidModuleCall]Operation failed. Cause: ' + JSON.stringify(err)); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0034 + * @tc.name: getProfileByAbilityEmptyModuleCall + * @tc.desc: Check the empty moduleName (by callback) + * @tc.level 0 + */ + it('getProfileByAbilityEmptyModuleCall', 0, async function (done) { + manager.getProfileByAbility('', ABILITY_NAME, METADATA_NAME, (err, data) => { + expect(err.code).assertEqual(ERROR_MODULE_NOT_EXIST); + console.error('[getProfileByAbilityEmptyModuleCall]Operation failed. Cause: ' + JSON.stringify(err)); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0012 + * @tc.name: getProfileByAbilityInvalidAbilityPro + * @tc.desc: Check the invalid abilityName (by promise) + * @tc.level 0 + */ + it('getProfileByAbilityInvalidAbilityPro', 0, async function (done) { + await manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME_TEST, METADATA_NAME).then(data => { + console.info("getProfileByAbilityInvalidAbilityPro success" + JSON.stringify(data)) + expect(data).assertFail() + done() + }).catch(err => { + console.info("getProfileByAbilityInvalidAbilityPro failed" + JSON.stringify(err)) + expect(err.code).assertEqual(ERROR_ABILITY_NOT_EXIST) + done() + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0029 + * @tc.name: getProfileByAbilityEmptyAbilityPro + * @tc.desc: Check the empty abilityName (by promise) + * @tc.level 0 + */ + it('getProfileByAbilityEmptyAbilityPro', 0, async function (done) { + await manager.getProfileByAbility(MODULE_NAME, '', METADATA_NAME).then(data => { + console.info("getProfileByAbilityEmptyAbilityPro success" + JSON.stringify(data)) + expect(data).assertFail() + done() + }).catch(err => { + console.info("getProfileByAbilityEmptyAbilityPro failed" + JSON.stringify(err)) + expect(err.code).assertEqual(ERROR_ABILITY_NOT_EXIST) + done() + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0022 + * @tc.name: getProfileByAbilityInvalidAbilityCall + * @tc.desc: Check the invalid abilityName (by callback) + * @tc.level 0 + */ + it('getProfileByAbilityInvalidAbilityCall', 0, async function (done) { + manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME_TEST, METADATA_NAME, (err, data) => { + expect(err.code).assertEqual(ERROR_ABILITY_NOT_EXIST); + console.error('[getProfileByAbilityInvalidAbilityCall]Operation failed. Cause: ' + JSON.stringify(err)); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0029 + * @tc.name: getProfileByAbilityEmptyAbilityCall + * @tc.desc: Check the empty abilityName (by callback) + * @tc.level 0 + */ + it('getProfileByAbilityEmptyAbilityCall', 0, async function (done) { + manager.getProfileByAbility(MODULE_NAME, '', METADATA_NAME, (err, data) => { + expect(err.code).assertEqual(ERROR_ABILITY_NOT_EXIST); + console.error('[getProfileByAbilityEmptyAbilityCall]Operation failed. Cause: ' + JSON.stringify(err)); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0024 + * @tc.name: getProfileByAbilityCallback + * @tc.desc: Check the valid metadataName (by callback) + * @tc.level 0 + */ + it('getProfileByAbilityCallback', 0, async function (done) { + manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME, (err, data) => { + console.info('[getProfileByAbilityCallback] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0026 + * @tc.name: getProfileByAbilityInvalidMetaDataCall + * @tc.desc: Check the invalid metadataName (by callback) + * @tc.level 0 + */ + it('getProfileByAbilityInvalidMetaDataCall', 0, async function (done) { + manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME_TEST, (err, data) => { + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + console.error('[getProfileByAbilityInvalidMetaDataCall]Operation failed. Cause: ' + JSON.stringify(err)); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0036 + * @tc.name: getProfileByAbilityEmptyMetaDataCall + * @tc.desc: Check the empty metadataName (by callback) + * @tc.level 0 + */ + it('getProfileByAbilityEmptyMetaDataCall', 0, async function (done) { + manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME, '', (err, data) => { + console.info('[getProfileByAbilityEmptyMetaDataCall] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + expect(typeof data[1]).assertEqual("string"); + expect(data[1]).assertEqual(PROFILE_JSON_STRING); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0002 + * @tc.name: getProfileByAbilityPromise + * @tc.desc: Check the valid metadataName (by promise) + * @tc.level 0 + */ + it('getProfileByAbilityPromise', 0, async function (done) { + await manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME).then(data => { + console.info('[getProfileByAbilityPromise] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + done(); + }).catch(err => { + console.error('[getProfileByAbilityPromise]Operation failed. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0004 + * @tc.name: getProfileByAbilityInvalidMetaDataPro + * @tc.desc: Check the invalid metadataName (by promise) + * @tc.level 0 + */ + it('getProfileByAbilityInvalidMetaDataPro', 0, async function (done) { + await manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME_TEST).then(data => { + console.info('[getProfileByAbilityInvalidMetaDataPro] getApplicationInfo callback data is: ' + JSON.stringify(data)); + done() + }).catch(err => { + console.error('[getProfileByAbilityInvalidMetaDataPro]Operation failed. Cause: ' + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0030 + * @tc.name: getProfileByAbilityEmptyMetaDataPro + * @tc.desc: Check the empty metadataName (by promise) + * @tc.level 0 + */ + it('getProfileByAbilityEmptyMetaDataPro', 0, async function (done) { + await manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME, '').then(data => { + console.info('[getProfileByAbilityEmptyMetaDataPro] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + expect(typeof data[1]).assertEqual("string"); + expect(data[1]).assertEqual(PROFILE_JSON_STRING); + done(); + }).catch(err => { + console.error('[getProfileByAbilityEmptyMetaDataPro]Operation failed. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0009 + * @tc.name: getProfileByAbilityNoMetaDataPro + * @tc.desc: without metadataName (by promise) + * @tc.level 0 + */ + it('getProfileByAbilityNoMetaDataPro', 0, async function (done) { + await manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME).then(data => { + console.info('[getProfileByAbilityNoMetaDataPro] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + expect(typeof data[1]).assertEqual("string"); + expect(data[1]).assertEqual(PROFILE_JSON_STRING); + done(); + }).catch(err => { + console.error('[getProfileByAbilityNoMetaDataPro]Operation failed. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0048 + * @tc.name: getProfileByAbilityNoProfilePro + * @tc.desc: no profile configured under the ability (by promise) + * @tc.level 0 + */ + it('getProfileByAbilityNoProfilePro', 0, async function (done) { + await manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME1).then(data => { + console.info('[getProfileByAbilityNoProfilePro] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(data).assertFail() + done(); + }).catch(err => { + console.error('[getProfileByAbilityNoProfilePro]Operation failed. Cause: ' + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0045 + * @tc.name: getProfileByAbilityNotPrefixPro + * @tc.desc: resource has no prefix '$profile:' (by promise) + * @tc.level 0 + */ + it('getProfileByAbilityNotPrefixPro', 0, async function (done) { + await manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME2).then(data => { + console.info('[getProfileByAbilityNotPrefixPro] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(data).assertFail() + done(); + }).catch(err => { + console.error('[getProfileByAbilityNotPrefixPro]Operation failed. Cause: ' + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0044 + * @tc.name: getProfileByAbilityNotPrefixCall + * @tc.desc: resource has no prefix '$profile:' (by callback) + * @tc.level 0 + */ + it('getProfileByAbilityNotPrefixCall', 0, async function (done) { + manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME2, (err, data) => { + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + console.error('[getProfileByAbilityNotPrefixCall]Operation failed. Cause: ' + JSON.stringify(err)); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0007 + * @tc.name: getProfileByAbilityNotSuffixPro + * @tc.desc: profile is .txt suffix (by promise) + * @tc.level 0 + */ + it('getProfileByAbilityNotSuffixPro', 0, async function (done) { + await manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME3).then(data => { + console.info('[getProfileByAbilityNotSuffixPro] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + done(); + }).catch(err => { + console.error('[getProfileByAbilityNotSuffixPro]Operation failed. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0040 + * @tc.name: getProfileByAbilityNotSuffixCall + * @tc.desc: profile is .txt suffix (by callback) + * @tc.level 0 + */ + it('getProfileByAbilityNotSuffixCall', 0, async function (done) { + manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME3, (err, data) => { + console.info('[getProfileByAbilityNotSuffixCall] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0008 + * @tc.name: getProfileByAbilityNoJsonPro + * @tc.desc: profile is invalid json format (by promise) + * @tc.level 0 + */ + it('getProfileByAbilityNoJsonPro', 0, async function (done) { + await manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME4).then(data => { + console.info('[getProfileByAbilityNoJsonPro] data is: ' + JSON.stringify(data)); + expect().assertFail(); + done(); + }).catch(err => { + console.error('[getProfileByAbilityNoJsonPro] Operation failed. Cause: ' + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0046 + * @tc.name: getProfileByAbilityNoJsonCall + * @tc.desc: profile is invalid json format (by callback) + * @tc.level 0 + */ + it('getProfileByAbilityNoJsonCall', 0, async function (done) { + manager.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME4, (err, data) => { + console.info('[getProfileByAbilityNoJsonCall] err: ' + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + done(); + }); + }) + }) +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/test/GetProfileByExtensionAbility.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/test/GetProfileByExtensionAbility.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..506c80b65bf937ec7b450d84f1d93b0c9428211d --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/test/GetProfileByExtensionAbility.test.ets @@ -0,0 +1,411 @@ +/** + * 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 manager from '@ohos.bundle.bundleManager'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "@ohos/hypium" + +const MODULE_NAME = "phone" +const MODULE_NAME_TEST = "phone1" +const ABILITY_NAME = "Form" +const ABILITY_NAME1 = "Form1" +const ABILITY_NAME_TEST = "FromTest" +const METADATA_NAME = "ohos.extension.form" +const METADATA_NAME1 = "ohos.extension.form1" +const METADATA_NAME2 = "ohos.extension.form2" +const METADATA_NAME3 = "ohos.extension.form3" +const METADATA_NAME4 = "ohos.extension.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 getProfileByExtensionAbility() { + describe('getProfileByExtensionAbility', function () { + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0011 + * @tc.name: getProfileByExtensionAbilityInvalidModulePro + * @tc.desc: Check the invalid moduleName (by promise) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityInvalidModulePro', 0, async function (done) { + await manager.getProfileByExtensionAbility(MODULE_NAME_TEST, ABILITY_NAME, METADATA_NAME).then(data => { + console.info("getProfileByExtensionAbilityInvalidModulePro success" + JSON.stringify(data)) + expect(data).assertFail() + done() + }).catch(err => { + console.info("getProfileByExtensionAbilityInvalidModulePro failed" + JSON.stringify(err)) + expect(err.code).assertEqual(ERROR_ABILITY_NOT_EXIST) + done() + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0015 + * @tc.name: getProfileByExtensionAbilityEmptyModulePro + * @tc.desc: Check the empty moduleName (by promise) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityEmptyModulePro', 0, async function (done) { + await manager.getProfileByExtensionAbility('', ABILITY_NAME, METADATA_NAME).then(data => { + console.info("getProfileByExtensionAbilityEmptyModulePro success" + JSON.stringify(data)) + expect(data).assertFail() + done() + }).catch(err => { + console.info("getProfileByExtensionAbilityEmptyModulePro failed" + JSON.stringify(err)) + expect(err.code).assertEqual(ERROR_MODULE_NOT_EXIST) + done() + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0017 + * @tc.name: getProfileByExtensionAbilityInvalidModuleCall + * @tc.desc: Check the invalid moduleName (by callback) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityInvalidModuleCall', 0, async function (done) { + manager.getProfileByExtensionAbility(MODULE_NAME_TEST, ABILITY_NAME, METADATA_NAME, (err, data) => { + expect(err.code).assertEqual(ERROR_ABILITY_NOT_EXIST); + console.error('[getProfileByExtensionAbilityInvalidModuleCall]Operation failed. Cause: ' + JSON.stringify(err)); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0034 + * @tc.name: getProfileByExtensionAbilityEmptyModuleCall + * @tc.desc: Check the empty moduleName (by callback) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityEmptyModuleCall', 0, async function (done) { + manager.getProfileByExtensionAbility('', ABILITY_NAME, METADATA_NAME, (err, data) => { + expect(err.code).assertEqual(ERROR_MODULE_NOT_EXIST); + console.error('[getProfileByExtensionAbilityEmptyModuleCall]Operation failed. Cause: ' + JSON.stringify(err)); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0012 + * @tc.name: getProfileByExtensionAbilityInvalidAbilityPro + * @tc.desc: Check the invalid abilityName (by promise) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityInvalidAbilityPro', 0, async function (done) { + await manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME_TEST, METADATA_NAME).then(data => { + console.info("getProfileByExtensionAbilityInvalidAbilityPro success" + JSON.stringify(data)) + expect(data).assertFail() + done() + }).catch(err => { + console.info("getProfileByExtensionAbilityInvalidAbilityPro failed" + JSON.stringify(err)) + expect(err.code).assertEqual(ERROR_ABILITY_NOT_EXIST) + done() + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0029 + * @tc.name: getProfileByExtensionAbilityEmptyAbilityPro + * @tc.desc: Check the empty abilityName (by promise) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityEmptyAbilityPro', 0, async function (done) { + await manager.getProfileByExtensionAbility(MODULE_NAME, '', METADATA_NAME).then(data => { + console.info("getProfileByExtensionAbilityEmptyAbilityPro success" + JSON.stringify(data)) + expect(data).assertFail() + done() + }).catch(err => { + console.info("getProfileByExtensionAbilityEmptyAbilityPro failed" + JSON.stringify(err)) + expect(err.code).assertEqual(ERROR_ABILITY_NOT_EXIST) + done() + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0022 + * @tc.name: getProfileByExtensionAbilityInvalidAbilityCall + * @tc.desc: Check the invalid abilityName (by callback) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityInvalidAbilityCall', 0, async function (done) { + manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME_TEST, METADATA_NAME, (err, data) => { + expect(err.code).assertEqual(ERROR_ABILITY_NOT_EXIST); + console.error('[getProfileByExtensionAbilityInvalidAbilityCall]Operation failed. Cause: ' + JSON.stringify(err)); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0029 + * @tc.name: getProfileByExtensionAbilityEmptyAbilityCall + * @tc.desc: Check the empty abilityName (by callback) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityEmptyAbilityCall', 0, async function (done) { + manager.getProfileByExtensionAbility(MODULE_NAME, '', METADATA_NAME, (err, data) => { + expect(err.code).assertEqual(ERROR_ABILITY_NOT_EXIST); + console.error('[getProfileByExtensionAbilityEmptyAbilityCall]Operation failed. Cause: ' + JSON.stringify(err)); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0024 + * @tc.name: getProfileByExtensionAbilityCallback + * @tc.desc: Check the valid metadataName (by callback) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityCallback', 0, async function (done) { + manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME, (err, data) => { + console.info('[getProfileByExtensionAbilityCallback] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0026 + * @tc.name: getProfileByExtensionAbilityInvalidMetaDataCall + * @tc.desc: Check the invalid metadataName (by callback) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityInvalidMetaDataCall', 0, async function (done) { + manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME_TEST, (err, data) => { + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + console.error('[getProfileByExtensionAbilityInvalidMetaDataCall]Operation failed. Cause: ' + JSON.stringify(err)); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0036 + * @tc.name: getProfileByExtensionAbilityEmptyMetaDataCall + * @tc.desc: Check the empty metadataName (by callback) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityEmptyMetaDataCall', 0, async function (done) { + manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, '', (err, data) => { + console.info('[getProfileByExtensionAbilityEmptyMetaDataCall] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + expect(typeof data[1]).assertEqual("string"); + expect(data[1]).assertEqual(PROFILE_JSON_STRING); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0002 + * @tc.name: getProfileByExtensionAbilityPromise + * @tc.desc: Check the valid metadataName (by promise) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityPromise', 0, async function (done) { + await manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME).then(data => { + console.info('[getProfileByExtensionAbilityPromise] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + done(); + }).catch(err => { + console.error('[getProfileByExtensionAbilityPromise]Operation failed. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0004 + * @tc.name: getProfileByExtensionAbilityInvalidMetaDataPro + * @tc.desc: Check the invalid metadataName (by promise) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityInvalidMetaDataPro', 0, async function (done) { + await manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME_TEST).then(data => { + console.info('[getProfileByExtensionAbilityInvalidMetaDataPro] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect().assertFail(); + done() + }).catch(err => { + console.error('[getProfileByExtensionAbilityInvalidMetaDataPro]Operation failed. Cause: ' + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0030 + * @tc.name: getProfileByExtensionAbilityEmptyMetaDataPro + * @tc.desc: Check the empty metadataName (by promise) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityEmptyMetaDataPro', 0, async function (done) { + await manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, '').then(data => { + console.info('[getProfileByExtensionAbilityEmptyMetaDataPro] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + expect(typeof data[1]).assertEqual("string"); + expect(data[1]).assertEqual(PROFILE_JSON_STRING); + done(); + }).catch(err => { + console.error('[getProfileByExtensionAbilityEmptyMetaDataPro]Operation failed. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0009 + * @tc.name: getProfileByExtensionAbilityNoMetaDataPro + * @tc.desc: without metadataName (by promise) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityNoMetaDataPro', 0, async function (done) { + await manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME).then(data => { + console.info('[getProfileByExtensionAbilityNoMetaDataPro] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + expect(data[0]).assertEqual(PROFILE_JSON_STRING); + expect(typeof data[1]).assertEqual("string"); + expect(data[1]).assertEqual(PROFILE_JSON_STRING); + done(); + }).catch(err => { + console.error('[getProfileByExtensionAbilityNoMetaDataPro]Operation failed. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0048 + * @tc.name: getProfileByExtensionAbilityNoProfilePro + * @tc.desc: no profile configured under the ability (by promise) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityNoProfilePro', 0, async function (done) { + await manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME1).then(data => { + console.info('[getProfileByExtensionAbilityNoProfilePro] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect().assertFail(); + done(); + }).catch(err => { + console.error('[getProfileByExtensionAbilityNoProfilePro]Operation failed. Cause: ' + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0045 + * @tc.name: getProfileByExtensionAbilityNotPrefixPro + * @tc.desc: resource has no prefix '$profile:' (by promise) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityNotPrefixPro', 0, async function (done) { + await manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME2).then(data => { + console.info('[getProfileByExtensionAbilityNotPrefixPro] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect().assertFail(); + done(); + }).catch(err => { + console.error('[getProfileByExtensionAbilityNotPrefixPro]Operation failed. Cause: ' + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0044 + * @tc.name: getProfileByExtensionAbilityNotPrefixCall + * @tc.desc: resource has no prefix '$profile:' (by callback) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityNotPrefixCall', 0, async function (done) { + manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME2, (err, data) => { + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + console.error('[getProfileByExtensionAbilityNotPrefixCall]Operation failed. Cause: ' + JSON.stringify(err)); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0007 + * @tc.name: getProfileByExtensionAbilityNotSuffixPro + * @tc.desc: profile is .txt suffix (by promise) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityNotSuffixPro', 0, async function (done) { + await manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME3).then(data => { + console.info('[getProfileByExtensionAbilityNotSuffixPro] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + done(); + }).catch(err => { + console.error('[getProfileByExtensionAbilityNotSuffixPro]Operation failed. Cause: ' + JSON.stringify(err)); + expect().assertFail(); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0040 + * @tc.name: getProfileByExtensionAbilityNotSuffixCall + * @tc.desc: profile is .txt suffix (by callback) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityNotSuffixCall', 0, async function (done) { + manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME3, (err, data) => { + console.info('[getProfileByExtensionAbilityNotSuffixCall] getApplicationInfo callback data is: ' + JSON.stringify(data)); + expect(Array.isArray(data)).assertTrue(); + expect(typeof data[0]).assertEqual("string"); + done(); + }); + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0008 + * @tc.name: getProfileByExtensionAbilityNoJsonPro + * @tc.desc: profile is invalid json format (by promise) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityNoJsonPro', 0, async function (done) { + await manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME4).then(data => { + console.info('[getProfileByExtensionAbilityNoJsonPro] data is: ' + JSON.stringify(data)); + expect().assertFail(); + done(); + }).catch(err => { + console.error('[getProfileByExtensionAbilityNoJsonPro] Operation failed. Cause: ' + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_QUERYMETAFILE_0046 + * @tc.name: getProfileByExtensionAbilityNoJsonCall + * @tc.desc: profile is invalid json format (by callback) + * @tc.level 0 + */ + it('getProfileByExtensionAbilityNoJsonCall', 0, async function (done) { + manager.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME4, (err, data) => { + console.info('[getProfileByExtensionAbilityNoJsonCall] err: ' + JSON.stringify(err)); + expect(err.code).assertEqual(ERROR_PROFILE_NOT_EXIST); + done(); + }); + }) + }) +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..9f75ecfa43762ceaab1ac9c2b3211e1908e8d02e --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,22 @@ +/* + * 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'; + +export default function testsuite() { + getProfileByAbility(); + getProfileByExtensionAbility(); +} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/module.json b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/module.json new file mode 100755 index 0000000000000000000000000000000000000000..7c6599d81198b57e5626ec40af99d0231d0ed72c --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/module.json @@ -0,0 +1,123 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "default" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ohos.acts.bundle.stage.test.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "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:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [] + } + ], + "extensionAbilities": [ + { + "description": "$string:form_description", + "descriptionId": 16777219, + "icon": "$media:icon", + "iconId": 16777225, + "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, + "name": "Form1", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "type": "form", + "visible": true + } + ] + } +} diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/element/string.json b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/element/string.json new file mode 100755 index 0000000000000000000000000000000000000000..c9962d9e060b2701436e65408ad934b871cd1867 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/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/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/media/icon.png b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/media/icon.png new file mode 100755 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/media/icon.png differ diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/profile/form_config.json b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/profile/form_config.json new file mode 100755 index 0000000000000000000000000000000000000000..e892d44722d9e5b09ff78cb069ccc15d1fac872e --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/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/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/profile/form_config1.txt b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/profile/form_config1.txt new file mode 100755 index 0000000000000000000000000000000000000000..77beb4dc531093a3800a53eb0afa76f313f55b87 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/profile/form_config1.txt @@ -0,0 +1 @@ +{"forms" :[{"colorMode" : "auto","defaultDimension" : "2*2","description" : "$string:16777219","formConfigAbility" : "ability://xxxxx","formVisibleNotify" : false,"isDefault" : true,"name" : "Form_Js","scheduledUpdateTime" : "10:30","src" : "pages/card/index","supportDimensions" :["2*2"],"updateDuration" : 1,"updateEnabled" : true,"window" :{"autoDesignWidth" : true,"designWidth" : 720}}]} \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/profile/invalid.txt b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/profile/invalid.txt new file mode 100755 index 0000000000000000000000000000000000000000..cdca51a17bcbc5128c3b424ef9467ecd68b98737 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/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/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/profile/main_pages.json b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/profile/main_pages.json new file mode 100755 index 0000000000000000000000000000000000000000..02221db61d317863114ff0ca4dd2b33586abff12 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/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/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/profile/shortcuts_config.json b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/entry/src/main/resources/base/profile/shortcuts_config.json new file mode 100755 index 0000000000000000000000000000000000000000..010134e5cdcb46ef62097816f127dac0bb93a398 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/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/actsbmsbundlemanagerstagetest/signature/openharmony_sx.p7b b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/signature/openharmony_sx.p7b new file mode 100755 index 0000000000000000000000000000000000000000..3a7eb6dc682f3ce734ec103281c9727559e00085 Binary files /dev/null and b/bundlemanager/bundle_standard/bundlemanager/actsbmsbundlemanagerstagetest/signature/openharmony_sx.p7b differ diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/module.json b/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/module.json index 69858ac37ab5ddb9ed9d304bae494e0cf90d2f9c..7c6599d81198b57e5626ec40af99d0231d0ed72c 100644 --- a/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/module.json +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/module.json @@ -6,7 +6,6 @@ "description": "$string:phone_entry_dsc", "mainElement": "MainAbility", "deviceTypes": [ - "default", "default" ], "deliveryWithInstall": true,