diff --git a/appexecfwk/bundle_standard/bundlemanager/BUILD.gn b/appexecfwk/bundle_standard/bundlemanager/BUILD.gn index c4bc989004a334c1d09e18a425b85f3535d0bc20..077406df6f2079db4f1e8445a919084f8fc9cddd 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", + "actsbmsetsunpermissiontest:ActsBmsEtsUnPermissionTest", "actsbmsgetinfostest:ActsBmsGetInfosTest", "actsbmshapmoduletest:ActsBmsHapModuleTest", "actsbmsjstest:ActsBmsJsTest", diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/BUILD.gn b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..02db041711840ac392b2e7fd4971f48f9aeff6e6 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/BUILD.gn @@ -0,0 +1,32 @@ +# 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_js_hap_suite("ActsBmsEtsUnPermissionTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":bms_ets_assets", + ":bms_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ActsBmsEtsUnPermissionTest" +} +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/actsbmsetsunpermissiontest/Test.json b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..1fa471400b6bebd10cbf965d15013104476f0c2a --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "JSUnitTest", + "test-timeout": "120000", + "package": "com.example.actsbmsetsunpermissiontest", + "shell-timeout": "60000" + }, + "kits": [ + { + "test-file-name": [ + "ActsBmsEtsUnPermissionTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + } + ] +} diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/config.json b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..6d78230a904987d65a6ad2721674f3a557258c3d --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/config.json @@ -0,0 +1,72 @@ +{ + "app": { + "bundleName": "com.example.actsbmsetsunpermissiontest", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 7, + "releaseType": "Release", + "target": 7 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.actsbmsetsunpermissiontest", + "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" + } + ], + "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/actsbmsetsunpermissiontest/entry/src/main/ets/MainAbility/app.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..261fadca29ff0ea310a8bc105ddd1af65e2dd2f6 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/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/actsbmsetsunpermissiontest/entry/src/main/ets/MainAbility/pages/index.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..613631a798f2e653d3734a7db7f26dda71089ed5 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/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/actsbmsetsunpermissiontest/entry/src/main/ets/MainAbility/test/ActsBmsEtsUnPermissionTest.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/MainAbility/test/ActsBmsEtsUnPermissionTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b63bd6bd88a089edc22e2a1431daf875457f6644 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/MainAbility/test/ActsBmsEtsUnPermissionTest.test.ets @@ -0,0 +1,180 @@ +/* + * 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from "deccjsunit/index.ets" +import bundle from '@ohos.bundle' + +const DEFAULT_FLAG = bundle.BundleFlag.GET_BUNDLE_DEFAULT; +const INVALID_CODE = 1; +const LAUNCHER_BUNDLE_NAME = "com.ohos.launcher"; +const SELF_BUNDLENAME = "com.example.actsbmsetsunpermissiontest"; +const SELF_ABILITYNAME = "com.example.actsbmsetsunpermissiontest.MainAbility"; + +export default function actsBmsJsUnPermissionTest() { + describe('actsBmsJsUnPermissionTest', function () { + + /** + * @tc.number getApplicationInfos_1300 + * @tc.name getApplicationInfos_1300 + * @tc.desc test getAllApplicationInfo + */ + it('getApplicationInfos_1300', 0, async function (done) { + await bundle.getAllApplicationInfo(DEFAULT_FLAG).then(data => { + expect().assertFail(); + done(); + }).catch(err => { + expect(err).assertEqual(INVALID_CODE); + done(); + }); + bundle.getAllApplicationInfo(DEFAULT_FLAG, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + expect(data).assertEqual(undefined); + done(); + }); + }); + + /** + * @tc.number getBundleInfo_2000 + * @tc.name getBundleInfo_2000 + * @tc.desc test getBundleInfo + */ + it('getBundleInfo_2000', 0, async function (done) { + await bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, { userId: 100 }).then(data => { + expect().assertFail(); + done(); + }).catch(err => { + expect(err).assertEqual(INVALID_CODE); + done(); + }); + bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, { userId: 100 }, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + expect(data).assertEqual(undefined); + done(); + }); + }); + + /** + * @tc.number getApplicationInfo_1800 + * @tc.name getApplicationInfo_1800 + * @tc.desc test getApplicationInfo + */ + it('getApplicationInfo_1800', 0, async function (done) { + await bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG).then(data => { + expect().assertFail(); + done(); + }).catch(err => { + expect(err).assertEqual(INVALID_CODE); + done(); + }); + bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + expect(data).assertEqual(undefined); + done(); + }); + }); + + /* + * @tc.number: getAbilityInfo_100 + * @tc.name: test getAbilityInfo + * @tc.desc: test getAbilityInfo + */ + it('getAbilityInfo_200', 0, async function (done) { + await bundle.getAbilityInfo(SELF_BUNDLENAME, SELF_ABILITYNAME).then(res => { + console.info('actwsBundleManager getAbilityInfo promise success res:' + JSON.stringify(res)); + for (const item in res) { + const a = res[item]; + console.info(item + ":" + JSON.stringify(a)); + }; + checkAbilityInfo(res); + }).catch(err => { + expect(err).assertFail(); + }); + bundle.getAbilityInfo(SELF_BUNDLENAME, SELF_ABILITYNAME, (err, res) => { + if (err) { + expect(err).assertFail(); + done(); + return; + } + console.info('actwsBundleManager getAbilityInfo callback success res:' + JSON.stringify(res)); + for (const item in res) { + const a = res[item]; + console.info(item + ":" + JSON.stringify(a)); + }; + checkAbilityInfo(res); + done(); + }); + }); + + async function checkAbilityInfo(data) { + console.info("checkAbilityInfo start !!!"); + expect(data.bundleName).assertEqual("com.example.actsbmsetsunpermissiontest"); + expect(data.name).assertEqual("com.example.actsbmsetsunpermissiontest.MainAbility"); + expect(data.label).assertEqual("$string:entry_MainAbility"); + expect(data.description).assertEqual("$string:description_mainability"); + expect(data.icon).assertEqual("$media:icon"); + expect(data.srcPath).assertEqual("MainAbility"); + expect(data.srcLanguage).assertEqual("ets"); + expect(data.isVisible).assertEqual(true); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(data.process).assertEqual(""); + expect(data.uri).assertEqual(""); + expect(data.moduleName).assertEqual("entry"); + expect(data.type).assertEqual(1); + expect(data.orientation).assertEqual(0); + expect(data.launchMode).assertEqual(1); + expect(data.backgroundModes).assertEqual(0); + expect(data.descriptionId).assertLarger(0); + expect(data.formEnabled).assertEqual(false); + expect(data.iconId).assertLarger(0); + except(data.labelId).assertLarger(0); + expect(data.subType).assertEqual(0); + except(data.enabled).assertEqual(true); + expect(data.readPermission).assertEqual(""); + expect(data.writePermission).assertEqual(""); + expect(data.targetAbility).assertEqual(""); + expect(data.theme).assertEqual(""); + expect(data.metaData).assertEqual([]); + expect(data.metadata).assertEqual([]); + checkApplicationInfo(data.applicationInfo); + console.log("---checkAbilityInfo_other End--- "); + } + + async function checkApplicationInfo(info) { + console.info("checkApplicationInfo start !!!"); + expect(info.name).assertEqual("com.example.actsbmsetsunpermissiontest"); + expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.example.actsbmsetsunpermissiontest"); + expect(info.accessTokenId > 0).assertTrue(); + expect(info.description).assertEqual("$string:description_mainability"); + expect(info.descriptionId > 0).assertTrue(); + expect(info.icon).assertEqual("$media:icon"); + expect(info.iconId > 0).assertTrue(); + expect(info.label).assertEqual("$string:entry_MainAbility"); + expect(info.labelId > 0).assertTrue(); + expect(info.systemApp).assertEqual(true); + expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/com.example.actsbmsetsunpermissiontest/com.example.actsbmsetsunpermissiontest"); + expect(info.supportedModes).assertEqual(0); + expect(info.process).assertEqual(""); + expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/com.example.actsbmsetsunpermissiontest/com.example.actsbmsetsunpermissiontest"); + expect(info.metaData).expect({}); + expect(info.metadata).expect({}); + expect(info.enabled).expect(true); + expect(info.flags).expect(0); + expect(info.uid).assertLarger(0); + expect(info.entityType).assertEqual("unspecified"); + expect(info.removable).assertEqual(true); + console.info("checkApplicationInfo end !!!"); + } + }) +} diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/MainAbility/test/List.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c6b87e8a4b93ebc430450a79d317a4c2b9617912 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/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 actsBmsEtsUnPermissionTest from './ActsBmsEtsUnPermissionTest.test.ets'; + +export default function testsuite() { + actsBmsEtsUnPermissionTest(); +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/resources/base/element/string.json b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..03b8532c53ca563f8ed6b1e21d20ad3f67a68906 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/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/actsbmsetsunpermissiontest/entry/src/main/resources/base/media/icon.png b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/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/actsbmsetsunpermissiontest/entry/src/main/resources/base/media/icon.png differ diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/signature/openharmony_sx.p7b b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..9be1e98fa4c0c28ca997ed660112fa16b194f0f5 Binary files /dev/null and b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/signature/openharmony_sx.p7b differ diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmshapmoduletest/entry/src/main/js/test/ActsBmsHapModuleTest.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmshapmoduletest/entry/src/main/js/test/ActsBmsHapModuleTest.test.js index cb81b8ca965f304d846067027e0d34cca941abaa..8784ae80f43d546570edda16a5c7bd3a9194061b 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmshapmoduletest/entry/src/main/js/test/ActsBmsHapModuleTest.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmshapmoduletest/entry/src/main/js/test/ActsBmsHapModuleTest.test.js @@ -98,6 +98,7 @@ describe('ActsBmsHapModuleTest', function () { let hapModuleInfo1 = result.hapModuleInfos[1]; checkHapMoudleInfos(hapModuleInfo); checkHapMoudleInfos(hapModuleInfo1); + expect(hapModuleInfo.label).assertEqual('$string:app_name'); expect(hapModuleInfo.name).assertEqual(BUNDLE_NAME1); expect(hapModuleInfo1.name).assertEqual(BUNDLE_NAME6); expect(hapModuleInfo.moduleName).assertEqual('entry'); @@ -288,7 +289,6 @@ describe('ActsBmsHapModuleTest', function () { expect(info.descriptionId).assertEqual(0); expect(info.iconPath).assertEqual("$media:icon"); expect(info.icon).assertEqual(''); - expect(info.label).assertEqual('$string:app_name'); expect(info.labelId).assertEqual(0); expect(info.iconId).assertEqual(0); expect(info.backgroundImg).assertEqual(""); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/Test.json b/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/Test.json index 64709c85c6a0be9454e275f12db585c785449b27..8674d332852dbc95df0054a31ef148a2c520edfb 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/Test.json +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/Test.json @@ -33,7 +33,18 @@ { "type": "ShellKit", "run-command": [ - "chmod 644 /data/test/*.hap" + "chmod 644 /data/test/*.hap", + "bm install -p /data/test/bmsThirdBundleTest2.hap", + "bm install -p /data/test/bmsThirdBundleTest5.hap", + "bm install -p /data/test/bmsThirdBundleJs.hap", + "bm install -p /data/test/bmsThirdBundleC.hap" + ], + "teardown-command":[ + "bm uninstall -n com.example.third2", + "bm uninstall -n com.example.third5", + "bm uninstall -n com.example.js", + "bm uninstall -n com.example.c", + "rm -rf /data/test/" ] } ] diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/entry/src/main/js/test/ActsBmsHasInstalldTest.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/entry/src/main/js/test/ActsBmsHasInstalldTest.test.js new file mode 100644 index 0000000000000000000000000000000000000000..d6db86a80a6eef10862a11c86878c8fb8e271028 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/entry/src/main/js/test/ActsBmsHasInstalldTest.test.js @@ -0,0 +1,121 @@ +/* + * 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 pkg from '@system.package' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + +const NUM_TWO = 2; +const ERR_CODE = 202; +const ERR_MERSSAGE = 'value is not an available number'; + +describe('ActsBmsHasInstalldTest', function () { + + /** + * @tc.number hasInstalled_0100 + * @tc.name Package::hasInstalled + * @tc.desc Test hasInstalled interface. + */ + it('hasInstalled_0100', 0, async function (done) { + pkg.hasInstalled({ + bundleName: 'com.ohos.launcher', + success: function success(data) { + console.info('hasInstalled success function in'); + expect(data.result).assertTrue(); + done(); + }, + fail: function fail(data, code) { + console.info('hasInstalled fail function in'); + expect().assertFail(); + done(); + }, + complete: function complete() { + console.info('hasInstalled complete function in'); + expect().assertFail(); + done(); + } + }); + }); + + /** + * @tc.number hasInstalled_0200 + * @tc.name Package::hasInstalled + * @tc.desc Test hasInstalled interface. + */ + it('hasInstalled_0200', 0, async function (done) { + pkg.hasInstalled({ + bundleName: 'wrongName', + success: function success(data) { + console.info('hasInstalled success function in'); + expect(data.result).assertFalse(); + done(); + }, + fail: function fail(data, code) { + console.info('hasInstalled fail function in'); + expect().assertFail(); + done(); + }, + complete: function complete() { + console.info('hasInstalled complete function in'); + expect().assertFail(); + done(); + } + }); + }); + + /** + * @tc.number hasInstalled_0300 + * @tc.name Package::hasInstalled + * @tc.desc Test hasInstalled interface. + */ + it('hasInstalled_0300', 0, async function (done) { + pkg.hasInstalled({ + bundleName: 'wrongName', + success: function success(data) { + console.info('hasInstalled success function in'); + expect(data.result).assertFalse(); + done(); + } + }); + }); + + /** + * @tc.number hasInstalled_0400 + * @tc.name Package::hasInstalled + * @tc.desc Test hasInstalled interface. + */ + it('hasInstalled_0400', 0, async function (done) { + let flag = 0; + pkg.hasInstalled({ + bundleName: NUM_TWO, + success: function success(data) { + console.info('hasInstalled success function in'); + expect().assertFail(); + done(); + }, + fail: function fail(data, code) { + flag += 2; + console.info('hasInstalled fail function in'); + expect(data).assertEqual(ERR_MERSSAGE); + expect(code).assertEqual(ERR_CODE); + }, + complete: function complete() { + flag += 3; + console.info('hasInstalled complete function in'); + expect(flag).assertEqual(5) + done(); + } + }); + }); +}) \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/entry/src/main/js/test/ActsBmsJsTest.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/entry/src/main/js/test/ActsBmsJsTest.test.js index c2dc00656fd864ba41840adcf86b51fc410c5437..5d2790ce4af11aa5c50e63c56767ffdfeed689d4 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/entry/src/main/js/test/ActsBmsJsTest.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/entry/src/main/js/test/ActsBmsJsTest.test.js @@ -18,9 +18,6 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from const NUM_TWO = 2; const NUM_FOUR = 4; -const ERR_CODE = 202; -const ERR_MERSSAGE = 'value is not an available number'; -const BUNDLE_NAME1 = 'com.ohos.launcher'; const BUNDLE_NAME2 = 'com.example.third2'; const BUNDLE_NAME3 = 'com.example.third5'; const BUNDLE_NAME4 = 'com.example.js'; @@ -33,15 +30,6 @@ const ABILITIY_NAME5 = '.MainAbility'; const ABILITIY_NAME6 = "com.example.third2.MainAbilityA"; const ABILITIY_NAME7 = "com.example.third5.MainAbilityA"; const ABILITIY_NAME8 = "com.example.third5.MainAbilityB"; -const BUNDLE_PATH1 = ['/data/test/bmsThirdBundleTest2.hap']; -const BUNDLE_PATH2 = ['/data/test/bmsThirdBundleTest5.hap']; -const BUNDLE_PATH3 = ['/data/test/bmsThirdBundleJs.hap']; -const BUNDLE_PATH4 = ['/data/test/bmsThirdBundleC.hap']; -let installParam = { - userId: 100, - installFlag: 1, - isKeepData: false -}; describe('ActsBmsJsTest', function () { @@ -52,54 +40,47 @@ describe('ActsBmsJsTest', function () { * 2.check the ability name by the interface of getBundleInfo */ it('bms_getJsAbility_0100', 0, async function (done) { - let installer = await bundle.getBundleInstaller(); - installer.install(BUNDLE_PATH1, installParam, onReceiveInstallEvent); - async function onReceiveInstallEvent(err, data) { - checkInstallOrUninstall(err, data); - let result = await bundle.getBundleInfo(BUNDLE_NAME2, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); - expect(result.abilityInfos.length).assertEqual(NUM_TWO); - if (result.abilityInfos.length == NUM_TWO) { - let abilityInfo1 = result.abilityInfos[0]; - let abilityInfo2 = result.abilityInfos[1]; - expect(abilityInfo1.name).assertEqual(ABILITIY_NAME1); - expect(abilityInfo2.name).assertEqual(ABILITIY_NAME6); - expect(abilityInfo1.srcLanguage).assertEqual('js'); - expect(abilityInfo1.srcPath).assertEqual(''); - expect(abilityInfo1.label).assertEqual("$string:app_name"); - expect(abilityInfo1.description).assertEqual("$string:mainability_description"); - expect(abilityInfo1.icon).assertEqual("$media:icon"); - expect(abilityInfo1.isVisible).assertEqual(true); - expect(abilityInfo1.permissions.length).assertEqual(0); - expect(abilityInfo1.deviceTypes[0]).assertEqual('phone'); - expect(abilityInfo1.process).assertEqual(""); - expect(abilityInfo1.uri).assertEqual(""); - expect(abilityInfo1.bundleName).assertEqual(BUNDLE_NAME2); - expect(abilityInfo1.moduleName).assertEqual("entry"); - expect(Object.keys(abilityInfo1.applicationInfo).length).assertLarger(0); - expect(abilityInfo1.type).assertEqual(1); - expect(abilityInfo2.type).assertEqual(2); - expect(abilityInfo1.orientation).assertEqual(0); - expect(abilityInfo1.launchMode).assertEqual(1); - expect(abilityInfo1.backgroundModes).assertEqual(0); - expect(abilityInfo2.backgroundModes).assertEqual(510); - expect(abilityInfo1.descriptionId).assertLarger(0); - expect(abilityInfo1.formEnabled).assertEqual(false); - expect(abilityInfo1.iconId).assertLarger(0); - expect(abilityInfo1.labelId).assertLarger(0); - expect(abilityInfo1.subType).assertEqual(0); - expect(abilityInfo1.readPermission).assertEqual(""); - expect(abilityInfo1.writePermission).assertEqual(""); - expect(abilityInfo1.targetAbility).assertEqual(""); - expect(abilityInfo1.theme).assertEqual(""); - expect(abilityInfo1.metaData.length).assertEqual(0); - expect(abilityInfo1.metadata.length).assertEqual(0); - expect(abilityInfo1.enabled).assertEqual(true); - } - installer.uninstall(BUNDLE_NAME2, installParam, (err, data) => { - checkInstallOrUninstall(err, data); - done(); - }); + let result = await bundle.getBundleInfo(BUNDLE_NAME2, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); + expect(result.abilityInfos.length).assertEqual(NUM_TWO); + if (result.abilityInfos.length == NUM_TWO) { + console.info("getBundleIno result" + JSON.stringify(result)); + let abilityInfo1 = result.abilityInfos[0]; + let abilityInfo2 = result.abilityInfos[1]; + expect(abilityInfo1.name).assertEqual(ABILITIY_NAME1); + expect(abilityInfo2.name).assertEqual(ABILITIY_NAME6); + expect(abilityInfo1.srcLanguage).assertEqual('js'); + expect(abilityInfo1.srcPath).assertEqual(''); + expect(abilityInfo1.label).assertEqual("$string:app_name"); + expect(abilityInfo1.description).assertEqual("$string:mainability_description"); + expect(abilityInfo1.icon).assertEqual("$media:icon"); + expect(abilityInfo1.isVisible).assertEqual(true); + expect(abilityInfo1.permissions.length).assertEqual(0); + expect(abilityInfo1.deviceTypes[0]).assertEqual('phone'); + expect(abilityInfo1.process).assertEqual(""); + expect(abilityInfo1.uri).assertEqual(""); + expect(abilityInfo1.bundleName).assertEqual(BUNDLE_NAME2); + expect(abilityInfo1.moduleName).assertEqual("entry"); + expect(Object.keys(abilityInfo1.applicationInfo).length).assertLarger(0); + expect(abilityInfo1.type).assertEqual(1); + expect(abilityInfo2.type).assertEqual(2); + expect(abilityInfo1.orientation).assertEqual(0); + expect(abilityInfo1.launchMode).assertEqual(1); + expect(abilityInfo1.backgroundModes).assertEqual(0); + expect(abilityInfo2.backgroundModes).assertEqual(510); + expect(abilityInfo1.descriptionId).assertLarger(0); + expect(abilityInfo1.formEnabled).assertEqual(false); + expect(abilityInfo1.iconId).assertLarger(0); + expect(abilityInfo1.labelId).assertLarger(0); + expect(abilityInfo1.subType).assertEqual(0); + expect(abilityInfo1.readPermission).assertEqual(""); + expect(abilityInfo1.writePermission).assertEqual(""); + expect(abilityInfo1.targetAbility).assertEqual(""); + expect(abilityInfo1.theme).assertEqual(""); + expect(abilityInfo1.metaData.length).assertEqual(0); + expect(abilityInfo1.metadata.length).assertEqual(0); + expect(abilityInfo1.enabled).assertEqual(true); } + done(); }); /* @@ -109,35 +90,28 @@ describe('ActsBmsJsTest', function () { * 2.check the ability name by the interface of getBundleInfo */ it('bms_getJsAbility_0200', 0, async function (done) { - let installer = await bundle.getBundleInstaller(); - installer.install(BUNDLE_PATH2, installParam, onReceiveInstallEvent); - async function onReceiveInstallEvent(err, data) { - checkInstallOrUninstall(err, data); - let result = await bundle.getBundleInfo(BUNDLE_NAME3, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); - expect(result.abilityInfos.length).assertEqual(NUM_FOUR); - if (result.abilityInfos.length == NUM_FOUR) { - let abilityInfo1 = result.abilityInfos[0]; - let abilityInfo2 = result.abilityInfos[1]; - let abilityInfo3 = result.abilityInfos[2]; - let abilityInfo4 = result.abilityInfos[3]; - checkAbilityInfos(abilityInfo1); - expect(abilityInfo2.metaData.length).assertEqual(1); - expect(abilityInfo2.metaData[0].name).assertEqual("Data5B"); - expect(abilityInfo2.metaData[0].value).assertEqual("float"); - expect(abilityInfo2.metaData[0].extra).assertEqual("$string:mainability_description"); - expect(abilityInfo2.name).assertEqual(ABILITIY_NAME3); - expect(abilityInfo3.name).assertEqual(ABILITIY_NAME7); - expect(abilityInfo4.name).assertEqual(ABILITIY_NAME8); - expect(abilityInfo3.type).assertEqual(2); - expect(abilityInfo4.type).assertEqual(2); - expect(abilityInfo3.backgroundModes).assertEqual(511); - expect(abilityInfo4.backgroundModes).assertEqual(129); - } - installer.uninstall(BUNDLE_NAME3, installParam, (err, data) => { - checkInstallOrUninstall(err, data); - done(); - }); + let result = await bundle.getBundleInfo(BUNDLE_NAME3, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); + expect(result.abilityInfos.length).assertEqual(NUM_FOUR); + if (result.abilityInfos.length == NUM_FOUR) { + console.info("getBundleIno result" + JSON.stringify(result)); + let abilityInfo1 = result.abilityInfos[0]; + let abilityInfo2 = result.abilityInfos[1]; + let abilityInfo3 = result.abilityInfos[2]; + let abilityInfo4 = result.abilityInfos[3]; + checkAbilityInfos(abilityInfo1); + expect(abilityInfo2.metaData.length).assertEqual(1); + expect(abilityInfo2.metaData[0].name).assertEqual("Data5B"); + expect(abilityInfo2.metaData[0].value).assertEqual("float"); + expect(abilityInfo2.metaData[0].extra).assertEqual("$string:mainability_description"); + expect(abilityInfo2.name).assertEqual(ABILITIY_NAME3); + expect(abilityInfo3.name).assertEqual(ABILITIY_NAME7); + expect(abilityInfo4.name).assertEqual(ABILITIY_NAME8); + expect(abilityInfo3.type).assertEqual(2); + expect(abilityInfo4.type).assertEqual(2); + expect(abilityInfo3.backgroundModes).assertEqual(511); + expect(abilityInfo4.backgroundModes).assertEqual(129); } + done(); }); /* @@ -147,50 +121,43 @@ describe('ActsBmsJsTest', function () { * 2.check the ability name by the interface of getBundleInfo */ it('bms_getJsAbility_0300', 0, async function (done) { - let installer = await bundle.getBundleInstaller(); - installer.install(BUNDLE_PATH3, installParam, onReceiveInstallEvent); - async function onReceiveInstallEvent(err, data) { - checkInstallOrUninstall(err, data); - let result = await bundle.getBundleInfo(BUNDLE_NAME4, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); - expect(result.abilityInfos.length).assertEqual(1); - if (result.abilityInfos.length == 1) { - let abilityInfo1 = result.abilityInfos[0]; - expect(abilityInfo1.name).assertEqual(ABILITIY_NAME4); - expect(abilityInfo1.srcLanguage).assertEqual('js'); - expect(abilityInfo1.srcPath).assertEqual('default'); - expect(abilityInfo1.label).assertEqual("$string:app_name"); - expect(abilityInfo1.description).assertEqual("$string:mainability_description"); - expect(abilityInfo1.icon).assertEqual("$media:icon"); - expect(abilityInfo1.isVisible).assertEqual(true); - expect(abilityInfo1.permissions.length).assertEqual(0); - expect(abilityInfo1.deviceTypes[0]).assertEqual('phone'); - expect(abilityInfo1.process).assertEqual(""); - expect(abilityInfo1.uri).assertEqual(""); - expect(abilityInfo1.bundleName).assertEqual(BUNDLE_NAME4); - expect(abilityInfo1.moduleName).assertEqual("entry"); - expect(Object.keys(abilityInfo1.applicationInfo).length).assertLarger(0); - expect(abilityInfo1.type).assertEqual(1); - expect(abilityInfo1.orientation).assertEqual(0); - expect(abilityInfo1.launchMode).assertEqual(1); - expect(abilityInfo1.backgroundModes).assertEqual(0); - expect(abilityInfo1.descriptionId).assertLarger(0); - expect(abilityInfo1.formEnabled).assertEqual(false); - expect(abilityInfo1.iconId).assertLarger(0); - expect(abilityInfo1.labelId).assertLarger(0); - expect(abilityInfo1.subType).assertEqual(0); - expect(abilityInfo1.readPermission).assertEqual(""); - expect(abilityInfo1.writePermission).assertEqual(""); - expect(abilityInfo1.targetAbility).assertEqual(""); - expect(abilityInfo1.theme).assertEqual(""); - expect(abilityInfo1.metaData.length).assertEqual(0); - expect(abilityInfo1.metadata.length).assertEqual(0); - expect(abilityInfo1.enabled).assertEqual(true); - } - installer.uninstall(BUNDLE_NAME4, installParam, (err, data) => { - checkInstallOrUninstall(err, data); - done(); - }); + let result = await bundle.getBundleInfo(BUNDLE_NAME4, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); + expect(result.abilityInfos.length).assertEqual(1); + if (result.abilityInfos.length == 1) { + console.info("getBundleIno result" + JSON.stringify(result)); + let abilityInfo1 = result.abilityInfos[0]; + expect(abilityInfo1.name).assertEqual(ABILITIY_NAME4); + expect(abilityInfo1.srcLanguage).assertEqual('js'); + expect(abilityInfo1.srcPath).assertEqual('default'); + expect(abilityInfo1.label).assertEqual("$string:app_name"); + expect(abilityInfo1.description).assertEqual("$string:mainability_description"); + expect(abilityInfo1.icon).assertEqual("$media:icon"); + expect(abilityInfo1.isVisible).assertEqual(true); + expect(abilityInfo1.permissions.length).assertEqual(0); + expect(abilityInfo1.deviceTypes[0]).assertEqual('phone'); + expect(abilityInfo1.process).assertEqual(""); + expect(abilityInfo1.uri).assertEqual(""); + expect(abilityInfo1.bundleName).assertEqual(BUNDLE_NAME4); + expect(abilityInfo1.moduleName).assertEqual("entry"); + expect(Object.keys(abilityInfo1.applicationInfo).length).assertLarger(0); + expect(abilityInfo1.type).assertEqual(1); + expect(abilityInfo1.orientation).assertEqual(0); + expect(abilityInfo1.launchMode).assertEqual(1); + expect(abilityInfo1.backgroundModes).assertEqual(0); + expect(abilityInfo1.descriptionId).assertLarger(0); + expect(abilityInfo1.formEnabled).assertEqual(false); + expect(abilityInfo1.iconId).assertLarger(0); + expect(abilityInfo1.labelId).assertLarger(0); + expect(abilityInfo1.subType).assertEqual(0); + expect(abilityInfo1.readPermission).assertEqual(""); + expect(abilityInfo1.writePermission).assertEqual(""); + expect(abilityInfo1.targetAbility).assertEqual(""); + expect(abilityInfo1.theme).assertEqual(""); + expect(abilityInfo1.metaData.length).assertEqual(0); + expect(abilityInfo1.metadata.length).assertEqual(0); + expect(abilityInfo1.enabled).assertEqual(true); } + done(); }); /* @@ -200,173 +167,42 @@ describe('ActsBmsJsTest', function () { * 2.check the ability name by the interface of getBundleInfo */ it('bms_getJsAbility_0400', 0, async function (done) { - let installer = await bundle.getBundleInstaller(); - installer.install(BUNDLE_PATH4, installParam, onReceiveInstallEvent); - async function onReceiveInstallEvent(err, data) { - checkInstallOrUninstall(err, data); - let result = await bundle.getBundleInfo(BUNDLE_NAME5, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); - expect(result.abilityInfos.length).assertEqual(1); - if (result.abilityInfos.length == 1) { - let abilityInfo1 = result.abilityInfos[0]; - expect(abilityInfo1.name).assertEqual(ABILITIY_NAME5); - expect(abilityInfo1.srcLanguage).assertEqual('c++'); - expect(abilityInfo1.srcPath).assertEqual('default/c++/'); - expect(abilityInfo1.label).assertEqual("$string:app_name"); - expect(abilityInfo1.description).assertEqual("$string:mainability_description"); - expect(abilityInfo1.icon).assertEqual("$media:icon"); - expect(abilityInfo1.isVisible).assertEqual(true); - expect(abilityInfo1.permissions.length).assertEqual(0); - expect(abilityInfo1.deviceTypes[0]).assertEqual('phone'); - expect(abilityInfo1.process).assertEqual(""); - expect(abilityInfo1.uri).assertEqual(""); - expect(abilityInfo1.bundleName).assertEqual(BUNDLE_NAME5); - expect(abilityInfo1.moduleName).assertEqual("entry"); - expect(Object.keys(abilityInfo1.applicationInfo).length).assertLarger(0); - expect(abilityInfo1.type).assertEqual(1); - expect(abilityInfo1.orientation).assertEqual(0); - expect(abilityInfo1.launchMode).assertEqual(1); - expect(abilityInfo1.backgroundModes).assertEqual(0); - expect(abilityInfo1.descriptionId).assertLarger(0); - expect(abilityInfo1.formEnabled).assertEqual(false); - expect(abilityInfo1.iconId).assertLarger(0); - expect(abilityInfo1.labelId).assertLarger(0); - expect(abilityInfo1.subType).assertEqual(0); - expect(abilityInfo1.readPermission).assertEqual(""); - expect(abilityInfo1.writePermission).assertEqual(""); - expect(abilityInfo1.targetAbility).assertEqual(""); - expect(abilityInfo1.theme).assertEqual(""); - expect(abilityInfo1.metaData.length).assertEqual(0); - expect(abilityInfo1.metadata.length).assertEqual(0); - expect(abilityInfo1.enabled).assertEqual(true); - } - installer.uninstall(BUNDLE_NAME5, installParam, (err, data) => { - checkInstallOrUninstall(err, data); - done(); - }); + let result = await bundle.getBundleInfo(BUNDLE_NAME5, bundle.BundleFlag.GET_BUNDLE_WITH_ABILITIES); + expect(result.abilityInfos.length).assertEqual(1); + if (result.abilityInfos.length == 1) { + console.info("getBundleIno result" + JSON.stringify(result)); + let abilityInfo1 = result.abilityInfos[0]; + expect(abilityInfo1.name).assertEqual(ABILITIY_NAME5); + expect(abilityInfo1.srcLanguage).assertEqual('c++'); + expect(abilityInfo1.srcPath).assertEqual('default/c++/'); + expect(abilityInfo1.label).assertEqual("$string:app_name"); + expect(abilityInfo1.description).assertEqual("$string:mainability_description"); + expect(abilityInfo1.icon).assertEqual("$media:icon"); + expect(abilityInfo1.isVisible).assertEqual(true); + expect(abilityInfo1.permissions.length).assertEqual(0); + expect(abilityInfo1.deviceTypes[0]).assertEqual('phone'); + expect(abilityInfo1.process).assertEqual(""); + expect(abilityInfo1.uri).assertEqual(""); + expect(abilityInfo1.bundleName).assertEqual(BUNDLE_NAME5); + expect(abilityInfo1.moduleName).assertEqual("entry"); + expect(Object.keys(abilityInfo1.applicationInfo).length).assertLarger(0); + expect(abilityInfo1.type).assertEqual(1); + expect(abilityInfo1.orientation).assertEqual(0); + expect(abilityInfo1.launchMode).assertEqual(1); + expect(abilityInfo1.backgroundModes).assertEqual(0); + expect(abilityInfo1.descriptionId).assertLarger(0); + expect(abilityInfo1.formEnabled).assertEqual(false); + expect(abilityInfo1.iconId).assertLarger(0); + expect(abilityInfo1.labelId).assertLarger(0); + expect(abilityInfo1.subType).assertEqual(0); + expect(abilityInfo1.readPermission).assertEqual(""); + expect(abilityInfo1.writePermission).assertEqual(""); + expect(abilityInfo1.targetAbility).assertEqual(""); + expect(abilityInfo1.theme).assertEqual(""); + expect(abilityInfo1.metaData.length).assertEqual(0); + expect(abilityInfo1.metadata.length).assertEqual(0); + expect(abilityInfo1.enabled).assertEqual(true); } - }); - - /** - * @tc.number getNameForUid_0100 - * @tc.name BUNDLE::getBundleInfo - * @tc.desc Test getBundleInfo interfaces with hap. - */ - it('getNameForUid_0100', 0, async function (done) { - await bundle.getBundleInfo(BUNDLE_NAME1).then(dataInfo => { - bundle.getNameForUid(dataInfo.uid).then(data => { - expect(data).assertEqual(BUNDLE_NAME1) - done(); - }) - }) - .catch(err => { - console.info("getNameForUid fail:" + JSON.stringify(err)) - expect(err).assertFail() - done(); - }); - }); - - /** - * @tc.number getNameForUid_0200 - * @tc.name BUNDLE::getBundleInfo - * @tc.desc Test getBundleInfo interfaces with hap. - */ - it('getNameForUid_0200', 0, async function (done) { - let dataInfo = await bundle.getBundleInfo(BUNDLE_NAME1); - let data = await bundle.getNameForUid(dataInfo.uid); - expect(data).assertEqual(BUNDLE_NAME1); - done(); - }); - - /** - * @tc.number hasInstalled_0100 - * @tc.name Package::hasInstalled - * @tc.desc Test hasInstalled interface. - */ - it('hasInstalled_0100', 0, async function (done) { - pkg.hasInstalled({ - bundleName: 'com.ohos.launcher', - success: function success(data) { - console.info('hasInstalled success function in'); - expect(data.result).assertTrue(); - }, - fail: function fail(data, code) { - console.info('hasInstalled fail function in'); - expect().assertFail(); - }, - complete: function complete() { - console.info('hasInstalled complete function in'); - expect().assertFail(); - } - }); - done(); - }); - - /** - * @tc.number hasInstalled_0200 - * @tc.name Package::hasInstalled - * @tc.desc Test hasInstalled interface. - */ - it('hasInstalled_0200', 0, async function (done) { - pkg.hasInstalled({ - bundleName: 'wrongName', - success: function success(data) { - console.info('hasInstalled success function in'); - expect(data.result).assertFalse(); - }, - fail: function fail(data, code) { - console.info('hasInstalled fail function in'); - expect().assertFail(); - }, - complete: function complete() { - console.info('hasInstalled complete function in'); - expect().assertFail(); - } - }); - done(); - }); - - /** - * @tc.number hasInstalled_0300 - * @tc.name Package::hasInstalled - * @tc.desc Test hasInstalled interface. - */ - it('hasInstalled_0300', 0, async function (done) { - pkg.hasInstalled({ - bundleName: 'wrongName', - success: function success(data) { - console.info('hasInstalled success function in'); - expect(data.result).assertFalse(); - } - }); - done(); - }); - - /** - * @tc.number hasInstalled_0400 - * @tc.name Package::hasInstalled - * @tc.desc Test hasInstalled interface. - */ - it('hasInstalled_0400', 0, async function (done) { - let flag = false; - pkg.hasInstalled({ - bundleName: NUM_TWO, - success: function success(data) { - console.info('hasInstalled success function in'); - expect().assertFail(); - }, - fail: function fail(data, code) { - console.info('hasInstalled fail function in'); - expect(flag).assertFalse(); - flag = true; - expect(data).assertEqual(ERR_MERSSAGE); - expect(code).assertEqual(ERR_CODE); - }, - complete: function complete() { - console.info('hasInstalled complete function in'); - expect(flag).assertTrue(); - flag = true; - } - }); done(); }); @@ -404,10 +240,4 @@ describe('ActsBmsJsTest', function () { expect(info.metaData[0].extra).assertEqual("$string:mainability_description"); expect(info.enabled).assertEqual(true); } - - function checkInstallOrUninstall(err, data) { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - } }) \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/entry/src/main/js/test/List.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/entry/src/main/js/test/List.test.js index 6cadb5202494955ee09a6ee0046db814275d4324..1bb3c4615ddcb5734b2d3c6c95bd214e370ec35f 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/entry/src/main/js/test/List.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsjstest/entry/src/main/js/test/List.test.js @@ -12,4 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -require('./ActsBmsJsTest.test.js') \ No newline at end of file + +require('./ActsBmsJsTest.test.js') +require('./ActsBmsHasInstalldTest.test.js') \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/entry/src/main/js/test/ActsBmsJsUnPermissionTest.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/entry/src/main/js/test/ActsBmsJsUnPermissionTest.test.js index 76cb62ae7841a9d415fa27e7c792fd0d979a9409..f04dd3da7251d7a879668b2fbb6a4c1e27b89cd6 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/entry/src/main/js/test/ActsBmsJsUnPermissionTest.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/entry/src/main/js/test/ActsBmsJsUnPermissionTest.test.js @@ -14,58 +14,16 @@ */ import bundle from '@ohos.bundle' -import innerBundleManager from '@ohos.bundle.innerBundleManager' import { describe, it, expect } from 'deccjsunit/index' -const STATUS_INSTALL_PERMISSION_DENIED = 0X44; -const STATUS_UNINSTALL_PERMISSION_DENIED = 0X45; const LAUNCHER_BUNDLE_NAME = 'com.ohos.launcher'; const LAUNCHER_MAIN_ABILITY = 'com.ohos.launcher.MainAbility'; -const DEFAULT_FLAG = 0; +const DEFAULT_FLAG = bundle.BundleFlag.GET_BUNDLE_DEFAULT; const DEFAULT_USER_ID = 100; const INVALID_CODE = 1; -const BUNDLE_PATH = ['/data/test/bmsJstest1.hap']; -const BUNDLE_NAME1 = 'com.example.myapplication1'; -let installParam = { - userId: 100, - installFlag: 1, - isKeepData: false -}; describe('ActsBmsJsUnPermissionTest', function () { - /* - * @tc.number: bms_JsInstallPermissionTest_0100 - * @tc.name: test js install - * @tc.desc: test js install - */ - it('bms_JsInstallPermissionTest_0100', 0, async function (done) { - let installer = await bundle.getBundleInstaller(); - installer.install(BUNDLE_PATH, installParam, OnReceiveInstallEvent); - async function OnReceiveInstallEvent(err, data) { - expect(err.code).assertEqual(-1); - expect(data.status).assertEqual(STATUS_INSTALL_PERMISSION_DENIED); - expect(data.statusMessage).assertEqual("STATUS_INSTALL_PERMISSION_DENIED"); - done(); - } - }); - - /* - * @tc.number: bms_JsUnInstallPermissionTest_0100 - * @tc.name: test js uninstall - * @tc.desc: test js uninstall - */ - it('bms_JsUnInstallPermissionTest_0100', 0, async function (done) { - let installer = await bundle.getBundleInstaller(); - installer.uninstall(BUNDLE_NAME1, installParam, OnReceiveUnInstallEvent); - async function OnReceiveUnInstallEvent(err, data) { - expect(err.code).assertEqual(-1); - expect(data.status).assertEqual(STATUS_UNINSTALL_PERMISSION_DENIED); - expect(data.statusMessage).assertEqual("STATUS_UNINSTALL_PERMISSION_DENIED"); - done(); - } - }); - /* * @tc.number: getApplicationInfoTest_100 * @tc.name: test getApplicationInfo @@ -79,6 +37,11 @@ describe('ActsBmsJsUnPermissionTest', function () { expect(err).assertEqual(INVALID_CODE); done(); }); + bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + expect(data).assertEqual(undefined); + done(); + }); }); /* @@ -94,6 +57,11 @@ describe('ActsBmsJsUnPermissionTest', function () { expect(err).assertEqual(INVALID_CODE); done(); }); + bundle.getAllApplicationInfo(DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + expect(data).assertEqual(undefined); + done(); + }); }); /* @@ -109,6 +77,11 @@ describe('ActsBmsJsUnPermissionTest', function () { expect(err).assertEqual(INVALID_CODE); done(); }); + bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_USER_ID, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + expect(data).assertEqual(undefined); + done(); + }); }); /* @@ -124,6 +97,11 @@ describe('ActsBmsJsUnPermissionTest', function () { expect(err).assertEqual(INVALID_CODE); done(); }); + bundle.getAllBundleInfo(DEFAULT_FLAG, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + expect(data).assertEqual(undefined); + done(); + }); }); /* @@ -142,6 +120,15 @@ describe('ActsBmsJsUnPermissionTest', function () { expect(err).assertEqual(INVALID_CODE); done(); }); + bundle.queryAbilityByWant({ + bundleName: LAUNCHER_BUNDLE_NAME, + abilityName: LAUNCHER_MAIN_ABILITY + }, DEFAULT_FLAG, DEFAULT_USER_ID, (err, data) => { + console.info("data ===================:" + data); + expect(err).assertEqual(INVALID_CODE); + expect(data).assertEqual("QueryAbilityInfos failed"); + done(); + }); }); /* @@ -157,6 +144,11 @@ describe('ActsBmsJsUnPermissionTest', function () { expect(err).assertEqual(INVALID_CODE); done(); }); + bundle.getLaunchWantForBundle(LAUNCHER_BUNDLE_NAME, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + expect(data).assertEqual(undefined); + done(); + }); }); /* @@ -194,56 +186,11 @@ describe('ActsBmsJsUnPermissionTest', function () { }); /* - * @tc.number: getLauncherAbilityInfosTest_100 - * @tc.name: test getLauncherAbilityInfos - * @tc.desc: test getLauncherAbilityInfos - */ - it('getLauncherAbilityInfosTest_100', 0, async function (done) { - await innerBundleManager.getLauncherAbilityInfos(LAUNCHER_BUNDLE_NAME, DEFAULT_USER_ID).then(data => { - expect().assertFail(); - done(); - }).catch(err => { - expect(err).assertEqual(INVALID_CODE); - done(); - }); - }); - - /* - * @tc.number: getAllLauncherAbilityInfosTest_100 - * @tc.name: test getAllLauncherAbilityInfos - * @tc.desc: test getAllLauncherAbilityInfos - */ - it('getAllLauncherAbilityInfosTest_100', 0, async function (done) { - await innerBundleManager.getAllLauncherAbilityInfos(DEFAULT_USER_ID).then(data => { - expect().assertFail(); - done(); - }).catch(err => { - expect(err).assertEqual(INVALID_CODE); - done(); - }); - }); - - /* - * @tc.number: getShortcutInfosTest_100 - * @tc.name: test getShortcutInfos - * @tc.desc: test getShortcutInfos - */ - it('getShortcutInfosTest_100', 0, async function (done) { - await innerBundleManager.getShortcutInfos(LAUNCHER_BUNDLE_NAME).then(data => { - expect().assertFail(); - done(); - }).catch(err => { - expect(err).assertEqual(INVALID_CODE); - done(); - }); - }); - - /* - * @tc.number: getAbilityLabelTest_100 - * @tc.name: getAbilityLabel : Gets the specified ability label - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ + * @tc.number: getAbilityLabelTest_100 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface + * @tc.level 0 + */ it('getAbilityLabelTest_100', 0, async function (done) { await bundle.getAbilityLabel(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY) .then((data) => { @@ -254,6 +201,11 @@ describe('ActsBmsJsUnPermissionTest', function () { expect(error).assertEqual(INVALID_CODE); done(); }); + bundle.getAbilityLabel(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + expect(data).assertEqual(undefined); + done(); + }); }); /* @@ -269,5 +221,10 @@ describe('ActsBmsJsUnPermissionTest', function () { expect(err).assertEqual(INVALID_CODE); done(); }); + bundle.getAbilityInfo(LAUNCHER_BUNDLE_NAME, LAUNCHER_MAIN_ABILITY, (err, data) => { + expect(err).assertEqual(INVALID_CODE); + expect(data).assertEqual(undefined); + done(); + }); }); }) diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json index c916382f6a76a6f0191eff83bbc70ee6ed88f308..168166f998124b15a3182b43f68b843c9fb8913f 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json @@ -13,6 +13,33 @@ ], "type": "AppInstallKit", "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test/" + ] + }, + { + "type": "PushKit", + "push":[ + "bmsThirdBundleTest1.hap -> /data/bmsThirdBundleTest1.hap ", + "first_right.hap -> /data/test/first_right.hap", + "second_right.hap -> /data/second_right.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "bm install -p /data/bmsThirdBundleTest1.hap", + "bm install -p /data/test/first_right.hap", + "bm install -p /data/second_right.hap" + ], + "teardown-command":[ + "bm uninstall -n com.example.third1", + "bm uninstall -n com.example.l3jsdemo" + ] } ] } diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/config.json b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/config.json index 983a51d061c5ef21f143c6499756ac381c1aaa6a..2b6dec181acab302658782fc2ebb22b19f69b374 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/config.json +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/config.json @@ -29,6 +29,9 @@ }, { "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE" } ], "distro": { diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetAbilityIcon.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetAbilityIcon.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..60b610e571c8ebf2742e95f2c067ab0ec627365b --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetAbilityIcon.test.ets @@ -0,0 +1,56 @@ +/* + * 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 bundle from '@ohos.bundle' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + +const BUNDLE_NAME = "com.ohos.callui" +const ABILITIY_NAME = "com.ohos.callui.MainAbility" + +export default function getAbilityIcon() { + describe('ActsBmsGetAbilityIconTest', function () { + + /* + * @tc.number: bms_getAbilityIcon_0100 + * @tc.name: test getAbilityIcon` + * @tc.desc: get the abilityIcon + */ + it('bms_getAbilityIcon_0100', 0, async function (done) { + bundle.getAbilityIcon(BUNDLE_NAME, ABILITIY_NAME).then(pixelmap => { + console.log('bms_getAbilityIcon_0100 success: ' + pixelmap); + expect(pixelmap !== null).assertTrue(); + done(); + }) + .catch(err => { + console.info("getAbilityIcon fail:" + JSON.stringify(err)) + expect(err).assertFail(); + done(); + }); + }); + + /* + * @tc.number: bms_getAbilityIcon_0200 + * @tc.name: test getAbilityIcon + * @tc.desc: get the abilityIcon + */ + it('bms_getAbilityIcon_0200', 0, async function (done) { + bundle.getAbilityIcon(BUNDLE_NAME, ABILITIY_NAME, (err, pixelmap) => { + expect(err).assertEqual(0); + expect(pixelmap !== null).assertTrue(); + done(); + }); + }); + }); +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetAbilityLabelJsUnit.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetAbilityLabelJsUnit.test.ets index 6424c7ab5c9d385f3cc2d65cfeb76ddb6efbf4dc..89be8576a48a1a9afc870c5ed305db7c60e2f6f6 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetAbilityLabelJsUnit.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetAbilityLabelJsUnit.test.ets @@ -12,203 +12,198 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {describe, it, expect} from 'deccjsunit/index.ets'; +import { describe, it, expect } from 'deccjsunit/index.ets'; import Utils from './Utils'; import Bundle from '@ohos.bundle'; -const BUNDLE_NAME = 'com.open.harmony.packagemag' -const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility' -const SERVICE_ABILITY_NAME = 'com.open.harmony.packagemag.ServiceAbility' +const BUNDLE_NAME = 'com.open.harmony.packagemag'; +const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility'; +const SERVICE_ABILITY_NAME = 'com.open.harmony.packagemag.ServiceAbility'; +const OTHER_BUNDLE_NAME = 'com.ohos.acepackage'; +const OTHER_ABILITY_NAME = 'com.ohos.acepackage.MainAbility'; +const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error'; +const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility'; -const OTHER_BUNDLE_NAME = 'com.ohos.acepackage' -const OTHER_ABILITY_NAME = 'com.ohos.acepackage.MainAbility' +export default function getAbilityLabelJsUnit() { -const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error' -const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility' + describe('context_getAbilityLabel_test', function () { -export default function getAbilityLabelJsUnit() { + /* + * @tc.number: context_getAbilityLabel_test_0100 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0100', 0, async function (done) { + let mData; + let timeOldStamp = await Utils.getNowTime(); + await Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0100]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_getAbilityLabel_test_0100] promise data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_getAbilityLabel_test_0100] promise error is: ' + error); + expect(error).assertFail(); + }); + getAbilityLabelSuccess('[context_getAbilityLabel_test_0100]', mData); + done(); + }); - describe('context_getAbilityLabel_test', function () { - /* - * @tc.number: context_getAbilityLabel_test_0100 - * @tc.name: getAbilityLabel : Gets the specified ability label - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it('context_getAbilityLabel_test_0100', 0, async function (done) { - let mData; - var timeOldStamp = await Utils.getNowTime(); - await Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_getAbilityLabel_test_0100]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_getAbilityLabel_test_0100] promise data is: ' + JSON.stringify(data)); - }) - .catch((error) => { - console.info('[context_getAbilityLabel_test_0100] promise error is: ' + error); - expect(error).assertFail(); + /* + * @tc.number: context_getAbilityLabel_test_0200 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0200', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME, (error, data) => { + if (error) { + console.error('[context_getAbilityLabel_test_0200]Operation failed. Cause: ' + JSON.stringify(error)); + expect(error).assertFail(); + } + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0200]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_getAbilityLabel_test_0200] callBack error: ' + error); + console.info('[context_getAbilityLabel_test_0200] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getAbilityLabelSuccess('[context_getAbilityLabel_test_0200]', mData); + done(); }); - getAbilityLabelSuccess('[context_getAbilityLabel_test_0100]', mData); - done(); - }); - /* - * @tc.number: context_getAbilityLabel_test_0200 - * @tc.name: getAbilityLabel : Gets the specified ability label - * @tc.desc: Check the return value of the interface (by callbac) - * @tc.level 0 - */ - it('context_getAbilityLabel_test_0200', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - let mData; - Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME, (error, data) => { - if(error){ - console.error('[context_getAbilityLabel_test_0200]Operation failed. Cause: ' + JSON.stringify(error)); - expect(error).assertFail(); - } - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_getAbilityLabel_test_0200]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_getAbilityLabel_test_0200] callBack error: ' + error); - console.info('[context_getAbilityLabel_test_0200] callBack data is:' + JSON.stringify(data)); - }); - await Utils.sleep(2000); - getAbilityLabelSuccess('[context_getAbilityLabel_test_0200]', mData); - done(); - }); + /* + * @tc.number: context_getAbilityLabel_test_0300 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0300', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + let mError; + await Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp); + console.info('[context_getAbilityLabel_test_0300] promise data is: ' + JSON.stringify(data)); + }).catch((error) => { + let timeNewStamp = Utils.getNowTime(); + mError = error; + Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp); + console.info('[context_getAbilityLabel_test_0300] promise error is: ' + error); + expect(mError).assertEqual(1); + }); + await Utils.sleep(2000); + getAbilityLabelFailure('[context_getAbilityLabel_test_0300]', mError); + done(); + }); - /* - * @tc.number: context_getAbilityLabel_test_0300 - * @tc.name: getAbilityLabel : Gets the specified ability label - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it('context_getAbilityLabel_test_0300', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - let mError; - await Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp); - console.info('[context_getAbilityLabel_test_0300] promise data is: ' + JSON.stringify(data)); - }) - .catch((error) => { - var timeNewStamp = Utils.getNowTime(); - mError = error; - Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp); - console.info('[context_getAbilityLabel_test_0300] promise error is: ' + error); - expect(mError).assertEqual(1); + /* + * @tc.number: context_getAbilityLabel_test_0400 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0400', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + let mError; + Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR, (error, data) => { + if (error !== null) { + console.info('[context_getAbilityLabel_test_0400] callBack error: ' + error); + expect(error).assertEqual(1); + } + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0400]', timeOldStamp, timeNewStamp); + mError = error; + console.info('[context_getAbilityLabel_test_0400] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getAbilityLabelFailure('[context_getAbilityLabel_test_0400]', mError); + done(); }); - await Utils.sleep(2000); - getAbilityLabelFailure('[context_getAbilityLabel_test_0300]', mError); - done(); - }); - /* - * @tc.number: context_getAbilityLabel_test_0400 - * @tc.name: getAbilityLabel : Gets the specified ability label - * @tc.desc: Check the return value of the interface (by callback) - * @tc.level 0 - */ - it('context_getAbilityLabel_test_0400', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - let mError; - Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR, (error, data) => { - if(error !== null){ - console.info('[context_getAbilityLabel_test_0400] callBack error: ' + error); - expect(error).assertEqual(1); - } - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_getAbilityLabel_test_0400]', timeOldStamp, timeNewStamp); - mError = error; - console.info('[context_getAbilityLabel_test_0400] callBack data is:' + JSON.stringify(data)); - }); - await Utils.sleep(2000); - getAbilityLabelFailure('[context_getAbilityLabel_test_0400]', mError); - done(); - }); + /* + * @tc.number: context_getAbilityLabel_test_0500 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0500', 0, async function (done) { + let mData; + let mError = null; + let timeOldStamp = await Utils.getNowTime(); + await Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0500]', timeOldStamp, timeNewStamp); + mData = data; + expect(mData).assertFail(); + console.info('[context_getAbilityLabel_test_0500] promise data is: ' + JSON.stringify(data)); + }).catch((error) => { + mError = error; + console.info('[context_getAbilityLabel_test_0500] promise error is: ' + error); + getAbilityLabelFailure('[context_getAbilityLabel_test_0500]', mError); + }); + done(); + }); - /* - * @tc.number: context_getAbilityLabel_test_0500 - * @tc.name: getAbilityLabel : Gets the specified ability label - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it('context_getAbilityLabel_test_0500', 0, async function (done) { - let mData; - let mError = null; - var timeOldStamp = await Utils.getNowTime(); - await Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_getAbilityLabel_test_0500]', timeOldStamp, timeNewStamp); - mData = data; - expect(mData).assertFail(); - console.info('[context_getAbilityLabel_test_0500] promise data is: ' + JSON.stringify(data)); - }) - .catch((error) => { - mError = error; - console.info('[context_getAbilityLabel_test_0500] promise error is: ' + error); - getAbilityLabelFailure('[context_getAbilityLabel_test_0500]', mError); + /* + * @tc.number: context_getAbilityLabel_test_0600 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0600', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME, (error, data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0600]', timeOldStamp, timeNewStamp); + console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error); + getAbilityLabelFailure('[context_getAbilityLabel_test_0600]', error); + expect(data).assertEqual(undefined); + }); + done(); }); - done(); - }); - /* - * @tc.number: context_getAbilityLabel_test_0600 - * @tc.name: getAbilityLabel : Gets the specified ability label - * @tc.desc: Check the return value of the interface (by callback) - * @tc.level 0 - */ - it('context_getAbilityLabel_test_0600', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME, (error, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_getAbilityLabel_test_0600]', timeOldStamp, timeNewStamp); - console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error); - getAbilityLabelFailure('[context_getAbilityLabel_test_0600]', error); - expect(data).assertEqual(undefined); - }); - done(); - }); + /* + * @tc.number: context_getAbilityLabel_test_0700 + * @tc.name: getAbilityLabel : Gets the specified ability label + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_getAbilityLabel_test_0700', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + let mError; + Bundle.getAbilityLabel(BUNDLE_NAME, SERVICE_ABILITY_NAME, (error, data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_getAbilityLabel_test_0700]', timeOldStamp, timeNewStamp); + mError = error; + if (mError !== null) { + console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error); + } + console.info('[context_getAbilityLabel_test_0700] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getAbilityLabelFailure('[context_getAbilityLabel_test_0700]', mError); + done(); + }); + + function getAbilityLabelSuccess(msg, data) { + console.log(msg + ' start ' + JSON.stringify(data)); + console.log(msg + ' result ' + data); + expect(typeof (data)).assertEqual('string'); + expect(data).assertEqual("entry_MainAbility"); + } - /* - * @tc.number: context_getAbilityLabel_test_0700 - * @tc.name: getAbilityLabel : Gets the specified ability label - * @tc.desc: Check the return value of the interface (by callback) - * @tc.level 0 - */ - it('context_getAbilityLabel_test_0700', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - let mError; - Bundle.getAbilityLabel(BUNDLE_NAME, SERVICE_ABILITY_NAME, (error, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_getAbilityLabel_test_0700]', timeOldStamp, timeNewStamp); - mError = error; - if(mError !== null){ - console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error); + function getAbilityLabelFailure(msg, error) { + console.log(msg + ' Failure '); + console.log(msg + ' error ' + JSON.stringify(error)); + expect(typeof (error)).assertEqual('number'); + expect(error).assertEqual(1) } - console.info('[context_getAbilityLabel_test_0700] callBack data is:' + JSON.stringify(data)); - }); - await Utils.sleep(2000); - getAbilityLabelFailure('[context_getAbilityLabel_test_0700]', mError); - done(); - }); - function getAbilityLabelSuccess(msg, data) { - console.log(msg + ' start ' + JSON.stringify(data)); - console.log(msg + ' result ' + data); - expect(typeof (data)).assertEqual('string'); - expect(data).assertEqual("entry_MainAbility"); - } + }) - function getAbilityLabelFailure(msg, error) { - console.log(msg + ' Failure '); - console.log(msg + ' error ' + JSON.stringify(error)); - expect(typeof (error)).assertEqual('number'); - expect(error).assertEqual(1) - } - }) } \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetLaunchWantForBundle.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetLaunchWantForBundle.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b45134fa8850dc66cadd43074c7adf7089bca45a --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetLaunchWantForBundle.test.ets @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file expect 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 bundleMgr from '@ohos.bundle'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'; + +const NAME1 = "com.example.third1"; +const NAME2 = "com.example.l3jsdemo"; +const NAME3 = "com.notexist.com"; +const ABILITYNAME1 = "com.example.third1.MainAbility"; +const ABILITYNAME2 = "com.example.l3jsdemo.MainAbility"; + +export default function getLaunchWantForBundle() { + describe('GetLaunchWantForBundleTest', function () { + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0069 + * @tc.name: testGetLaunchWantForBundle. + * @tc.desc: Test getLaunchWantForBundle api by promise and callback. + * @tc.author renyi 00559040 + * @tc.size MediumTest + * @tc.type Function + * @tc.level Level 1 + */ + it('testGetLaunchWantForBundle', 0, async function (done) { + await bundleMgr.getLaunchWantForBundle(NAME1).then(res => { + expect(res.bundleName).assertEqual(NAME1); + expect(res.abilityName).assertEqual(ABILITYNAME1); + expect(res.deviceId).assertEqual(''); + expect(res.action).assertEqual('action.system.home'); + expect(res.entities[0]).assertEqual('entity.system.home'); + }).catch(err => { + expect(err).assertFail(); + }); + bundleMgr.getLaunchWantForBundle(NAME1, (err, res) => { + expect(err).assertEqual(0); + expect(res.bundleName).assertEqual(NAME1); + expect(res.abilityName).assertEqual(ABILITYNAME1); + expect(res.deviceId).assertEqual(''); + expect(res.action).assertEqual('action.system.home'); + expect(res.entities[0]).assertEqual('entity.system.home'); + done(); + }); + }); + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0012 + * @tc.name: testGetLaunchWantForBundleWithManyHaps. + * @tc.desc: Test getLaunchWantForBundle api by promise and callback. + * @tc.author renyi 00559040 + * @tc.size MediumTest + * @tc.type Function + * @tc.level Level 1 + */ + it('testGetLaunchWantForBundleWithManyHaps', 0, async function (done) { + await bundleMgr.getLaunchWantForBundle(NAME2).then(res => { + expect(res.bundleName).assertEqual(NAME2); + expect(res.abilityName).assertEqual(ABILITYNAME2); + expect(res.deviceId).assertEqual(''); + expect(res.action).assertEqual('action.system.home'); + expect(res.entities[0]).assertEqual('entity.system.home'); + }).catch(err => { + expect(err).assertFail(); + }); + bundleMgr.getLaunchWantForBundle(NAME2, (err, res) => { + expect(err).assertEqual(0); + expect(res.bundleName).assertEqual(NAME2); + expect(res.abilityName).assertEqual(ABILITYNAME2); + expect(res.deviceId).assertEqual(''); + expect(res.action).assertEqual('action.system.home'); + expect(res.entities[0]).assertEqual('entity.system.home'); + done(); + }); + }); + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0013 + * @tc.name: testGetLaunchWantForBundleWithNotExist. + * @tc.desc: Test getLaunchWantForBundle api by promise and callback. + * @tc.author renyi 00559040 + * @tc.size MediumTest + * @tc.type Function + * @tc.level Level 2 + */ + it('testGetLaunchWantForBundleWithNotExist', 0, async function (done) { + await bundleMgr.getLaunchWantForBundle(NAME3).then(res => { + expect().assertFail(); + }).catch(err => { + expect(err).assertEqual(1); + }); + bundleMgr.getLaunchWantForBundle(NAME3, (err, res) => { + if (err) { + expect(err).assertEqual(1); + done(); + return; + } + expect().assertFail(); + done(); + }); + }); + + /* + * @tc.number: SUB_BMS_APPINFO_QUERY_0014 + * @tc.name: testGetLaunchWantForBundleWithInvalidParam. + * @tc.desc: Test getLaunchWantForBundle api by promise and callback. + * @tc.author renyi 00559040 + * @tc.size MediumTest + * @tc.type Function + * @tc.level Level 3 + */ + it('testGetLaunchWantForBundleWithInvalidParam', 0, async function (done) { + await bundleMgr.getLaunchWantForBundle(null).then(res => { + expect().assertFail(); + }).catch(err => { + expect(err).assertEqual(1); + }); + bundleMgr.getLaunchWantForBundle(null, (err, res) => { + if (err) { + expect(err).assertEqual(1); + done(); + return; + } + expect().assertFail(); + done(); + }); + }); + }); +} diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetNameForUid.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetNameForUid.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..580e791173c3891f977f791b1b48807474534188 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetNameForUid.test.ets @@ -0,0 +1,106 @@ +/* + * 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 bundle from '@ohos.bundle' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' + +const BUNDLE_NAME1 = 'com.ohos.launcher'; +const BUNDLE_NAME2 = 'com.open.harmony.packagemag'; + +export default function getNameForUid() { + describe('ActsBmsgetNameForUidTest', function () { + + /** + * @tc.number getNameForUid_0100 + * @tc.name BUNDLE::getBundleInfo + * @tc.desc Test getBundleInfo interfaces with other hap. + */ + it('getNameForUid_0100', 0, async function (done) { + let dataInfo = await bundle.getBundleInfo(BUNDLE_NAME1); + await bundle.getNameForUid(dataInfo.uid).then(data => { + expect(data).assertEqual(BUNDLE_NAME1); + }).catch(err => { + console.info("getNameForUid fail:" + JSON.stringify(err)); + expect(err).assertFail(); + }); + bundle.getNameForUid(dataInfo.uid, (err, data) => { + console.info("getNameForUid result:" + JSON.stringify(data)); + expect(data).assertEqual(BUNDLE_NAME1); + expect(err).assertEqual(0); + done(); + }); + }); + + /** + * @tc.number getNameForUid_0200 + * @tc.name BUNDLE::getBundleInfo + * @tc.desc Test getBundleInfo interfaces with hap. + */ + it('getNameForUid_0200', 0, async function (done) { + let dataInfo = await bundle.getBundleInfo(BUNDLE_NAME2); + await bundle.getNameForUid(dataInfo.uid).then(data => { + expect(data).assertEqual(BUNDLE_NAME2); + }).catch(err => { + console.info("getNameForUid fail:" + JSON.stringify(err)); + expect(err).assertFail(); + }); + bundle.getNameForUid(dataInfo.uid, (err, data) => { + console.info("getNameForUid result:" + JSON.stringify(data)); + expect(data).assertEqual(BUNDLE_NAME2); + expect(err).assertEqual(0); + done(); + }); + }); + + /** + * @tc.number getNameForUid_0300 + * @tc.name BUNDLE::getBundleInfo + * @tc.desc Test getBundleInfo interfaces with notexist hap. + */ + it('getNameForUid_0300', 0, async function (done) { + await bundle.getNameForUid(123456).then(data => { + expect(data).assertFail(); + }).catch(err => { + console.info("getNameForUid fail:" + JSON.stringify(err)); + expect(err).assertEqual(1); + }); + bundle.getNameForUid(123456, (err, data) => { + console.info("getNameForUid result:" + JSON.stringify(data)); + expect(err).assertEqual(1); + done() + }); + }); + + /** + * @tc.number getNameForUid_0400 + * @tc.name BUNDLE::getBundleInfo + * @tc.desc Test getBundleInfo interfaces with error param. + */ + it('getNameForUid_0400', 0, async function (done) { + await bundle.getNameForUid(undefined).then(data => { + expect(data).assertFail(); + }).catch(err => { + console.info("getNameForUid fail:" + JSON.stringify(err)); + expect(err).assertEqual(2); + }); + bundle.getNameForUid(undefined, (err, data) => { + console.info("getNameForUid result:" + JSON.stringify(data)); + expect(err).assertEqual(2); + done() + }); + }); + + }); +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetabilityInfo.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetabilityInfo.test.ets index e9e441a6280ab06a9125bef55b3672bcd364dc52..512b379200874acd53d7e10a54197b96038435bb 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetabilityInfo.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/GetabilityInfo.test.ets @@ -13,295 +13,338 @@ * limitations under the License. */ -import {describe, it, expect} from 'deccjsunit/index.ets'; +import { describe, it, expect } from 'deccjsunit/index.ets'; import Utils from './Utils'; import bundleManager from '@ohos.bundle'; +const BUNDLE_NAME1 = 'com.open.harmony.packagemag'; +const BUNDLE_NAME_OTHER = 'com.ohos.acecollaboration'; +const BUNDLE_NAME2 = 'com.harmony.packagemag'; +const BUNDLE_NAME3 = ""; +const BUNDLE_NAME4 = 'com.example.third1'; +const ABILITY_NAME1 = 'com.open.harmony.packagemag.MainAbility'; +const ABILITY_NAME_OTHER = 'com.ohos.acecollaboration.MainAbility'; +const ABILITY_NAME2 = 'com.harmony.packagemag1.MainAbility'; +const ABILITY_NAME3 = 'com.example.third1.MainAbility'; + export default function GetabilityInfo() { - describe('GetabilityInfo', function () { - let bundleName = "com.open.harmony.packagemag"; - let abilityName = "com.open.harmony.packagemag.MainAbility"; - let bundleName_other = "com.ohos.acecollaboration"; - let abilityName_other = "com.ohos.acecollaboration.MainAbility"; + describe('GetabilityInfo', function () { - let bundleName1 = "com.harmony.packagemag"; - let abilityName1 = "com.harmony.packagemag1.MainAbility"; + /* + * @tc.number: bundle_GetabilityInfo_test_0100 + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('bundle_GetabilityInfo_test_0100', 0, async function (done) { + let mData; + let timeOldStamp = await Utils.getNowTime(); + await bundleManager.getAbilityInfo(BUNDLE_NAME1, ABILITY_NAME1).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('bundle_GetabilityInfo_test_0100', timeOldStamp, timeNewStamp) + console.info('[bundle_GetabilityInfo_test_0100] getApplicationInfo promise data is: ' + JSON.stringify(data)); + for (const item in data) { + const a = data[item]; + console.info(item + ":" + JSON.stringify(a)); + }; + expect(typeof (data)).assertEqual("object"); + mData = data; + checkAbilityInfo(mData); + done(); + }).catch((error) => { + console.error('[bundle_GetabilityInfo_test_0100]Operation failed. Cause: ' + JSON.stringify(error)); + expect(error).assertFail(); + done(); + }); + }); - /* - * @tc.number: bundle_GetabilityInfo_test_0100 - * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it('bundle_GetabilityInfo_test_0100', 0, async function (done) { - let mData; - var timeOldStamp = await Utils.getNowTime(); - await bundleManager.getAbilityInfo(bundleName, abilityName) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('bundle_GetabilityInfo_test_0100', timeOldStamp, timeNewStamp) - console.info('[bundle_GetabilityInfo_test_0100] getApplicationInfo promise data is: ' + JSON.stringify(data)); - expect(typeof (data)).assertEqual("object"); - mData = data; - }).catch((error) => { - console.error('[bundle_GetabilityInfo_test_0100]Operation failed. Cause: ' + JSON.stringify(error)); - expect(error).assertFail(); - }) - checkAbilityInfo(mData); - done(); - }); + /* + * @tc.number: bundle_GetabilityInfo_test_0200 + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('bundle_GetabilityInfo_test_0200', 0, async function (done) { + let mData; + let timeOldStamp = await Utils.getNowTime(); + bundleManager.getAbilityInfo(BUNDLE_NAME1, ABILITY_NAME1, (err, data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('bundle_GetabilityInfo_test_0200', timeOldStamp, timeNewStamp); + if (err) { + console.error('[bundle_GetabilityInfo_test_0200]Operation failed. Cause: ' + JSON.stringify(err)); + expect(err).assertFail(); + } + console.info('[bundle_GetabilityInfo_test_0200] getApplicationInfo callback data is: ' + JSON.stringify(data)); + mData = data; + Utils.sleep(2000); + checkAbilityInfo(mData); + done(); + }); + }); + + /* + * @tc.number: testgetAbilityInfoOtherBundle + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('testgetAbilityInfoOtherBundle', 0, async function (done) { + await bundleManager.getAbilityInfo(BUNDLE_NAME4, ABILITY_NAME3).then(res => { + checkAbilityInfo_other(res); + console.info('actwsBundleManager getAbilityInfo promise success res:' + JSON.stringify(res)); + for (const item in res) { + const a = res[item]; + console.info(item + ":" + JSON.stringify(a)); + }; + }).catch(err => { + console.info('actwsBundleManager getAbilityInfo promise err:' + JSON.stringify(err)); + expect().assertFail(); + }); + bundleManager.getAbilityInfo(BUNDLE_NAME4, ABILITY_NAME3, (err, res) => { + if (err) { + console.info('actwsBundleManager getAbilityInfo callback err:' + JSON.stringify(err)); + expect().assertFail(); + done(); + return; + } + checkAbilityInfo_other(res); + console.info('actwsBundleManager getAbilityInfo callback success res:' + JSON.stringify(res)); + for (const item in res) { + const a = res[item]; + console.info(item + ":" + JSON.stringify(a)); + }; + done(); + }); + }); - /* - * @tc.number: bundle_GetabilityInfo_test_0200 - * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information - * @tc.desc: Check the return value of the interface (by callback) - * @tc.level 0 - */ - it('bundle_GetabilityInfo_test_0200', 0, async function (done) { - let mData; - var timeOldStamp = await Utils.getNowTime(); - await bundleManager.getAbilityInfo(bundleName, abilityName, (err, data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('bundle_GetabilityInfo_test_0200', timeOldStamp, timeNewStamp) - if (err) { - console.error('[bundle_GetabilityInfo_test_0200]Operation failed. Cause: ' + JSON.stringify(err)); - expect(err).assertFail(); - } - console.info('[bundle_GetabilityInfo_test_0200] getApplicationInfo callback data is: ' + JSON.stringify(data)); - mData = data; - }) - await Utils.sleep(2000); - checkAbilityInfo(mData); - done(); - }); - /* - * @tc.number: bundle_GetabilityInfo_test_0300 - * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it('bundle_GetabilityInfo_test_0300', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - await bundleManager.getAbilityInfo(bundleName_other, abilityName_other) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('bundle_GetabilityInfo_test_0300',timeOldStamp,timeNewStamp) - expect(data).assertFail(); - }).catch((error) => { - console.error('[bundle_GetabilityInfo_test_0300]Operation failed. Cause: ' + JSON.stringify(error)); - expect(error).assertEqual(1); + /* + * @tc.number: bundle_GetabilityInfo_test_0300 + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('bundle_GetabilityInfo_test_0300', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + await bundleManager.getAbilityInfo(BUNDLE_NAME_OTHER, ABILITY_NAME_OTHER).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('bundle_GetabilityInfo_test_0300', timeOldStamp, timeNewStamp); + expect(data).assertFail(); + }).catch((error) => { + console.error('[bundle_GetabilityInfo_test_0300]Operation failed. Cause: ' + JSON.stringify(error)); + expect(error).assertEqual(1); + }); + done(); }); - done(); - }); - /* - * @tc.number: bundle_GetabilityInfo_test_0400 - * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it('bundle_GetabilityInfo_test_0400', 0, async function (done) { - let error1; - var timeOldStamp = await Utils.getNowTime(); - bundleManager.getAbilityInfo(bundleName1, abilityName) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('bundle_GetabilityInfo_test_0400', timeOldStamp, timeNewStamp) - console.info('[bundle_GetabilityInfo_test_0400] getApplicationInfo data is: ' + JSON.stringify(data)); - expect(typeof (data)).assertEqual("object"); - }).catch((error) => { - console.error('[bundle_GetabilityInfo_test_0400]Operation failed. Cause: ' + JSON.stringify(error)); - error1 = error; - }) - await Utils.sleep(1000); - await expect(error1).assertEqual(1); - done(); - }); + /* + * @tc.number: bundle_GetabilityInfo_test_0400 + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('bundle_GetabilityInfo_test_0400', 0, async function (done) { + let error1; + let timeOldStamp = await Utils.getNowTime(); + await bundleManager.getAbilityInfo(BUNDLE_NAME2, ABILITY_NAME1).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('bundle_GetabilityInfo_test_0400', timeOldStamp, timeNewStamp); + console.info('[bundle_GetabilityInfo_test_0400] getApplicationInfo data is: ' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }).catch((error) => { + console.error('[bundle_GetabilityInfo_test_0400]Operation failed. Cause: ' + JSON.stringify(error)); + error1 = error; + }); + await Utils.sleep(1000); + await expect(error1).assertEqual(1); + done(); + }); - /* - * @tc.number: bundle_GetabilityInfo_test_0500 - * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information - * @tc.desc: Check the return value of the interface (by callback) - * @tc.level 0 - */ - it('bundle_GetabilityInfo_test_0500', 0, async function (done) { - let error - await bundleManager.getAbilityInfo(bundleName, abilityName1).then((data) => { - console.info('[bundle_GetabilityInfo_test_0500] START' + JSON.stringify(data)); - }).catch((err) => { - console.info('[bundle_GetabilityInfo_test_0500] err = ' + JSON.stringify(err)); - error = err - }) - expect(error).assertEqual(1); - done(); - console.info('[bundle_GetabilityInfo_test_0500] END'); - }); + /* + * @tc.number: bundle_GetabilityInfo_test_0500 + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('bundle_GetabilityInfo_test_0500', 0, async function (done) { + let error + await bundleManager.getAbilityInfo(BUNDLE_NAME1, ABILITY_NAME2).then((data) => { + console.info('[bundle_GetabilityInfo_test_0500] START' + JSON.stringify(data)); + }).catch((err) => { + console.info('[bundle_GetabilityInfo_test_0500] err = ' + JSON.stringify(err)); + error = err; + }) + expect(error).assertEqual(1); + done(); + console.info('[bundle_GetabilityInfo_test_0500] END'); + }); - /* - * @tc.number: bundle_GetabilityInfo_test_0600 - * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - let bundleName2 = ""; - it('bundle_GetabilityInfo_test_0600', 0, async function (done) { - let error1; - var timeOldStamp = await Utils.getNowTime(); - bundleManager.getAbilityInfo(bundleName2, abilityName) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('bundle_GetabilityInfo_test_0600', timeOldStamp, timeNewStamp) - console.info('[bundle_GetabilityInfo_test_0600] getApplicationInfo data promise is: ' + JSON.stringify(data)); - expect(typeof (data)).assertEqual("object"); - }).catch((error) => { - console.error('[bundle_GetabilityInfo_test_0600]Operation failed. Cause: ' + JSON.stringify(error)); - error1 = error; - }) - await Utils.sleep(1000); - await expect(error1).assertEqual(1); - done(); - }); + /* + * @tc.number: bundle_GetabilityInfo_test_0600 + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('bundle_GetabilityInfo_test_0600', 0, async function (done) { + let error1; + let timeOldStamp = await Utils.getNowTime(); + await bundleManager.getAbilityInfo(BUNDLE_NAME3, ABILITY_NAME1).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('bundle_GetabilityInfo_test_0600', timeOldStamp, timeNewStamp); + console.info('[bundle_GetabilityInfo_test_0600] getApplicationInfo data promise is: ' + JSON.stringify(data)); + expect(typeof (data)).assertEqual("object"); + }).catch((error) => { + console.error('[bundle_GetabilityInfo_test_0600]Operation failed. Cause: ' + JSON.stringify(error)); + error1 = error; + }) + await Utils.sleep(1000); + await expect(error1).assertEqual(1); + done(); + }); - /** - * 打印AbilityInfo属性信息 - * @param data - */ - function checkAbilityInfo(data) { - expect(typeof (data.bundleName)).assertEqual("string"); - expect(data.bundleName).assertEqual("com.open.harmony.packagemag") - expect(typeof (data.name)).assertEqual("string"); - expect(data.name).assertEqual("com.open.harmony.packagemag.MainAbility"); - expect(data.label).assertEqual("$string:entry_MainAbility"); - 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("MainAbility"); - expect(typeof (data.srcPath)).assertEqual("string"); - expect(data.srcLanguage).assertEqual("ets"); - expect(typeof (data.srcLanguage)).assertEqual("string"); - expect(data.isVisible).assertEqual(true); - expect(Array.isArray(data.permissions)).assertEqual(true); - expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); - 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"); - checkApplicationInfo(data.applicationInfo); - console.log("---checkAbilityInfo End--- "); - } + /* + * @tc.number: testgetAbilityInfoOtherBundle + * @tc.name: getAbilityInfo : The basic ability is enhanced to obtain the specified Ability information + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('testgetAbilityInfoUndefined', 0, async function (done) { + await bundleManager.getAbilityInfo(undefined, undefined).then(res => { + console.info('actwsBundleManager getAbilityInfo promise success res:' + JSON.stringify(res)); + expect().assertFail(); + }).catch(err => { + expect(err).assertEqual(2); + }); + bundleManager.getAbilityInfo(null, null, (err, res) => { + if (err) { + expect(err).assertEqual(2); + done(); + return; + } + console.info('actwsBundleManager getAbilityInfo callback success res:' + JSON.stringify(res)); + expect().assertFail(); + done(); + }); + }); - /** - * 打印ApplicationInfo属性信息 - * @param data - */ - function checkApplicationInfo(info) { - expect(typeof (info)).assertEqual("object") - expect(typeof (info.name)).assertEqual("string") - expect(info.name).assertEqual("com.open.harmony.packagemag"); - expect(typeof (info.codePath)).assertEqual("string") - expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag"); - 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:entry_MainAbility") - 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.open.harmony.packagemag/com.open.harmony.packagemag"); - expect(typeof (info.supportedModes)).assertEqual("number") - expect(info.supportedModes).assertEqual(0) - expect(typeof (info.process)).assertEqual("string") - expect(info.process).assertEqual("") - expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true); - expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag"); - expect(Array.isArray(info.permissions)).assertEqual(true); - } + function checkAbilityInfo(data) { + expect(typeof (data.bundleName)).assertEqual("string"); + expect(data.bundleName).assertEqual("com.open.harmony.packagemag"); + expect(typeof (data.name)).assertEqual("string"); + expect(data.name).assertEqual("com.open.harmony.packagemag.MainAbility"); + expect(data.label).assertEqual("$string:entry_MainAbility"); + 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("MainAbility"); + expect(typeof (data.srcPath)).assertEqual("string"); + expect(data.srcLanguage).assertEqual("ets"); + expect(typeof (data.srcLanguage)).assertEqual("string"); + expect(data.isVisible).assertEqual(true); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); + 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"); + checkApplicationInfo(data.applicationInfo); + console.log("---checkAbilityInfo End--- "); + } - /** - * 打印ApplicationInfo属性信息 - * @param data - */ - function checkAbilityInfo_other(data) { - expect(typeof (data.bundleName)).assertEqual("string"); - expect(data.bundleName).assertEqual("com.ohos.acecollaboration"); - expect(typeof (data.name)).assertEqual("string"); - expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility"); - expect(data.label).assertEqual("$string:entry_MainAbility"); - 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("MainAbility"); - expect(typeof (data.srcPath)).assertEqual("string"); - expect(data.srcLanguage).assertEqual("ets"); - expect(typeof (data.srcLanguage)).assertEqual("string"); - expect(data.isVisible).assertEqual(true); - expect(Array.isArray(data.permissions)).assertEqual(true); - expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); - 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"); - checkApplicationInfo_other(data.applicationInfo); - console.log("---checkAbilityInfo_other End--- "); - } + function checkApplicationInfo(info) { + expect(typeof (info)).assertEqual("object"); + expect(typeof (info.name)).assertEqual("string"); + expect(info.name).assertEqual("com.open.harmony.packagemag"); + expect(typeof (info.codePath)).assertEqual("string"); + expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag"); + 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:entry_MainAbility"); + 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.open.harmony.packagemag/com.open.harmony.packagemag"); + expect(typeof (info.supportedModes)).assertEqual("number"); + expect(info.supportedModes).assertEqual(0); + expect(typeof (info.process)).assertEqual("string"); + expect(info.process).assertEqual(""); + expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true); + expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag"); + expect(Array.isArray(info.permissions)).assertEqual(true); + } + + async function checkAbilityInfo_other(data) { + expect(data.bundleName).assertEqual("com.example.third1"); + expect(data.name).assertEqual("com.example.third1.MainAbility"); + expect(data.label).assertEqual("$string:app_name"); + expect(data.description).assertEqual("$string:mainability_description"); + expect(data.icon).assertEqual("$media:icon"); + expect(data.srcPath).assertEqual(""); + expect(data.srcLanguage).assertEqual("js"); + expect(data.isVisible).assertEqual(true); + expect(data.deviceTypes[0]).assertEqual("phone"); + expect(data.process).assertEqual(""); + expect(data.uri).assertEqual(""); + expect(data.moduleName).assertEqual("entry"); + expect(data.type).assertEqual(1); + expect(data.orientation).assertEqual(0); + expect(data.launchMode).assertEqual(1); + expect(data.backgroundModes).assertEqual(0); + expect(data.descriptionId).assertLarger(0); + expect(data.formEnabled).assertEqual(false); + expect(data.iconId).assertLarger(0); + except(data.labelId).assertLarger(0); + expect(data.subType).assertEqual(0); + except(data.enabled).assertEqual(true); + expect(data.readPermission).assertEqual(""); + expect(data.writePermission).assertEqual(""); + expect(data.targetAbility).assertEqual(""); + expect(data.theme).assertEqual(""); + expect(data.metaData).assertEqual([]); + expect(data.metadata).assertEqual([]); + checkApplicationInfo_other(data.applicationInfo); + console.log("---checkAbilityInfo_other End--- "); + } - /** - * 打印ApplicationInfo属性信息 - * @param data - */ - function checkApplicationInfo_other(info) { - expect(typeof (info)).assertEqual("object") - expect(typeof (info.name)).assertEqual("string") - expect(info.name).assertEqual("com.ohos.acecollaboration"); - expect(typeof (info.codePath)).assertEqual("string") - expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration"); - 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:entry_MainAbility") - 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.ohos.acecollaboration/com.ohos.acecollaboration"); - expect(typeof (info.supportedModes)).assertEqual("number") - expect(info.supportedModes).assertEqual(0) - expect(typeof (info.process)).assertEqual("string") - expect(info.process).assertEqual("") - expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true); - expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration/com.ohos.acecollaboration"); - expect(Array.isArray(info.permissions)).assertEqual(true); - } - }); + async function checkApplicationInfo_other(info) { + expect(info.name).assertEqual("com.example.third1"); + expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.example.third1"); + expect(info.accessTokenId > 0).assertTrue(); + expect(info.description).assertEqual("$string:mainability_description"); + expect(info.descriptionId > 0).assertTrue(); + expect(info.icon).assertEqual("$media:icon"); + expect(info.iconId > 0).assertTrue(); + expect(info.label).assertEqual("$string:app_name"); + expect(info.labelId > 0).assertTrue(); + expect(info.systemApp).assertEqual(true); + expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration/com.ohos.acecollaboration"); + expect(info.supportedModes).assertEqual(0); + expect(info.process).assertEqual(""); + expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration/com.ohos.acecollaboration"); + expect(info.metaData).expect({}); + expect(info.metadata).expect({}); + expect(info.enabled).expect(true); + expect(info.flags).expect(0); + expect(info.uid).assertLarger(0); + expect(info.entityType).assertEqual("unspecified"); + expect(info.removable).assertEqual(true); + } + }); } \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsAbilityEnabledETSUnit.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsAbilityEnabledETSUnit.ets index 275d03f206729ddd57a398aa469bb3b4241fe9f0..d3f3a4d400158668e23dbda4ebe26c913dc2616b 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsAbilityEnabledETSUnit.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsAbilityEnabledETSUnit.ets @@ -12,274 +12,259 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {describe, it, expect} from 'deccjsunit/index.ets'; +import { describe, it, expect } from 'deccjsunit/index.ets'; import Utils from './Utils'; import Bundle from '@ohos.bundle'; -const BUNDLE_NAME = 'com.open.harmony.packagemag' -const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility' +const BUNDLE_NAME = 'com.open.harmony.packagemag'; +const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error'; +const ABILITY_NAME = 'com.open.harmony.packagemag.MainAbility'; +const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility'; const ABILITY = { - bundleName: BUNDLE_NAME, - name: ABILITY_NAME + bundleName: BUNDLE_NAME, + name: ABILITY_NAME } - -const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error' -const ABILITY_NAME_ERROR = 'com.ohos.acepackage.error.MainAbility' const ABILITY_ERROR = { - bundleName: BUNDLE_NAME_ERROR, - name: ABILITY_NAME_ERROR + bundleName: BUNDLE_NAME_ERROR, + name: ABILITY_NAME_ERROR } export default function isAbilityEnabledETSUnit() { - describe('context_isAbilityEnabled_test', function () { - /* - * @tc.number: context_isAbilityEnabled_test_0100 - * @tc.name: isAbilityEnabled : Get whether to enable a specified ability - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it('context_isAbilityEnabled_test_0100', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - let mData; - await Bundle.isAbilityEnabled(ABILITY) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isAbilityEnabled_test_0100]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isAbilityEnabled_test_0100] promise data is: ' + JSON.stringify(data)); - }) - .catch((error) => { - console.info('[context_isAbilityEnabled_test_0100] promise error is: ' + error); - expect(error).assertFail(); - }); - getAbilityEnabledSuccess('[context_isAbilityEnabled_test_0100]', mData); - done(); - }); - /* - * @tc.number: context_isAbilityEnabled_test_0200 - * @tc.name: isAbilityEnabled : Get whether to enable a specified ability - * @tc.desc: Check the return value of the interface (by callback) - * @tc.level 0 - */ - it('context_isAbilityEnabled_test_0200', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - let mData; - Bundle.isAbilityEnabled(ABILITY, (error, data) => { - if(error){ - console.error('[context_isAbilityEnabled_test_0200]Operation failed. Cause: ' + JSON.stringify(error)); - expect(error).assertFail(); - } - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isAbilityEnabled_test_0200]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isAbilityEnabled_test_0200] callBack error: ' + error); - console.info('[context_isAbilityEnabled_test_0200] callBack data is:' + JSON.stringify(data)); - }); - await Utils.sleep(2000); - getAbilityEnabledSuccess('[context_isAbilityEnabled_test_0200]', mData); - done(); - }); + describe('context_isAbilityEnabled_test', function () { - /* - * @tc.number: context_isAbilityEnabled_test_0300 - * @tc.name: isAbilityEnabled : Get whether to enable a specified ability - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it('context_isAbilityEnabled_test_0300', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - let mData; - await Bundle.isAbilityEnabled(ABILITY_ERROR) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isAbilityEnabled_test_0300] promise data is: ' + JSON.stringify(data)); - }) - .catch((error) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp); - console.info('[context_isAbilityEnabled_test_0300] promise error is: ' + error); - expect(error).assertFail(); + /* + * @tc.number: context_isAbilityEnabled_test_0100 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0100', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isAbilityEnabled(ABILITY).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0100]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0100] promise data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isAbilityEnabled_test_0100] promise error is: ' + error); + expect(error).assertFail(); + }); + getAbilityEnabledSuccess('[context_isAbilityEnabled_test_0100]', mData); + done(); }); - getAbilityEnabledFalse('[context_isAbilityEnabled_test_0300]', mData); - done(); - }); - - /* - * @tc.number: context_isAbilityEnabled_test_0400 - * @tc.name: isAbilityEnabled : Get whether to enable a specified ability - * @tc.desc: Check the return value of the interface (by callback) - * @tc.level 0 - */ - it('context_isAbilityEnabled_test_0400', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - let mData; - Bundle.isAbilityEnabled(ABILITY_ERROR, (error, data) => { - if(error){ - console.error('[context_isAbilityEnabled_test_0400]Operation failed. Cause: ' + JSON.stringify(error)); - expect(error).assertFail(); - } - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isAbilityEnabled_test_0400] callBack error: ' + error); - console.info('[context_isAbilityEnabled_test_0400] callBack data is:' + JSON.stringify(data)); - }); - await Utils.sleep(2000); - console.info('[context_isAbilityEnabled_test_0400] Failure '); - getAbilityEnabledFalse('[context_isAbilityEnabled_test_0300]', mData); - done(); - }); + /* + * @tc.number: context_isAbilityEnabled_test_0200 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0200', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.isAbilityEnabled(ABILITY, (error, data) => { + if (error) { + console.error('[context_isAbilityEnabled_test_0200]Operation failed. Cause: ' + JSON.stringify(error)); + expect(error).assertFail(); + } + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0200]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0200] callBack error: ' + error); + console.info('[context_isAbilityEnabled_test_0200] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getAbilityEnabledSuccess('[context_isAbilityEnabled_test_0200]', mData); + done(); + }); - /* - * @tc.number: context_isAbilityEnabled_test_0500 - * @tc.name: isAbilityEnabled : Get whether to enable a specified ability - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it('context_isAbilityEnabled_test_0500', 0, async function (done) { - await Bundle.setAbilityEnabled(ABILITY, true) - .then((data) => { - console.info('[context_isAbilityEnabled_test_0500] set enable true data is: ' + JSON.stringify(data)); - }).catch((error) => { - console.info('[context_isAbilityEnabled_test_0500] set enable true error is: ' + error); - expect(error).assertFail(); - }) + /* + * @tc.number: context_isAbilityEnabled_test_0300 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0300', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isAbilityEnabled(ABILITY_ERROR).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0300] promise data is: ' + JSON.stringify(data)); + }).catch((error) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp); + console.info('[context_isAbilityEnabled_test_0300] promise error is: ' + error); + expect(error).assertFail(); + }); + getAbilityEnabledFalse('[context_isAbilityEnabled_test_0300]', mData); + done(); + }); - var timeOldStamp = await Utils.getNowTime(); - let mData; - await Bundle.isAbilityEnabled(ABILITY) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isAbilityEnabled_test_0500]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isAbilityEnabled_test_0500] promise data is: ' + JSON.stringify(data)); - }) - .catch((error) => { - console.info('[context_isAbilityEnabled_test_0500] promise error is: ' + error); - expect(error).assertFail(); + /* + * @tc.number: context_isAbilityEnabled_test_0400 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0400', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.isAbilityEnabled(ABILITY_ERROR, (error, data) => { + if (error) { + console.error('[context_isAbilityEnabled_test_0400]Operation failed. Cause: ' + JSON.stringify(error)); + expect(error).assertFail(); + } + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0400] callBack error: ' + error); + console.info('[context_isAbilityEnabled_test_0400] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + console.info('[context_isAbilityEnabled_test_0400] Failure '); + getAbilityEnabledFalse('[context_isAbilityEnabled_test_0300]', mData); + done(); }); - getAbilityEnabledTrue('[context_isAbilityEnabled_test_0500]', mData); - done(); - }); - /* - * @tc.number: context_isAbilityEnabled_test_0600 - * @tc.name: isAbilityEnabled : Get whether to enable a specified ability - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it('context_isAbilityEnabled_test_0600', 0, async function (done) { - await Bundle.setAbilityEnabled(ABILITY, false) - .then((data) => { - console.info('[context_isAbilityEnabled_test_0600] set enable false data is: ' + JSON.stringify(data)); - }).catch((error) => { - console.info('[context_isAbilityEnabled_test_0600] set enable false error is: ' + error); - expect(error).assertFail(); - }) - var timeOldStamp = await Utils.getNowTime(); - let mData; - await Bundle.isAbilityEnabled(ABILITY) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isAbilityEnabled_test_0600]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isAbilityEnabled_test_0600] promise data is: ' + JSON.stringify(data)); - }) - .catch((error) => { - console.info('[context_isAbilityEnabled_test_0600] promise error is: ' + error); - expect(error).assertFail(); + /* + * @tc.number: context_isAbilityEnabled_test_0500 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0500', 0, async function (done) { + await Bundle.setAbilityEnabled(ABILITY, true).then((data) => { + console.info('[context_isAbilityEnabled_test_0500] set enable true data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isAbilityEnabled_test_0500] set enable true error is: ' + error); + expect(error).assertFail(); + }) + let timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isAbilityEnabled(ABILITY).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0500]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0500] promise data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isAbilityEnabled_test_0500] promise error is: ' + error); + expect(error).assertFail(); + }); + getAbilityEnabledTrue('[context_isAbilityEnabled_test_0500]', mData); + done(); }); - getAbilityEnabledFalse('[context_isAbilityEnabled_test_0600]', mData); - done(); - }); - /* - * @tc.number: context_isAbilityEnabled_test_0700 - * @tc.name: isAbilityEnabled : Get whether to enable a specified ability - * @tc.desc: Check the return value of the interface (by callback) - * @tc.level 0 - */ - it('context_isAbilityEnabled_test_0700', 0, async function (done) { - await Bundle.setAbilityEnabled(ABILITY, true) - .then((data) => { - console.info('[context_isAbilityEnabled_test_0700] set enable true data is: ' + JSON.stringify(data)); - }).catch((error) => { - console.info('[context_isAbilityEnabled_test_0700] set enable true error is: ' + error); - expect(error).assertFail(); - }) + /* + * @tc.number: context_isAbilityEnabled_test_0600 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0600', 0, async function (done) { + await Bundle.setAbilityEnabled(ABILITY, false).then((data) => { + console.info('[context_isAbilityEnabled_test_0600] set enable false data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isAbilityEnabled_test_0600] set enable false error is: ' + error); + expect(error).assertFail(); + }) + let timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isAbilityEnabled(ABILITY).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0600]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0600] promise data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isAbilityEnabled_test_0600] promise error is: ' + error); + expect(error).assertFail(); + }); + getAbilityEnabledFalse('[context_isAbilityEnabled_test_0600]', mData); + done(); + }); - var timeOldStamp = await Utils.getNowTime(); - let mData; - Bundle.isAbilityEnabled(ABILITY, (error, data) => { - if(error){ - console.error('[context_isAbilityEnabled_test_0700]Operation failed. Cause: ' + JSON.stringify(error)); - expect(error).assertFail(); - } - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isAbilityEnabled_test_0700]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isAbilityEnabled_test_0700] callBack error: ' + error); - console.info('[context_isAbilityEnabled_test_0700] callBack data is:' + JSON.stringify(data)); - }); - await Utils.sleep(2000); - getAbilityEnabledTrue('[context_isAbilityEnabled_test_0700]', mData); - done(); - }); + /* + * @tc.number: context_isAbilityEnabled_test_0700 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0700', 0, async function (done) { + await Bundle.setAbilityEnabled(ABILITY, true).then((data) => { + console.info('[context_isAbilityEnabled_test_0700] set enable true data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isAbilityEnabled_test_0700] set enable true error is: ' + error); + expect(error).assertFail(); + }) + let timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.isAbilityEnabled(ABILITY, (error, data) => { + if (error) { + console.error('[context_isAbilityEnabled_test_0700]Operation failed. Cause: ' + JSON.stringify(error)); + expect(error).assertFail(); + } + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0700]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0700] callBack error: ' + error); + console.info('[context_isAbilityEnabled_test_0700] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getAbilityEnabledTrue('[context_isAbilityEnabled_test_0700]', mData); + done(); + }); - /* - * @tc.number: context_isAbilityEnabled_test_0800 - * @tc.name: isAbilityEnabled : Get whether to enable a specified ability - * @tc.desc: Check the return value of the interface (by callback) - * @tc.level 0 - */ - it('context_isAbilityEnabled_test_0800', 0, async function (done) { - await Bundle.setAbilityEnabled(ABILITY, false) - .then((data) => { - console.info('[context_isAbilityEnabled_test_0800] set enable false data is: ' + JSON.stringify(data)); - }).catch((error) => { - console.info('[context_isAbilityEnabled_test_0800] set enable false error is: ' + error); - expect(error).assertFail(); - }) + /* + * @tc.number: context_isAbilityEnabled_test_0800 + * @tc.name: isAbilityEnabled : Get whether to enable a specified ability + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isAbilityEnabled_test_0800', 0, async function (done) { + await Bundle.setAbilityEnabled(ABILITY, false).then((data) => { + console.info('[context_isAbilityEnabled_test_0800] set enable false data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isAbilityEnabled_test_0800] set enable false error is: ' + error); + expect(error).assertFail(); + }) + let timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.isAbilityEnabled(ABILITY, (error, data) => { + if (error) { + console.error('[context_isAbilityEnabled_test_0800]Operation failed. Cause: ' + JSON.stringify(error)); + expect(error).assertFail(); + } + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isAbilityEnabled_test_0800]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isAbilityEnabled_test_0800] callBack error: ' + error); + console.info('[context_isAbilityEnabled_test_0800] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getAbilityEnabledFalse('[context_isAbilityEnabled_test_0800]', mData); + done(); + }); - var timeOldStamp = await Utils.getNowTime(); - let mData; - Bundle.isAbilityEnabled(ABILITY, (error, data) => { - if(error){ - console.error('[context_isAbilityEnabled_test_0800]Operation failed. Cause: ' + JSON.stringify(error)); - expect(error).assertFail(); + function getAbilityEnabledSuccess(msg, data) { + console.log(msg + ' start ' + JSON.stringify(data)); + console.log(msg + ' data : ' + data); + expect(typeof (data)).assertEqual('boolean') } - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isAbilityEnabled_test_0800]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isAbilityEnabled_test_0800] callBack error: ' + error); - console.info('[context_isAbilityEnabled_test_0800] callBack data is:' + JSON.stringify(data)); - }); - await Utils.sleep(2000); - getAbilityEnabledFalse('[context_isAbilityEnabled_test_0800]', mData); - done(); - }); + function getAbilityEnabledTrue(msg, data) { + getAbilityEnabledSuccess(msg, data); + expect(data).assertEqual(true); + } - function getAbilityEnabledSuccess(msg, data) { - console.log(msg + ' start ' + JSON.stringify(data)); - console.log(msg + ' data : ' + data); - expect(typeof (data)).assertEqual('boolean') - } - - function getAbilityEnabledTrue(msg, data) { - getAbilityEnabledSuccess(msg, data); - expect(data).assertEqual(true); - } + function getAbilityEnabledFalse(msg, data) { + getAbilityEnabledSuccess(msg, data); + expect(data).assertEqual(false); + } - function getAbilityEnabledFalse(msg, data) { - getAbilityEnabledSuccess(msg, data); - expect(data).assertEqual(false); - } + }) - }) } \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsApplicationEnabledETSUnit.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsApplicationEnabledETSUnit.ets index 76905279163c26f97a1cc08ed0ff174498e4b1c5..19f9aec604794ce886310bc0619c12bad0a05567 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsApplicationEnabledETSUnit.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/IsApplicationEnabledETSUnit.ets @@ -12,197 +12,191 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {describe, it, expect} from 'deccjsunit/index.ets'; +import { describe, it, expect } from 'deccjsunit/index.ets'; import Utils from './Utils'; import Bundle from '@ohos.bundle'; const BUNDLE_NAME = 'com.open.harmony.packagemag' - const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error' export default function IsApplicationEnabledETSUnit() { - describe('context_isApplicationEnabled_test', function () { - /* - * @tc.number: context_isApplicationEnabled_test_0100 - * @tc.name: isApplicationEnabled : Get whether to enable a specified application - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it('context_isApplicationEnabled_test_0100', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - let mData; - await Bundle.isApplicationEnabled(BUNDLE_NAME) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isApplicationEnabled_test_0100]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isApplicationEnabled_test_0100] promise data is: ' + JSON.stringify(data)); - }) - .catch((error) => { - console.info('[context_isApplicationEnabled_test_0100] promise error is: ' + error); - expect(error).assertFail(); - }); - getApplicationEnabledSuccess('[context_isApplicationEnabled_test_0100]', mData); - done(); - }); - /* - * @tc.number: context_isApplicationEnabled_test_0200 - * @tc.name: isApplicationEnabled : Get whether to enable a specified application - * @tc.desc: Check the return value of the interface (by callback) - * @tc.level 0 - */ - it('context_isApplicationEnabled_test_0200', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - let mData; - Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => { - if(error){ - console.error('[context_isApplicationEnabled_test_0200]Operation failed. Cause: ' + JSON.stringify(error)); - expect(error).assertFail(); - } - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isApplicationEnabled_test_0200]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isApplicationEnabled_test_0200] callBack error: ' + error); - console.info('[context_isApplicationEnabled_test_0200] callBack data is:' + JSON.stringify(data)); - }); - await Utils.sleep(2000); - getApplicationEnabledSuccess('[context_isApplicationEnabled_test_0200]', mData); - done(); - }); + describe('context_isApplicationEnabled_test', function () { - /* - * @tc.number: context_isApplicationEnabled_test_0300 - * @tc.name: isApplicationEnabled : Get whether to enable a specified application - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it('context_isApplicationEnabled_test_0300', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - let mData; - await Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isApplicationEnabled_test_0300]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isApplicationEnabled_test_0300] promise data is: ' + JSON.stringify(data)); - }) - .catch((error) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isApplicationEnabled_test_0300]', timeOldStamp, timeNewStamp); - console.info('[context_isApplicationEnabled_test_0300] promise error is: ' + error); - expect(error).assertFail(); + /* + * @tc.number: context_isApplicationEnabled_test_0100 + * @tc.name: isApplicationEnabled : Get whether to enable a specified application + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isApplicationEnabled_test_0100', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isApplicationEnabled(BUNDLE_NAME).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0100]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isApplicationEnabled_test_0100] promise data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isApplicationEnabled_test_0100] promise error is: ' + error); + expect(error).assertFail(); + }); + getApplicationEnabledSuccess('[context_isApplicationEnabled_test_0100]', mData); + done(); }); - getApplicationEnabledFalse('[context_isApplicationEnabled_test_0300]', mData); - done(); - }); - /* - * @tc.number: context_isApplicationEnabled_test_0400 - * @tc.name: isApplicationEnabled : Get whether to enable a specified application - * @tc.desc: Check the return value of the interface (by callback) - * @tc.level 0 - */ - it('context_isApplicationEnabled_test_0400', 0, async function (done) { - var timeOldStamp = await Utils.getNowTime(); - let mData; - Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR, (error, data) => { - if(error){ - console.error('[context_isApplicationEnabled_test_0400]Operation failed. Cause: ' + JSON.stringify(error)); - expect(error).assertFail(); - } - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isApplicationEnabled_test_0400]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isApplicationEnabled_test_0400] callBack error: ' + error); - console.info('[context_isApplicationEnabled_test_0400] callBack data is:' + JSON.stringify(data)); - }); - await Utils.sleep(2000); - getApplicationEnabledFalse('[context_isApplicationEnabled_test_0300]', mData); - console.info('[context_isApplicationEnabled_test_0400] Failure '); - done(); - }); + /* + * @tc.number: context_isApplicationEnabled_test_0200 + * @tc.name: isApplicationEnabled : Get whether to enable a specified application + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isApplicationEnabled_test_0200', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => { + if (error) { + console.error('[context_isApplicationEnabled_test_0200]Operation failed. Cause: ' + JSON.stringify(error)); + expect(error).assertFail(); + } + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0200]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isApplicationEnabled_test_0200] callBack error: ' + error); + console.info('[context_isApplicationEnabled_test_0200] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getApplicationEnabledSuccess('[context_isApplicationEnabled_test_0200]', mData); + done(); + }); - /* - * @tc.number: context_isApplicationEnabled_test_0500 - * @tc.name: isApplicationEnabled : Get whether to enable a specified application - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it('context_isApplicationEnabled_test_0500', 0, async function (done) { - await Bundle.setApplicationEnabled(BUNDLE_NAME, true) - .then((data) => { - console.info('[context_isApplicationEnabled_test_0500] set enable true data is: ' + JSON.stringify(data)); - }).catch((error) => { - console.info('[context_isApplicationEnabled_test_0500] set enable true error is: ' + error); - expect(error).assertFail(); + /* + * @tc.number: context_isApplicationEnabled_test_0300 + * @tc.name: isApplicationEnabled : Get whether to enable a specified application + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isApplicationEnabled_test_0300', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0300]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isApplicationEnabled_test_0300] promise data is: ' + JSON.stringify(data)); + }).catch((error) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0300]', timeOldStamp, timeNewStamp); + console.info('[context_isApplicationEnabled_test_0300] promise error is: ' + error); + expect(error).assertFail(); + }); + getApplicationEnabledFalse('[context_isApplicationEnabled_test_0300]', mData); + done(); }); - await Utils.sleep(1000); - var timeOldStamp = await Utils.getNowTime(); - let mData; - await Bundle.isApplicationEnabled(BUNDLE_NAME) - .then((data) => { - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isApplicationEnabled_test_0500]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isApplicationEnabled_test_0500] promise data is: ' + JSON.stringify(data)); - }) - .catch((error) => { - console.info('[context_isApplicationEnabled_test_0500] promise error is: ' + error); - expect(error).assertFail(); + + /* + * @tc.number: context_isApplicationEnabled_test_0400 + * @tc.name: isApplicationEnabled : Get whether to enable a specified application + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isApplicationEnabled_test_0400', 0, async function (done) { + let timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR, (error, data) => { + if (error) { + console.error('[context_isApplicationEnabled_test_0400]Operation failed. Cause: ' + JSON.stringify(error)); + expect(error).assertFail(); + } + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0400]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isApplicationEnabled_test_0400] callBack error: ' + error); + console.info('[context_isApplicationEnabled_test_0400] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getApplicationEnabledFalse('[context_isApplicationEnabled_test_0300]', mData); + console.info('[context_isApplicationEnabled_test_0400] Failure '); + done(); }); - getApplicationEnabledTrue('[context_isApplicationEnabled_test_0500]', mData); - done(); - }); - /* - * @tc.number: context_isApplicationEnabled_test_0600 - * @tc.name: isApplicationEnabled : Get whether to enable a specified application - * @tc.desc: Check the return value of the interface (by callback) - * @tc.level 0 - */ - it('context_isApplicationEnabled_test_0600', 0, async function (done) { - await Bundle.setApplicationEnabled(BUNDLE_NAME, false) - .then((data) => { - console.info('[context_isApplicationEnabled_test_0600] set enable false data is: ' + JSON.stringify(data)); - }).catch((error) => { - console.info('[context_isApplicationEnabled_test_0600] set enable false error is: ' + error); - expect(error).assertFail(); + /* + * @tc.number: context_isApplicationEnabled_test_0500 + * @tc.name: isApplicationEnabled : Get whether to enable a specified application + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it('context_isApplicationEnabled_test_0500', 0, async function (done) { + await Bundle.setApplicationEnabled(BUNDLE_NAME, true).then((data) => { + console.info('[context_isApplicationEnabled_test_0500] set enable true data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isApplicationEnabled_test_0500] set enable true error is: ' + error); + expect(error).assertFail(); + }); + await Utils.sleep(1000); + let timeOldStamp = await Utils.getNowTime(); + let mData; + await Bundle.isApplicationEnabled(BUNDLE_NAME).then((data) => { + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0500]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isApplicationEnabled_test_0500] promise data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isApplicationEnabled_test_0500] promise error is: ' + error); + expect(error).assertFail(); + }); + getApplicationEnabledTrue('[context_isApplicationEnabled_test_0500]', mData); + done(); }); - await Utils.sleep(1000); - var timeOldStamp = await Utils.getNowTime(); - let mData; - Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => { - if(error){ - console.error('[context_isApplicationEnabled_test_0600]Operation failed. Cause: ' + JSON.stringify(error)); - expect(error).assertFail(); + /* + * @tc.number: context_isApplicationEnabled_test_0600 + * @tc.name: isApplicationEnabled : Get whether to enable a specified application + * @tc.desc: Check the return value of the interface (by callback) + * @tc.level 0 + */ + it('context_isApplicationEnabled_test_0600', 0, async function (done) { + await Bundle.setApplicationEnabled(BUNDLE_NAME, false).then((data) => { + console.info('[context_isApplicationEnabled_test_0600] set enable false data is: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('[context_isApplicationEnabled_test_0600] set enable false error is: ' + error); + expect(error).assertFail(); + }); + await Utils.sleep(1000); + let timeOldStamp = await Utils.getNowTime(); + let mData; + Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => { + if (error) { + console.error('[context_isApplicationEnabled_test_0600]Operation failed. Cause: ' + JSON.stringify(error)); + expect(error).assertFail(); + } + let timeNewStamp = Utils.getNowTime(); + Utils.getDurationTime('[context_isApplicationEnabled_test_0600]', timeOldStamp, timeNewStamp); + mData = data; + console.info('[context_isApplicationEnabled_test_0600] callBack error: ' + error); + console.info('[context_isApplicationEnabled_test_0600] callBack data is:' + JSON.stringify(data)); + }); + await Utils.sleep(2000); + getApplicationEnabledFalse('[context_isApplicationEnabled_test_0600]', mData); + done(); + }); + + function getApplicationEnabledSuccess(msg, data) { + console.log(msg + ' start ' + JSON.stringify(data)); + console.log(msg + ' data : ' + data); + expect(typeof (data)).assertEqual('boolean') } - var timeNewStamp = Utils.getNowTime(); - Utils.getDurationTime('[context_isApplicationEnabled_test_0600]', timeOldStamp, timeNewStamp); - mData = data; - console.info('[context_isApplicationEnabled_test_0600] callBack error: ' + error); - console.info('[context_isApplicationEnabled_test_0600] callBack data is:' + JSON.stringify(data)); - }); - await Utils.sleep(2000); - getApplicationEnabledFalse('[context_isApplicationEnabled_test_0600]', mData); - done(); - }); - function getApplicationEnabledSuccess(msg, data) { - console.log(msg + ' start ' + JSON.stringify(data)); - console.log(msg + ' data : ' + data); - expect(typeof (data)).assertEqual('boolean') - } + function getApplicationEnabledTrue(msg, data) { + getApplicationEnabledSuccess(msg, data); + expect(data).assertEqual(true); + } + + function getApplicationEnabledFalse(msg, data) { + getApplicationEnabledSuccess(msg, data); + expect(data).assertEqual(false); + } - function getApplicationEnabledTrue(msg, data) { - getApplicationEnabledSuccess(msg, data); - expect(data).assertEqual(true); - } + }) - function getApplicationEnabledFalse(msg, data) { - getApplicationEnabledSuccess(msg, data); - expect(data).assertEqual(false); - } - }) } \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets index a962e2f545a3794aabd7f61f090ee348f378d97d..0d567bdf11f434f2ee1e69cc40841515092cf0c8 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/List.test.ets @@ -12,14 +12,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import getLaunchWantForBundle from './GetLaunchWantForBundle.test.ets'; import getabilityInfo from './GetabilityInfo.test.ets'; import getApplicationInfoJsunit from './getApplicationInfoJsunit.test.ets'; import getAllAppInfoJsunit from './getAllApplicationInfoJsunit.test.ets'; import getAbilityLabelJsUnit from "./GetAbilityLabelJsUnit.test.ets"; import isAbilityEnableETSUnit from "./IsAbilityEnabledETSUnit.ets"; import isApplicationEnabledETSUnit from "./IsApplicationEnabledETSUnit.ets"; +import getAbilityIcon from "./GetAbilityIcon.test.ets"; +import getNameForUid from "./GetNameForUid.test.ets"; export default function testsuite() { + getAbilityIcon(); + getLaunchWantForBundle(); + getNameForUid(); //RM.007 getApplicationInfoJsunit(); getAllAppInfoJsunit(); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/Utils.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/Utils.ets index 4d9553a5c660be0a6ae524110f2dd4a6477abfd6..4437fa06f93f079ebd680fce496fba345fbc7eb8 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/Utils.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/Utils.ets @@ -15,114 +15,115 @@ */ export default class Utils { - static rect_left; - static rect_top; - static rect_right; - static rect_bottom; - static rect_value; + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; - static sleep(time) { - return new Promise((resolve, reject) => { - setTimeout(() => { - resolve() - }, time) + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) }).then(() => { - console.info(`sleep ${time} over...`) + console.info(`sleep ${time} over...`) }) - } - - static getComponentRect(key) { - let strJson = getInspectorByKey(key); - let obj = JSON.parse(strJson); - console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); - let rectInfo = JSON.parse('[' + obj.$rect + ']') - console.info("[getInspectorByKey] rectInfo is: " + rectInfo); - this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] - this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] - this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] - this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] - return this.rect_value = { - "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom } - } - - static async swipe(downX, downY, upX, upY, steps) { - console.info('start to swipe') - this.drags(downX, downY, upX, upY, steps, false) - } - - static async drag(downX, downY, upX, upY, steps) { - console.info('start to drag') - this.drags(downX, downY, upX, upY, steps, true) - } - static async drags(downX, downY, upX, upY, steps, drag) { - var xStep; - var yStep; - var swipeSteps; - var ret; - xStep = 0; - yStep = 0; - ret = false; - swipeSteps = steps; - if (swipeSteps == 0) { - swipeSteps = 1; + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } } - xStep = (upX - downX) / swipeSteps; - yStep = (upY - downY) / swipeSteps; - console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) - var downPonit: TouchObject = { - id: 1, - x: downX, - y: downY, - type: TouchType.Down, - } - console.info('down touch started: ' + JSON.stringify(downPonit)) - sendTouchEvent(downPonit); - console.info('start to move') - if (drag) { - await this.sleep(500) + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) } - for (var i = 1;i <= swipeSteps; i++) { - var movePoint: TouchObject = { - id: 1, - x: downX + (xStep * i), - y: downY + (yStep * i), - type: TouchType.Move - } - console.info('move touch started: ' + JSON.stringify(movePoint)) - ret = sendTouchEvent(movePoint) - if (ret == false) { - break; - } - await this.sleep(5) + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) } - console.info('start to up') - if (drag) { - await this.sleep(100) + + static async drags(downX, downY, upX, upY, steps, drag) { + let xStep; + let yStep; + let swipeSteps; + let ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + let downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (let i = 1;i <= swipeSteps; i++) { + let movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + let upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) } - var upPoint: TouchObject = { - id: 1, - x: upX, - y: upY, - type: TouchType.Up, + + static getNowTime() { + return new Date().getTime(); } - console.info('up touch started: ' + JSON.stringify(upPoint)) - sendTouchEvent(upPoint) - await this.sleep(500) - } - static getNowTime() { - return new Date().getTime(); - } + static getDurationTime(log,startTime, endTime) { + console.info("Get Interface startTime: " + startTime); + console.info("Get Interface endTime: " + endTime); + let duration = (endTime - startTime); + console.info("Get Interface duration: " + duration); + return duration; + } - static getDurationTime(log,startTime, endTime) { - console.info("Get Interface startTime: " + startTime); - console.info("Get Interface endTime: " + endTime); - var duration = (endTime - startTime); - console.info("Get Interface duration: " + duration); - return duration; - } } diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getAllApplicationInfoJsunit.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getAllApplicationInfoJsunit.test.ets index 10a824ae624ed7b2de2df24b9388fc4cc4dffb48..02234bba220192063675a2ca6b08d248a135fc29 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getAllApplicationInfoJsunit.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getAllApplicationInfoJsunit.test.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {describe, it, expect} from 'deccjsunit/index.ets'; +import { describe, it, expect } from 'deccjsunit/index.ets'; import Utils from './Utils'; import Bundle from '@ohos.bundle'; @@ -29,315 +29,303 @@ const TAG_TEST_0500_002 = ' bundle_getAllApplicationInfo_test_0500_0010 '; const USER_ID_100 = 100; export default function applicationBundleJsunit() { - describe('appInfoTest', function () { - /** - * @tc.number: bundle_getApplicationInfo_test_0100_001 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0100_001, 0, async function (done) { - var startTime = await Utils.getNowTime(); - let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100) - .catch((error) => { - console.info(TAG_TEST_0100_001 + 'UserId promise error is: ' + error); - expect(error).assertFail(); + + describe('appInfoTest', function () { + + /** + * @tc.number: bundle_getApplicationInfo_test_0100_001 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0100_001, 0, async function (done) { + let startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo( + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100).catch((error) => { + console.info(TAG_TEST_0100_001 + 'UserId promise error is: ' + error); + expect(error).assertFail(); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0100_001, startTime, endTime); + console.info(TAG_TEST_0100_001 + ' UserId promise data is: ' + JSON.stringify(data)); + expectData(TAG_TEST_0100_001, data) + getApplicationInfoSuccess(TAG_TEST_0100_001, data); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0100_001, startTime, endTime); - console.info(TAG_TEST_0100_001 + ' UserId promise data is: ' + JSON.stringify(data)); - expectData(TAG_TEST_0100_001, data) - getApplicationInfoSuccess(TAG_TEST_0100_001, data); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0100_002 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0100_002, 0, async function (done) { - var startTime = await Utils.getNowTime(); - let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_ALL_APPLICATION_INFO, USER_ID_100) - .catch((error) => { - console.info(TAG_TEST_0100_002 + 'UserId promise error is: ' + error); - expect(error).assertFail(); + /** + * @tc.number: bundle_getApplicationInfo_test_0100_002 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0100_002, 0, async function (done) { + let startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo( + Bundle.BundleFlag.GET_ALL_APPLICATION_INFO, USER_ID_100).catch((error) => { + console.info(TAG_TEST_0100_002 + 'UserId promise error is: ' + error); + expect(error).assertFail(); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0100_002, startTime, endTime); + console.info(TAG_TEST_0100_002 + ' UserId promise data is: ' + JSON.stringify(data)); + expectData(TAG_TEST_0100_002, data) + getApplicationInfoSuccess(TAG_TEST_0100_002, data); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0100_002, startTime, endTime); - console.info(TAG_TEST_0100_002 + ' UserId promise data is: ' + JSON.stringify(data)); - expectData(TAG_TEST_0100_002, data) - getApplicationInfoSuccess(TAG_TEST_0100_002, data); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0100_003 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0100_003, 0, async function (done) { - var startTime = await Utils.getNowTime(); - let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE, USER_ID_100) - .catch((error) => { - console.info(TAG_TEST_0100_003 + 'UserId promise error is: ' + error); - expect(error).assertFail(); + /** + * @tc.number: bundle_getApplicationInfo_test_0100_003 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0100_003, 0, async function (done) { + let startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo( + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE, USER_ID_100).catch((error) => { + console.info(TAG_TEST_0100_003 + 'UserId promise error is: ' + error); + expect(error).assertFail(); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0100_003, startTime, endTime); + console.info(TAG_TEST_0100_003 + ' UserId promise data is: ' + JSON.stringify(data)); + expectData(TAG_TEST_0100_003, data) + getApplicationInfoSuccess(TAG_TEST_0100_003, data); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0100_003, startTime, endTime); - console.info(TAG_TEST_0100_003 + ' UserId promise data is: ' + JSON.stringify(data)); - expectData(TAG_TEST_0100_003, data) - getApplicationInfoSuccess(TAG_TEST_0100_003, data); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0200_004 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0200_001, 0, async function (done) { - var startTime = await Utils.getNowTime(); - let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION) - .catch((error) => { - console.info(TAG_TEST_0200_001 + 'onUserId promise error is: ' + error); - expect(error).assertFail(); + /** + * @tc.number: bundle_getApplicationInfo_test_0200_004 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0200_001, 0, async function (done) { + let startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo( + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION).catch((error) => { + console.info(TAG_TEST_0200_001 + 'onUserId promise error is: ' + error); + expect(error).assertFail(); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0200_001, startTime, endTime); + console.info(TAG_TEST_0200_001 + ' onUserId promise data is: ' + JSON.stringify(data)); + expectData(TAG_TEST_0200_001, data) + getApplicationInfoSuccess(TAG_TEST_0200_001, data); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0200_001, startTime, endTime); - console.info(TAG_TEST_0200_001 + ' onUserId promise data is: ' + JSON.stringify(data)); - expectData(TAG_TEST_0200_001, data) - getApplicationInfoSuccess(TAG_TEST_0200_001, data); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0200_005 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0200_002, 0, async function (done) { - var startTime = await Utils.getNowTime(); - let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_ALL_APPLICATION_INFO) - .catch((error) => { - console.info(TAG_TEST_0200_002 + 'onUserId promise error is: ' + error); - expect(error).assertFail(); + /** + * @tc.number: bundle_getApplicationInfo_test_0200_005 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0200_002, 0, async function (done) { + let startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo( + Bundle.BundleFlag.GET_ALL_APPLICATION_INFO).catch((error) => { + console.info(TAG_TEST_0200_002 + 'onUserId promise error is: ' + error); + expect(error).assertFail(); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0200_002, startTime, endTime); + console.info(TAG_TEST_0200_002 + ' onUserId promise data is: ' + JSON.stringify(data)); + expectData(TAG_TEST_0200_002, data) + getApplicationInfoSuccess(TAG_TEST_0200_002, data); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0200_002, startTime, endTime); - console.info(TAG_TEST_0200_002 + ' onUserId promise data is: ' + JSON.stringify(data)); - expectData(TAG_TEST_0200_002, data) - getApplicationInfoSuccess(TAG_TEST_0200_002, data); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0200_006 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0200_003, 0, async function (done) { - var startTime = await Utils.getNowTime(); - let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE) - .catch((error) => { - console.info(TAG_TEST_0200_003 + 'onUserId promise error is: ' + error); - expect(error).assertFail(); + /** + * @tc.number: bundle_getApplicationInfo_test_0200_006 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0200_003, 0, async function (done) { + let startTime = await Utils.getNowTime(); + let data = await Bundle.getAllApplicationInfo( + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE).catch((error) => { + console.info(TAG_TEST_0200_003 + 'onUserId promise error is: ' + error); + expect(error).assertFail(); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0200_003, startTime, endTime); + console.info(TAG_TEST_0200_003 + ' onUserId promise data is: ' + JSON.stringify(data)); + expectData(TAG_TEST_0200_003, data) + getApplicationInfoSuccess(TAG_TEST_0200_003, data); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0200_003, startTime, endTime); - console.info(TAG_TEST_0200_003 + ' onUserId promise data is: ' + JSON.stringify(data)); - expectData(TAG_TEST_0200_003, data) - getApplicationInfoSuccess(TAG_TEST_0200_003, data); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0300_007 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by callBack) - * @tc.level 0 - */ - it(TAG_TEST_0300_001, 0, async function (done) { - let datas; - var startTime = await Utils.getNowTime(); - Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100, - (error, data) => { - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0300_001, startTime, endTime); - if(error){ - expect(error).assertFail(); - console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error); - } - console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error); - console.info(TAG_TEST_0300_001 + 'UserId callBack data is:' + JSON.stringify(data)); - datas = data; + /** + * @tc.number: bundle_getApplicationInfo_test_0300_007 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by callBack) + * @tc.level 0 + */ + it(TAG_TEST_0300_001, 0, async function (done) { + let datas; + let startTime = await Utils.getNowTime(); + Bundle.getAllApplicationInfo( + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100, (error, data) => { + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0300_001, startTime, endTime); + if (error) { + expect(error).assertFail(); + console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error); + } + console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error); + console.info(TAG_TEST_0300_001 + 'UserId callBack data is:' + JSON.stringify(data)); + datas = data; + }); + await Utils.sleep(2000); + console.info(TAG_TEST_0300_001 + 'UserId callBack datas is:' + JSON.stringify(datas)); + expectData(TAG_TEST_0300_001, datas) + getApplicationInfoSuccess(TAG_TEST_0300_001, datas); + done(); }); - await Utils.sleep(2000); - console.info(TAG_TEST_0300_001 + 'UserId callBack datas is:' + JSON.stringify(datas)); - expectData(TAG_TEST_0300_001, datas) - getApplicationInfoSuccess(TAG_TEST_0300_001, datas); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0400_008 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by callBack) - * @tc.level 0 - */ - it(TAG_TEST_0400_001, 0, async function (done) { - let datas; - var startTime = await Utils.getNowTime(); - Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, (error, data) => { - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0400_001, startTime, endTime); - if(error){ - expect(error).assertFail(); - console.info(TAG_TEST_0400_001 + 'UserId callBack error: ' + error); - } - console.info(TAG_TEST_0400_001 + 'noUserId callBack error: ' + error); - console.info(TAG_TEST_0400_001 + 'noUserId callBack data is:' + JSON.stringify(data)); - datas = data; - }); - await Utils.sleep(2000); - console.info(TAG_TEST_0400_001 + 'noUserId callBack datas is:' + JSON.stringify(datas)); - expectData(TAG_TEST_0400_001, datas) - getApplicationInfoSuccess(TAG_TEST_0400_001, datas); - done(); - }); - - /** - * @tc.number: bundle_getApplicationInfo_test_0500_009 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0500_001, 0, async function (done) { - let errors; - var startTime = await Utils.getNowTime(); - await Bundle.getAllApplicationInfo('0') - .then((data) => { - console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data); - expect(data).assertFail(); - }) - .catch((error) => { - console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error); - errors = error; - expect(errors).assertEqual(1); + /** + * @tc.number: bundle_getApplicationInfo_test_0400_008 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by callBack) + * @tc.level 0 + */ + it(TAG_TEST_0400_001, 0, async function (done) { + let datas; + let startTime = await Utils.getNowTime(); + Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, (error, data) => { + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0400_001, startTime, endTime); + if (error) { + expect(error).assertFail(); + console.info(TAG_TEST_0400_001 + 'UserId callBack error: ' + error); + } + console.info(TAG_TEST_0400_001 + 'noUserId callBack error: ' + error); + console.info(TAG_TEST_0400_001 + 'noUserId callBack data is:' + JSON.stringify(data)); + datas = data; + }); + await Utils.sleep(2000); + console.info(TAG_TEST_0400_001 + 'noUserId callBack datas is:' + JSON.stringify(datas)); + expectData(TAG_TEST_0400_001, datas) + getApplicationInfoSuccess(TAG_TEST_0400_001, datas); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0500_0010 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0500_002, 0, async function (done) { - let errors; - var startTime = await Utils.getNowTime(); - await Bundle.getAllApplicationInfo('0', USER_ID_100) - .then((data) => { - console.info(TAG_TEST_0500_002 + 'noUserId promise data is: ' + data); - expect(data).assertFail(); - }) - .catch((error) => { - console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error); - errors = error; - expect(errors).assertEqual(1); + /** + * @tc.number: bundle_getApplicationInfo_test_0500_009 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0500_001, 0, async function (done) { + let errors; + let startTime = await Utils.getNowTime(); + await Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT').then((data) => { + console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data); + expect(data).assertFail(); + }).catch((error) => { + console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error); + errors = error; + expect(errors).assertEqual(1); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime); - done(); - }); + /** + * @tc.number: bundle_getApplicationInfo_test_0500_0010 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0500_002, 0, async function (done) { + let errors; + let startTime = await Utils.getNowTime(); + await Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT', USER_ID_100).then((data) => { + console.info(TAG_TEST_0500_002 + 'noUserId promise data is: ' + data); + expect(data).assertFail(); + }).catch((error) => { + console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error); + errors = error; + expect(errors).assertEqual(1); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime); + done(); + }); - /** - * expect属性 - * @param msg log信息 - * @param data 数据源 - */ - function expectData(msg, data) { - console.info(msg + 'commonTest data length [' + data.length + ']'); - for (var i = 0; i < data.length; i++) { - expect(typeof (data)).assertEqual('object'); - expect(typeof (data[i].name)).assertEqual('string'); - expect(typeof (data[i].codePath)).assertEqual('string'); - expect(typeof (data[i].accessTokenId)).assertEqual('number'); - expect(typeof (data[i].description)).assertEqual('string'); - expect(typeof (data[i].descriptionId)).assertEqual('number'); - expect(typeof (data[i].icon)).assertEqual('string'); - expect(typeof (data[i].iconId)).assertEqual('number'); - expect(typeof (data[i].label)).assertEqual('string'); - expect(typeof (data[i].labelId)).assertEqual('number'); - expect(typeof (data[i].systemApp)).assertEqual('boolean') - expect(typeof (data[i].supportedModes)).assertEqual('number'); - expect(typeof (data[i].process)).assertEqual('string'); - expect(typeof (data[i].entryDir)).assertEqual('string'); - expect(typeof (data[i].metaData)).assertEqual('object'); - expect(typeof (data[i].metadata)).assertEqual('object'); - expect(typeof (data[i].enabled)).assertEqual('boolean'); - expect(typeof (data[i].flags)).assertEqual('number'); - expect(typeof (data[i].uid)).assertEqual('number'); - expect(typeof (data[i].entityType)).assertEqual('string'); - expect(typeof (data[i].removable)).assertEqual('boolean'); - expect(Array.isArray(data[i].permissions)).assertEqual(true); - expect(Array.isArray(data[i].moduleSourceDirs)).assertEqual(true); - expect(Array.isArray(data[i].moduleInfos)).assertEqual(true); - } - } + function expectData(msg, data) { + console.info(msg + 'commonTest data length [' + data.length + ']'); + for (let i = 0; i < data.length; i++) { + expect(typeof (data)).assertEqual('object'); + expect(typeof (data[i].name)).assertEqual('string'); + expect(typeof (data[i].codePath)).assertEqual('string'); + expect(typeof (data[i].accessTokenId)).assertEqual('number'); + expect(typeof (data[i].description)).assertEqual('string'); + expect(typeof (data[i].descriptionId)).assertEqual('number'); + expect(typeof (data[i].icon)).assertEqual('string'); + expect(typeof (data[i].iconId)).assertEqual('number'); + expect(typeof (data[i].label)).assertEqual('string'); + expect(typeof (data[i].labelId)).assertEqual('number'); + expect(typeof (data[i].systemApp)).assertEqual('boolean') + expect(typeof (data[i].supportedModes)).assertEqual('number'); + expect(typeof (data[i].process)).assertEqual('string'); + expect(typeof (data[i].metaData)).assertEqual('object'); + expect(typeof (data[i].metadata)).assertEqual('object'); + expect(typeof (data[i].enabled)).assertEqual('boolean'); + expect(typeof (data[i].flags)).assertEqual('number'); + expect(typeof (data[i].uid)).assertEqual('number'); + expect(typeof (data[i].entityType)).assertEqual('string'); + expect(typeof (data[i].removable)).assertEqual('boolean'); + expect(Array.isArray(data[i].permissions)).assertEqual(true); + expect(Array.isArray(data[i].moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(data[i].moduleInfos)).assertEqual(true); + } + } - /** - * expect指定数据属性值 - * @param msg log信息 - * @param data 数据源 - */ - function getApplicationInfoSuccess(msg, data) { - console.info(msg + 'getApplicationInfoSuccess data length [' + data.length + ']'); - for (var i = 0; i < data.length; i++) { - if (data[i].name === 'com.open.harmony.packagemag' || i === 0 && data[i].name === '') { - console.info(msg + JSON.stringify(data[i])); - expect(data[i].name).assertEqual('com.open.harmony.packagemag'); - expect(data[i].codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag'); - expect(data[i].description).assertEqual('$string:mainability_description'); - if (data[i].descriptionId !== 0) { - expect(data[i].descriptionId > 0).assertEqual(true); - } - expect(data[i].icon).assertEqual('$media:icon'); - expect(data[i].iconId > 0).assertEqual(true); - expect(data[i].label).assertEqual('$string:entry_MainAbility'); - expect(data[i].accessTokenId > 0).assertEqual(true); - if (data[i].label !== 0) { - expect(data[i].labelId > 0).assertEqual(true); - }; - if (data[i].uid !== 0) { - expect(data[i].uid > 0).assertEqual(true); - }; - expect(data[i].systemApp).assertEqual(true); - expect(data[i].supportedModes).assertEqual(0); - expect(data[i].process).assertEqual(""); - expect(data[i].entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' + - '/com.open.harmony.packagemag'); - expect(data[i].enabled).assertEqual(true); - expect(data[i].flags).assertEqual(0); - expect(data[i].entityType).assertEqual('unspecified'); - expect(data[i].removable).assertEqual(true); - expect(data[i].moduleInfos[0].moduleName).assertEqual('entry'); - expect(data[i].moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' + - 'com.open.harmony.packagemag/com.open.harmony.packagemag'); - expect(data[i].moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' + - 'com.open.harmony.packagemag/com.open.harmony.packagemag'); + function getApplicationInfoSuccess(msg, data) { + console.info(msg + 'getApplicationInfoSuccess data length [' + data.length + ']'); + for (let i = 0; i < data.length; i++) { + if (data[i].name === 'com.open.harmony.packagemag' || i === 0 && data[i].name === '') { + console.info(msg + JSON.stringify(data[i])); + expect(data[i].name).assertEqual('com.open.harmony.packagemag'); + expect(data[i].codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag'); + expect(data[i].description).assertEqual('$string:mainability_description'); + if (data[i].descriptionId !== 0) { + expect(data[i].descriptionId > 0).assertEqual(true); + } + expect(data[i].icon).assertEqual('$media:icon'); + expect(data[i].iconId > 0).assertEqual(true); + expect(data[i].label).assertEqual('$string:entry_MainAbility'); + expect(data[i].accessTokenId > 0).assertEqual(true); + if (data[i].label !== 0) { + expect(data[i].labelId > 0).assertEqual(true); + }; + if (data[i].uid !== 0) { + expect(data[i].uid > 0).assertEqual(true); + }; + expect(data[i].systemApp).assertEqual(true); + expect(data[i].supportedModes).assertEqual(0); + expect(data[i].process).assertEqual(""); + expect(data[i].entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' + + '/com.open.harmony.packagemag'); + expect(data[i].enabled).assertEqual(true); + expect(data[i].flags).assertEqual(0); + expect(data[i].entityType).assertEqual('unspecified'); + expect(data[i].removable).assertEqual(true); + expect(data[i].moduleInfos[0].moduleName).assertEqual('entry'); + expect(data[i].moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' + + 'com.open.harmony.packagemag/com.open.harmony.packagemag'); + expect(data[i].moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' + + 'com.open.harmony.packagemag/com.open.harmony.packagemag'); + } + } } - } - } - }); + + }); + } \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getApplicationInfoJsunit.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getApplicationInfoJsunit.test.ets index f39646991b06a45a6ea7d236c1d48f6415951a9c..a9bcb952a31d5cb7702aa18d03fae45b9b289640 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getApplicationInfoJsunit.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/test/getApplicationInfoJsunit.test.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {describe, it, expect} from 'deccjsunit/index.ets'; +import { describe, it, expect } from 'deccjsunit/index.ets'; import Utils from './Utils'; import Bundle from '@ohos.bundle'; @@ -33,413 +33,389 @@ const BUNDLE_NAME = 'com.open.harmony.packagemag'; const BUNDLE_NAME_OTHER = 'com.ohos.acepackage'; const USER_ID_100 = 100; - export default function applicationBundleJsunit() { - describe('appInfoTest', function () { - /** - * @tc.number: bundle_getApplicationInfo_test_0100_001 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0100_001, 0, async function (done) { - var startTime = await Utils.getNowTime(); - let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - USER_ID_100) - .catch((error) => { - console.info(TAG_TEST_0100_001 + 'UserId promise error is: ' + error); - expect(error).assertFail(); + + describe('appInfoTest', function () { + + /** + * @tc.number: bundle_getApplicationInfo_test_0100_001 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0100_001, 0, async function (done) { + let startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME, + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100).catch((error) => { + console.info(TAG_TEST_0100_001 + 'UserId promise error is: ' + error); + expect(error).assertFail(); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0100_001, startTime, endTime); + console.info(TAG_TEST_0100_001 + ' UserId promise data is: ' + JSON.stringify(data)); + expectData(TAG_TEST_0100_001, data); + getApplicationInfoSuccess(TAG_TEST_0100_001, data); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0100_001, startTime, endTime); - console.info(TAG_TEST_0100_001 + ' UserId promise data is: ' + JSON.stringify(data)); - expectData(TAG_TEST_0100_001, data); - getApplicationInfoSuccess(TAG_TEST_0100_001, data); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0100_002 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0100_002, 0, async function (done) { - var startTime = await Utils.getNowTime(); - let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_ALL_APPLICATION_INFO, USER_ID_100) - .catch((error) => { - console.info(TAG_TEST_0100_002 + 'UserId promise error is: ' + error); - expect(error).assertFail(); + /** + * @tc.number: bundle_getApplicationInfo_test_0100_002 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0100_002, 0, async function (done) { + let startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME, + Bundle.BundleFlag.GET_ALL_APPLICATION_INFO, USER_ID_100).catch((error) => { + console.info(TAG_TEST_0100_002 + 'UserId promise error is: ' + error); + expect(error).assertFail(); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0100_002, startTime, endTime); + console.info(TAG_TEST_0100_002 + ' UserId promise data is: ' + JSON.stringify(data)); + expectData(TAG_TEST_0100_002, data); + getApplicationInfoSuccess_plus(TAG_TEST_0100_002, data); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0100_002, startTime, endTime); - console.info(TAG_TEST_0100_002 + ' UserId promise data is: ' + JSON.stringify(data)); - expectData(TAG_TEST_0100_002, data); - getApplicationInfoSuccess_plus(TAG_TEST_0100_002, data); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0100_003 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0100_003, 0, async function (done) { - var startTime = await Utils.getNowTime(); - let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE, - USER_ID_100) - .catch((error) => { - console.info(TAG_TEST_0100_003 + 'UserId promise error is: ' + error); - expect(error).assertFail(); + /** + * @tc.number: bundle_getApplicationInfo_test_0100_003 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0100_003, 0, async function (done) { + let startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME, + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE, USER_ID_100).catch((error) => { + console.info(TAG_TEST_0100_003 + 'UserId promise error is: ' + error); + expect(error).assertFail(); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0100_003, startTime, endTime); + console.info(TAG_TEST_0100_003 + ' UserId promise data is: ' + JSON.stringify(data)); + expectData(TAG_TEST_0100_003, data); + getApplicationInfoSuccess_plus(TAG_TEST_0100_003, data); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0100_003, startTime, endTime); - console.info(TAG_TEST_0100_003 + ' UserId promise data is: ' + JSON.stringify(data)); - expectData(TAG_TEST_0100_003, data); - getApplicationInfoSuccess_plus(TAG_TEST_0100_003, data); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0200_004 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0200_001, 0, async function (done) { - var startTime = await Utils.getNowTime(); - let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION) - .catch((error) => { - console.info(TAG_TEST_0200_001 + 'onUserId promise error is: ' + error); - expect(error).assertFail(); + /** + * @tc.number: bundle_getApplicationInfo_test_0200_001 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0200_001, 0, async function (done) { + let startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME, + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION).catch((error) => { + console.info(TAG_TEST_0200_001 + 'onUserId promise error is: ' + error); + expect(error).assertFail(); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0200_001, startTime, endTime); + console.info(TAG_TEST_0200_001 + ' onUserId promise data is: ' + JSON.stringify(data)); + expectData(TAG_TEST_0200_001, data); + getApplicationInfoSuccess(TAG_TEST_0200_001, data); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0200_001, startTime, endTime); - console.info(TAG_TEST_0200_001 + ' onUserId promise data is: ' + JSON.stringify(data)); - expectData(TAG_TEST_0200_001, data); - getApplicationInfoSuccess(TAG_TEST_0200_001, data); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0200_005 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0200_002, 0, async function (done) { - var startTime = await Utils.getNowTime(); - let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_ALL_APPLICATION_INFO) - .catch((error) => { - console.info(TAG_TEST_0200_002 + 'onUserId promise error is: ' + error); - expect(error).assertFail(); + /** + * @tc.number: bundle_getApplicationInfo_test_0200_002 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0200_002, 0, async function (done) { + let startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME, + Bundle.BundleFlag.GET_ALL_APPLICATION_INFO).catch((error) => { + console.info(TAG_TEST_0200_002 + 'onUserId promise error is: ' + error); + expect(error).assertFail(); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0200_002, startTime, endTime); + console.info(TAG_TEST_0200_002 + ' onUserId promise data is: ' + JSON.stringify(data)); + expectData(TAG_TEST_0200_002, data); + getApplicationInfoSuccess_plus(TAG_TEST_0200_002, data); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0200_002, startTime, endTime); - console.info(TAG_TEST_0200_002 + ' onUserId promise data is: ' + JSON.stringify(data)); - expectData(TAG_TEST_0200_002, data); - getApplicationInfoSuccess_plus(TAG_TEST_0200_002, data); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0200_006 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0200_003, 0, async function (done) { - var startTime = await Utils.getNowTime(); - let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE) - .catch((error) => { - console.info(TAG_TEST_0200_003 + 'onUserId promise error is: ' + error); - expect(error).assertFail(); + /** + * @tc.number: bundle_getApplicationInfo_test_0200_003 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0200_003, 0, async function (done) { + let startTime = await Utils.getNowTime(); + let data = await Bundle.getApplicationInfo(BUNDLE_NAME, + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE).catch((error) => { + console.info(TAG_TEST_0200_003 + 'onUserId promise error is: ' + error); + expect(error).assertFail(); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0200_003, startTime, endTime); + console.info(TAG_TEST_0200_003 + ' onUserId promise data is: ' + JSON.stringify(data)); + expectData(TAG_TEST_0200_003, data); + getApplicationInfoSuccess_plus(TAG_TEST_0200_003, data); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0200_003, startTime, endTime); - console.info(TAG_TEST_0200_003 + ' onUserId promise data is: ' + JSON.stringify(data)); - expectData(TAG_TEST_0200_003, data); - getApplicationInfoSuccess_plus(TAG_TEST_0200_003, data); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0300_007 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by callBack) - * @tc.level 0 - */ - it(TAG_TEST_0300_001, 0, async function (done) { - let errors; - let datas; - var startTime = await Utils.getNowTime(); - Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - USER_ID_100, (error, data) => { - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0300_001, startTime, endTime); - errors = error; - if(errors){ - expect(errors).assertFail(); - console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error); - } - console.info(TAG_TEST_0300_001 + 'UserId callBack data is:' + JSON.stringify(data)); - datas = data; + /** + * @tc.number: bundle_getApplicationInfo_test_0300_001 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by callBack) + * @tc.level 0 + */ + it(TAG_TEST_0300_001, 0, async function (done) { + let errors; + let datas; + let startTime = await Utils.getNowTime(); + Bundle.getApplicationInfo(BUNDLE_NAME, + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100, (error, data) => { + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0300_001, startTime, endTime); + errors = error; + if (errors) { + expect(errors).assertFail(); + console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error); + } + console.info(TAG_TEST_0300_001 + 'UserId callBack data is:' + JSON.stringify(data)); + datas = data; + }); + await Utils.sleep(2000); + console.info(TAG_TEST_0300_001 + 'UserId callBack data is: ' + JSON.stringify(datas)); + expectData(TAG_TEST_0300_001, datas); + getApplicationInfoSuccess(TAG_TEST_0300_001, datas); + done(); }); - await Utils.sleep(2000); - console.info(TAG_TEST_0300_001 + 'UserId callBack data is: ' + JSON.stringify(datas)); - expectData(TAG_TEST_0300_001, datas); - getApplicationInfoSuccess(TAG_TEST_0300_001, datas); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0400_008 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by callBack) - * @tc.level 0 - */ - it(TAG_TEST_0400_001, 0, async function (done) { - let errors; - let datas; - var startTime = await Utils.getNowTime(); - Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, (error, data) => { - var endTime = Utils.getNowTime(); - errors = error; - if(errors){ - expect(errors).assertFail(); - console.info(TAG_TEST_0400_001 + 'UserId callBack error: ' + error); - } - Utils.getDurationTime(TAG_TEST_0400_001, startTime, endTime); - console.info(TAG_TEST_0400_001 + 'noUserId callBack data is:' + JSON.stringify(data)); - datas = data; - }); - await Utils.sleep(2000); - console.info(TAG_TEST_0400_001 + 'noUserId callBack data is: ' + JSON.stringify(datas)); - expectData(TAG_TEST_0400_001, datas); - getApplicationInfoSuccess(TAG_TEST_0400_001, datas); - done(); - }); + /** + * @tc.number: bundle_getApplicationInfo_test_0400_001 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by callBack) + * @tc.level 0 + */ + it(TAG_TEST_0400_001, 0, async function (done) { + let errors; + let datas; + let startTime = await Utils.getNowTime(); + Bundle.getApplicationInfo(BUNDLE_NAME, + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, (error, data) => { + let endTime = Utils.getNowTime(); + errors = error; + if (errors) { + expect(errors).assertFail(); + console.info(TAG_TEST_0400_001 + 'UserId callBack error: ' + error); + } + Utils.getDurationTime(TAG_TEST_0400_001, startTime, endTime); + console.info(TAG_TEST_0400_001 + 'noUserId callBack data is:' + JSON.stringify(data)); + datas = data; + }); + await Utils.sleep(2000); + console.info(TAG_TEST_0400_001 + 'noUserId callBack data is: ' + JSON.stringify(datas)); + expectData(TAG_TEST_0400_001, datas); + getApplicationInfoSuccess(TAG_TEST_0400_001, datas); + done(); + }); - /** - * @tc.number: bundle_getApplicationInfo_test_0500_009 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0500_001, 0, async function (done) { - var startTime = await Utils.getNowTime(); - await Bundle.getApplicationInfo('', 0) - .then((data) => { - console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data); - expect(data).assertFail(); - }) - .catch((error) => { - console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error); - expect(error).assertEqual(1); + /** + * @tc.number: bundle_getApplicationInfo_test_0500_001 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0500_001, 0, async function (done) { + let startTime = await Utils.getNowTime(); + await Bundle.getApplicationInfo('', Bundle.BundleFlag.GET_BUNDLE_DEFAULT).then((data) => { + console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data); + expect(data).assertFail(); + }).catch((error) => { + console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error); + expect(error).assertEqual(1); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0500_0010 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0500_002, 0, async function (done) { - var startTime = await Utils.getNowTime(); - await Bundle.getApplicationInfo('', '0', USER_ID_100) - .then((data) => { - console.info(TAG_TEST_0500_002 + 'UserId promise data is: ' + data); - expect(data).assertFail(); - }) - .catch((error) => { - console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error); - expect(error).assertEqual(1); + /** + * @tc.number: bundle_getApplicationInfo_test_0500_002 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0500_002, 0, async function (done) { + let startTime = await Utils.getNowTime(); + await Bundle.getApplicationInfo('', 'Bundle.BundleFlag.GET_BUNDLE_DEFAULT', USER_ID_100).then((data) => { + console.info(TAG_TEST_0500_002 + 'UserId promise data is: ' + data); + expect(data).assertFail(); + }).catch((error) => { + console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error); + expect(error).assertEqual(1); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0600_0011 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0600_001, 0, async function (done) { - let errors - var startTime = await Utils.getNowTime(); - await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER, - Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION) - .then((data) => { - console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise data is: ' + data); - expect(data).assertFail(); - }) - .catch((error) => { - console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise error is: ' + error); - errors = error - expect(errors).assertEqual(1); + /** + * @tc.number: bundle_getApplicationInfo_test_0600_001 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0600_001, 0, async function (done) { + let errors + let startTime = await Utils.getNowTime(); + await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER, + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION).then((data) => { + console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise data is: ' + data); + expect(data).assertFail(); + }).catch((error) => { + console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise error is: ' + error); + errors = error + expect(errors).assertEqual(1); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime); + done(); }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime); - done(); - }); - /** - * @tc.number: bundle_getApplicationInfo_test_0600_0012 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0600_002, 0, async function (done) { - var startTime = await Utils.getNowTime(); - let errors - await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - USER_ID_100) - .then((data) => { - console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise data is: ' + data); - expect(data).assertFail(); - }) - .catch((error) => { - console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise error is: ' + error); - errors = error - expect(errors).assertEqual(1); - }); - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0600_002, startTime, endTime); - done(); - }); + /** + * @tc.number: bundle_getApplicationInfo_test_0600_002 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0600_002, 0, async function (done) { + let startTime = await Utils.getNowTime(); + let errors + await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER, + Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100).then((data) => { + console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise data is: ' + data); + expect(data).assertFail(); + }).catch((error) => { + console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise error is: ' + error); + errors = error + expect(errors).assertEqual(1); + }); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0600_002, startTime, endTime); + done(); + }); - /** - * @tc.number: bundle_getApplicationInfo_test_0500_009 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0600_003, 0, async function (done) { - var startTime = await Utils.getNowTime(); - await Bundle.getApplicationInfo(BUNDLE_NAME, 0) - .then((data) => { - var endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0600_003, startTime, endTime); - console.info(TAG_TEST_0600_003 + 'noUserId promise data is: ' + data); - expect(typeof (data)).assertEqual("object"); - expectData(TAG_TEST_0600_003, data); - getApplicationInfoSuccess_plus(TAG_TEST_0600_003, data); - }) - .catch((error) => { - console.info(TAG_TEST_0600_003 + 'noUserId promise error is: ' + error); - expect(error).assertFail(); + /** + * @tc.number: bundle_getApplicationInfo_test_0600_003 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface (by promise) + * @tc.level 0 + */ + it(TAG_TEST_0600_003, 0, async function (done) { + let startTime = await Utils.getNowTime(); + await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_BUNDLE_DEFAULT).then((data) => { + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0600_003, startTime, endTime); + console.info(TAG_TEST_0600_003 + 'noUserId promise data is: ' + data); + expect(typeof (data)).assertEqual("object"); + expectData(TAG_TEST_0600_003, data); + getApplicationInfoSuccess_plus(TAG_TEST_0600_003, data); + }).catch((error) => { + console.info(TAG_TEST_0600_003 + 'noUserId promise error is: ' + error); + expect(error).assertFail(); + }); + done(); }); - done(); - }); + function expectData(msg, data) { + expect(typeof (data)).assertEqual('object'); + expect(typeof (data.name)).assertEqual('string'); + expect(typeof (data.codePath)).assertEqual('string'); + expect(typeof (data.accessTokenId)).assertEqual('number'); + expect(typeof (data.description)).assertEqual('string'); + expect(typeof (data.descriptionId)).assertEqual('number'); + expect(typeof (data.icon)).assertEqual('string'); + expect(typeof (data.iconId)).assertEqual('number'); + expect(typeof (data.label)).assertEqual('string'); + expect(typeof (data.labelId)).assertEqual('number'); + expect(typeof (data.systemApp)).assertEqual('boolean') + expect(typeof (data.supportedModes)).assertEqual('number'); + expect(typeof (data.process)).assertEqual('string'); + expect(typeof (data.entryDir)).assertEqual('string'); + expect(typeof (data.metaData)).assertEqual('object'); + expect(typeof (data.metadata)).assertEqual('object'); + expect(typeof (data.enabled)).assertEqual('boolean'); + expect(typeof (data.flags)).assertEqual('number'); + expect(typeof (data.uid)).assertEqual('number'); + expect(typeof (data.entityType)).assertEqual('string'); + expect(typeof (data.removable)).assertEqual('boolean'); + expect(Array.isArray(data.permissions)).assertEqual(true); + expect(Array.isArray(data.moduleSourceDirs)).assertEqual(true); + expect(Array.isArray(data.moduleInfos)).assertEqual(true); + } + + function getApplicationInfoSuccess(msg, data) { + expect(data.name).assertEqual('com.open.harmony.packagemag'); + expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag'); + expect(data.accessTokenId > 0).assertEqual(true); + expect(data.description).assertEqual('$string:mainability_description'); + expect(data.descriptionId > 0).assertEqual(true); + expect(data.icon).assertEqual('$media:icon'); + expect(data.iconId > 0).assertEqual(true); + expect(data.uid > 0).assertEqual(true); + expect(data.label).assertEqual('$string:entry_MainAbility'); + expect(data.labelId > 0).assertEqual(true); + expect(data.systemApp).assertEqual(true); + expect(data.supportedModes).assertEqual(0); + expect(data.flags).assertEqual(0); + expect(data.process).assertEqual(""); + expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' + + '/com.open.harmony.packagemag'); + expect(data.enabled).assertEqual(true); + expect(data.entityType).assertEqual('unspecified'); + expect(data.removable).assertEqual(true); + expect(data.moduleInfos[0].moduleName).assertEqual('entry'); + expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' + + 'com.open.harmony.packagemag/com.open.harmony.packagemag'); + expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' + + 'com.open.harmony.packagemag/com.open.harmony.packagemag'); + expect(data.permissions[0]).assertEqual("ohos.permission.CHANGE_ABILITY_ENABLED_STATE"); + expect(data.permissions[1]).assertEqual("ohos.permission.GET_BUNDLE_INFO"); + expect(data.permissions[2]).assertEqual("ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"); + console.log(msg + ' end ' + JSON.stringify(data)); + } - /** - * expect属性 - * @param msg log信息 - * @param data 数据源 - */ - function expectData(msg, data) { - expect(typeof (data)).assertEqual('object'); - expect(typeof (data.name)).assertEqual('string'); - expect(typeof (data.codePath)).assertEqual('string'); - expect(typeof (data.accessTokenId)).assertEqual('number'); - expect(typeof (data.description)).assertEqual('string'); - expect(typeof (data.descriptionId)).assertEqual('number'); - expect(typeof (data.icon)).assertEqual('string'); - expect(typeof (data.iconId)).assertEqual('number'); - expect(typeof (data.label)).assertEqual('string'); - expect(typeof (data.labelId)).assertEqual('number'); - expect(typeof (data.systemApp)).assertEqual('boolean') - expect(typeof (data.supportedModes)).assertEqual('number'); - expect(typeof (data.process)).assertEqual('string'); - expect(typeof (data.entryDir)).assertEqual('string'); - expect(typeof (data.metaData)).assertEqual('object'); - expect(typeof (data.metadata)).assertEqual('object'); - expect(typeof (data.enabled)).assertEqual('boolean'); - expect(typeof (data.flags)).assertEqual('number'); - expect(typeof (data.uid)).assertEqual('number'); - expect(typeof (data.entityType)).assertEqual('string'); - expect(typeof (data.removable)).assertEqual('boolean'); - expect(Array.isArray(data.permissions)).assertEqual(true); - expect(Array.isArray(data.moduleSourceDirs)).assertEqual(true); - expect(Array.isArray(data.moduleInfos)).assertEqual(true); - } + function getApplicationInfoSuccess_plus(msg, data) { + expect(data.name).assertEqual('com.open.harmony.packagemag'); + expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag'); + expect(data.accessTokenId > 0).assertEqual(true); + expect(data.description).assertEqual('$string:mainability_description'); + expect(data.descriptionId > 0).assertEqual(true); + expect(data.icon).assertEqual('$media:icon'); + expect(data.iconId > 0).assertEqual(true); + expect(data.uid > 0).assertEqual(true); + expect(data.label).assertEqual('$string:entry_MainAbility'); + expect(data.labelId > 0).assertEqual(true); + expect(data.systemApp).assertEqual(true); + expect(data.supportedModes).assertEqual(0); + expect(data.flags).assertEqual(0); + expect(data.process).assertEqual(""); + expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' + + '/com.open.harmony.packagemag'); + expect(data.enabled).assertEqual(true); + expect(data.entityType).assertEqual('unspecified'); + expect(data.removable).assertEqual(true); + expect(data.moduleInfos[0].moduleName).assertEqual('entry'); + expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' + + 'com.open.harmony.packagemag/com.open.harmony.packagemag'); + expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' + + 'com.open.harmony.packagemag/com.open.harmony.packagemag'); + console.log(msg + ' end ' + JSON.stringify(data)); + } - /** - * expect属性值 - * @param msg log信息 - * @param data 数据源 - */ - function getApplicationInfoSuccess(msg, data) { - expect(data.name).assertEqual('com.open.harmony.packagemag'); - expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag'); - expect(data.accessTokenId > 0).assertEqual(true); - expect(data.description).assertEqual('$string:mainability_description'); - expect(data.descriptionId > 0).assertEqual(true); - expect(data.icon).assertEqual('$media:icon'); - expect(data.iconId > 0).assertEqual(true); - expect(data.uid > 0).assertEqual(true); - expect(data.label).assertEqual('$string:entry_MainAbility'); - expect(data.labelId > 0).assertEqual(true); - expect(data.systemApp).assertEqual(true); - expect(data.supportedModes).assertEqual(0); - expect(data.flags).assertEqual(0); - expect(data.process).assertEqual(""); - expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' + - '/com.open.harmony.packagemag'); - expect(data.enabled).assertEqual(true); - expect(data.entityType).assertEqual('unspecified'); - expect(data.removable).assertEqual(true); - expect(data.moduleInfos[0].moduleName).assertEqual('entry'); - expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' + - 'com.open.harmony.packagemag/com.open.harmony.packagemag'); - expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' + - 'com.open.harmony.packagemag/com.open.harmony.packagemag'); - expect(data.permissions[0]).assertEqual("ohos.permission.CHANGE_ABILITY_ENABLED_STATE"); - expect(data.permissions[1]).assertEqual("ohos.permission.GET_BUNDLE_INFO"); - expect(data.permissions[2]).assertEqual("ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"); - console.log(msg + ' end ' + JSON.stringify(data)); - } + }); - /** - * expect属性值 - * @param msg log信息 - * @param data 数据源 - */ - function getApplicationInfoSuccess_plus(msg, data) { - expect(data.name).assertEqual('com.open.harmony.packagemag'); - expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag'); - expect(data.accessTokenId > 0).assertEqual(true); - expect(data.description).assertEqual('$string:mainability_description'); - expect(data.descriptionId > 0).assertEqual(true); - expect(data.icon).assertEqual('$media:icon'); - expect(data.iconId > 0).assertEqual(true); - expect(data.uid > 0).assertEqual(true); - expect(data.label).assertEqual('$string:entry_MainAbility'); - expect(data.labelId > 0).assertEqual(true); - expect(data.systemApp).assertEqual(true); - expect(data.supportedModes).assertEqual(0); - expect(data.flags).assertEqual(0); - expect(data.process).assertEqual(""); - expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' + - '/com.open.harmony.packagemag'); - expect(data.enabled).assertEqual(true); - expect(data.entityType).assertEqual('unspecified'); - expect(data.removable).assertEqual(true); - expect(data.moduleInfos[0].moduleName).assertEqual('entry'); - expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' + - 'com.open.harmony.packagemag/com.open.harmony.packagemag'); - expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' + - 'com.open.harmony.packagemag/com.open.harmony.packagemag'); - console.log(msg + ' end ' + JSON.stringify(data)); - } - }); } \ 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 381d4f8f94d6480772867e78907d4653eeafb7d0..98b343125894d218c6e6499f43bc027ffe2aeb83 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 @@ -1901,7 +1901,6 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.versionName.length).assertLarger(0) expect(datainfo.uid).assertLarger(2099) expect(datainfo.appInfo.name).assertEqual(LAUNCHER) - expect(datainfo.appInfo.description).assertEqual(DESCRIPTION) expect(datainfo.appInfo.systemApp).assertEqual(true) expect(datainfo.appInfo.supportedModes).assertEqual(0) expect(datainfo.appInfo.moduleInfos.length).assertLarger(0)