diff --git a/appexecfwk/bundle_standard/bundlemanager/BUILD.gn b/appexecfwk/bundle_standard/bundlemanager/BUILD.gn index bb2c809e111b9c879fd0cc99a3701c05306d81d5..b6776ebf54fd67c6be1a20089d277d1a82ac8d24 100644 --- a/appexecfwk/bundle_standard/bundlemanager/BUILD.gn +++ b/appexecfwk/bundle_standard/bundlemanager/BUILD.gn @@ -18,6 +18,7 @@ group("bundlemanager") { if (is_standard_system) { deps = [ "actsbmsaccesstokentest:ActsBmsAccessTokenTest", + "actsbmsetsmodulenametest:ActsBmsEtsModuleNameTest", "actsbmsetsunpermissiontest:ActsBmsEtsUnPermissionTest", "actsbmsgetinfostest:ActsBmsGetInfosTest", "actsbmshapmoduletest:ActsBmsHapModuleTest", @@ -46,6 +47,8 @@ group("bundlemanager") { "sceneProject/bmsgetinfosthirdscene:bmsThirdBundleTest3", "sceneProject/bmsmainabilityfirstscene:bmsMainAbilityFirstScene", "sceneProject/bmsmainabilitysecondscene:bmsMainAbilitySecondScene", + "sceneProject/bmsmodulenameone:bmsModuleNameTest1", + "sceneProject/bmsmodulenametwo:bmsModuleNameTest2", "sceneProject/bmsscenefive:bmsJstest5", "sceneProject/bmsscenefour:bmsJstest4", "sceneProject/bmssceneone:bmsJstest1", diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/BUILD.gn b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..781deb28884ad42b6e646bedb0e3d0b557b7cf84 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/BUILD.gn @@ -0,0 +1,32 @@ +# 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("ActsBmsEtsModuleNameTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":bms_ets_assets", + ":bms_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsBmsEtsModuleNameTest" +} +ohos_js_assets("bms_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("bms_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/Test.json b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d8be2990574e9b976f1a4149845c7f6c63170665 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/Test.json @@ -0,0 +1,43 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.actsbmsmodulenametest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsBmsEtsModuleNameTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test" + ] + }, + { + "type": "PushKit", + "push": [ + "bmsModuleNameTest1.hap->/data/test/bmsModuleNameTest1.hap", + "bmsModuleNameTest2.hap->/data/test/bmsModuleNameTest2.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "bm install -p /data/test/bmsModuleNameTest1.hap", + "bm install -p /data/test/bmsModuleNameTest2.hap" + ], + "teardown-command":[ + "bm uninstall -n com.example.bmsmodulename", + "rm -rf /data/test/" + ] + } + ] +} diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/config.json b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..4ab9ec1cc39d3226b7b121e9ef93c6ae18a6c950 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/config.json @@ -0,0 +1,86 @@ +{ + "app": { + "bundleName": "com.example.actsbmsmodulenametest", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsbmsmodulenametest", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name":"ohos.permission.GET_BUNDLE_INFO", + "reason":"need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/app.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..261fadca29ff0ea310a8bc105ddd1af65e2dd2f6 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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 { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/pages/index.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..613631a798f2e653d3734a7db7f26dda71089ed5 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,69 @@ +/* + * 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 file from '@system.file'; + +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" +import testsuite from "../test/List.test.ets" +import featureAbility from "@ohos.ability.featureAbility" + + +@Entry +@Component +struct MyComponent { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + const configService = core.getDefaultService('config') + const timeout=10000 + configService.setConfig(timeout) + console.info('parameters---->' + JSON.stringify(Want.parameters)) + configService.setConfig(Want.parameters) + testsuite() + core.execute() + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ + direction: FlexDirection.Column, + alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center + }) { + Text('ccc World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + .height('100%') + } +} + diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/test/ActsBmsEtsModuleNameTest.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/test/ActsBmsEtsModuleNameTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ae35038a901a9c0a9a895303a1eb54a7c77f1500 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/test/ActsBmsEtsModuleNameTest.test.ets @@ -0,0 +1,479 @@ +/* + * 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 bundle from '@ohos.bundle' +import image from '@ohos.multimedia.image' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + +const ABILITY_NAME = 'com.example.bmsmodulename.MainAbility'; +const BUNDLE_NAME = 'com.example.bmsmodulename'; +const MODULE_NAME1 = ''; +const MODULE_NAME2 = 'noModule'; +const MODULE_NAME3 = 'entry'; +const DEFAULT_FLAG = bundle.BundleFlag.GET_BUNDLE_DEFAULT; +const DEFAULT_USER_ID = 100; +const SUCCESS_CODE = 0; +const INVALID_CODE = 1; +const INVALID_PARAM = 2; +const ABILITY_INFO_ONE = { + bundleName: BUNDLE_NAME, + moduleName: MODULE_NAME1, + name: ABILITY_NAME +}; +const ABILITY_INFO_TWO = { + bundleName: BUNDLE_NAME, + moduleName: MODULE_NAME2, + name: ABILITY_NAME +}; +const ABILITY_INFO_THREE = { + bundleName: BUNDLE_NAME, + moduleName: MODULE_NAME3, + name: ABILITY_NAME +}; + +export default function actsBmsJsModuleNameTest() { + describe('actsBmsJsModuleNameTest', function () { + + /* + * @tc.number: GetabilityInfo_0100 + * @tc.name: test getAbilityInfo + * @tc.desc: test empty moduleName + */ + it('GetabilityInfo_0100', 0, async function (done) { + await bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME) + .then(data => { + expect(data).assertFail(); + }).catch((err) => { + console.error('[GetabilityInfo_0100]Operation failed. Err: ' + JSON.stringify(err)); + expect(err).assertEqual(INVALID_CODE); + }); + bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + if (err) { + console.error('[GetabilityInfo_0100]Operation failed. Err: ' + JSON.stringify(err)); + } + console.info("'[GetabilityInfo_0100]Return data: " + JSON.stringify(data)); + done(); + }); + }); + + /* + * @tc.number: GetabilityInfo_0200 + * @tc.name: test getAbilityInfo + * @tc.desc: test non-existent moduleName + */ + it('GetabilityInfo_0200', 0, async function (done) { + await bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME) + .then(data => { + expect(data).assertFail(); + }).catch((err) => { + console.error('[GetabilityInfo_0200]Operation failed. Err: ' + JSON.stringify(err)); + expect(err).assertEqual(INVALID_CODE); + }); + bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + if (err) { + console.error('[GetabilityInfo_0200]Operation failed. Err: ' + JSON.stringify(err)); + } + console.info("'[GetabilityInfo_0200]Return data : " + JSON.stringify(data)); + done(); + }); + }); + + /* + * @tc.number: GetabilityInfo_0300 + * @tc.name: test getAbilityInfo + * @tc.desc: test existent moduleName + */ + it('GetabilityInfo_0300', 0, async function (done) { + await bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME) + .then(data => { + console.info('[GetabilityInfo_0300]Return data successful: ' + JSON.stringify(data)); + checkDataInfo(data); + }).catch((err) => { + console.error('[GetabilityInfo_0300]Operation . Err: ' + JSON.stringify(err)); + expect(err).assertFail(); + }); + bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME, (err, data) => { + checkDataInfo(data); + expect(err).assertEqual(SUCCESS_CODE); + if (err) { + console.error('[GetabilityInfo_0300]Operation failed. Err: ' + JSON.stringify(err)); + } + console.info("'[GetabilityInfo_0300]Return data: " + JSON.stringify(data)); + done(); + }); + }); + + /* + * @tc.number: GetAbilityIcon_0100 + * @tc.name: test getAbilityIcon + * @tc.desc: test empty moduleName + */ + it('GetAbilityIcon_0100', 0, async function (done) { + await bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME) + .then(data => { + expect(data).assertFail(); + }).catch((err) => { + console.error('[GetAbilityIcon_0100]Operation failed. Err: ' + JSON.stringify(err)); + expect(err).assertEqual(INVALID_CODE); + }); + bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + if (err) { + console.error('[GetAbilityIcon_0100]Operation failed. Err: ' + JSON.stringify(err)); + } + console.info("'[GetAbilityIcon_0100]Return data: " + JSON.stringify(data)); + done(); + }); + }); + + /* + * @tc.number: GetAbilityIcon_0200 + * @tc.name: test getAbilityIcon + * @tc.desc: test non-existent moduleName + */ + it('GetAbilityIcon_0200', 0, async function (done) { + await bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME) + .then(data => { + expect(data).assertFail(); + }).catch((err) => { + console.error('[GetAbilityIcon_0200]Operation successful. Err: ' + JSON.stringify(err)); + expect(err).assertEqual(INVALID_CODE); + }); + bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + if (err) { + console.error('[GetAbilityIcon_0200]Operation failed. Err: ' + JSON.stringify(err)); + } + console.info("'[GetAbilityIcon_0200]Return data: " + JSON.stringify(data)); + done(); + }); + }); + + /* + * @tc.number: GetAbilityIcon_0300 + * @tc.name: test getAbilityIcon + * @tc.desc: test existent moduleName + */ + it('GetAbilityIcon_0300', 0, async function (done) { + await bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME) + .then(data => { + console.info('[GetAbilityIcon_0300]Return data successful: ' + JSON.stringify(data)); + image = data; + expect(image.getBytesNumberPerRow()).assertLarger(0); + }).catch((err) => { + console.error('[GetAbilityIcon_0300]Operation failed. Err: ' + JSON.stringify(err)); + expect(err).assertFail(); + }); + bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME, (err, data) => { + expect(err).assertEqual(SUCCESS_CODE); + expect(image.getBytesNumberPerRow()).assertLarger(0); + if (err) { + console.error('[GetAbilityIcon_0300]Operation failed. Err: ' + JSON.stringify(err)); + } + console.info("'[GetAbilityIcon_0300]Return data: " + JSON.stringify(data)); + done(); + }); + }); + + /* + * @tc.number: GetAbilityLabel_0100 + * @tc.name: test getAbilityLabel + * @tc.desc: test empty moduleName + */ + it('GetAbilityLabel_0100', 0, async function (done) { + await bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME) + .then(data => { + expect(data).assertFail(); + }).catch((err) => { + console.error('[GetAbilityLabel_0100]Operation failed. Err: ' + JSON.stringify(err)); + expect(err).assertEqual(INVALID_CODE); + }); + bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + if (err) { + console.error('[GetAbilityLabel_0100]Operation failed. Err: ' + JSON.stringify(err)); + } + console.info("'[GetAbilityLabel_0100]Return data: " + JSON.stringify(data)); + done(); + }); + }); + + /* + * @tc.number: GetAbilityLabel_0200 + * @tc.name: test getAbilityLabel + * @tc.desc: test non-existent moduleName + */ + it('GetAbilityLabel_0200', 0, async function (done) { + await bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME) + .then(data => { + expect(data).assertFail(); + }).catch((err) => { + console.error('[GetAbilityLabel_0200]Operation . Err: ' + JSON.stringify(err)); + expect(err).assertEqual(INVALID_CODE); + }); + bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + if (err) { + console.error('[GetAbilityLabel_0200]Operation failed. Err: ' + JSON.stringify(err)); + } + console.info("'[GetAbilityLabel_0200]Return data: " + JSON.stringify(data)); + done(); + }); + }); + + /* + * @tc.number: GetAbilityLabel_0300 + * @tc.name: test getAbilityLabel + * @tc.desc: test existent moduleName + */ + it('GetAbilityLabel_0300', 0, async function (done) { + await bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME) + .then(data => { + console.info('[GetAbilityLabel_0300]Return data successful: ' + JSON.stringify(data)); + expect(data).assertEqual("bmsfirstright"); + }).catch((err) => { + console.error('[GetAbilityLabel_0300]Operation failed. Err: ' + JSON.stringify(err)); + expect(err).assertFail(); + }); + bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME, (err, data) => { + expect(err).assertEqual(SUCCESS_CODE); + if (err) { + console.error('[GetAbilityLabel_0300]Operation failed. Err: ' + JSON.stringify(err)); + } + expect(data).assertEqual("bmsfirstright"); + console.info("'[GetAbilityLabel_0300]Return data: " + JSON.stringify(data)); + done(); + }); + }); + + /* + * @tc.number: IsAbilityEnabled_0100 + * @tc.name: test isAbilityEnabled + * @tc.desc: test empty moduleName + */ + it('IsAbilityEnabled_0100', 0, async function (done) { + await bundle.isAbilityEnabled(ABILITY_INFO_ONE) + .then(data => { + expect(data).assertFail(); + }).catch((err) => { + console.error('[IsAbilityEnabled_0100]Operation failed. Err: ' + JSON.stringify(err)); + expect(err).assertEqual(INVALID_PARAM); + }); + bundle.isAbilityEnabled(ABILITY_INFO_ONE, (err, data) => { + expect(data).assertEqual(undefined); + if (err) { + console.error('[IsAbilityEnabled_0100]Operation failed. Err: ' + JSON.stringify(err)); + } + expect(err).assertEqual(INVALID_PARAM); + console.info("'[IsAbilityEnabled_0100]Return data: " + JSON.stringify(data)); + done(); + }); + }); + + /* + * @tc.number: IsAbilityEnabled_0200 + * @tc.name: test isAbilityEnabled + * @tc.desc: test non-existent moduleName + */ + it('IsAbilityEnabled_0200', 0, async function (done) { + await bundle.isAbilityEnabled(ABILITY_INFO_TWO) + .then(data => { + expect(data).assertEqual(false); + }).catch((err) => { + console.error('[IsAbilityEnabled_0200]Operation failed. Err: ' + JSON.stringify(err)); + expect(err).assertFail(); + }); + bundle.isAbilityEnabled(ABILITY_INFO_TWO, (err, data) => { + expect(data).assertEqual(false); + if (err) { + console.error('[IsAbilityEnabled_0200]Operation failed. Err: ' + JSON.stringify(err)); + } + expect(err).assertEqual(SUCCESS_CODE); + console.info("'[IsAbilityEnabled_0200]Return data: " + JSON.stringify(data)); + done(); + }); + }); + + /* + * @tc.number: IsAbilityEnabled_0300 + * @tc.name: test isAbilityEnabled + * @tc.desc: test existent moduleName + */ + it('IsAbilityEnabled_0300', 0, async function (done) { + await bundle.isAbilityEnabled(ABILITY_INFO_THREE) + .then(data => { + console.info('[IsAbilityEnabled_0300]Return data successful: ' + JSON.stringify(data)); + expect(data).assertTrue(); + }).catch((err) => { + console.error('[IsAbilityEnabled_0300]Operation failed. Err: ' + JSON.stringify(err)); + expect(err).assertEqual(SUCCESS_CODE); + }); + bundle.isAbilityEnabled(ABILITY_INFO_THREE, (err, data) => { + expect(err).assertEqual(SUCCESS_CODE); + if (err) { + console.error('[IsAbilityEnabled_0300]Operation failed. Err: ' + JSON.stringify(err)); + } + expect(data).assertTrue(); + console.info("'[IsAbilityEnabled_0300]Return data: " + JSON.stringify(data)); + done(); + }); + }); + + /* + * @tc.number: QueryAbilityByWant_0100 + * @tc.name: test queryAbilityByWant + * @tc.desc: test empty moduleName + */ + it('QueryAbilityByWant_0100', 0, async function (done) { + await bundle.queryAbilityByWant({ + bundleName: BUNDLE_NAME, + abilityName: ABILITY_NAME, + moduleName: MODULE_NAME1 + }, DEFAULT_FLAG, DEFAULT_USER_ID).then(data => { + expect(data).assertFail(); + }).catch(err => { + console.error('[QueryAbilityByWant_0100]Operation failed. Err: ' + JSON.stringify(err)); + expect(err).assertEqual(INVALID_CODE); + }); + bundle.queryAbilityByWant({ + bundleName: BUNDLE_NAME, + abilityName: ABILITY_NAME, + moduleName: MODULE_NAME1 + }, DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => { + console.info("'[QueryAbilityByWant_0100]Return data " + JSON.stringify(data)); + expect(data).assertEqual("type mismatch"); + console.error('[QueryAbilityByWant_0100]Operation failed. Err: ' + JSON.stringify(err)); + expect(err).assertEqual(INVALID_CODE); + done(); + }); + }); + + /* + * @tc.number: QueryAbilityByWant_0200 + * @tc.name: test queryAbilityByWant + * @tc.desc: test non-existent moduleName + */ + it('QueryAbilityByWant_0200', 0, async function (done) { + await bundle.queryAbilityByWant({ + bundleName: BUNDLE_NAME, + abilityName: ABILITY_NAME, + moduleName: MODULE_NAME2 + }, DEFAULT_FLAG, DEFAULT_USER_ID).then(data => { + expect(data).assertFail(); + }).catch(err => { + console.error('[QueryAbilityByWant_0200]Operation failed. Err: ' + JSON.stringify(err)); + expect(err).assertEqual(INVALID_CODE); + }); + bundle.queryAbilityByWant({ + bundleName: BUNDLE_NAME, + abilityName: ABILITY_NAME, + moduleName: MODULE_NAME2 + }, DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => { + console.info("'[QueryAbilityByWant_0200]Return data " + JSON.stringify(data)); + expect(data).assertEqual("QueryAbilityInfos failed"); + console.error('[QueryAbilityByWant_0200]Operation failed. Err: ' + JSON.stringify(err)); + expect(err).assertEqual(INVALID_CODE); + done(); + }); + }); + + /* + * @tc.number: QueryAbilityByWant_0300 + * @tc.name: test queryAbilityByWant + * @tc.desc: test existent moduleName + */ + it('QueryAbilityByWant_0300', 0, async function (done) { + await bundle.queryAbilityByWant({ + bundleName: BUNDLE_NAME, + abilityName: ABILITY_NAME, + moduleName: MODULE_NAME3 + }, DEFAULT_FLAG, DEFAULT_USER_ID).then(data => { + checkDataInfo(data[0]); + console.info("'[QueryAbilityByWant_0300]Return data : " + JSON.stringify(data)); + }).catch(err => { + console.info("[QueryAbilityByWant_0300]Operation failed. Err: " + JSON.stringify(err)); + expect(err).assertFail(); + }); + bundle.queryAbilityByWant({ + bundleName: BUNDLE_NAME, + abilityName: ABILITY_NAME, + moduleName: MODULE_NAME3 + }, DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => { + expect(err).assertEqual(SUCCESS_CODE); + if (err) { + console.error('[QueryAbilityByWant_0300]Operation failed. Err: ' + JSON.stringify(err)); + } + checkDataInfo(data[0]); + console.info("'[QueryAbilityByWant_0300]Return data : " + JSON.stringify(data)); + done(); + }); + }); + + function checkDataInfo(data) { + expect(typeof (data.bundleName)).assertEqual("string"); + expect(data.bundleName).assertEqual("com.example.bmsmodulename"); + expect(typeof (data.name)).assertEqual("string"); + expect(data.name).assertEqual("com.example.bmsmodulename.MainAbility"); + expect(data.label).assertEqual("$string:app_name"); + expect(typeof (data.label)).assertEqual("string"); + expect(data.description).assertEqual("$string:mainability_description"); + expect(typeof (data.description)).assertEqual("string"); + expect(data.icon).assertEqual("$media:icon"); + expect(typeof (data.icon)).assertEqual("string"); + expect(data.srcPath).assertEqual(""); + expect(typeof (data.srcPath)).assertEqual("string"); + expect(data.srcLanguage).assertEqual("js"); + expect(typeof (data.srcLanguage)).assertEqual("string"); + expect(data.isVisible).assertEqual(false); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(typeof (data.process)).assertEqual("string"); + expect(data.process).assertEqual(""); + expect(typeof (data.uri)).assertEqual("string"); + expect(data.uri).assertEqual(""); + expect(data.moduleName).assertEqual("entry"); + expect(typeof (data.moduleName)).assertEqual("string"); + expect(typeof (data.applicationInfo)).assertEqual("object"); + let info = data.applicationInfo; + expect(typeof (info)).assertEqual("object"); + expect(typeof (info.name)).assertEqual("string"); + expect(info.name).assertEqual("com.example.bmsmodulename"); + expect(typeof (info.codePath)).assertEqual("string"); + expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.example.bmsmodulename"); + expect(typeof (info.accessTokenId)).assertEqual("number"); + expect(info.accessTokenId > 0).assertTrue(); + expect(typeof (info.description)).assertEqual("string"); + expect(info.description).assertEqual("$string:mainability_description"); + expect(typeof (info.descriptionId)).assertEqual("number"); + expect(info.descriptionId > 0).assertTrue(); + expect(typeof (info.icon)).assertEqual("string"); + expect(info.icon).assertEqual("$media:icon"); + expect(typeof (info.iconId)).assertEqual("number"); + expect(info.iconId > 0).assertTrue(); + expect(typeof (info.label)).assertEqual("string"); + expect(info.label).assertEqual("$string:app_name"); + expect(typeof (info.labelId)).assertEqual("number"); + expect(info.labelId > 0).assertTrue(); + expect(info.systemApp).assertEqual(true); + expect(typeof (info.entryDir)).assertEqual("string"); + expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/com.example.bmsmodulename/com.example.bmsmodulenamedentry"); + expect(typeof (info.process)).assertEqual("string"); + expect(info.process).assertEqual(""); + expect(Array.isArray(info.permissions)).assertEqual(true); + console.log("---checkDataInfo End--- "); + } + }); +} diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/test/List.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4649d85e81b34b45859ae5a77539e5b4cd7812eb --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import actsBmsJsModuleNameTest from './ActsBmsEtsModuleNameTest.test.ets'; + +export default function testsuite() { + actsBmsJsModuleNameTest(); +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/resources/base/element/string.json b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03b8532c53ca563f8ed6b1e21d20ad3f67a68906 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "entry_MainAbility" + }, + { + "name": "description_mainability", + "value": "ETS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/resources/base/media/icon.png b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/resources/base/media/icon.png differ diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/signature/openharmony_sx.p7b b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/signature/openharmony_sx.p7b differ diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/BUILD.gn b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..916695838bd2b8fd98d1d83a3fa509911e8a6026 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import("//test/xts/tools/build/suite.gni") + +ohos_hap("bmsModuleNameTest1") { + hap_profile = "./src/main/config.json" + hap_name = "bmsModuleNameTest1" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "./signature/openharmony_sx.p7b" +} +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "./src/main/js/default" +} +ohos_resources("hjs_demo_resources") { + sources = [ "./src/main/js/resources" ] + hap_profile = "./src/main/config.json" +} diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/Test.json b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..7a88763ed8d2ac31dd30211b9574f47273e84549 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/signature/openharmony_sx.p7b b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/signature/openharmony_sx.p7b differ diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/config.json b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..24352f307390232866839335caf8ca694f64f8da --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/config.json @@ -0,0 +1,104 @@ +{ + "app": { + "bundleName": "com.example.bmsmodulename", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5, + "releaseType": "Beta1" + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.bmsmodulenamedentry", + "name": "MyApplication1", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.bmsmodulename.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "isVisible": "true", + "launchType": "standard", + "language": "C++", + "metaData": { + "customizeData": [ + { + "name": "originWidgetName", + "value": "com.weather.testWidget" + } + ] + } + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "definePermissions":[ + { + "availableLevel":"normal", + "description":"ALPHA description", + "distributedSceneEnable":true, + "grantMode":"user_grant", + "label":"ALPHA label", + "name":"ohos.permission.ALPHA", + "provisionEnable":true + }, + { + "availableLevel":"normal", + "description":"BETA description", + "distributedSceneEnable":true, + "grantMode":"user_grant", + "label":"BETA label", + "name":"ohos.permission.BETA", + "provisionEnable":true + } + ], + "reqPermissions":[ + { + "name":"ohos.permission.ALPHA", + "reason":"use ohos.permission.ALPHA" + }, + { + "name":"ohos.permission.BETA", + "reason":"use ohos.permission.BETA" + }, + { + "name": "ohos.permission.KEEP_BACKGROUND_RUNNING", + "reason": "use ohos.permission.KEEP_BACKGROUND_RUNNING" + } + ] + } +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/app.js b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/app.js new file mode 100644 index 0000000000000000000000000000000000000000..2a68c1992145a976957d7dcdd69a7e9c2e8e9877 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/app.js @@ -0,0 +1,22 @@ +/* + * 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 { + onCreate() { + console.info('AceApplication onCreate'); + }, + onDestroy() { + console.info('AceApplication onDestroy'); + } +}; diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/i18n/en-US.json b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/i18n/en-US.json new file mode 100644 index 0000000000000000000000000000000000000000..e63c70d978a3a53be988388c87182f81785e170c --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/i18n/en-US.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "Hello", + "world": "World" + } +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/i18n/zh-CN.json b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/i18n/zh-CN.json new file mode 100644 index 0000000000000000000000000000000000000000..de6ee5748322f44942c1b003319d8e66c837675f --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/i18n/zh-CN.json @@ -0,0 +1,6 @@ +{ + "strings": { + "hello": "您好", + "world": "世界" + } +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/pages/index/index.css b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..01ad739b27f208ff04f21924695104bd27c59df0 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/pages/index/index.css @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +.container { + flex-direction: column; + justify-content: center; + align-items: center; +} + +.title { + font-size: 100px; +} diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/pages/index/index.hml b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..8d0e2061b88c99c91488405f0f2ead0c77de1a9e --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsmodulenameone/src/main/js/default/pages/index/index.hml @@ -0,0 +1,20 @@ + + +