From 471f53c64e6ea95e220e1990f4b690e9f021663c Mon Sep 17 00:00:00 2001 From: inter515 Date: Mon, 6 Jun 2022 20:47:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E5=BA=94=E7=94=A8=E5=8C=85?= =?UTF-8?q?=E5=90=8D=E4=BF=AE=E6=94=B9=E4=B8=BA=E8=BE=85=E5=8A=A9demo?= =?UTF-8?q?=E5=8C=85=E5=90=8D'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: inter515 --- .../actsbmsetsunpermissiontest/Test.json | 23 +++++++++++++++++++ .../test/ActsBmsEtsUnPermissionTest.test.ets | 19 ++++++++------- .../actsbmsjsunpermissiontest/Test.json | 6 ++++- .../js/test/ActsBmsJsUnPermissionTest.test.js | 4 ++-- .../src/main/ets/test/GetAbilityIcon.test.ets | 4 ++-- .../src/main/ets/test/GetNameForUid.test.ets | 2 +- .../src/main/js/test/ExampleJsunit.test.js | 15 ++++++------ 7 files changed, 49 insertions(+), 24 deletions(-) diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/Test.json b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/Test.json index 98dd8d191..dc69426f0 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/Test.json +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/Test.json @@ -14,6 +14,29 @@ ], "type": "AppInstallKit", "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test" + ] + }, + { + "type": "PushKit", + "push": [ + "bmsJstest1.hap->/data/test/bmsJstest1.hap" + ] + }, + { + "type": "ShellKit", + "run-command": [ + "chmod 644 /data/test/*.hap", + "bm install -p /data/test/bmsJstest1.hap" + ], + "teardown-command":[ + "bm uninstall -n com.example.myapplication1" + ] } ] } 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 067acf014..cd139d142 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 @@ -20,11 +20,10 @@ import account from '@ohos.account.osAccount' 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"; -const BUNDLE_SETTINGS = "com.ohos.settings"; -const ABILITIY_SETTINGS = "com.ohos.settings.MainAbility"; +const BUNDLE_NAME_OTHER = "com.example.myapplication1"; +const ABILITIY_NAME_OTHER = "com.example.myapplication1.MainAbility"; const BUNDLE_NAME1 = "ohos.acts.bundle.stage"; const ABILITY_NAME1 = "ExtensionAbility1"; let userId = 0; @@ -67,12 +66,12 @@ export default function actsBmsJsUnPermissionTest() { * @tc.desc test getBundleInfo */ it('getBundleInfo_2000', 0, async function (done) { - await bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, { userId: userId }).then(data => { + await bundle.getBundleInfo(BUNDLE_NAME_OTHER, DEFAULT_FLAG, { userId: userId }).then(data => { expect().assertFail(); }).catch(err => { expect(err).assertEqual(INVALID_CODE); }); - bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, { userId: userId }, (err, data) => { + bundle.getBundleInfo(BUNDLE_NAME_OTHER, DEFAULT_FLAG, { userId: userId }, (err, data) => { expect(err).assertEqual(INVALID_CODE); expect(data).assertEqual(undefined); done(); @@ -85,12 +84,12 @@ export default function actsBmsJsUnPermissionTest() { * @tc.desc test getApplicationInfo */ it('getApplicationInfo_1800', 0, async function (done) { - await bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG).then(data => { + await bundle.getApplicationInfo(BUNDLE_NAME_OTHER, DEFAULT_FLAG).then(data => { expect().assertFail(); }).catch(err => { expect(err).assertEqual(INVALID_CODE); }); - bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, (err, data) => { + bundle.getApplicationInfo(BUNDLE_NAME_OTHER, DEFAULT_FLAG, (err, data) => { expect(err).assertEqual(INVALID_CODE); expect(data).assertEqual(undefined); done(); @@ -130,7 +129,7 @@ export default function actsBmsJsUnPermissionTest() { */ it('SUB_BMS_HAP_STATUS_0012', 0, async function (done) { pkg.hasInstalled({ - bundleName: LAUNCHER_BUNDLE_NAME, + bundleName: BUNDLE_NAME_OTHER, success: function success(data) { console.info("get hasInstalled success" + JSON.stringify(data)); expect(data.result).assertFalse(); @@ -155,12 +154,12 @@ export default function actsBmsJsUnPermissionTest() { * @tc.desc: test getAbilityIcon without permission */ it('SUB_BMS_APPINFO_GETABILITYICON_0006', 0, async function (done) { - await bundle.getAbilityIcon(BUNDLE_SETTINGS, ABILITIY_SETTINGS).then(pixelmap => { + await bundle.getAbilityIcon(BUNDLE_NAME_OTHER, ABILITIY_NAME_OTHER).then(pixelmap => { expect(pixelmap).assertFail(); }).catch(err => { expect(err).assertEqual(1); }); - bundle.getAbilityIcon(BUNDLE_SETTINGS, ABILITIY_SETTINGS, (err, pixelmap) => { + bundle.getAbilityIcon(BUNDLE_NAME_OTHER, ABILITIY_NAME_OTHER, (err, pixelmap) => { expect(err).assertEqual(1); done(); }); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/Test.json b/appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/Test.json index d2d58667e..fd4057a15 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/Test.json +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsjsunpermissiontest/Test.json @@ -31,7 +31,11 @@ { "type": "ShellKit", "run-command": [ - "chmod 644 /data/test/*.hap" + "chmod 644 /data/test/*.hap", + "bm install -p /data/test/bmsJstest1.hap" + ], + "teardown-command":[ + "bm uninstall -n com.example.myapplication1" ] } ] 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 889f57f5b..adfd336c8 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 @@ -17,8 +17,8 @@ import bundle from '@ohos.bundle' import account from '@ohos.account.osAccount' import { describe, beforeAll, it, expect } from 'deccjsunit/index' -const LAUNCHER_BUNDLE_NAME = 'com.ohos.launcher'; -const LAUNCHER_MAIN_ABILITY = 'com.ohos.launcher.MainAbility'; +const LAUNCHER_BUNDLE_NAME = 'com.example.myapplication1'; +const LAUNCHER_MAIN_ABILITY = 'com.example.myapplication1.MainAbility'; const DEFAULT_FLAG = bundle.BundleFlag.GET_BUNDLE_DEFAULT; const INVALID_CODE = 1; let userId = 0; 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 f53cfa1dc..b96c1e1df 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 @@ -20,8 +20,8 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from const BUNDLE_NAME = "com.open.harmony.packagemag"; const ABILITIY_NAME = "com.open.harmony.packagemag.MainAbility"; const SERVICE_NAME = "com.open.harmony.packagemag.ServiceAbility"; -const BUNDLE_NAME_OTHER = "com.ohos.settings"; -const ABILITIY_NAME_OTHER = "com.ohos.settings.MainAbility"; +const BUNDLE_NAME_OTHER = "com.example.l3jsdemo"; +const ABILITIY_NAME_OTHER = "com.example.l3jsdemo.MainAbility"; const BUNDLE_NAME_ERROR = "com.ohos.packagemag"; const ABILITIY_NAME_ERROR = "com.ohos.packagemag.MainAbility"; 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 f9cd261f4..38aaa0116 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 @@ -16,7 +16,7 @@ import bundle from '@ohos.bundle' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index' -const BUNDLE_NAME1 = 'com.ohos.launcher'; +const BUNDLE_NAME1 = 'com.example.l3jsdemo'; const BUNDLE_NAME2 = 'com.open.harmony.packagemag'; export default function getNameForUid() { 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 717ef95be..5ef2efdc3 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 @@ -24,7 +24,6 @@ const NAME2 = "com.example.myapplication2" const NAME3 = "com.example.myapplication4" const NAME4 = "com.example.myapplication5" const NAME5 = "com.example.myapplication6" -const LAUNCHER = "com.ohos.launcher" const VERSIONCODE1 = 1 const OBJECT = "object" const DIR1 = "/data/app/el1/bundle/public/com.example.myapplication1/com.example.myapplication1" @@ -436,13 +435,13 @@ describe('ActsBundleManagerTest', function () { /** * @tc.number getBundleInfo_1400 * @tc.name BUNDLE::getBundleInfo - * @tc.desc Test getBundleInfo interfaces with LAUNCHER hap.(by callback) + * @tc.desc Test getBundleInfo interfaces with systemApp.(by callback) */ it('getBundleInfo_1400', 0, async function (done) { let bundleOptions = { userId: userId }; - demo.getBundleInfo(LAUNCHER, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, + demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, bundleOptions, (err, datainfo) => { if (err) { console.info("getBundleInfo_1400 fail:" + JSON.stringify(err)); @@ -451,12 +450,12 @@ describe('ActsBundleManagerTest', function () { return; } console.info("getBundleInfo_1400 success:" + JSON.stringify(datainfo)); - expect(datainfo.name).assertEqual(LAUNCHER); - expect(datainfo.vendor).assertEqual("ohos"); - expect(datainfo.versionCode).assertEqual(1000000); + expect(datainfo.name).assertEqual(NAME1); + expect(datainfo.vendor).assertEqual("example"); + expect(datainfo.versionCode).assertEqual(1); expect(datainfo.versionName.length).assertLarger(0); expect(datainfo.uid).assertLarger(2099); - expect(datainfo.appInfo.name).assertEqual(LAUNCHER); + expect(datainfo.appInfo.name).assertEqual(NAME1); expect(datainfo.appInfo.systemApp).assertEqual(true); expect(datainfo.appInfo.supportedModes).assertEqual(0); expect(datainfo.appInfo.moduleInfos.length).assertLarger(0); @@ -597,7 +596,7 @@ describe('ActsBundleManagerTest', function () { done(); return; } - console.info("getBundleInfo_1800 success" + JSON.stringify(datainfo)); + console.info("getBundleInfo_1800 success" + JSON.stringify(dataInfo)); expect(dataInfo).assertFail(); done(); }); -- GitLab