From bb6c7de3da5a47e78bc85fd7f5b3d637281ba7c0 Mon Sep 17 00:00:00 2001 From: inter515 Date: Mon, 27 Jun 2022 21:03:56 +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 --- .../actsbmsetsmodulenametest/BUILD.gn | 4 + .../actsbmsetsmodulenametest/Test.json | 5 +- .../entry/src/main/config.json | 29 ++++++- .../entry/src/main/ets/MainAbility/app.ets | 2 +- .../src/main/ets/MainAbility/pages/index.ets | 32 -------- .../entry/src/main/ets/TestAbility/app.ets | 32 ++++++++ .../src/main/ets/TestAbility/pages/index.ets | 49 ++++++++++++ .../ets/TestRunner/OpenHarmonyTestRunner.ts | 77 +++++++++++++++++++ .../test/ActsBmsEtsModuleNameTest.test.ets | 7 +- .../ets/{MainAbility => }/test/List.test.ets | 0 .../main/resources/base/element/string.json | 8 ++ .../test/ActsBmsEtsUnPermissionTest.test.ets | 4 +- .../src/main/ets/test/GetAbilityIcon.test.ets | 20 +++-- .../src/main/ets/test/GetNameForUid.test.ets | 4 +- .../test/QueryExtensionAbilityInfos.test.ets | 9 --- .../test/getAllApplicationInfoJsunit.test.ets | 35 +-------- .../test/getApplicationInfoJsunit.test.ets | 44 ----------- .../ets/test/getBundleArchiveInfo.test.ets | 32 ++++---- 18 files changed, 236 insertions(+), 157 deletions(-) create mode 100644 appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/TestAbility/app.ets create mode 100644 appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/TestAbility/pages/index.ets create mode 100644 appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts rename appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/{MainAbility => }/test/ActsBmsEtsModuleNameTest.test.ets (99%) rename appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/{MainAbility => }/test/List.test.ets (100%) diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/BUILD.gn b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/BUILD.gn index 781deb288..5f657d28f 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/BUILD.gn +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/BUILD.gn @@ -18,6 +18,7 @@ ohos_js_hap_suite("ActsBmsEtsModuleNameTest") { deps = [ ":bms_ets_assets", ":bms_ets_resources", + ":bms_ets_test_assets", ] ets2abc = true certificate_profile = "./signature/openharmony_sx.p7b" @@ -26,6 +27,9 @@ ohos_js_hap_suite("ActsBmsEtsModuleNameTest") { ohos_js_assets("bms_ets_assets") { source_dir = "./entry/src/main/ets/MainAbility" } +ohos_js_assets("bms_ets_test_assets") { + source_dir = "./entry/src/main/ets/TestAbility" +} ohos_resources("bms_ets_resources") { sources = [ "./entry/src/main/resources" ] hap_profile = "./entry/src/main/config.json" diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/Test.json b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/Test.json index d8be29905..b0b5e7c20 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/Test.json +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/Test.json @@ -1,9 +1,10 @@ { "description": "Configuration for hjunit demo Tests", "driver": { - "type": "JSUnitTest", + "type": "OHJSUnitTest", "test-timeout": "120000", - "package": "com.example.actsbmsmodulenametest", + "bundle-name": "com.example.actsbmsmodulenametest", + "package-name": "com.example.actsbmsmodulenametest", "shell-timeout": "60000" }, "kits": [ diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/config.json b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/config.json index 4ab9ec1cc..087686cc3 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/config.json +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/config.json @@ -17,7 +17,7 @@ "package": "com.example.actsbmsmodulenametest", "name": ".MyApplication", "mainAbility": ".MainAbility", - "srcPath": "MainAbility", + "srcPath": "", "deviceType": [ "phone" ], @@ -50,6 +50,19 @@ "label": "$string:entry_MainAbility", "type": "page", "launchType": "standard" + }, + { + "orientation": "unspecified", + "visible": true, + "srcPath": "TestAbility", + "name": ".TestAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:TestAbility_desc", + "formsEnabled": false, + "label": "$string:TestAbility_label", + "type": "page", + "launchType": "standard" } ], "reqPermissions": [ @@ -80,6 +93,20 @@ "designWidth": 720, "autoDesignWidth": false } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".TestAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } } ] } diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/app.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/app.ets index 261fadca2..bf28e58b3 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/app.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/app.ets @@ -12,7 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - + export default { onCreate() { console.info('Application onCreate') diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/pages/index.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/pages/index.ets index 613631a79..2a1282ca7 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/pages/index.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/pages/index.ets @@ -12,44 +12,12 @@ * 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() { diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/TestAbility/app.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 000000000..1405dd359 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import { Hypium } from 'hypium/index' +import testsuite from '../test/List.test' + +export default { + onCreate() { + console.info('Application onCreate') + var abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/TestAbility/pages/index.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 000000000..52663437c --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import router from '@system.router'; + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info('TestAbility index aboutToAppear') + } + + @State message: string = 'Hello World' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .width('35%') + .height('5%') + .onClick(()=>{ + }) + } + .width('100%') + } + .height('100%') + } + } \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 000000000..14e78a653 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/test/ActsBmsEtsModuleNameTest.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/test/ActsBmsEtsModuleNameTest.test.ets similarity index 99% rename from appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/test/ActsBmsEtsModuleNameTest.test.ets rename to appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/test/ActsBmsEtsModuleNameTest.test.ets index 599b818b1..39ef40558 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/test/ActsBmsEtsModuleNameTest.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/test/ActsBmsEtsModuleNameTest.test.ets @@ -16,7 +16,7 @@ import bundle from '@ohos.bundle' import image from '@ohos.multimedia.image' import account from '@ohos.account.osAccount' -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index' const ABILITY_NAME = 'com.example.bmsmodulename.MainAbility'; const BUNDLE_NAME = 'com.example.bmsmodulename'; @@ -190,15 +190,14 @@ export default function actsBmsJsModuleNameTest() { await bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME) .then(data => { console.info('[GetAbilityIcon_0300]Return data successful: ' + JSON.stringify(data)); - image = data; - expect(image.getBytesNumberPerRow()).assertLarger(0); + expect(data.getBytesNumberPerRow()).assertLarger(0); }).catch((err) => { console.error('[GetAbilityIcon_0300]Operation failed. Err: ' + JSON.stringify(err)); expect(err).assertFail(); }); bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME, (err, data) => { expect(err).assertEqual(SUCCESS_CODE); - expect(image.getBytesNumberPerRow()).assertLarger(0); + expect(data.getBytesNumberPerRow()).assertLarger(0); if (err) { console.error('[GetAbilityIcon_0300]Operation failed. Err: ' + JSON.stringify(err)); } diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/test/List.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/test/List.test.ets similarity index 100% rename from appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/MainAbility/test/List.test.ets rename to appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/ets/test/List.test.ets diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/resources/base/element/string.json b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/resources/base/element/string.json index 03b8532c5..498677efb 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/resources/base/element/string.json +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsmodulenametest/entry/src/main/resources/base/element/string.json @@ -7,6 +7,14 @@ { "name": "description_mainability", "value": "ETS_Empty Ability" + }, + { + "name": "TestAbility_desc", + "value": "description" + }, + { + "name": "TestAbility_label", + "value": "label" } ] } \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/test/ActsBmsEtsUnPermissionTest.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/test/ActsBmsEtsUnPermissionTest.test.ets index c1f6ff2b1..26257a1ca 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/test/ActsBmsEtsUnPermissionTest.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/test/ActsBmsEtsUnPermissionTest.test.ets @@ -116,7 +116,7 @@ export default function actsBmsJsUnPermissionTest() { }, complete: function complete() { console.info("get hasInstalled complete"); - expect(data).assertFail(); + expect().assertFail(); done(); } }) @@ -142,7 +142,7 @@ export default function actsBmsJsUnPermissionTest() { }, complete: function complete() { console.info("get hasInstalled complete"); - expect(data).assertFail(); + expect().assertFail(); done(); } }) diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetAbilityIcon.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetAbilityIcon.test.ets index b96c1e1df..264547f71 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetAbilityIcon.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetAbilityIcon.test.ets @@ -35,16 +35,15 @@ export default function getAbilityIcon() { */ it('bms_getAbilityIcon_0100', 0, async function (done) { await bundle.getAbilityIcon(BUNDLE_NAME_OTHER, ABILITIY_NAME_OTHER).then(pixelmap => { - image = pixelmap; - console.log('bms_getAbilityIcon_0100 success: ' + image.getBytesNumberPerRow()); - expect(image.getBytesNumberPerRow()).assertLarger(0); + console.log('bms_getAbilityIcon_0100 success: ' + pixelmap.getBytesNumberPerRow()); + expect(pixelmap.getBytesNumberPerRow()).assertLarger(0); }).catch(err => { console.info("getAbilityIcon fail:" + JSON.stringify(err)); expect(err).assertFail(); }); bundle.getAbilityIcon(BUNDLE_NAME_OTHER, ABILITIY_NAME_OTHER, (err, pixelmap) => { expect(err).assertEqual(0); - expect(image.getBytesNumberPerRow()).assertLarger(0); + expect(pixelmap.getBytesNumberPerRow()).assertLarger(0); done(); }); }); @@ -56,16 +55,15 @@ export default function getAbilityIcon() { */ it('bms_getAbilityIcon_0200', 0, async function (done) { await bundle.getAbilityIcon(BUNDLE_NAME, ABILITIY_NAME).then(pixelmap => { - image = pixelmap; - console.log('bms_getAbilityIcon_0200 success: ' + image.getBytesNumberPerRow()); - expect(image.getBytesNumberPerRow()).assertLarger(0); + console.log('bms_getAbilityIcon_0200 success: ' + pixelmap.getBytesNumberPerRow()); + expect(pixelmap.getBytesNumberPerRow()).assertLarger(0); }).catch(err => { console.info("getAbilityIcon fail:" + JSON.stringify(err)); expect(err).assertFail(); }); bundle.getAbilityIcon(BUNDLE_NAME, ABILITIY_NAME, (err, pixelmap) => { expect(err).assertEqual(0); - expect(image.getBytesNumberPerRow()).assertLarger(0); + expect(pixelmap.getBytesNumberPerRow()).assertLarger(0); done(); }); }); @@ -77,7 +75,7 @@ export default function getAbilityIcon() { */ it('bms_getAbilityIcon_0300', 0, async function (done) { await bundle.getAbilityIcon(BUNDLE_NAME, SERVICE_NAME).then(pixelmap => { - expect(err).assertFail(); + expect().assertFail(); }).catch(err => { console.info("getAbilityIcon fail:" + JSON.stringify(err)); expect(err).assertEqual(1); @@ -101,13 +99,13 @@ export default function getAbilityIcon() { expect(err).assertEqual(1); }); await bundle.getAbilityIcon(BUNDLE_NAME_ERROR, ABILITIY_NAME).then(pixelmap => { - expect(err).assertFail(); + expect().assertFail(); }).catch(err => { console.info("getAbilityIcon fail:" + JSON.stringify(err)) expect(err).assertEqual(1); }); await bundle.getAbilityIcon("", "").then(pixelmap => { - expect(err).assertFail(); + expect().assertFail(); }).catch(err => { console.info("getAbilityIcon fail:" + JSON.stringify(err)) expect(err).assertEqual(1); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetNameForUid.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetNameForUid.test.ets index 38aaa0116..6735a77f5 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetNameForUid.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetNameForUid.test.ets @@ -28,7 +28,7 @@ export default function getNameForUid() { * @tc.desc Test getBundleInfo interfaces with other hap. */ it('getNameForUid_0100', 0, async function (done) { - let dataInfo = await bundle.getBundleInfo(BUNDLE_NAME1); + let dataInfo = await bundle.getBundleInfo(BUNDLE_NAME1, bundle.BundleFlag.GET_BUNDLE_DEFAULT); await bundle.getNameForUid(dataInfo.uid).then(data => { expect(data).assertEqual(BUNDLE_NAME1); }).catch(err => { @@ -49,7 +49,7 @@ export default function getNameForUid() { * @tc.desc Test getBundleInfo interfaces with hap. */ it('getNameForUid_0200', 0, async function (done) { - let dataInfo = await bundle.getBundleInfo(BUNDLE_NAME2); + let dataInfo = await bundle.getBundleInfo(BUNDLE_NAME2,bundle.BundleFlag.GET_BUNDLE_DEFAULT); await bundle.getNameForUid(dataInfo.uid).then(data => { expect(data).assertEqual(BUNDLE_NAME2); }).catch(err => { diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/QueryExtensionAbilityInfos.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/QueryExtensionAbilityInfos.test.ets index e7c564091..cfcacb040 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/QueryExtensionAbilityInfos.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/QueryExtensionAbilityInfos.test.ets @@ -309,15 +309,6 @@ export default function QueryExtensionAbilityInfos() { }).catch(err => { expect(err).assertEqual(1); }); - await bundle.queryExtensionAbilityInfos( - { - "bundleName": BUNDLE_NAME1, - "abilityName": ABILITY_NAME1 - }, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, null).then(data => { - expect(data).assertFail(); - }).catch(err => { - expect(err).assertEqual(1); - }); bundle.queryExtensionAbilityInfos( { "bundleName": BUNDLE_NAME1, diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getAllApplicationInfoJsunit.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getAllApplicationInfoJsunit.test.ets index af86e927f..5a7960611 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getAllApplicationInfoJsunit.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getAllApplicationInfoJsunit.test.ets @@ -229,28 +229,6 @@ export default function getAllApplicationBundleTest() { 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(); - }); - /** * @tc.number: getApplicationInfos_1000 * @tc.name: getApplicationInfo : Obtains based on a given bundle name. @@ -291,11 +269,6 @@ export default function getAllApplicationBundleTest() { * @tc.desc: Check the return value of the interface */ it('getApplicationInfos_1200', 0, async function (done) { - await Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT').then((data) => { - expect(data).assertFail(); - }).catch((error) => { - expect(error).assertEqual(1); - }); await Bundle.getAllApplicationInfo(null).then((data) => { expect(data).assertFail(); }).catch((error) => { @@ -309,14 +282,10 @@ export default function getAllApplicationBundleTest() { Bundle.getAllApplicationInfo(undefined, (err, data) => { expect(err).assertEqual(1); expect(data).assertEqual("type mismatch"); - Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT', (err, data) => { + Bundle.getAllApplicationInfo(null, (err, data) => { expect(err).assertEqual(1); expect(data).assertEqual("type mismatch"); - Bundle.getAllApplicationInfo(null, (err, data) => { - expect(err).assertEqual(1); - expect(data).assertEqual("type mismatch"); - done(); - }); + done(); }); }); }); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getApplicationInfoJsunit.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getApplicationInfoJsunit.test.ets index bf56bc394..40a045c47 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getApplicationInfoJsunit.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getApplicationInfoJsunit.test.ets @@ -238,26 +238,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_002 * @tc.name: getApplicationInfo : Obtains based on a given bundle name. @@ -418,30 +398,6 @@ export default function applicationBundleJsunit() { }); }); - /** - * @tc.number: getApplicationInfo_2000 - * @tc.name: Test getApplicationInfo - * @tc.desc: Test whether the iconResource, labelResource and descriptionResource - * in the getApplicationInfo of the case meet the expectations - */ - it('testGetApplicationInfo', 0, async function (done) { - await Bundle.getApplicationInfo(BUNDLE_NAME, 0) - .then((applicationInfo) => { - expect(applicationInfo.iconResource.bundleName).assertEqual('com.open.harmony.packagemag') - expect(applicationInfo.iconResource.moduleName).assertEqual('entry') - expect(applicationInfo.iconResource.id).assertLarger(0) - expect(applicationInfo.labelResource.bundleName).assertEqual('com.open.harmony.packagemag') - expect(applicationInfo.labelResource.moduleName).assertEqual('entry') - expect(applicationInfo.labelResource.id).assertLarger(0) - expect(applicationInfo.descriptionResource.bundleName).assertEqual('com.open.harmony.packagemag') - expect(applicationInfo.descriptionResource.moduleName).assertEqual('entry') - expect(applicationInfo.descriptionResource.id).assertLarger(0) - done(); - }).catch((err) => { - expect(err).assertFail(); - done(); - }); - }) function expectData(msg, data) { expect(typeof (data)).assertEqual('object'); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getBundleArchiveInfo.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getBundleArchiveInfo.test.ets index 46105ab74..6e2fed05a 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getBundleArchiveInfo.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getBundleArchiveInfo.test.ets @@ -51,9 +51,9 @@ export default function getBundleArchiveInfo() { expect(datainfo.appInfo.description).assertEqual(APPLICATION_DESCRIPTION) expect(datainfo.appInfo.descriptionId >= 0).assertTrue() expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.iconId)).assertLarger(0) expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.labelId)).assertLarger(0) expect(datainfo.appInfo.systemApp).assertEqual(false) done(); }) @@ -73,9 +73,9 @@ export default function getBundleArchiveInfo() { expect(datainfo.appInfo.description).assertEqual(APPLICATION_DESCRIPTION) expect(datainfo.appInfo.descriptionId >= 0).assertTrue() expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.iconId)).assertLarger(0) expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.labelId)).assertLarger(0) expect(datainfo.appInfo.systemApp).assertEqual(false) done(); }) @@ -95,9 +95,9 @@ export default function getBundleArchiveInfo() { expect(datainfo.appInfo.description).assertEqual(APPLICATION_DESCRIPTION) expect(datainfo.appInfo.descriptionId >= 0).assertTrue() expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.iconId)).assertLarger(0) expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.labelId)).assertLarger(0) expect(datainfo.appInfo.systemApp).assertEqual(false) done(); }) @@ -153,9 +153,9 @@ export default function getBundleArchiveInfo() { expect(datainfo.appInfo.description).assertEqual(APPLICATION_DESCRIPTION) expect(datainfo.appInfo.descriptionId >= 0).assertTrue() expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.iconId)).assertLarger(0) expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.labelId)).assertLarger(0) expect(datainfo.appInfo.systemApp).assertEqual(false) expect(datainfo.appInfo.supportedModes).assertEqual(0) for (let j = 0; j < datainfo.appInfo.moduleInfos.length; j++) { @@ -190,9 +190,9 @@ export default function getBundleArchiveInfo() { expect(datainfo.appInfo.description).assertEqual(APPLICATION_DESCRIPTION) expect(datainfo.appInfo.descriptionId >= 0).assertTrue() expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.iconId)).assertLarger(0) expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.labelId)).assertLarger(0) expect(datainfo.appInfo.systemApp).assertEqual(false) done(); } @@ -214,9 +214,9 @@ export default function getBundleArchiveInfo() { expect(datainfo.appInfo.description).assertEqual(APPLICATION_DESCRIPTION) expect(datainfo.appInfo.descriptionId >= 0).assertTrue() expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.iconId)).assertLarger(0) expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.labelId)).assertLarger(0) expect(datainfo.appInfo.systemApp).assertEqual(false) done(); } @@ -279,9 +279,9 @@ export default function getBundleArchiveInfo() { expect(datainfo.appInfo.description).assertEqual(APPLICATION_DESCRIPTION) expect(datainfo.appInfo.descriptionId >= 0).assertTrue() expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.iconId)).assertLarger(0) expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.labelId)).assertLarger(0) expect(datainfo.appInfo.systemApp).assertEqual(false) expect(datainfo.appInfo.supportedModes).assertEqual(0) for (let j = 0; j < datainfo.appInfo.moduleInfos.length; j++) { @@ -317,9 +317,9 @@ export default function getBundleArchiveInfo() { expect(datainfo.appInfo.description).assertEqual(APPLICATION_DESCRIPTION) expect(datainfo.appInfo.descriptionId >= 0).assertTrue() expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.iconId)).assertLarger(0) expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(parseInt(datainfo.appInfo.labelId)).assertLarger(0) expect(datainfo.appInfo.systemApp).assertEqual(false) expect(datainfo.appInfo.supportedModes).assertEqual(0) for (let j = 0; j < datainfo.appInfo.moduleInfos.length; j++) { -- GitLab