From 12a4286001dc54f1ef15c78e4bf425a3e733207d Mon Sep 17 00:00:00 2001 From: inter515 Date: Mon, 4 Jul 2022 15:45:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BC=96=E8=AF=91=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: inter515 --- .../src/main/ets/MainAbility/pages/index.ets | 2 +- .../test/GetAbilityLabelJsUnit.test.ets | 2 +- .../MainAbility/test/GetabilityInfo.test.ets | 2 +- .../test/IsAbilityEnabledETSUnit.ets | 64 +++++++++++++++---- .../test/IsApplicationEnabledETSUnit.ets | 2 +- .../test/getAllApplicationInfoJsunit.test.ets | 46 +------------ .../test/getApplicationInfoJsunit.test.ets | 22 +------ .../src/main/js/default/pages/index/index.js | 2 +- 8 files changed, 58 insertions(+), 84 deletions(-) diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/index.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/index.ets index b81c3ae70..8315b59db 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/MainAbility/pages/index.ets @@ -15,7 +15,7 @@ import router from '@system.router'; import file from '@system.file'; -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index"; import testsuite from "../test/List.test.ets"; import featureAbility from "@ohos.ability.featureAbility"; 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 481d77a3c..8a95165d4 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,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'; import Utils from './Utils'; import Bundle from '@ohos.bundle'; 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 c6721e832..61bab6b5d 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,7 +13,7 @@ * limitations under the License. */ -import { describe, it, expect } from 'deccjsunit/index.ets'; +import { describe, it, expect } from 'deccjsunit/index'; import Utils from './Utils'; import bundleManager from '@ohos.bundle'; 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 79bd45b0f..892e70a54 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,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'; import Utils from './Utils'; import Bundle from '@ohos.bundle'; @@ -20,14 +20,6 @@ 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 -} -const ABILITY_ERROR = { - bundleName: BUNDLE_NAME_ERROR, - name: ABILITY_NAME_ERROR -} export default function isAbilityEnabledETSUnit() { @@ -40,9 +32,10 @@ export default function isAbilityEnabledETSUnit() { * @tc.level 0 */ it('isAbilityEnabled_test_0100', 0, async function (done) { + let abilityInfo = generateAbilityInfoForTest(BUNDLE_NAME,ABILITY_NAME); let timeOldStamp = await Utils.getNowTime(); let mData; - await Bundle.isAbilityEnabled(ABILITY).then((data) => { + await Bundle.isAbilityEnabled(abilityInfo).then((data) => { let timeNewStamp = Utils.getNowTime(); Utils.getDurationTime('[isAbilityEnabled_test_0100]', timeOldStamp, timeNewStamp); mData = data; @@ -62,9 +55,10 @@ export default function isAbilityEnabledETSUnit() { * @tc.level 0 */ it('isAbilityEnabled_test_0200', 0, async function (done) { + let abilityInfo = generateAbilityInfoForTest(BUNDLE_NAME,ABILITY_NAME); let timeOldStamp = await Utils.getNowTime(); let mData; - Bundle.isAbilityEnabled(ABILITY, (error, data) => { + Bundle.isAbilityEnabled(abilityInfo, (error, data) => { if (error) { console.error('[isAbilityEnabled_test_0200]Operation failed. Cause: ' + JSON.stringify(error)); expect(error).assertFail(); @@ -86,9 +80,10 @@ export default function isAbilityEnabledETSUnit() { * @tc.level 0 */ it('isAbilityEnabled_test_0300', 0, async function (done) { + let abilityInfo = generateAbilityInfoForTest(BUNDLE_NAME_ERROR,ABILITY_NAME_ERROR); let timeOldStamp = await Utils.getNowTime(); let mData; - await Bundle.isAbilityEnabled(ABILITY_ERROR).then((data) => { + await Bundle.isAbilityEnabled(abilityInfo).then((data) => { let timeNewStamp = Utils.getNowTime(); Utils.getDurationTime('[isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp); mData = data; @@ -110,9 +105,10 @@ export default function isAbilityEnabledETSUnit() { * @tc.level 0 */ it('isAbilityEnabled_test_0400', 0, async function (done) { + let abilityInfo = generateAbilityInfoForTest(BUNDLE_NAME_ERROR,ABILITY_NAME_ERROR); let timeOldStamp = await Utils.getNowTime(); let mData; - Bundle.isAbilityEnabled(ABILITY_ERROR, (error, data) => { + Bundle.isAbilityEnabled(abilityInfo, (error, data) => { if (error) { console.error('[isAbilityEnabled_test_0400]Operation failed. Cause: ' + JSON.stringify(error)); expect(error).assertFail(); @@ -144,6 +140,48 @@ export default function isAbilityEnabledETSUnit() { expect(data).assertEqual(false); } + function generateAbilityInfoForTest(bundleName, name) { + let map1 = new Map([ + ["", [{ + "name": "", "value": "", "extra": "" + }]] + ]); + + let abilityInfo = { + bundleName: bundleName, + name: name, + label: "", + description: "", + icon: "", + labelId: 0, + descriptionId: 0, + iconId: 0, + moduleName: "", + process: "", + targetAbility: "", + backgroundModes: 0, + isVisible: true, + formEnabled: true, + type: 0, + subType: 0, + orientation: 0, + launchMode: 0, + permissions: [], + deviceTypes: [], + deviceCapabilities: [], + readPermission: "", + writePermission: "", + applicationInfo: { + name: "", description: "", descriptionId: 0, systemApp: true, enabled: true, label: "", + labelId: "", icon: "", iconId: "", process: "", supportedModes: 0, moduleSourceDirs: [], + permissions: [], moduleInfos: [], entryDir: "", codePath: "", metaData: map1, + removable: true, accessTokenId: 0, uid: 0, entityType: "" + }, + uri: "", metaData: [], enabled: true + }; + return abilityInfo; + } + }) } \ 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 e5b4b39d0..132bb99a9 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,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'; import Utils from './Utils'; import Bundle from '@ohos.bundle'; 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 d64a1136b..13c5f03ef 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, beforeAll ,it, expect } from 'deccjsunit/index.ets'; +import { describe, beforeAll ,it, expect } from 'deccjsunit/index'; import Utils from './Utils'; import Bundle from '@ohos.bundle'; import account from '@ohos.account.osAccount'; @@ -226,50 +226,6 @@ export default function applicationBundleJsunit() { 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; - 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(); - }); - - /** - * @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', userId).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(); - }); - function expectData(msg, data) { console.info(msg + 'commonTest data length [' + data.length + ']'); for (let i = 0; i < data.length; i++) { 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 63d92cf12..bd919e7f5 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, beforeAll, expect } from 'deccjsunit/index.ets'; +import { describe, it, beforeAll, expect } from 'deccjsunit/index'; import Utils from './Utils'; import Bundle from '@ohos.bundle'; import account from '@ohos.account.osAccount'; @@ -254,26 +254,6 @@ export default function applicationBundleJsunit() { done(); }); - /** - * @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', userId).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(); - }); - /** * @tc.number: bundle_getApplicationInfo_test_0600_001 * @tc.name: getApplicationInfo : Obtains based on a given bundle name. diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmssceneeight/src/main/js/default/pages/index/index.js b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmssceneeight/src/main/js/default/pages/index/index.js index a2ff58470..d7c6ca6e1 100644 --- a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmssceneeight/src/main/js/default/pages/index/index.js +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmssceneeight/src/main/js/default/pages/index/index.js @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import commonEvent from '@ohos.commonevent' +import commonEvent from '@ohos.commonEvent' const injectRef = Object.getPrototypeOf(global) || global injectRef.regeneratorRuntime = require('@babel/runtime/regenerator') -- GitLab