diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json index 11e749abee7ca2a31ea6f2b6d7cfa0337a20ec83..846e77340c16336ea9c1a6c69e22ce9b44b04d44 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json @@ -29,7 +29,13 @@ "first_right.hap -> /data/test/first_right.hap", "second_right.hap -> /data/second_right.hap", "bmsStageDemo1.hap -> /data/test/bmsStageDemo1.hap", - "bmsStageDemo2.hap -> /data/test/bmsStageDemo2.hap" + "bmsStageDemo2.hap -> /data/test/bmsStageDemo2.hap", + "bmsJstest1.hap -> /data/test/bmsJstest1.hap", + "bmsJstest2.hap -> /data/test/bmsJstest2.hap", + "bmsJstest3.hap -> /data/test/bmsJstest3.hap", + "bmsJstest4.hap -> /data/test/bmsJstest4.hap", + "bmsJstest5.hap -> /data/test/bmsJstest5.hap", + "bmsJstest6.hap -> /data/test/bmsJstest6.hap" ] }, { @@ -39,11 +45,22 @@ "bm install -p /data/test/first_right.hap", "bm install -p /data/second_right.hap", "bm install -p /data/test/bmsStageDemo1.hap", - "bm install -p /data/test/bmsStageDemo2.hap" + "bm install -p /data/test/bmsStageDemo2.hap", + "bm install -p /data/test/bmsJstest1.hap", + "bm install -p /data/test/bmsJstest2.hap", + "bm install -p /data/test/bmsJstest3.hap", + "bm install -p /data/test/bmsJstest4.hap", + "bm install -p /data/test/bmsJstest5.hap", + "bm install -p /data/test/bmsJstest6.hap" ], "teardown-command":[ "bm uninstall -n com.example.third1", "bm uninstall -n com.example.l3jsdemo", + "bm uninstall -n com.example.myapplication1", + "bm uninstall -n com.example.myapplication2", + "bm uninstall -n com.example.myapplication4", + "bm uninstall -n com.example.myapplication5", + "bm uninstall -n com.example.myapplication6", "bm uninstall -n ohos.acts.bundle.stage" ] } diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/List.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/List.test.ets index 04b6fa4379b263a1824d19e4c5f3b065ad5d233f..c5ff6d6de98c6dbb22a2c0c2bfc9317a85b61ae7 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/List.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/List.test.ets @@ -22,8 +22,10 @@ import isApplicationEnabledETSUnit from "./IsApplicationEnabledETSUnit.ets"; import getAbilityIcon from "./GetAbilityIcon.test.ets"; import getNameForUid from "./GetNameForUid.test.ets"; import queryExtensionAbilityInfos from "./QueryExtensionAbilityInfos.test.ets"; +import getBundleArchiveInfo from "./getBundleArchiveInfo.test.ets"; export default function testsuite() { + getBundleArchiveInfo(); queryExtensionAbilityInfos(); getAbilityIcon(); getLaunchWantForBundle(); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getBundleArchiveInfo.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getBundleArchiveInfo.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..487262698e1ee2271c29be933b40ce4a8ddcb03d --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getBundleArchiveInfo.test.ets @@ -0,0 +1,342 @@ +/** + * 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 { describe, beforeAll, it, expect } from 'hypium/index'; + +const PATH = "/data/test/" +const ERROR = "error.hap" +const BMSJSTEST1 = "bmsJstest1.hap" +const BMSJSTEST2 = "bmsJstest2.hap" +const BMSJSTEST3 = "bmsJstest3.hap" +const BMSJSTEST4 = "bmsJstest4.hap" +const BMSJSTEST5 = "bmsJstest5.hap" +const BMSJSTEST6 = "bmsJstest6.hap" +const NAME1 = "com.example.myapplication1" +const NAME2 = "com.example.myapplication2" +const NAME3 = "com.example.myapplication4" +const NAME4 = "com.example.myapplication5" +const NAME5 = "com.example.myapplication6" +const DESCRIPTION = "$string:mainability_description" + +export default function getBundleArchiveInfo() { + + describe('getBundleArchiveInfo', function () { + + /** + * @tc.number getBundleArchiveInfo_0100 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with one hap. + */ + it('getBundleArchiveInfo_0100', 0, async function (done) { + let datainfo = await bundle.getBundleArchiveInfo(PATH + BMSJSTEST1, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES) + expect(datainfo.name).assertEqual(NAME1) + expect(datainfo.vendor).assertEqual("example") + expect(datainfo.versionCode).assertEqual(1) + expect(datainfo.versionName).assertLarger(0) + expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.description).assertEqual(DESCRIPTION) + expect(datainfo.appInfo.descriptionId >= 0).assertTrue() + expect(datainfo.appInfo.icon).assertEqual("$media:icon") + expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(datainfo.appInfo.label).assertEqual("$string:app_name") + expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(datainfo.appInfo.systemApp).assertEqual(false) + done(); + }) + + /** + * @tc.number getBundleArchiveInfo_0200 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with two haps. + */ + it('getBundleArchiveInfo_0200', 0, async function (done) { + let datainfo = await bundle.getBundleArchiveInfo(PATH + BMSJSTEST2, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES) + expect(datainfo.name).assertEqual(NAME2) + expect(datainfo.vendor).assertEqual("example") + expect(datainfo.versionCode).assertEqual(1) + expect(datainfo.versionName).assertLarger(0) + expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.description).assertEqual(DESCRIPTION) + expect(datainfo.appInfo.descriptionId >= 0).assertTrue() + expect(datainfo.appInfo.icon).assertEqual("$media:icon") + expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(datainfo.appInfo.label).assertEqual("$string:app_name") + expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(datainfo.appInfo.systemApp).assertEqual(false) + done(); + }) + + /** + * @tc.number getBundleArchiveInfo_0300 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with three haps. + */ + it('getBundleArchiveInfo_0300', 0, async function (done) { + let datainfo = await bundle.getBundleArchiveInfo(PATH + BMSJSTEST4, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES) + expect(datainfo.name).assertEqual(NAME3) + expect(datainfo.vendor).assertEqual("example") + expect(datainfo.versionCode).assertEqual(1) + expect(datainfo.versionName).assertLarger(0) + expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.description).assertEqual(DESCRIPTION) + expect(datainfo.appInfo.descriptionId >= 0).assertTrue() + expect(datainfo.appInfo.icon).assertEqual("$media:icon") + expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(datainfo.appInfo.label).assertEqual("$string:app_name") + expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(datainfo.appInfo.systemApp).assertEqual(false) + done(); + }) + + /** + * @tc.number getBundleArchiveInfo_0400 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with error hap. + */ + it('getBundleArchiveInfo_0400', 0, async function (done) { + await bundle.getBundleArchiveInfo(PATH + ERROR, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => { + console.info("getBundleArchiveInfo success" + JSON.stringify(datainfo)) + expect(datainfo).assertFail() + done() + }).catch(err => { + console.info("getBundleArchiveInfo fail" + JSON.stringify(err)) + expect(err).assertEqual(1) + done() + }) + }) + + /** + * @tc.number getBundleArchiveInfo_0500 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with none hap. + */ + it('getBundleArchiveInfo_0500', 0, async function (done) { + let datainfo = await bundle.getBundleArchiveInfo(' ', bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => { + console.info("getBundleArchiveInfo success" + JSON.stringify(datainfo)) + expect(datainfo).assertFail() + done() + }).catch(err => { + console.info("getBundleArchiveInfo fail" + JSON.stringify(err)) + expect(err).assertEqual(1) + done() + }) + }) + + /** + * @tc.number getBundleArchiveInfo_0600 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with none hap. + */ + it('getBundleArchiveInfo_0600', 0, async function (done) { + await bundle.getBundleArchiveInfo(PATH + BMSJSTEST1, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent) + function OnReceiveEvent(err, datainfo) { + expect(datainfo.name).assertEqual(NAME1) + expect(datainfo.vendor).assertEqual("example") + expect(datainfo.versionCode).assertEqual(1) + expect(datainfo.versionName).assertEqual("1.0") + expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.name).assertEqual(NAME1) + expect(datainfo.appInfo.description).assertEqual(DESCRIPTION) + expect(datainfo.appInfo.descriptionId >= 0).assertTrue() + expect(datainfo.appInfo.icon).assertEqual("$media:icon") + expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(datainfo.appInfo.label).assertEqual("$string:app_name") + expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(datainfo.appInfo.systemApp).assertEqual(false) + expect(datainfo.appInfo.supportedModes).assertEqual(0) + for (let j = 0; j < datainfo.appInfo.moduleInfos.length; j++) { + expect(datainfo.appInfo.moduleInfos[j].moduleName).assertEqual("entry") + } + for (let j = 0; j < datainfo.abilityInfos.length; j++) { + expect(datainfo.abilityInfos[j].name).assertEqual("com.example.myapplication1.MainAbility") + expect(datainfo.abilityInfos[j].label).assertEqual("$string:app_name") + expect(datainfo.abilityInfos[j].description).assertEqual(DESCRIPTION) + expect(datainfo.abilityInfos[j].icon).assertEqual("$media:icon") + expect(datainfo.abilityInfos[j].isVisible).assertEqual(false) + expect(datainfo.abilityInfos[j].bundleName).assertEqual(NAME1) + expect(datainfo.abilityInfos[j].moduleName).assertEqual("entry") + } + done(); + } + }) + + /** + * @tc.number getBundleArchiveInfo_0700 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with two hap. + */ + it('getBundleArchiveInfo_0700', 0, async function (done) { + await bundle.getBundleArchiveInfo(PATH + BMSJSTEST2, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent) + function OnReceiveEvent(err, datainfo) { + expect(datainfo.name).assertEqual(NAME2) + expect(datainfo.vendor).assertEqual("example") + expect(datainfo.versionCode).assertEqual(1) + expect(datainfo.versionName).assertLarger(0) + expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.description).assertEqual(DESCRIPTION) + expect(datainfo.appInfo.descriptionId >= 0).assertTrue() + expect(datainfo.appInfo.icon).assertEqual("$media:icon") + expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(datainfo.appInfo.label).assertEqual("$string:app_name") + expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(datainfo.appInfo.systemApp).assertEqual(false) + done(); + } + }) + + /** + * @tc.number getBundleArchiveInfo_0800 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with one hap. + */ + it('getBundleArchiveInfo_0800', 0, async function (done) { + await bundle.getBundleArchiveInfo(PATH + BMSJSTEST4, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent) + function OnReceiveEvent(err, datainfo) { + expect(datainfo.name).assertEqual(NAME3) + expect(datainfo.vendor).assertEqual("example") + expect(datainfo.versionCode).assertEqual(1) + expect(datainfo.versionName).assertLarger(0) + expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.description).assertEqual(DESCRIPTION) + expect(datainfo.appInfo.descriptionId >= 0).assertTrue() + expect(datainfo.appInfo.icon).assertEqual("$media:icon") + expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(datainfo.appInfo.label).assertEqual("$string:app_name") + expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(datainfo.appInfo.systemApp).assertEqual(false) + done(); + } + }) + + /** + * @tc.number getBundleArchiveInfo_0900 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with error hap. + */ + it('getBundleArchiveInfo_0900', 0, async function (done) { + await bundle.getBundleArchiveInfo(PATH + ERROR, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent) + function OnReceiveEvent(err, datainfo) { + if (err) { + console.info("getBundleArchiveInfo error" + JSON.stringify(err)); + expect(err).assertEqual(1); + done(); + return; + } + console.info("getBundleArchiveInfo sucess" + JSON.stringify(datainfo)); + expect(datainfo).assertFail(); + done(); + } + }) + + /** + * @tc.number getBundleArchiveInfo_1000 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with none hap. + */ + it('getBundleArchiveInfo_1000', 0, async function (done) { + await bundle.getBundleArchiveInfo(' ', bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent) + function OnReceiveEvent(err, datainfo) { + if (err) { + console.info("getBundleArchiveInfo error" + JSON.stringify(err)); + expect(err).assertEqual(1); + done(); + return; + } + console.info("getBundleArchiveInfo sucess" + JSON.stringify(datainfo)); + expect(datainfo).assertFail(); + done(); + } + }) + + /** + * @tc.number getBundleArchiveInfo_1100 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with none hap. + */ + it('getBundleArchiveInfo_1100', 0, async function (done) { + await bundle.getBundleArchiveInfo(PATH + BMSJSTEST1, bundle.BundleFlag.GET_BUNDLE_DEFAULT, OnReceiveEvent) + function OnReceiveEvent(err, datainfo) { + expect(datainfo.name).assertEqual(NAME1) + expect(datainfo.vendor).assertEqual("example") + expect(datainfo.versionCode).assertEqual(1) + expect(datainfo.versionName).assertEqual("1.0") + expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.name).assertEqual(NAME1) + expect(datainfo.appInfo.description).assertEqual(DESCRIPTION) + expect(datainfo.appInfo.descriptionId >= 0).assertTrue() + expect(datainfo.appInfo.icon).assertEqual("$media:icon") + expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(datainfo.appInfo.label).assertEqual("$string:app_name") + expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(datainfo.appInfo.systemApp).assertEqual(false) + expect(datainfo.appInfo.supportedModes).assertEqual(0) + for (let j = 0; j < datainfo.appInfo.moduleInfos.length; j++) { + expect(datainfo.appInfo.moduleInfos[j].moduleName).assertEqual("entry") + } + for (let j = 0; j < datainfo.abilityInfos.length; j++) { + expect(datainfo.abilityInfos[j].name).assertEqual(".MainAbility") + expect(datainfo.abilityInfos[j].label).assertEqual("$string:app_name") + expect(datainfo.abilityInfos[j].description).assertEqual(DESCRIPTION) + expect(datainfo.abilityInfos[j].icon).assertEqual("$media:icon") + expect(datainfo.abilityInfos[j].isVisible).assertEqual(false) + expect(datainfo.abilityInfos[j].bundleName).assertEqual(NAME1) + expect(datainfo.abilityInfos[j].moduleName).assertEqual("entry") + } + done(); + } + }) + + /** + * @tc.number getBundleArchiveInfo_1200 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with none hap. + */ + it('getBundleArchiveInfo_1200', 0, async function (done) { + await bundle.getBundleArchiveInfo(PATH + BMSJSTEST1, bundle.BundleFlag.GET_BUNDLE_DEFAULT, OnReceiveEvent) + function OnReceiveEvent(err, datainfo) { + expect(datainfo.name).assertEqual(NAME1) + expect(datainfo.vendor).assertEqual("example") + expect(datainfo.versionCode).assertEqual(1) + expect(datainfo.versionName).assertEqual("1.0") + expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.name).assertEqual(NAME1) + expect(datainfo.appInfo.description).assertEqual(DESCRIPTION) + expect(datainfo.appInfo.descriptionId >= 0).assertTrue() + expect(datainfo.appInfo.icon).assertEqual("$media:icon") + expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(datainfo.appInfo.label).assertEqual("$string:app_name") + expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(datainfo.appInfo.systemApp).assertEqual(false) + expect(datainfo.appInfo.supportedModes).assertEqual(0) + for (let j = 0; j < datainfo.appInfo.moduleInfos.length; j++) { + expect(datainfo.appInfo.moduleInfos[j].moduleName).assertEqual("entry") + } + for (let j = 0; j < datainfo.abilityInfos.length; j++) { + expect(datainfo.abilityInfos[j].name).assertEqual(".MainAbility") + expect(datainfo.abilityInfos[j].label).assertEqual("$string:app_name") + expect(datainfo.abilityInfos[j].description).assertEqual(DESCRIPTION) + expect(datainfo.abilityInfos[j].icon).assertEqual("$media:icon") + expect(datainfo.abilityInfos[j].isVisible).assertEqual(false) + expect(datainfo.abilityInfos[j].bundleName).assertEqual(NAME1) + expect(datainfo.abilityInfos[j].moduleName).assertEqual("entry") + } + done(); + } + }) + + + }) +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js index 5ef2efdc3ffe0298eef5912d5181fb23dc02d6c4..7589b8ac26eafbcad1dc207e09b08bef29f06ce5 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js @@ -712,7 +712,7 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.moduleSourceDirs.length).assertLarger(0); for (let j = 0; j < datainfo.moduleInfos.length; j++) { expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry"); - expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0); + expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0); } done(); }).catch(err => {