From e3a88de2642dd41d8765c215c03392ca51752fba Mon Sep 17 00:00:00 2001 From: shilei Date: Sat, 25 Dec 2021 09:17:09 +0000 Subject: [PATCH] fixed 9f66a25 from https://gitee.com/shilei91/xts_acts/pulls/1434 update xts Signed-off-by: shilei --- .../test/ActsBmsAllShortcutInfoTest.test.js | 419 +- .../main/js/test/ActsBmsHapModuleTest.test.js | 96 +- .../src/main/js/test/ActsBmsJsTest.test.js | 64 +- .../src/main/js/test/ActsBmsKitTest.test.js | 4 +- .../main/js/test/ActsBmsMetaDataTest.test.js | 247 +- .../test/ActsBmsModuleUsageRecordTest.test.js | 149 +- .../src/main/js/test/ExampleJsunit.test.js | 3424 ++++++----------- .../src/main/js/test/ExampleJsunit.test.js | 155 +- 8 files changed, 1565 insertions(+), 2993 deletions(-) mode change 100755 => 100644 appexecfwk/bundle_standard/bundlemanager/actsbundlemanagertest/entry/src/main/js/test/ExampleJsunit.test.js mode change 100755 => 100644 appexecfwk/bundle_standard/bundlemanager/actsbundlemanageruninstall/entry/src/main/js/test/ExampleJsunit.test.js diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsallshortcutinfotest/entry/src/main/js/test/ActsBmsAllShortcutInfoTest.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsallshortcutinfotest/entry/src/main/js/test/ActsBmsAllShortcutInfoTest.test.js index 0f626f6cb..fe550069f 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsallshortcutinfotest/entry/src/main/js/test/ActsBmsAllShortcutInfoTest.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsallshortcutinfotest/entry/src/main/js/test/ActsBmsAllShortcutInfoTest.test.js @@ -31,42 +31,39 @@ describe('ActsBmsAllShortcutInfoTest', function () { var bundleName = 'com.example.third1'; let installer = await bundle.getBundleInstaller(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, OnReceiveInstallEvent); async function OnReceiveInstallEvent(err, data) { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); - let shortInfos = await bundle.getAllShortcutInfo(bundleName) - expect(typeof shortInfos).assertEqual('object'); - expect(shortInfos.length).assertEqual(1); - for (var i = 0; i < shortInfos.length; i++) { - expect(shortInfos[i].id).assertEqual('id.third1'); - expect(shortInfos[i].bundleName).assertEqual('com.example.third1'); - expect(shortInfos[i].hostAbility).assertEqual(""); - expect(shortInfos[i].icon).assertEqual('$media:icon'); - expect(shortInfos[i].label).assertEqual('$string:app_name'); - expect(shortInfos[i].disableMessage).assertEqual(""); - expect(shortInfos[i].isStatic).assertEqual(false); - expect(shortInfos[i].isHomeShortcut).assertEqual(false); - expect(shortInfos[i].isEnabled).assertEqual(false); - for (var j = 0; j < shortInfos[i].wants.length; j++) { - expect(shortInfos[i].wants[j].targetClass).assertEqual('com.example.third1.MainAbility'); - expect(shortInfos[i].wants[j].targetBundle).assertEqual('com.example.third1'); + bundle.getAllShortcutInfo(bundleName).then(shortInfos => { + expect(typeof shortInfos).assertEqual('object'); + expect(shortInfos.length).assertEqual(1); + for (var i = 0; i < shortInfos.length; i++) { + expect(shortInfos[i].id).assertEqual('id.third1'); + expect(shortInfos[i].bundleName).assertEqual('com.example.third1'); + expect(shortInfos[i].hostAbility).assertEqual(""); + expect(shortInfos[i].icon).assertEqual('$media:icon'); + expect(shortInfos[i].label).assertEqual('$string:app_name'); + expect(shortInfos[i].disableMessage).assertEqual(""); + expect(shortInfos[i].isStatic).assertEqual(false); + expect(shortInfos[i].isHomeShortcut).assertEqual(false); + expect(shortInfos[i].isEnabled).assertEqual(false); + for (var j = 0; j < shortInfos[i].wants.length; j++) { + expect(shortInfos[i].wants[j].targetClass).assertEqual('com.example.third1.MainAbility'); + expect(shortInfos[i].wants[j].targetBundle).assertEqual('com.example.third1'); + } } - } - checkShortcutIsExist(shortInfos, 'id.third1', 'third1'); + checkShortcutIsExist(shortInfos, 'id.third1', 'third1'); + }); installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, OnReceiveUninstallEvent); }; function OnReceiveUninstallEvent(err, data) { @@ -88,11 +85,9 @@ describe('ActsBmsAllShortcutInfoTest', function () { var bundleName = 'com.example.third1'; let installer = await bundle.getBundleInstaller(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, OnReceiveInstallEvent); function OnReceiveInstallEvent(err, data) { @@ -100,15 +95,13 @@ describe('ActsBmsAllShortcutInfoTest', function () { expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); bundle.getAllShortcutInfo(bundleName, async (result, shortcutInfos) => { - expect(result.code).assertEqual(0); + expect(result).assertEqual(0); expect(shortcutInfos.length).assertEqual(1); checkShortcutIsExist(shortcutInfos, 'id.third1', 'third1'); installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); @@ -130,26 +123,23 @@ describe('ActsBmsAllShortcutInfoTest', function () { var bundlePath = ['/data/test/bmsThirdBundleTest1.hap', '/data/test/bmsThirdBundleTest3.hap']; let installer = await bundle.getBundleInstaller(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); - var shortInfos = await bundle.getAllShortcutInfo(bundleName); - expect(typeof shortInfos).assertEqual('object'); - expect(shortInfos.length).assertEqual(2); - checkShortcutIsExist(shortInfos, 'id.third1', 'third1'); - checkShortcutIsExist(shortInfos, 'id.third3', 'third3'); + bundle.getAllShortcutInfo(bundleName).then(shortInfos => { + expect(typeof shortInfos).assertEqual('object'); + expect(shortInfos.length).assertEqual(2); + checkShortcutIsExist(shortInfos, 'id.third1', 'third1'); + checkShortcutIsExist(shortInfos, 'id.third3', 'third3'); + }); installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); @@ -169,26 +159,22 @@ describe('ActsBmsAllShortcutInfoTest', function () { var bundleName = 'com.example.third1'; let installer = await bundle.getBundleInstaller(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); bundle.getAllShortcutInfo(bundleName, async (result, shortInfos) => { - expect(result.code).assertEqual(0); + expect(result).assertEqual(0); expect(shortInfos.length).assertEqual(2); checkShortcutIsExist(shortInfos, 'id.third1', 'third1'); checkShortcutIsExist(shortInfos, 'id.third3', 'third3'); installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); @@ -205,9 +191,11 @@ describe('ActsBmsAllShortcutInfoTest', function () { */ it('bms_getAllShortcutInfo_0500', 0, async function (done) { console.info('=====================bms_getAllShortcutInfo_0500=================='); - var data = await bundle.getAllShortcutInfo(''); - expect(typeof data).assertEqual('object'); - expect(data.length).assertEqual(0); + var bundleName = ''; + bundle.getAllShortcutInfo(bundleName).then(data => { + expect(typeof data).assertEqual('object'); + expect(data.length).assertEqual(0); + }); done(); }) @@ -220,10 +208,10 @@ describe('ActsBmsAllShortcutInfoTest', function () { console.info('=====================bms_getAllShortcutInfo_0600=================='); var bundleName = ''; bundle.getAllShortcutInfo(bundleName, (result, data) => { - expect(result.code).assertEqual(-1); + expect(result).assertEqual(1); expect(data.length).assertEqual(0); - done(); }); + done(); }) /* @@ -238,53 +226,50 @@ describe('ActsBmsAllShortcutInfoTest', function () { var bundlePath1 = ['/data/test/bmsThirdBundleTest1.hap']; var bundleName = 'com.example.third1'; var bundlePath2 = ['/data/test/bmsThirdBundleTestA1.hap']; + var abilityName = 'com.example.third1.AMainAbility'; let installer = await bundle.getBundleInstaller(); installer.install(bundlePath1, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); installer.install(bundlePath2, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); - var shortInfos = await bundle.getAllShortcutInfo(bundleName); - expect(typeof shortInfos).assertEqual('object'); - expect(shortInfos.length).assertEqual(1); - for (var i = 0; i < shortInfos.length; i++) { - expect(typeof shortInfos[i]).assertEqual('object'); - expect(typeof shortInfos[i].id).assertEqual('string'); - expect(shortInfos[i].id).assertEqual('id.thirdA1'); - expect(typeof shortInfos[i].disableMessage).assertEqual('string'); - expect(typeof shortInfos[i].isStatic).assertEqual('boolean'); - expect(typeof shortInfos[i].isHomeShortcut).assertEqual('boolean'); - expect(typeof shortInfos[i].isEnabled).assertEqual('boolean'); - expect(typeof shortInfos[i].hostAbility).assertEqual('string'); - expect(typeof shortInfos[i].wants).assertEqual('object') - if (typeof shortInfos[i].wants != 'undefined' && Object.keys(shortInfos[i].wants).length != 0) { - for (var j = 0; j < shortInfos[i].wants.length; j++) { - expect(shortInfos[i].wants[j].targetClass).assertEqual('com.example.third1.AMainAbility'); - expect(shortInfos[i].wants[j].targetBundle).assertEqual('com.example.third1'); + bundle.getAllShortcutInfo(bundleName).then(shortInfos => { + expect(typeof shortInfos).assertEqual('object'); + expect(shortInfos.length).assertEqual(1); + for (var i = 0; i < shortInfos.length; i++) { + expect(typeof shortInfos[i]).assertEqual('object'); + expect(typeof shortInfos[i].id).assertEqual('string'); + expect(shortInfos[i].id).assertEqual('id.thirdA1'); + expect(typeof shortInfos[i].disableMessage).assertEqual('string'); + expect(typeof shortInfos[i].isStatic).assertEqual('boolean'); + expect(typeof shortInfos[i].isHomeShortcut).assertEqual('boolean'); + expect(typeof shortInfos[i].isEnabled).assertEqual('boolean'); + expect(typeof shortInfos[i].hostAbility).assertEqual('string'); + expect(typeof shortInfos[i].wants).assertEqual('object') + if (typeof shortInfos[i].wants != 'undefined' && + Object.keys(shortInfos[i].wants).length != 0) { + for (var j = 0; j < shortInfos[i].wants.length; j++) { + expect(shortInfos[i].wants[j].targetClass).assertEqual(abilityName); + expect(shortInfos[i].wants[j].targetBundle).assertEqual('com.example.third1'); + } } } - } + }); installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); @@ -304,28 +289,25 @@ describe('ActsBmsAllShortcutInfoTest', function () { var bundleName = 'com.example.third1'; var bundlePath1 = ['/data/test/bmsThirdBundleTest1.hap']; var bundlePath2 = ['/data/test/bmsThirdBundleTestA1.hap']; + var abilityName = 'com.example.third1.AMainAbility'; let installer = await bundle.getBundleInstaller(); installer.install(bundlePath1, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); installer.install(bundlePath2, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); bundle.getAllShortcutInfo(bundleName, async (result, shortInfos) => { - expect(result.code).assertEqual(0); + expect(result).assertEqual(0); expect(shortInfos.length).assertEqual(1); for (var i = 0; i < shortInfos.length; i++) { expect(typeof shortInfos[i]).assertEqual('object'); @@ -337,19 +319,18 @@ describe('ActsBmsAllShortcutInfoTest', function () { expect(typeof shortInfos[i].isEnabled).assertEqual('boolean'); expect(typeof shortInfos[i].hostAbility).assertEqual('string'); expect(typeof shortInfos[i].wants).assertEqual('object') - if (typeof shortInfos[i].wants != 'undefined' && Object.keys(shortInfos[i].wants).length != 0) { + if (typeof shortInfos[i].wants != 'undefined' && + Object.keys(shortInfos[i].wants).length != 0) { for (var j = 0; j < shortInfos[i].wants.length; j++) { - expect(shortInfos[i].wants[j].targetClass).assertEqual('com.example.third1.AMainAbility'); + expect(shortInfos[i].wants[j].targetClass).assertEqual(abilityName); expect(shortInfos[i].wants[j].targetBundle).assertEqual('com.example.third1'); } } } installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); @@ -371,24 +352,21 @@ describe('ActsBmsAllShortcutInfoTest', function () { var bundlePath = ['/data/test/bmsThirdBundleTest2.hap']; let installer = await bundle.getBundleInstaller(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); - var shortcutInfos = await bundle.getAllShortcutInfo(bundleName); - expect(typeof shortcutInfos).assertEqual('object'); - expect(shortcutInfos.length).assertEqual(0); + bundle.getAllShortcutInfo(bundleName).then(data => { + expect(typeof data).assertEqual('object'); + expect(data.length).assertEqual(0); + }); installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); @@ -408,29 +386,25 @@ describe('ActsBmsAllShortcutInfoTest', function () { var bundlePath = ['/data/test/bmsThirdBundleTest2.hap']; let installer = await bundle.getBundleInstaller(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); bundle.getAllShortcutInfo(bundleName, async (result, shortcutInfos) => { - expect(result.code).assertEqual(0); + expect(result).assertEqual(1); expect(shortcutInfos.length).assertEqual(0); - installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } - }, (err, data) => { - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual("SUCCESS"); - done(); - }); + }); + installer.uninstall(bundleName, { + userId: 0, + installFlag: 1, + isKeepData: false + }, (err, data) => { + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual("SUCCESS"); + done(); }); }); }) @@ -443,11 +417,12 @@ describe('ActsBmsAllShortcutInfoTest', function () { it('bms_getAllShortcutInfo_1100', 0, async function (done) { console.info('=====================bms_getAllShortcutInfo_1100=================='); var bundleName = 'com.example.system1'; - var data = await bundle.getAllShortcutInfo(bundleName); - expect(typeof data).assertEqual('object'); - expect(data.length).assertEqual(1); - checkShortcutIsExist(data, 'id.system1', 'system1'); - done(); + bundle.getAllShortcutInfo(bundleName).then(data => { + expect(typeof data).assertEqual('object'); + expect(data.length).assertEqual(1); + checkShortcutIsExist(data, 'id.system1', 'system1'); + done(); + }); }) /* @@ -459,7 +434,7 @@ describe('ActsBmsAllShortcutInfoTest', function () { console.info('=====================bms_getAllShortcutInfo_1200=================='); var bundleName = 'com.example.system1'; bundle.getAllShortcutInfo(bundleName, (result, data) => { - expect(result.code).assertEqual(0); + expect(result).assertEqual(0); expect(data.length).assertEqual(1); checkShortcutIsExist(data, 'id.system1', 'system1'); done(); @@ -474,11 +449,12 @@ describe('ActsBmsAllShortcutInfoTest', function () { it('bms_getAllShortcutInfo_1300', 0, async function (done) { console.info('=====================bms_getAllShortcutInfo_1300=================='); var bundleName = 'com.example.vendor1'; - var data = await bundle.getAllShortcutInfo(bundleName); - expect(typeof data).assertEqual('object'); - expect(data.length).assertEqual(1); - checkShortcutIsExist(data, 'id.vendor1', 'vendor1'); - done(); + bundle.getAllShortcutInfo(bundleName).then(data => { + expect(typeof data).assertEqual('object'); + expect(data.length).assertEqual(1); + checkShortcutIsExist(data, 'id.vendor1', 'vendor1'); + done(); + }); }) /* @@ -490,7 +466,7 @@ describe('ActsBmsAllShortcutInfoTest', function () { console.info('=====================bms_getAllShortcutInfo_1400=================='); var bundleName = 'com.example.vendor1'; bundle.getAllShortcutInfo(bundleName, (result, data) => { - expect(result.code).assertEqual(0); + expect(result).assertEqual(0); expect(data.length).assertEqual(1); checkShortcutIsExist(data, 'id.vendor1', 'vendor1'); done(); @@ -510,29 +486,27 @@ describe('ActsBmsAllShortcutInfoTest', function () { var bundleName = 'com.example.third1'; let installer = await bundle.getBundleInstaller(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); - var shortcutInfos = await bundle.getAllShortcutInfo(bundleName); - checkShortcutIsExist(shortcutInfos, 'id.third1', 'third1'); + bundle.getAllShortcutInfo(bundleName).then(shortcutInfos => { + checkShortcutIsExist(shortcutInfos, 'id.third1', 'third1'); + }); installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); - var shortcutInfos = await bundle.getAllShortcutInfo(bundleName); - expect(shortcutInfos.length).assertEqual(0); + bundle.getAllShortcutInfo(bundleName).then(shortcutInfos => { + expect(shortcutInfos.length).assertEqual(0); + }); done(); }); }); @@ -549,34 +523,31 @@ describe('ActsBmsAllShortcutInfoTest', function () { var bundleName = 'com.example.third1'; let installer = await bundle.getBundleInstaller(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); - var shortcutInfos = await bundle.getAllShortcutInfo(bundleName); - expect(typeof shortcutInfos).assertEqual('object'); - expect(shortcutInfos.length).assertEqual(1); - checkShortcutIsExist(shortcutInfos, 'id.third1', 'third1'); + bundle.getAllShortcutInfo(bundleName).then(shortcutInfos => { + expect(typeof shortcutInfos).assertEqual('object'); + expect(shortcutInfos.length).assertEqual(1); + checkShortcutIsExist(shortcutInfos, 'id.third1', 'third1'); + }); installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); bundle.getAllShortcutInfo(bundleName, async (result, data) => { - expect(result.code).assertEqual(-1); + expect(result).assertEqual(1); expect(data.length).assertEqual(0); - done(); }); + done(); }); }); }) @@ -592,26 +563,23 @@ describe('ActsBmsAllShortcutInfoTest', function () { var bundlePath = ['/data/test/bmsThirdBundleTest4.hap']; let installer = await bundle.getBundleInstaller(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); - var shortcutInfos = await bundle.getAllShortcutInfo(bundleName); - expect(typeof shortcutInfos).assertEqual('object'); - expect(shortcutInfos.length).assertEqual(2); - checkShortcutInfo(shortcutInfos[0], 'third4A'); - checkShortcutInfo(shortcutInfos[1], 'third4B'); + bundle.getAllShortcutInfo(bundleName).then(shortcutInfos => { + expect(typeof shortcutInfos).assertEqual('object'); + expect(shortcutInfos.length).assertEqual(2); + checkShortcutInfo(shortcutInfos[0], 'third4A'); + checkShortcutInfo(shortcutInfos[1], 'third4B'); + }); installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -631,26 +599,22 @@ describe('ActsBmsAllShortcutInfoTest', function () { var bundleName = 'com.example.third4'; let installer = await bundle.getBundleInstaller(); installer.install(['/data/test/bmsThirdBundleTest4.hap'], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); bundle.getAllShortcutInfo(bundleName, async (result, shortcutInfos) => { - expect(result.code).assertEqual(0); + expect(result).assertEqual(0); expect(shortcutInfos.length).assertEqual(2); checkShortcutInfo(shortcutInfos[0], 'third4A'); checkShortcutInfo(shortcutInfos[1], 'third4B'); installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -671,8 +635,8 @@ describe('ActsBmsAllShortcutInfoTest', function () { var bundleName = '!@#$%^&ERTYUhusdf7254_=-'; bundle.getAllShortcutInfo(bundleName).then((data) => { expect(data.length).assertEqual(0); - done(); }); + done(); }) /* @@ -684,10 +648,10 @@ describe('ActsBmsAllShortcutInfoTest', function () { console.info('=====================bms_getAllShortcutInfo_2000=================='); var bundleName = '!@#$%^&ERTYUhusdf7254_=-'; bundle.getAllShortcutInfo(bundleName, async (result, data) => { - expect(result.code).assertEqual(-1); + expect(result).assertEqual(1); expect(data.length).assertEqual(0); - done(); }); + done(); }) /* @@ -701,9 +665,10 @@ describe('ActsBmsAllShortcutInfoTest', function () { for (var i = 0; i < NAMECOUNT; i++) { bundleName += 'test'; } - var data = await bundle.getAllShortcutInfo(bundleName); - expect(typeof data).assertEqual('object'); - expect(data.length).assertEqual(0); + bundle.getAllShortcutInfo(bundleName).then(data => { + expect(typeof data).assertEqual('object'); + expect(data.length).assertEqual(0); + }); done(); }) @@ -719,10 +684,10 @@ describe('ActsBmsAllShortcutInfoTest', function () { bundleName += 'test'; } bundle.getAllShortcutInfo(bundleName, async (result, data) => { - expect(result.code).assertEqual(-1); + expect(result).assertEqual(1); expect(data.length).assertEqual(0); - done(); }); + done(); }) function checkShortcutInfo(dataInfo, name) { 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 a78ef3b8e..02831649b 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 @@ -29,11 +29,9 @@ describe('ActsBmsHapModuleTest', function () { let bundleName = 'com.example.bmsmainabilityfirstscene'; var installer = await bundle.getBundleInstaller(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, onReceiveInstallEvent); function onReceiveInstallEvent(err, data) { expect(err.code).assertEqual(0); @@ -72,11 +70,9 @@ describe('ActsBmsHapModuleTest', function () { } } installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -100,11 +96,9 @@ describe('ActsBmsHapModuleTest', function () { let secondMainAbility = 'com.example.bmsmainabilitysecondscene.MainAbility'; var installer = await bundle.getBundleInstaller(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -120,11 +114,9 @@ describe('ActsBmsHapModuleTest', function () { checkHapModuleInfo(result.hapModuleInfo[1]); } installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -147,11 +139,9 @@ describe('ActsBmsHapModuleTest', function () { var installer = await bundle.getBundleInstaller(); console.log('========install========' + typeof installer); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, onReceiveInstallEvent); function onReceiveInstallEvent(err, data) { console.info('========install Finish========'); @@ -170,11 +160,9 @@ describe('ActsBmsHapModuleTest', function () { checkHapModuleInfo(result.hapModuleInfo[0]); } installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, onReceiveUninstallEvent); function onReceiveUninstallEvent(err, data) { @@ -192,8 +180,8 @@ describe('ActsBmsHapModuleTest', function () { /* * @tc.number: bms_getHapModuleInfo_0400 - * @tc.name: get hapModuleInfo through getBundleInfo, an application that adds mainAbility - * @tc.desc: get the module information of the hap with the added field mainAbility + * @tc.name: get hapModuleInfo through getBundleInfo, an application that adds mainAbility + * @tc.desc: get the module information of the hap with the added field mainAbility */ it('bms_getHapModuleInfo_0400', 0, async function (done) { console.debug('===========begin bms_getHapModuleInfo_0400===========') @@ -202,11 +190,9 @@ describe('ActsBmsHapModuleTest', function () { var installer = await bundle.getBundleInstaller(); console.log('========install========' + typeof installer); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { console.info('========install Finish========'); expect(typeof err).assertEqual('object'); @@ -223,11 +209,9 @@ describe('ActsBmsHapModuleTest', function () { checkHapModuleInfo(result.hapModuleInfo[0]); } installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, onReceiveUninstallEvent); function onReceiveUninstallEvent(err, data) { @@ -242,8 +226,8 @@ describe('ActsBmsHapModuleTest', function () { /* * @tc.number: bms_getHapModuleInfo_0500 - * @tc.name: get the hapModuleInfo of the upgraded hap package from an application through getBundleInfo - * @tc.desc: get the module information of the mainAbility upgrade hap + * @tc.name: get the hapModuleInfo of the upgraded hap package from an application through getBundleInfo + * @tc.desc: get the module information of the mainAbility upgrade hap */ it('bms_getHapModuleInfo_0500', 0, async function (done) { console.debug('===========begin bms_getHapModuleInfo_0500===========') @@ -252,21 +236,17 @@ describe('ActsBmsHapModuleTest', function () { let bundleName = 'com.example.third1'; var installer = await bundle.getBundleInstaller(); installer.install(bundlePath1, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual('SUCCESS'); installer.install(bundlePath2, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -283,11 +263,9 @@ describe('ActsBmsHapModuleTest', function () { checkHapModuleInfo(hapModuleInfo); } installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); 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 3d11808d9..aea5c47e9 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 @@ -29,11 +29,9 @@ describe('ActsBmsJsTest', function () { let abilityName = 'com.example.third2.MainAbility'; var installer = await bundle.getBundleInstaller(); installer.install(['/data/test/bmsThirdBundleTest2.hap'], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, onReceiveInstallEvent); async function onReceiveInstallEvent(err, data) { @@ -52,11 +50,9 @@ describe('ActsBmsJsTest', function () { expect(result.abilityInfo[0].srcPath).assertEqual(''); } installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { console.info('========uninstall Finish========'); expect(err.code).assertEqual(0); @@ -80,11 +76,9 @@ describe('ActsBmsJsTest', function () { let abilityName2 = 'com.example.third5.BMainAbility'; var installer = await bundle.getBundleInstaller(); installer.install(['/data/test/bmsThirdBundleTest5.hap'], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, onReceiveInstallEvent); async function onReceiveInstallEvent(err, data) { @@ -107,11 +101,9 @@ describe('ActsBmsJsTest', function () { expect(result.abilityInfo[1].srcPath).assertEqual(''); } installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -133,11 +125,9 @@ describe('ActsBmsJsTest', function () { let abilityName = 'com.example.js.MainAbility'; var installer = await bundle.getBundleInstaller(); installer.install(['/data/test/bmsThirdBundleJs.hap'], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, onReceiveInstallEvent); async function onReceiveInstallEvent(err, data) { @@ -156,11 +146,9 @@ describe('ActsBmsJsTest', function () { expect(result.abilityInfo[0].srcPath).assertEqual('default'); } installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { console.info('========uninstall Finish========'); expect(err.code).assertEqual(0); @@ -183,11 +171,9 @@ describe('ActsBmsJsTest', function () { let abilityName = '.MainAbility'; var installer = await bundle.getBundleInstaller(); installer.install(['/data/test/bmsThirdBundleC.hap'], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, onReceiveInstallEvent); async function onReceiveInstallEvent(err, data) { @@ -206,11 +192,9 @@ describe('ActsBmsJsTest', function () { expect(result.abilityInfo[0].srcPath).assertEqual('default/c++/'); } installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { console.info('========uninstall Finish========'); expect(err.code).assertEqual(0); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmskittest/entry/src/main/js/test/ActsBmsKitTest.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmskittest/entry/src/main/js/test/ActsBmsKitTest.test.js index 1bba1ddf0..ab827ea20 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmskittest/entry/src/main/js/test/ActsBmsKitTest.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmskittest/entry/src/main/js/test/ActsBmsKitTest.test.js @@ -96,11 +96,11 @@ describe('ActsBmsKitTest', function () { for (let i = 0; i < STRESSLEVEL; i++) { bundle.getAllShortcutInfo(bundleName, async (err, data) => { expect(data.length).assertEqual(1); - expect(err.code).assertEqual(0); + expect(err).assertEqual(0); checkShortcutIsExist(data, 'id.third1', 'third1'); if (count == STRESSLEVEL - 1) { done(); - } else if (err.code != 0) { + } else if (err != 0) { console.log('call function level is: ' + count); expect().assertFail(); flag = false; diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsmetadatatest/entry/src/main/js/test/ActsBmsMetaDataTest.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsmetadatatest/entry/src/main/js/test/ActsBmsMetaDataTest.test.js index 80ed2f82b..7e64f7512 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsmetadatatest/entry/src/main/js/test/ActsBmsMetaDataTest.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsmetadatatest/entry/src/main/js/test/ActsBmsMetaDataTest.test.js @@ -25,47 +25,34 @@ describe('ActsBmsMetaDataTest', function () { */ it('bms_getMetaData_0100', 0, async function (done) { console.info('=====================bms_getMetaData_0100=================='); - var bundlePath = ['/data/test/bmsThirdBundleTest1.hap', '/data/test/bmsThirdBundleTest3.hap'] + var bundlePath = ['/data/test/bmsThirdBundleTest1.hap'] var installer = await bundle.getBundleInstaller(); let abilityName1 = 'com.example.third1.MainAbility'; - let abilityName2 = 'com.example.third3.MainAbility'; let dataMap = new Map(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual('SUCCESS'); - var dataInfos = await bundle.queryAbilityByWant({ - want: { - action: 'action.system.home', - entities: ['entity.system.home'], - elementName: { - deviceId: '0', - bundleName: 'com.example.third1', - abilityName: 'com.example.third1.MainAbility', - }, - } - }, 0, 0) - for (let i = 0, len = dataInfos.length; i < len; i++) { - dataMap.set(dataInfos[i].name, dataInfos[i].metaData) - } - expect(dataMap.has(abilityName1)).assertTrue(); - expect(dataMap.has(abilityName2)).assertTrue(); - if (dataMap.has(abilityName1) && dataMap.has(abilityName2)) { + bundle.queryAbilityByWant( + { + "bundleName": 'com.example.third1', + "abilityName": 'com.example.third1.MainAbility', + }, 32, 0).then(dataInfos => { + for (let i = 0, len = dataInfos.length; i < len; i++) { + dataMap.set(dataInfos[i].name, dataInfos[i].metaData) + } + }) + if (dataMap.has(abilityName1)) { checkMetaData(dataMap.get(abilityName1), 'Data1'); - checkMetaData(dataMap.get(abilityName2), 'Data3'); } installer.uninstall('com.example.third1', { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -89,49 +76,37 @@ describe('ActsBmsMetaDataTest', function () { let abilityName1 = 'com.example.third1.AMainAbility'; var installer = await bundle.getBundleInstaller(); installer.install(bundlePath1, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual('SUCCESS'); installer.install(bundlePath2, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual('SUCCESS'); - var dataInfos = await bundle.queryAbilityByWant({ - want: { - action: 'action.system.home', - entities: ['entity.system.home'], - elementName: { - deviceId: '0', - bundleName: 'com.example.third1', - abilityName: 'com.example.third1.AMainAbility', - }, - } - }, 0, 0) - for (let i = 0, len = dataInfos.length; i < len; i++) { - dataMap.set(dataInfos[i].name, dataInfos[i].metaData) - } - expect(dataMap.has(abilityName1)).assertTrue(); + bundle.queryAbilityByWant( + { + "bundleName": 'com.example.third1', + "abilityName": 'com.example.third1.AMainAbility', + }, 32, 0).then(dataInfos => { + for (let i = 0, len = dataInfos.length; i < len; i++) { + dataMap.set(dataInfos[i].name, dataInfos[i].metaData) + } + }) if (dataMap.has(abilityName1)) { checkMetaData(dataMap.get(abilityName1), 'DataA1'); } installer.uninstall('com.example.third1', { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -153,37 +128,25 @@ describe('ActsBmsMetaDataTest', function () { let bundleName = 'com.example.third1'; var installer = await bundle.getBundleInstaller(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual('SUCCESS'); installer.uninstall(bundleName, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - var dataInfos = await bundle.queryAbilityByWant({ - want: { - action: 'action.system.home', - entities: ['entity.system.home'], - elementName: { - deviceId: '0', - bundleName: 'com.example.third1', - abilityName: 'com.example.third1.MainAbility', - }, - } - }, 0, 0); - expect(dataInfos.length).assertEqual(0); + bundle.queryAbilityByWant( + { + bundleName: 'com.example.third1', + abilityName: 'com.example.third1.MainAbility', + }, 32, 0).then(dataInfos => { + expect(dataInfos.length).assertEqual(0); + }); done(); }); }); @@ -192,52 +155,39 @@ describe('ActsBmsMetaDataTest', function () { /* * @tc.number: bms_getMetaData_0400 * @tc.name: test to get meta data for an application. - * @tc.desc: get an application's meta data which has two abilities. + * @tc.desc: get an application's meta data which has one ability. */ it('bms_getMetaData_0400', 0, async function (done) { console.info('=====================bms_getMetaData_0400=================='); var bundlePath = ['/data/test/bmsThirdBundleTest5.hap'] let dataMap = new Map(); let abilityName1 = 'com.example.third5.AMainAbility'; - let abilityName2 = 'com.example.third5.BMainAbility'; var installer = await bundle.getBundleInstaller(); installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, onReceiveinstallEvent); async function onReceiveinstallEvent(err, data) { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual('SUCCESS'); - var dataInfos = await bundle.queryAbilityByWant({ - want: { - action: 'action.system.home', - entities: ['entity.system.home'], - elementName: { - deviceId: '0', - bundleName: 'com.example.third5', - abilityName: 'com.example.third5.AMainAbility', - }, - } - }, 0, 0) - for (let i = 0, len = dataInfos.length; i < len; i++) { - dataMap.set(dataInfos[i].name, dataInfos[i].metaData) - } - expect(dataMap.has(abilityName1)).assertTrue(); - expect(dataMap.has(abilityName2)).assertTrue(); - if (dataMap.has(abilityName1) && dataMap.has(abilityName2)) { + bundle.queryAbilityByWant( + { + bundleName: 'com.example.third5', + abilityName: 'com.example.third5.AMainAbility', + }, 32, 0).then(dataInfos => { + for (let i = 0, len = dataInfos.length; i < len; i++) { + dataMap.set(dataInfos[i].name, dataInfos[i].metaData) + } + }) + if (dataMap.has(abilityName1)) { checkMetaData(dataMap.get(abilityName1), 'Data5A'); - checkMetaData(dataMap.get(abilityName2), 'Data5B'); } installer.uninstall('com.example.third5', { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -254,18 +204,13 @@ describe('ActsBmsMetaDataTest', function () { */ it('bms_getMetaData_0500', 0, async function (done) { console.info('=====================bms_getMetaData_0500=================='); - var dataInfos = await bundle.queryAbilityByWant({ - want: { - action: 'action.system.home', - entities: ['entity.system.home'], - elementName: { - deviceId: '0', - bundleName: 'com.example.noexist', - abilityName: 'com.example.noexist.MainAbility', - }, - } - }, 0, 0) - expect(dataInfos.length).assertEqual(0); + bundle.queryAbilityByWant( + { + bundleName: 'com.example.noexist', + abilityName: 'com.example.noexist.MainAbility', + }, 32, 0).then(dataInfos => { + expect(dataInfos.length).assertEqual(0); + }) done(); }) @@ -278,21 +223,15 @@ describe('ActsBmsMetaDataTest', function () { console.info('=====================bms_getMetaData_0600=================='); let dataMap = new Map(); let abilityName1 = 'com.example.system1.MainAbility'; - var dataInfos = await bundle.queryAbilityByWant({ - want: { - action: 'action.system.home', - entities: ['entity.system.home'], - elementName: { - deviceId: '0', - bundleName: 'com.example.system1', - abilityName: 'com.example.system1.MainAbility', - }, - } - }, 0, 0); - for (let i = 0, len = dataInfos.length; i < len; i++) { - dataMap.set(dataInfos[i].name, dataInfos[i].metaData) - } - expect(dataMap.has(abilityName1)).assertTrue(); + bundle.queryAbilityByWant( + { + bundleName: 'com.example.system1', + abilityName: 'com.example.system1.MainAbility', + }, 32, 0).then(dataInfos => { + for (let i = 0, len = dataInfos.length; i < len; i++) { + dataMap.set(dataInfos[i].name, dataInfos[i].metaData) + } + }) if (dataMap.has(abilityName1)) { checkMetaData(dataMap.get(abilityName1), 'Data1S'); } @@ -308,21 +247,15 @@ describe('ActsBmsMetaDataTest', function () { console.info('=====================bms_getMetaData_0700=================='); let dataMap = new Map(); let abilityName1 = 'com.example.vendor1.MainAbility'; - var dataInfos = await bundle.queryAbilityByWant({ - want: { - action: 'action.system.home', - entities: ['entity.system.home'], - elementName: { - deviceId: '0', - bundleName: 'com.example.vendor1', - abilityName: 'com.example.vendor1.MainAbility', - }, - } - }, 0, 0); - for (let i = 0, len = dataInfos.length; i < len; i++) { - dataMap.set(dataInfos[i].name, dataInfos[i].metaData) - } - expect(dataMap.has(abilityName1)).assertTrue(); + bundle.queryAbilityByWant( + { + bundleName: 'com.example.vendor1', + abilityName: 'com.example.vendor1.MainAbility', + }, 32, 0).then(dataInfos => { + for (let i = 0, len = dataInfos.length; i < len; i++) { + dataMap.set(dataInfos[i].name, dataInfos[i].metaData) + } + }); if (dataMap.has(abilityName1)) { let data = dataMap.get(abilityName1); var parameters = data.parameters; diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsmoduleusagerecordtest/entry/src/main/js/test/ActsBmsModuleUsageRecordTest.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbmsmoduleusagerecordtest/entry/src/main/js/test/ActsBmsModuleUsageRecordTest.test.js index 1d9939242..76a7adca7 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsmoduleusagerecordtest/entry/src/main/js/test/ActsBmsModuleUsageRecordTest.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsmoduleusagerecordtest/entry/src/main/js/test/ActsBmsModuleUsageRecordTest.test.js @@ -75,11 +75,9 @@ describe('ActsBmsModuleUsageRecordTest', function () { console.debug('=======start ability========') let installer = await bundle.getBundleInstaller(); installer.install(['/data/test/bmsThirdBundleTest1.hap'], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { console.debug('========install Finish========'); id = setTimeout(timeout, START_ABILITY_TIMEOUT); @@ -100,11 +98,9 @@ describe('ActsBmsModuleUsageRecordTest', function () { if (err.code != 0 && data.name.length == 0) { let installer = await bundle.getBundleInstaller(); installer.install(['/data/test/bmsThirdBundleTest1.hap'], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { console.debug('========install Finish========' + JSON.stringify(data)); done(); @@ -183,7 +179,7 @@ describe('ActsBmsModuleUsageRecordTest', function () { */ it('bms_getModuleUsageRecordTest_0300', 0, async function (done) { console.debug('=====================bms_getModuleUsageRecordTest_0300=================='); - bundle.getModuleUsageRecords(RECORD_COUNT + NUM_TEN, (err, data) => { + bundle.getModuleUsageRecords(RECORD_COUNT + NUM_TWO, (err, data) => { expect(err.code).assertEqual(0); checkModuleUsageRecord(data); var result = checkIsExist(data, BUNDLE_NAME); @@ -208,20 +204,21 @@ describe('ActsBmsModuleUsageRecordTest', function () { */ it('bms_getModuleUsageRecordTest_0400', 0, async function (done) { console.debug('=====================bms_getModuleUsageRecordTest_0400=================='); - var records = await bundle.getModuleUsageRecords(RECORD_COUNT + NUM_TEN); - checkModuleUsageRecord(records); - var result = checkIsExist(records, BUNDLE_NAME); - expect(result).assertTrue(); - if (result) { - let counts = new Map(); - console.debug('======LaunchedCount======' + START_COUNT); - expect(records[0].launchedCount).assertEqual(START_COUNT); - for (let i = 0, length = records.length; i < length; i++) { - counts.set(records[i].bundleName, records[i].launchedCount); - console.debug('=============launchedCount is=========' + records[i].launchedCount); + bundle.getModuleUsageRecords(RECORD_COUNT + NUM_TWO).then(records => { + checkModuleUsageRecord(records); + var result = checkIsExist(records, BUNDLE_NAME); + expect(result).assertTrue(); + if (result) { + let counts = new Map(); + console.debug('======LaunchedCount======' + START_COUNT); + expect(records[0].launchedCount).assertEqual(START_COUNT); + for (let i = 0, length = records.length; i < length; i++) { + counts.set(records[i].bundleName, records[i].launchedCount); + console.debug('=============launchedCount is=========' + records[i].launchedCount); + } + expect(counts.get(BUNDLE_NAME)).assertEqual(START_COUNT); } - expect(counts.get(BUNDLE_NAME)).assertEqual(START_COUNT); - } + }); done(); }) @@ -235,11 +232,9 @@ describe('ActsBmsModuleUsageRecordTest', function () { console.debug('=====================bms_getModuleUsageRecordTest_0500=================='); var installer = await bundle.getBundleInstaller(); installer.uninstall(BUNDLE_NAME, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, onReceiveinstallEvent); async function onReceiveinstallEvent(err, data) { @@ -253,11 +248,9 @@ describe('ActsBmsModuleUsageRecordTest', function () { var result = checkIsExist(records, BUNDLE_NAME); expect(result).assertEqual(false); installer.install(['/data/test/bmsThirdBundleTest1.hap'], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -277,11 +270,9 @@ describe('ActsBmsModuleUsageRecordTest', function () { console.debug('=====================bms_getModuleUsageRecordTest_0600=================='); var installer = await bundle.getBundleInstaller(); installer.uninstall(BUNDLE_NAME, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -291,11 +282,9 @@ describe('ActsBmsModuleUsageRecordTest', function () { var result = checkIsExist(moduleUsageRecord, BUNDLE_NAME); expect(result).assertEqual(false); installer.install(['/data/test/bmsThirdBundleTest1.hap'], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -371,22 +360,18 @@ describe('ActsBmsModuleUsageRecordTest', function () { console.debug('=====================bms_getModuleUsageRecordTest_1100=================='); var installer = await bundle.getBundleInstaller(); installer.uninstall(BUNDLE_NAME, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); var bundlePath = ['/data/test/bmsThirdBundleTest1.hap']; installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -408,22 +393,18 @@ describe('ActsBmsModuleUsageRecordTest', function () { console.debug('=====================bms_getModuleUsageRecordTest_1200=================='); var installer = await bundle.getBundleInstaller(); installer.uninstall(BUNDLE_NAME, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); var bundlePath = ['/data/test/bmsThirdBundleTest1.hap'] installer.install(bundlePath, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -476,21 +457,17 @@ describe('ActsBmsModuleUsageRecordTest', function () { } let installer = await bundle.getBundleInstaller(); installer.uninstall(BUNDLE_NAME, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); installer.install(['/data/test/bmsThirdBundleTest1.hap'], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -545,21 +522,17 @@ describe('ActsBmsModuleUsageRecordTest', function () { } let installer = await bundle.getBundleInstaller(); installer.uninstall(BUNDLE_NAME, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual("SUCCESS"); installer.install(['/data/test/bmsThirdBundleTest1.hap'], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -700,11 +673,9 @@ describe('ActsBmsModuleUsageRecordTest', function () { console.debug('=======after all install========'); let installer = await bundle.getBundleInstaller(); installer.uninstall(BUNDLE_NAME, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, (err, data) => { console.info('uninstall finish'); done(); 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 old mode 100755 new mode 100644 index abf2fa2ec..46031cbaf --- 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 @@ -64,11 +64,9 @@ describe('ActsBundleManagerTest', function () { it('getBundleInfo_0100', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -111,11 +109,9 @@ describe('ActsBundleManagerTest', function () { } expect(datainfo.appInfo.enabled).assertEqual(true); installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -133,11 +129,9 @@ describe('ActsBundleManagerTest', function () { it('getBundleInfo_0600', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -168,11 +162,9 @@ describe('ActsBundleManagerTest', function () { } expect(datainfo.appInfo.enabled).assertEqual(true) installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -192,11 +184,9 @@ describe('ActsBundleManagerTest', function () { let installData = await demo.getBundleInstaller() await demo.getBundleInstaller().then((data) => { data.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -222,11 +212,9 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.appInfo.supportedModes).assertEqual(0) expect(datainfo.appInfo.enabled).assertEqual(true) installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -245,11 +233,9 @@ describe('ActsBundleManagerTest', function () { let installData = await demo.getBundleInstaller() await demo.getBundleInstaller().then((data) => { data.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -280,11 +266,9 @@ describe('ActsBundleManagerTest', function () { } expect(datainfo.appInfo.enabled).assertEqual(true) installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -303,11 +287,9 @@ describe('ActsBundleManagerTest', function () { it('getApplicationInfos_0100', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -318,11 +300,9 @@ describe('ActsBundleManagerTest', function () { var datainfo = await demo.getAllApplicationInfo(8, 0) checkgetApplicationInfos(datainfo) installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -363,11 +343,9 @@ describe('ActsBundleManagerTest', function () { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -393,11 +371,9 @@ describe('ActsBundleManagerTest', function () { } } installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -416,11 +392,9 @@ describe('ActsBundleManagerTest', function () { it('getBundleInfos_0100', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -445,11 +419,9 @@ describe('ActsBundleManagerTest', function () { expect(data[i].appInfo.moduleInfos.length).assertLarger(0) } installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -468,11 +440,9 @@ describe('ActsBundleManagerTest', function () { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { userId: 0, installFlag: 0, isKeepData: false - } }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -509,11 +479,9 @@ describe('ActsBundleManagerTest', function () { } installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -531,11 +499,9 @@ describe('ActsBundleManagerTest', function () { it('getBundleInfos_0600', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -558,11 +524,9 @@ describe('ActsBundleManagerTest', function () { expect(data[i].appInfo.moduleInfos.length).assertLarger(0) } installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -581,11 +545,9 @@ describe('ActsBundleManagerTest', function () { it('getApplicationInfo_0600', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -616,11 +578,9 @@ describe('ActsBundleManagerTest', function () { } installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -639,11 +599,9 @@ describe('ActsBundleManagerTest', function () { it('getApplicationInfo_1100', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -668,11 +626,9 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.systemApp).assertEqual(true) expect(datainfo.supportedModes).assertEqual(0) installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -690,11 +646,9 @@ describe('ActsBundleManagerTest', function () { it('getApplicationInfo_1200', 0, async function (done) { let installData = await demo.getBundleInstaller(); installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -719,11 +673,9 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.systemApp).assertEqual(true) expect(datainfo.supportedModes).assertEqual(0) installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -742,11 +694,9 @@ describe('ActsBundleManagerTest', function () { it('getBundleArchiveInfo_0100', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -782,11 +732,9 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.abilityInfos[j].moduleName).assertEqual("entry") } installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -797,18 +745,16 @@ describe('ActsBundleManagerTest', function () { }) /** - * @tc.number queryAbilityByWant_0400 - * @tc.name BUNDLE::queryAbilityByWant - * @tc.desc Test queryAbilityByWant interfaces with one hap. + * @tc.number getBundleArchiveInfo_0200 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with two haps. */ - it('queryAbilityByWant_0400', 0, async function (done) { - let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + it('getBundleArchiveInfo_0200', 0, async function (done) { + let installData = await demo.getBundleInstaller(); + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -816,27 +762,23 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - var datainfo = - await demo.queryAbilityByWant({ - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "", - abilityName: "com.example.myapplication1.MainAbility", - uri: "", - shortName: "" - }, - } - }, 0, 0) - expect(datainfo.length).assertEqual(0) - installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + var datainfo = await demo.getBundleArchiveInfo(PATH + BMSJSTEST2, 1) + expect(datainfo.name).assertEqual(NAME2) + expect(datainfo.vendor).assertEqual("example") + expect(datainfo.versionCode).assertEqual(1) + expect(datainfo.versionName).assertLarger(0) + expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") + expect(datainfo.appInfo.descriptionId >= 0).assertTrue() + expect(datainfo.appInfo.icon).assertEqual("$media:icon") + expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(datainfo.appInfo.label).assertEqual("$string:app_name") + expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(datainfo.appInfo.systemApp).assertEqual(false) + installData.uninstall(NAME2, { + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -847,144 +789,91 @@ describe('ActsBundleManagerTest', function () { }) /** - * @tc.number queryAbilityByWant_0500 - * @tc.name BUNDLE::queryAbilityByWant - * @tc.desc Test queryAbilityByWant interfaces with one hap. + * @tc.number getBundleArchiveInfo_0300 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with three haps. */ - it('queryAbilityByWant_0500', 0, async function (done) { + it('getBundleArchiveInfo_0300', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); + expect(err.code).assertEqual(-1); + expect(data.status).assertEqual(3); + expect(data.statusMessage).assertEqual('STATUS_INSTALL_FAILURE_INVALID'); getInfo(); }); async function getInfo() { - var datainfo = - await demo.queryAbilityByWant({ - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "", - abilityName: "", - uri: "", - shortName: "" - }, - } - }, 0, 0) - expect(datainfo.length).assertEqual(0) - installData.uninstall(NAME1, { - param: { + var datainfo = await demo.getBundleArchiveInfo(PATH + BMSJSTEST4, 1) + expect(datainfo.name).assertEqual(NAME3) + expect(datainfo.vendor).assertEqual("example") + expect(datainfo.versionCode).assertEqual(1) + expect(datainfo.versionName).assertLarger(0) + expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") + expect(datainfo.appInfo.descriptionId >= 0).assertTrue() + expect(datainfo.appInfo.icon).assertEqual("$media:icon") + expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(datainfo.appInfo.label).assertEqual("$string:app_name") + expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(datainfo.appInfo.systemApp).assertEqual(false) + installData.uninstall(NAME3, { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + installData.uninstall(NAME4, { userId: 0, installFlag: 0, isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); + }, (err, data) => { + installData.uninstall(NAME5, { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + done(); + }); + }); }); } }) /** - * @tc.number queryAbilityByWant_0600 - * @tc.name BUNDLE::queryAbilityByWant - * @tc.desc Test queryAbilityByWant interfaces with one hap. + * @tc.number getBundleArchiveInfo_0400 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with error hap. */ - it('queryAbilityByWant_0600', 0, async function (done) { - let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST2], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - await demo.queryAbilityByWant({ - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "com.example.myapplication2", - abilityName: "com.example.myapplication1.MainAbility", - uri: "", - shortName: "" - }, - } - }, 0, 0, OnReceiveEvent) - - function OnReceiveEvent(err, data) { - expect(data.length).assertLarger(0); - for (let i = 0, len = data.length; i < len; i++) { - var datainfo = data[i]; - expect(datainfo.name).assertEqual("com.example.myapplication" + (i + 1) + ".MainAbility") - expect(datainfo.label).assertEqual("$string:app_name") - expect(datainfo.description).assertEqual("$string:mainability_description") - expect(datainfo.icon).assertEqual("$media:icon") - expect(datainfo.moduleName).assertEqual("entry") - expect(datainfo.bundleName).assertEqual(NAME2) - expect(datainfo.applicationInfo.name).assertEqual(NAME2) - expect(datainfo.applicationInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue() - expect(datainfo.applicationInfo.icon).assertEqual("$media:icon") - expect(datainfo.applicationInfo.iconId >= 0).assertTrue() - expect(datainfo.applicationInfo.label).assertEqual("$string:app_name") - expect(datainfo.applicationInfo.labelId >= 0).assertTrue() - expect(datainfo.applicationInfo.systemApp).assertEqual(true) - expect(datainfo.applicationInfo.supportedModes).assertEqual(0) - expect(datainfo.applicationInfo.enabled).assertEqual(true) - for (var j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { - expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") - expect(datainfo.applicationInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR2) - } - } - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } - } + it('getBundleArchiveInfo_0400', 0, async function (done) { + var datainfo = await demo.getBundleArchiveInfo(PATH + ERROR, 1) + expect(datainfo.name.length).assertEqual(0) + done() }) + /** + * @tc.number getBundleArchiveInfo_0500 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with none hap. + */ + it('getBundleArchiveInfo_0500', 0, async function (done) { + var datainfo = await demo.getBundleArchiveInfo(' ', 1) + expect(datainfo.name.length).assertEqual(0) + done() + }) /** - * @tc.number queryAbilityByWant_0900 - * @tc.name BUNDLE::queryAbilityByWant - * @tc.desc Test queryAbilityByWant interfaces with one hap. + * @tc.number getBundleArchiveInfo_0600 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with none hap. */ - it('queryAbilityByWant_0900', 0, async function (done) { + it('getBundleArchiveInfo_0600', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -992,29 +881,40 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - await demo.queryAbilityByWant({ - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "", - abilityName: "com.example.myapplication1.MainAbility", - uri: "", - shortName: "" - }, - } - }, 0, 0, OnReceiveEvent) + await demo.getBundleArchiveInfo(PATH + BMSJSTEST1, 1, OnReceiveEvent) function OnReceiveEvent(err, datainfo) { - expect(datainfo.length).assertEqual(0) + expect(datainfo.name).assertEqual(NAME1) + expect(datainfo.vendor).assertEqual("example") + expect(datainfo.versionCode).assertEqual(1) + expect(datainfo.versionName).assertLarger(0) + expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.name).assertEqual(NAME1) + expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") + expect(datainfo.appInfo.descriptionId >= 0).assertTrue() + expect(datainfo.appInfo.icon).assertEqual("$media:icon") + expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(datainfo.appInfo.label).assertEqual("$string:app_name") + expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(datainfo.appInfo.systemApp).assertEqual(false) + expect(datainfo.appInfo.supportedModes).assertEqual(0) + for (var j = 0; j < datainfo.appInfo.moduleInfos; j++) { + expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") + } + for (var j = 0; j < datainfo.abilityInfos; j++) { + expect(datainfo.abilityInfos[j].name).assertEqual(".MainAbility") + expect(datainfo.abilityInfos[j].label).assertEqual("$string:app_name") + expect(datainfo.abilityInfos[j].description).assertEqual("$string:mainability_description") + expect(datainfo.abilityInfos[j].icon).assertEqual("$media:icon") + expect(datainfo.abilityInfos[j].isVisible).assertEqual(false) + expect(datainfo.abilityInfos[j].bundleName).assertEqual(NAME1) + expect(datainfo.abilityInfos[j].moduleName).assertEqual("entry") + } installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { + userId: 0, + installFlag: 0, + isKeepData: false + }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual('SUCCESS'); @@ -1025,18 +925,16 @@ describe('ActsBundleManagerTest', function () { }) /** - * @tc.number getBundleInfo_0200 - * @tc.name BUNDLE::getBundleInfo - * @tc.desc Test getBundleInfo interfaces with two haps. + * @tc.number getBundleArchiveInfo_0700 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with two hap. */ - it('getBundleInfo_0200', 0, async function (done) { - let installData = await demo.getBundleInstaller() + it('getBundleArchiveInfo_0700', 0, async function (done) { + let installData = await demo.getBundleInstaller(); installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -1044,76 +942,25 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - var datainfo = await demo.getBundleInfo(NAME2, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES) - expect(datainfo.name).assertEqual(NAME2) - expect(datainfo.vendor).assertEqual("example") - expect(datainfo.versionCode).assertEqual(1) - expect(datainfo.versionName).assertLarger(0) - expect(datainfo.entryModuleName).assertEqual("entry") - expect(datainfo.appInfo.name).assertEqual(NAME2) - expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.appInfo.descriptionId >= 0).assertTrue() - expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() - expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() - expect(datainfo.appInfo.systemApp).assertEqual(true) - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } - }) + await demo.getBundleArchiveInfo(PATH + BMSJSTEST2, 1, OnReceiveEvent) - /** - * @tc.number getBundleInfo_0700 - * @tc.name BUNDLE::getBundleInfo - * @tc.desc Test getBundleInfo interfaces with two haps. - */ - it('getBundleInfo_0700', 0, async function (done) { - let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - await demo.getBundleInfo(NAME2, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent) function OnReceiveEvent(err, datainfo) { expect(datainfo.name).assertEqual(NAME2) expect(datainfo.vendor).assertEqual("example") expect(datainfo.versionCode).assertEqual(1) expect(datainfo.versionName).assertLarger(0) expect(datainfo.entryModuleName).assertEqual("entry") - expect(datainfo.appInfo.name).assertEqual(NAME2) expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") expect(datainfo.appInfo.descriptionId >= 0).assertTrue() expect(datainfo.appInfo.icon).assertEqual("$media:icon") expect(datainfo.appInfo.iconId >= 0).assertTrue() expect(datainfo.appInfo.label).assertEqual("$string:app_name") expect(datainfo.appInfo.labelId >= 0).assertTrue() - expect(datainfo.appInfo.systemApp).assertEqual(true) + expect(datainfo.appInfo.systemApp).assertEqual(false) installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -1125,19 +972,16 @@ describe('ActsBundleManagerTest', function () { }) /** - * @tc.number getApplicationInfos_0200 - * @tc.name BUNDLE::getApplicationInfos - * @tc.desc Test getApplicationInfos interfaces with two haps. + * @tc.number getBundleArchiveInfo_0800 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with one hap. */ - it('getApplicationInfos_0200', 0, async function (done) { + it('getBundleArchiveInfo_0800', 0, async function (done) { let installData = await demo.getBundleInstaller() - - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.install([PATH + BMSJSTEST4], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -1145,37 +989,71 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - var datainfo = await demo.getAllApplicationInfo(8, 0) - console.info("==========ActsBmsGetInfosSecondScene is ==========" + JSON.stringify(datainfo)); - checkgetApplicationInfos(datainfo) - installData.uninstall(NAME2, { - param: { + await demo.getBundleArchiveInfo(PATH + BMSJSTEST4, 1, OnReceiveEvent) + + function OnReceiveEvent(err, datainfo) { + expect(datainfo.name).assertEqual(NAME3) + expect(datainfo.vendor).assertEqual("example") + expect(datainfo.versionCode).assertEqual(1) + expect(datainfo.versionName).assertLarger(0) + expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") + expect(datainfo.appInfo.descriptionId >= 0).assertTrue() + expect(datainfo.appInfo.icon).assertEqual("$media:icon") + expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(datainfo.appInfo.label).assertEqual("$string:app_name") + expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(datainfo.appInfo.systemApp).assertEqual(false) + installData.uninstall(NAME3, { userId: 0, installFlag: 0, isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); + }, (err, data) => { + done(); + }); + } } }) /** - * @tc.number getApplicationInfos_0400 - * @tc.name BUNDLE::getApplicationInfos - * @tc.desc Test getApplicationInfos interfaces with two haps and different param. + * @tc.number getBundleArchiveInfo_0900 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with error hap. */ - it('getApplicationInfos_0400', 0, async function (done) { + it('getBundleArchiveInfo_0900', 0, async function (done) { + await demo.getBundleArchiveInfo(PATH + ERROR, 1, OnReceiveEvent) + + function OnReceiveEvent(err, datainfo) { + expect(datainfo.name.length).assertEqual(0) + done() + } + }) + + /** + * @tc.number getBundleArchiveInfo_1000 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with none hap. + */ + it('getBundleArchiveInfo_1000', 0, async function (done) { + await demo.getBundleArchiveInfo(' ', 1, OnReceiveEvent) + + function OnReceiveEvent(err, datainfo) { + expect(datainfo.name.length).assertEqual(0) + done() + } + }) + + /** + * @tc.number getBundleArchiveInfo_1100 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with none hap. + */ + it('getBundleArchiveInfo_1100', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.install([PATH + BMSJSTEST1], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -1183,539 +1061,15 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - var datainfo = await demo.getAllApplicationInfo(0, 0) - expect(datainfo.length).assertLarger(0) - checkgetApplicationInfos(datainfo) - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } - }) - - /** - * @tc.number getApplicationInfos_0700 - * @tc.name BUNDLE::getApplicationInfos - * @tc.desc Test getApplicationInfos interfaces with two haps. - */ - it('getApplicationInfos_0700', 0, async function (done) { - let installData = await demo.getBundleInstaller() - - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - await demo.getAllApplicationInfo(8, 0, (error, datainfo) => { - for (var i = 0; i < datainfo.length; i++) { - expect(datainfo[i].name.length).assertLarger(0) - if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2 - || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { - expect(datainfo[i].description.length).assertLarger(0) - expect(datainfo[i].icon.length).assertLarger(0) - expect(datainfo[i].label.length).assertLarger(0) - } - expect(datainfo[i].moduleSourceDirs.length).assertLarger(0) - expect(datainfo[i].moduleInfos.length).assertLarger(0) - expect(datainfo[i].supportedModes).assertEqual(0) - expect(datainfo[i].flags).assertEqual(0) - for (var j = 0; j < datainfo[i].moduleInfos; j++) { - expect(datainfo[i].moduleInfos[j].moduleName.length).assertLarger(0) - expect(datainfo[i].moduleInfos[j].moduleSourceDir.length).assertLarger(0) - } - } - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - }); - } - }) - - /** - * @tc.number getApplicationInfos_0900 - * @tc.name BUNDLE::getApplicationInfos - * @tc.desc Test getApplicationInfos interfaces with two haps and different param. - */ - it('getApplicationInfos_0900', 0, async function (done) { - let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - await demo.getAllApplicationInfo(0, 0, (error, datainfo) => { - for (var i = 0; i < datainfo.length; i++) { - expect(datainfo[i].name.length).assertLarger(0) - if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2 - || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { - expect(datainfo[i].description.length).assertLarger(0) - expect(datainfo[i].icon.length).assertLarger(0) - expect(datainfo[i].label.length).assertLarger(0) - } - expect(datainfo[i].moduleSourceDirs.length).assertLarger(0) - expect(datainfo[i].moduleInfos.length).assertLarger(0) - expect(datainfo[i].supportedModes).assertEqual(0) - expect(datainfo[i].flags).assertEqual(0) - for (var j = 0; j < datainfo[i].moduleInfos; j++) { - expect(datainfo[i].moduleInfos[j].moduleName.length).assertLarger(0) - expect(datainfo[i].moduleInfos[j].moduleSourceDir.length).assertLarger(0) - } - } - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - }); - } - }) - - /** - * @tc.number getBundleInfos_0200 - * @tc.name BUNDLE::getBundleInfos - * @tc.desc Test getBundleInfos interfaces with two haps. - */ - it('getBundleInfos_0200', 0, async function (done) { - let installData = await demo.getBundleInstaller() - - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - - async function getInfo() { - var data = await demo.getAllBundleInfo(0) - expect(typeof data).assertEqual(OBJECT) - - for (var i = 0; i < data.length; i++) { - console.info('====> getBundleInfos_02200 =====>' + JSON.stringify(data[i].name.length)) - console.info('====> getBundleInfos_03300 =====>' + JSON.stringify(data[i].entryModuleName.length)) - console.info('====> getBundleInfos_04400 =====>' + JSON.stringify(data[i].appInfo.name.length)) - console.info('====> getBundleInfos_05500 =====>' + JSON.stringify(data[i].appInfo.description.length)) - console.info('====> getBundleInfos_06600 =====>' + JSON.stringify(data[i].appInfo.icon.length)) - console.info('====> getBundleInfos_07700 =====>' + JSON.stringify(data[i].appInfo.label.length)) - console.info('====> getBundleInfos_08800 =====>' + JSON.stringify(data[i].appInfo.supportedModes)) - console.info('====> getBundleInfos_09900 =====>' + JSON.stringify(data[i].appInfo.moduleInfos.length)) - expect(data[i].name.length).assertLarger(0) - expect(data[i].appInfo.name.length).assertLarger(0) - if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { - expect(data[i].appInfo.description.length).assertLarger(0) - expect(data[i].appInfo.icon.length).assertLarger(0) - expect(data[i].appInfo.label.length).assertLarger(0) - } - expect(data[i].appInfo.supportedModes).assertEqual(0) - expect(data[i].appInfo.moduleInfos.length).assertLarger(0) - - } - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } - }) - - /** - * @tc.number getBundleInfos_0400 - * @tc.name BUNDLE::getBundleInfos - * @tc.desc Test getBundleInfos interfaces with two haps and different param. - */ - it('getBundleInfos_0400', 0, async function (done) { - let installData = await demo.getBundleInstaller() - - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - var data = await demo.getAllBundleInfo(1) - expect(typeof data).assertEqual(OBJECT) - - for (var i = 0; i < data.length; i++) { - expect(data[i].name.length).assertLarger(0) - expect(data[i].appInfo.name.length).assertLarger(0) - if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { - expect(data[i].appInfo.description.length).assertLarger(0) - expect(data[i].appInfo.icon.length).assertLarger(0) - expect(data[i].appInfo.label.length).assertLarger(0) - } - expect(data[i].appInfo.supportedModes).assertEqual(0) - expect(data[i].appInfo.moduleInfos.length).assertLarger(0) - } - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } - }) - /** - * @tc.number getApplicationInfo_0200 - * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with two haps. - */ - it('getApplicationInfo_0200', 0, async function (done) { - let installData = await demo.getBundleInstaller() - - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - var datainfo = await demo.getApplicationInfo(NAME2, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES) - expect(typeof datainfo).assertEqual(OBJECT) - expect(datainfo.name.length).assertLarger(0) - expect(datainfo.description.length).assertLarger(0) - expect(datainfo.icon.length).assertLarger(0) - expect(datainfo.label.length).assertLarger(0) - expect(datainfo.moduleSourceDirs.length).assertLarger(0) - expect(datainfo.moduleInfos.length).assertLarger(0) - expect(datainfo.name).assertEqual(NAME2) - expect(datainfo.description).assertEqual("$string:mainability_description") - expect(datainfo.icon).assertEqual("$media:icon") - expect(datainfo.label).assertEqual("$string:app_name") - expect(datainfo.systemApp).assertEqual(true) - expect(datainfo.descriptionId >= 0).assertTrue() - expect(datainfo.iconId >= 0).assertTrue() - expect(datainfo.labelId >= 0).assertTrue() - expect(datainfo.supportedModes).assertEqual(0) - expect(datainfo.process).assertEqual(NAME2) - expect(datainfo.enabled).assertEqual(true) - expect(datainfo.flags).assertEqual(0) - expect(datainfo.moduleSourceDirs.length).assertLarger(0) - for (var j = 0; j < datainfo.moduleInfos; j++) { - expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry") - expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0) - } - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } - }) - - /** - * @tc.number getBundleInfos_0700 - * @tc.name BUNDLE::getBundleInfos - * @tc.desc Test getBundleInfos interfaces with two haps. - */ - it('getBundleInfos_0700', 0, async function (done) { - let installData = await demo.getBundleInstaller() - - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - await demo.getAllBundleInfo(0, (error, data) => { - expect(typeof data).assertEqual(OBJECT) - - for (var i = 0; i < data.length; i++) { - expect(data[i].name.length).assertLarger(0) - expect(data[i].appInfo.name.length).assertLarger(0) - if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { - expect(data[i].appInfo.description.length).assertLarger(0) - expect(data[i].appInfo.icon.length).assertLarger(0) - expect(data[i].appInfo.label.length).assertLarger(0) - } - expect(data[i].appInfo.supportedModes).assertEqual(0) - expect(data[i].appInfo.moduleInfos.length).assertLarger(0) - } - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - }) - } - }) - - /** - * @tc.number getBundleInfos_0900 - * @tc.name BUNDLE::getBundleInfos - * @tc.desc Test getBundleInfos interfaces with two haps and different param. - */ - it('getBundleInfos_0900', 0, async function (done) { - let installData = await demo.getBundleInstaller() - - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - await demo.getAllBundleInfo(1, (error, data) => { - expect(typeof data).assertEqual(OBJECT) - - for (var i = 0; i < data.length; i++) { - expect(data[i].name.length).assertLarger(0) - expect(data[i].appInfo.name.length).assertLarger(0) - if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { - expect(data[i].appInfo.description.length).assertLarger(0) - expect(data[i].appInfo.icon.length).assertLarger(0) - expect(data[i].appInfo.label.length).assertLarger(0) - } - expect(data[i].appInfo.supportedModes).assertEqual(0) - expect(data[i].appInfo.moduleInfos.length).assertLarger(0) - } - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - }) - } - }) - - - /** - * @tc.number getApplicationInfo_0700 - * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with two haps. - */ - it('getApplicationInfo_0700', 0, async function (done) { - let installData = await demo.getBundleInstaller(); - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - await demo.getApplicationInfo(NAME2, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, (error, datainfo) => { - expect(typeof datainfo).assertEqual(OBJECT) - expect(datainfo.name).assertEqual(NAME2) - expect(datainfo.label).assertEqual("$string:app_name") - expect(datainfo.description).assertEqual("$string:mainability_description") - expect(datainfo.icon).assertEqual("$media:icon") - expect(datainfo.name).assertEqual(NAME2) - expect(datainfo.description).assertEqual("$string:mainability_description") - expect(datainfo.descriptionId >= 0).assertTrue() - expect(datainfo.icon).assertEqual("$media:icon") - expect(datainfo.iconId >= 0).assertTrue() - expect(datainfo.label).assertEqual("$string:app_name") - expect(datainfo.labelId >= 0).assertTrue() - expect(datainfo.systemApp).assertEqual(true) - expect(datainfo.supportedModes).assertEqual(0) - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - }) - } - }) - - /** - * @tc.number getBundleArchiveInfo_0200 - * @tc.name BUNDLE::getBundleArchiveInfo - * @tc.desc Test getBundleArchiveInfo interfaces with two haps. - */ - it('getBundleArchiveInfo_0200', 0, async function (done) { - let installData = await demo.getBundleInstaller(); - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - var datainfo = await demo.getBundleArchiveInfo(PATH + BMSJSTEST2, 1) - expect(datainfo.name).assertEqual(NAME2) - expect(datainfo.vendor).assertEqual("example") - expect(datainfo.versionCode).assertEqual(1) - expect(datainfo.versionName).assertLarger(0) - expect(datainfo.entryModuleName).assertEqual("entry") - expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.appInfo.descriptionId >= 0).assertTrue() - expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() - expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() - expect(datainfo.appInfo.systemApp).assertEqual(false) - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } - }) - - /** - * @tc.number getBundleArchiveInfo_0700 - * @tc.name BUNDLE::getBundleArchiveInfo - * @tc.desc Test getBundleArchiveInfo interfaces with two hap. - */ - it('getBundleArchiveInfo_0700', 0, async function (done) { - let installData = await demo.getBundleInstaller(); - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - await demo.getBundleArchiveInfo(PATH + BMSJSTEST2, 1, OnReceiveEvent) + await demo.getBundleArchiveInfo(PATH + BMSJSTEST1, 0, OnReceiveEvent) function OnReceiveEvent(err, datainfo) { - expect(datainfo.name).assertEqual(NAME2) + expect(datainfo.name).assertEqual(NAME1) expect(datainfo.vendor).assertEqual("example") expect(datainfo.versionCode).assertEqual(1) expect(datainfo.versionName).assertLarger(0) expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.name).assertEqual(NAME1) expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") expect(datainfo.appInfo.descriptionId >= 0).assertTrue() expect(datainfo.appInfo.icon).assertEqual("$media:icon") @@ -1723,13 +1077,24 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.appInfo.label).assertEqual("$string:app_name") expect(datainfo.appInfo.labelId >= 0).assertTrue() expect(datainfo.appInfo.systemApp).assertEqual(false) - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { + expect(datainfo.appInfo.supportedModes).assertEqual(0) + for (var j = 0; j < datainfo.appInfo.moduleInfos; j++) { + expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") + } + for (var j = 0; j < datainfo.abilityInfos; j++) { + expect(datainfo.abilityInfos[j].name).assertEqual(".MainAbility") + expect(datainfo.abilityInfos[j].label).assertEqual("$string:app_name") + expect(datainfo.abilityInfos[j].description).assertEqual("$string:mainability_description") + expect(datainfo.abilityInfos[j].icon).assertEqual("$media:icon") + expect(datainfo.abilityInfos[j].isVisible).assertEqual(false) + expect(datainfo.abilityInfos[j].bundleName).assertEqual(NAME1) + expect(datainfo.abilityInfos[j].moduleName).assertEqual("entry") + } + installData.uninstall(NAME1, { + userId: 0, + installFlag: 0, + isKeepData: false + }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual('SUCCESS'); @@ -1740,94 +1105,16 @@ describe('ActsBundleManagerTest', function () { }) /** - * @tc.number queryAbilityByWant_0200 - * @tc.name BUNDLE::queryAbilityByWant - * @tc.desc Test queryAbilityByWant interfaces with two haps. - */ - it('queryAbilityByWant_0200', 0, async function (done) { - let installData = await demo.getBundleInstaller(); - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - var data = - await demo.queryAbilityByWant({ - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "com.example.myapplication2", - abilityName: "com.example.myapplication1.MainAbility", - uri: "", - shortName: "" - }, - } - }, 0, 0) - expect(data.length).assertLarger(0); - for (let i = 0, len = data.length; i < len; i++) { - var datainfo = data[i]; - expect(datainfo.name.length).assertLarger(0) - expect(datainfo.label).assertEqual("$string:app_name") - expect(datainfo.description).assertEqual("$string:mainability_description") - expect(datainfo.icon).assertEqual("$media:icon") - expect(datainfo.type).assertEqual(demo.AbilityType.SERVICE) - expect(datainfo.launchMode).assertEqual(demo.LaunchMode.SINGLETON) - expect(datainfo.orientation).assertEqual(demo.DisplayOrientation.LANDSCAPE) - expect(datainfo.moduleName).assertEqual("entry") - expect(datainfo.bundleName).assertEqual(NAME2) - expect(datainfo.applicationInfo.name).assertEqual(NAME2) - expect(datainfo.applicationInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue() - expect(datainfo.applicationInfo.icon).assertEqual("$media:icon") - expect(datainfo.applicationInfo.iconId >= 0).assertTrue() - expect(datainfo.applicationInfo.label).assertEqual("$string:app_name") - expect(datainfo.applicationInfo.labelId >= 0).assertTrue() - expect(datainfo.applicationInfo.systemApp).assertEqual(true) - expect(datainfo.applicationInfo.supportedModes).assertEqual(0) - expect(datainfo.applicationInfo.enabled).assertEqual(true) - for (var j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { - expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") - expect(datainfo.applicationInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR2) - } - } - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } - }) - - /** - * @tc.number queryAbilityByWant_0700 - * @tc.name BUNDLE::queryAbilityByWant - * @tc.desc Test queryAbilityByWant interfaces with two haps. + * @tc.number getBundleArchiveInfo_1200 + * @tc.name BUNDLE::getBundleArchiveInfo + * @tc.desc Test getBundleArchiveInfo interfaces with none hap. */ - it('queryAbilityByWant_0700', 0, async function (done) { - let installData = await demo.getBundleInstaller(); - installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + it('getBundleArchiveInfo_1200', 0, async function (done) { + let installData = await demo.getBundleInstaller() + installData.install([PATH + BMSJSTEST1], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -1835,52 +1122,40 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - await demo.queryAbilityByWant({ - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "com.example.myapplication2", - abilityName: "com.example.myapplication1.MainAbility", - uri: "", - shortName: "" - }, - } - }, 0, 0, OnReceiveEvent) + await demo.getBundleArchiveInfo(PATH + BMSJSTEST1, 0, OnReceiveEvent) - function OnReceiveEvent(err, data) { - expect(data.length).assertLarger(0); - for (let i = 0, len = data.length; i < len; i++) { - var datainfo = data[i]; - expect(datainfo.name).assertEqual("com.example.myapplication" + (i + 1) + ".MainAbility") - expect(datainfo.label).assertEqual("$string:app_name") - expect(datainfo.description).assertEqual("$string:mainability_description") - expect(datainfo.icon).assertEqual("$media:icon") - expect(datainfo.moduleName).assertEqual("entry") - expect(datainfo.bundleName).assertEqual(NAME2) - expect(datainfo.applicationInfo.name).assertEqual(NAME2) - expect(datainfo.applicationInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue() - expect(datainfo.applicationInfo.icon).assertEqual("$media:icon") - expect(datainfo.applicationInfo.iconId >= 0).assertTrue() - expect(datainfo.applicationInfo.label).assertEqual("$string:app_name") - expect(datainfo.applicationInfo.labelId >= 0).assertTrue() - expect(datainfo.applicationInfo.systemApp).assertEqual(true) - expect(datainfo.applicationInfo.supportedModes).assertEqual(0) - expect(datainfo.applicationInfo.enabled).assertEqual(true) - for (var j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { - expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") - expect(datainfo.applicationInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR2) - } + function OnReceiveEvent(err, datainfo) { + expect(datainfo.name).assertEqual(NAME1) + expect(datainfo.vendor).assertEqual("example") + expect(datainfo.versionCode).assertEqual(1) + expect(datainfo.versionName).assertLarger(0) + expect(datainfo.entryModuleName).assertEqual("entry") + expect(datainfo.appInfo.name).assertEqual(NAME1) + expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") + expect(datainfo.appInfo.descriptionId >= 0).assertTrue() + expect(datainfo.appInfo.icon).assertEqual("$media:icon") + expect(datainfo.appInfo.iconId >= 0).assertTrue() + expect(datainfo.appInfo.label).assertEqual("$string:app_name") + expect(datainfo.appInfo.labelId >= 0).assertTrue() + expect(datainfo.appInfo.systemApp).assertEqual(false) + expect(datainfo.appInfo.supportedModes).assertEqual(0) + for (var j = 0; j < datainfo.appInfo.moduleInfos; j++) { + expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") } - installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { + for (var j = 0; j < datainfo.abilityInfos; j++) { + expect(datainfo.abilityInfos[j].name).assertEqual(".MainAbility") + expect(datainfo.abilityInfos[j].label).assertEqual("$string:app_name") + expect(datainfo.abilityInfos[j].description).assertEqual("$string:mainability_description") + expect(datainfo.abilityInfos[j].icon).assertEqual("$media:icon") + expect(datainfo.abilityInfos[j].isVisible).assertEqual(false) + expect(datainfo.abilityInfos[j].bundleName).assertEqual(NAME1) + expect(datainfo.abilityInfos[j].moduleName).assertEqual("entry") + } + installData.uninstall(NAME1, { + userId: 0, + installFlag: 0, + isKeepData: false + }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual('SUCCESS'); @@ -1891,18 +1166,16 @@ describe('ActsBundleManagerTest', function () { }) /** - * @tc.number getBundleInfo_0300 + * @tc.number getBundleInfo_0200 * @tc.name BUNDLE::getBundleInfo - * @tc.desc Test getBundleInfo interfaces with three haps. + * @tc.desc Test getBundleInfo interfaces with two haps. */ - it('getBundleInfo_0300', 0, async function (done) { + it('getBundleInfo_0200', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -1910,13 +1183,13 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - var datainfo = await demo.getBundleInfo(NAME3, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES) - expect(datainfo.name).assertEqual(NAME3) + var datainfo = await demo.getBundleInfo(NAME2, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES) + expect(datainfo.name).assertEqual(NAME2) expect(datainfo.vendor).assertEqual("example") expect(datainfo.versionCode).assertEqual(1) expect(datainfo.versionName).assertLarger(0) expect(datainfo.entryModuleName).assertEqual("entry") - expect(datainfo.appInfo.name).assertEqual(NAME3) + expect(datainfo.appInfo.name).assertEqual(NAME2) expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") expect(datainfo.appInfo.descriptionId >= 0).assertTrue() expect(datainfo.appInfo.icon).assertEqual("$media:icon") @@ -1924,47 +1197,30 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.appInfo.label).assertEqual("$string:app_name") expect(datainfo.appInfo.labelId >= 0).assertTrue() expect(datainfo.appInfo.systemApp).assertEqual(true) - installData.uninstall(NAME3, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.uninstall(NAME2, { + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); - }); + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); }); } }) /** - * @tc.number getBundleInfo_0800 + * @tc.number getBundleInfo_0700 * @tc.name BUNDLE::getBundleInfo - * @tc.desc Test getBundleInfo interfaces with three haps. + * @tc.desc Test getBundleInfo interfaces with two haps. */ - it('getBundleInfo_0800', 0, async function (done) { + it('getBundleInfo_0700', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -1972,15 +1228,14 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - await demo.getBundleInfo(NAME3, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent) - + await demo.getBundleInfo(NAME2, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent) function OnReceiveEvent(err, datainfo) { - expect(datainfo.name).assertEqual(NAME3) + expect(datainfo.name).assertEqual(NAME2) expect(datainfo.vendor).assertEqual("example") expect(datainfo.versionCode).assertEqual(1) expect(datainfo.versionName).assertLarger(0) expect(datainfo.entryModuleName).assertEqual("entry") - expect(datainfo.appInfo.name).assertEqual(NAME3) + expect(datainfo.appInfo.name).assertEqual(NAME2) expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") expect(datainfo.appInfo.descriptionId >= 0).assertTrue() expect(datainfo.appInfo.icon).assertEqual("$media:icon") @@ -1988,48 +1243,32 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.appInfo.label).assertEqual("$string:app_name") expect(datainfo.appInfo.labelId >= 0).assertTrue() expect(datainfo.appInfo.systemApp).assertEqual(true) - } - installData.uninstall(NAME3, { - param: { + installData.uninstall(NAME2, { userId: 0, installFlag: 0, isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); }); - }); + } } }) /** - * @tc.number getApplicationInfos_0300 - * @tc.name BUNDLE::getApplicationInfos - * @tc.desc Test getApplicationInfos interfaces with three haps. + * @tc.number getApplicationInfos_0200 + * @tc.name BUNDLE::getApplicationInfos + * @tc.desc Test getApplicationInfos interfaces with two haps. */ - it('getApplicationInfos_0300', 0, async function (done) { + it('getApplicationInfos_0200', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -2037,51 +1276,33 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - console.info('===start getApplicationInfos===') var datainfo = await demo.getAllApplicationInfo(8, 0) - expect(datainfo.length).assertLarger(0) + console.info("==========ActsBmsGetInfosSecondScene is ==========" + JSON.stringify(datainfo)); checkgetApplicationInfos(datainfo) - installData.uninstall(NAME3, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.uninstall(NAME2, { + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); - }); + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); }); } }) /** - * @tc.number getApplicationInfos_0500 + * @tc.number getApplicationInfos_0400 * @tc.name BUNDLE::getApplicationInfos - * @tc.desc Test getApplicationInfos interfaces with three haps and different param. + * @tc.desc Test getApplicationInfos interfaces with two haps and different param. */ - it('getApplicationInfos_0500', 0, async function (done) { + it('getApplicationInfos_0400', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -2089,68 +1310,34 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - await demo.getAllApplicationInfo(0, 0, (error, datainfo) => { - - for (var i = 0; i < datainfo.length; i++) { - expect(datainfo[i].name.length).assertLarger(0) - if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2 - || datainfo[i].name == NAME3 || datainfo[i].name == NAME4 || datainfo[i].name == NAME5) { - expect(datainfo[i].description.length).assertLarger(0) - expect(datainfo[i].icon.length).assertLarger(0) - expect(datainfo[i].label.length).assertLarger(0) - } - expect(datainfo[i].moduleSourceDirs.length).assertLarger(0) - expect(datainfo[i].moduleInfos.length).assertLarger(0) - expect(datainfo[i].supportedModes).assertEqual(0) - expect(datainfo[i].flags).assertEqual(0) - - for (var j = 0; j < datainfo[i].moduleInfos; j++) { - expect(datainfo[i].moduleInfos[j].moduleName.length).assertLarger(0) - expect(datainfo[i].moduleInfos[j].moduleSourceDir.length).assertLarger(0) - } - } - installData.uninstall(NAME3, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); - }); - }); + var datainfo = await demo.getAllApplicationInfo(0, 0) + expect(datainfo.length).assertLarger(0) + checkgetApplicationInfos(datainfo) + installData.uninstall(NAME2, { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); }); } }) /** - * @tc.number getApplicationInfos_0800 + * @tc.number getApplicationInfos_0700 * @tc.name BUNDLE::getApplicationInfos - * @tc.desc Test getApplicationInfos interfaces with three haps. + * @tc.desc Test getApplicationInfos interfaces with two haps. */ - it('getApplicationInfos_0800', 0, async function (done) { + it('getApplicationInfos_0700', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -2176,48 +1363,31 @@ describe('ActsBundleManagerTest', function () { expect(datainfo[i].moduleInfos[j].moduleSourceDir.length).assertLarger(0) } } - installData.uninstall(NAME3, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.uninstall(NAME2, { + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); - }); + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); }); - }) + }); } }) /** - * @tc.number getApplicationInfos_1000 + * @tc.number getApplicationInfos_0900 * @tc.name BUNDLE::getApplicationInfos - * @tc.desc Test getApplicationInfos interfaces with three haps and different param. + * @tc.desc Test getApplicationInfos interfaces with two haps and different param. */ - it('getApplicationInfos_1000', 0, async function (done) { + it('getApplicationInfos_0900', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -2226,7 +1396,6 @@ describe('ActsBundleManagerTest', function () { }); async function getInfo() { await demo.getAllApplicationInfo(0, 0, (error, datainfo) => { - for (var i = 0; i < datainfo.length; i++) { expect(datainfo[i].name.length).assertLarger(0) if (datainfo[i].name == NAME1 || datainfo[i].name == NAME2 @@ -2244,58 +1413,52 @@ describe('ActsBundleManagerTest', function () { expect(datainfo[i].moduleInfos[j].moduleSourceDir.length).assertLarger(0) } } - installData.uninstall(NAME3, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.uninstall(NAME2, { + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); - }); + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); }); - }) + }); } }) /** - * @tc.number getBundleInfos_0300 + * @tc.number getBundleInfos_0200 * @tc.name BUNDLE::getBundleInfos - * @tc.desc Test getBundleInfos interfaces with three haps. + * @tc.desc Test getBundleInfos interfaces with two haps. */ - it('getBundleInfos_0300', 0, async function (done) { + it('getBundleInfos_0200', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual('SUCCESS'); getInfo(); }); + async function getInfo() { var data = await demo.getAllBundleInfo(0) + expect(typeof data).assertEqual(OBJECT) for (var i = 0; i < data.length; i++) { + console.info('====> getBundleInfos_02200 =====>' + JSON.stringify(data[i].name.length)) + console.info('====> getBundleInfos_03300 =====>' + JSON.stringify(data[i].entryModuleName.length)) + console.info('====> getBundleInfos_04400 =====>' + JSON.stringify(data[i].appInfo.name.length)) + console.info('====> getBundleInfos_05500 =====>' + JSON.stringify(data[i].appInfo.description.length)) + console.info('====> getBundleInfos_06600 =====>' + JSON.stringify(data[i].appInfo.icon.length)) + console.info('====> getBundleInfos_07700 =====>' + JSON.stringify(data[i].appInfo.label.length)) + console.info('====> getBundleInfos_08800 =====>' + JSON.stringify(data[i].appInfo.supportedModes)) + console.info('====> getBundleInfos_09900 =====>' + JSON.stringify(data[i].appInfo.moduleInfos.length)) expect(data[i].name.length).assertLarger(0) expect(data[i].appInfo.name.length).assertLarger(0) if (data[i].name == NAME1 || data[i].name == NAME2 @@ -2306,48 +1469,33 @@ describe('ActsBundleManagerTest', function () { } expect(data[i].appInfo.supportedModes).assertEqual(0) expect(data[i].appInfo.moduleInfos.length).assertLarger(0) + } - installData.uninstall(NAME3, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.uninstall(NAME2, { + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); - }); + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); }); } }) /** - * @tc.number getBundleInfos_0500 + * @tc.number getBundleInfos_0400 * @tc.name BUNDLE::getBundleInfos - * @tc.desc Test getBundleInfos interfaces with three haps and different param. + * @tc.desc Test getBundleInfos interfaces with two haps and different param. */ - it('getBundleInfos_0500', 0, async function (done) { + it('getBundleInfos_0400', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -2356,6 +1504,7 @@ describe('ActsBundleManagerTest', function () { }); async function getInfo() { var data = await demo.getAllBundleInfo(1) + expect(typeof data).assertEqual(OBJECT) for (var i = 0; i < data.length; i++) { expect(data[i].name.length).assertLarger(0) @@ -2368,49 +1517,31 @@ describe('ActsBundleManagerTest', function () { } expect(data[i].appInfo.supportedModes).assertEqual(0) expect(data[i].appInfo.moduleInfos.length).assertLarger(0) - } - installData.uninstall(NAME3, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.uninstall(NAME2, { + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); - }); + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); }); } }) - /** - * @tc.number getBundleInfos_0800 - * @tc.name BUNDLE::getBundleInfos - * @tc.desc Test getBundleInfos interfaces with three haps. + * @tc.number getApplicationInfo_0200 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with two haps. */ - it('getBundleInfos_0800', 0, async function (done) { + it('getApplicationInfo_0200', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -2418,62 +1549,57 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - await demo.getAllBundleInfo(0, (error, data) => { - - for (var i = 0; i < data.length; i++) { - expect(data[i].name.length).assertLarger(0) - expect(data[i].appInfo.name.length).assertLarger(0) - if (data[i].name == NAME1 || data[i].name == NAME2 - || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { - expect(data[i].appInfo.description.length).assertLarger(0) - expect(data[i].appInfo.icon.length).assertLarger(0) - expect(data[i].appInfo.label.length).assertLarger(0) - } - expect(data[i].appInfo.supportedModes).assertEqual(0) - expect(data[i].appInfo.moduleInfos.length).assertLarger(0) - } - installData.uninstall(NAME3, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); - }); - }); - }) + var datainfo = await demo.getApplicationInfo(NAME2, BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + BundleFlag.GET_BUNDLE_WITH_ABILITIES) + expect(typeof datainfo).assertEqual(OBJECT) + expect(datainfo.name.length).assertLarger(0) + expect(datainfo.description.length).assertLarger(0) + expect(datainfo.icon.length).assertLarger(0) + expect(datainfo.label.length).assertLarger(0) + expect(datainfo.moduleSourceDirs.length).assertLarger(0) + expect(datainfo.moduleInfos.length).assertLarger(0) + expect(datainfo.name).assertEqual(NAME2) + expect(datainfo.description).assertEqual("$string:mainability_description") + expect(datainfo.icon).assertEqual("$media:icon") + expect(datainfo.label).assertEqual("$string:app_name") + expect(datainfo.systemApp).assertEqual(true) + expect(datainfo.descriptionId >= 0).assertTrue() + expect(datainfo.iconId >= 0).assertTrue() + expect(datainfo.labelId >= 0).assertTrue() + expect(datainfo.supportedModes).assertEqual(0) + expect(datainfo.process).assertEqual("") + expect(datainfo.enabled).assertEqual(true) + expect(datainfo.flags).assertEqual(0) + expect(datainfo.moduleSourceDirs.length).assertLarger(0) + for (var j = 0; j < datainfo.moduleInfos; j++) { + expect(datainfo.moduleInfos[j].moduleName).assertEqual("entry") + expect(datainfo.moduleInfos[j].moduleSourceDir.length).assertLarger(0) + } + installData.uninstall(NAME2, { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); + }); } }) /** - * @tc.number getBundleInfos_1000 + * @tc.number getBundleInfos_0700 * @tc.name BUNDLE::getBundleInfos - * @tc.desc Test getBundleInfos interfaces with three haps and different param. + * @tc.desc Test getBundleInfos interfaces with two haps. */ - it('getBundleInfos_1000', 0, async function (done) { + it('getBundleInfos_0700', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -2481,7 +1607,8 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - await demo.getAllBundleInfo(1, (error, data) => { + await demo.getAllBundleInfo(0, (error, data) => { + expect(typeof data).assertEqual(OBJECT) for (var i = 0; i < data.length; i++) { expect(data[i].name.length).assertLarger(0) @@ -2495,48 +1622,32 @@ describe('ActsBundleManagerTest', function () { expect(data[i].appInfo.supportedModes).assertEqual(0) expect(data[i].appInfo.moduleInfos.length).assertLarger(0) } - installData.uninstall(NAME3, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.uninstall(NAME2, { + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); - }); + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); }); }) } }) /** - * @tc.number getApplicationInfo_0300 - * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with three haps. + * @tc.number getBundleInfos_0900 + * @tc.name BUNDLE::getBundleInfos + * @tc.desc Test getBundleInfos interfaces with two haps and different param. */ - it('getApplicationInfo_0300', 0, async function (done) { + it('getBundleInfos_0900', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -2544,62 +1655,47 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - var datainfo = await demo.getApplicationInfo(NAME3, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES) - expect(datainfo.name).assertEqual(NAME3) - expect(datainfo.label).assertEqual("$string:app_name") - expect(datainfo.description).assertEqual("$string:mainability_description") - expect(datainfo.icon).assertEqual("$media:icon") - expect(datainfo.name).assertEqual(NAME3) - expect(datainfo.description).assertEqual("$string:mainability_description") - expect(datainfo.descriptionId >= 0).assertTrue() - expect(datainfo.icon).assertEqual("$media:icon") - expect(datainfo.iconId >= 0).assertTrue() - expect(datainfo.label).assertEqual("$string:app_name") - expect(datainfo.labelId >= 0).assertTrue() - expect(datainfo.systemApp).assertEqual(true) - expect(datainfo.supportedModes).assertEqual(0) - installData.uninstall(NAME3, { - param: { + await demo.getAllBundleInfo(1, (error, data) => { + expect(typeof data).assertEqual(OBJECT) + + for (var i = 0; i < data.length; i++) { + expect(data[i].name.length).assertLarger(0) + expect(data[i].appInfo.name.length).assertLarger(0) + if (data[i].name == NAME1 || data[i].name == NAME2 + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + expect(data[i].appInfo.description.length).assertLarger(0) + expect(data[i].appInfo.icon.length).assertLarger(0) + expect(data[i].appInfo.label.length).assertLarger(0) + } + expect(data[i].appInfo.supportedModes).assertEqual(0) + expect(data[i].appInfo.moduleInfos.length).assertLarger(0) + } + installData.uninstall(NAME2, { userId: 0, installFlag: 0, isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); }); - }); + }) } }) + /** - * @tc.number getApplicationInfo_0800 + * @tc.number getApplicationInfo_0700 * @tc.name BUNDLE::getApplicationInfo - * @tc.desc Test getApplicationInfo interfaces with three haps. + * @tc.desc Test getApplicationInfo interfaces with two haps. */ - it('getApplicationInfo_0800', 0, async function (done) { - let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + it('getApplicationInfo_0700', 0, async function (done) { + let installData = await demo.getBundleInstaller(); + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -2607,13 +1703,14 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - await demo.getApplicationInfo(NAME3, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + await demo.getApplicationInfo(NAME2, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, (error, datainfo) => { - expect(datainfo.name).assertEqual(NAME3) + expect(typeof datainfo).assertEqual(OBJECT) + expect(datainfo.name).assertEqual(NAME2) expect(datainfo.label).assertEqual("$string:app_name") expect(datainfo.description).assertEqual("$string:mainability_description") expect(datainfo.icon).assertEqual("$media:icon") - expect(datainfo.name).assertEqual(NAME3) + expect(datainfo.name).assertEqual(NAME2) expect(datainfo.description).assertEqual("$string:mainability_description") expect(datainfo.descriptionId >= 0).assertTrue() expect(datainfo.icon).assertEqual("$media:icon") @@ -2622,259 +1719,140 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.labelId >= 0).assertTrue() expect(datainfo.systemApp).assertEqual(true) expect(datainfo.supportedModes).assertEqual(0) - installData.uninstall(NAME3, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + installData.uninstall(NAME2, { + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); - }); + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); }); }) } }) /** - * @tc.number getBundleArchiveInfo_0300 - * @tc.name BUNDLE::getBundleArchiveInfo - * @tc.desc Test getBundleArchiveInfo interfaces with three haps. + * @tc.number getApplicationInfos_0800 + * @tc.name BUNDLE::getApplicationInfos + * @tc.desc Test getApplicationInfos interfaces with three haps. */ - it('getBundleArchiveInfo_0300', 0, async function (done) { + it('getApplicationInfos_0800', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); + expect(err.code).assertEqual(-1); + expect(data.status).assertEqual(3); + expect(data.statusMessage).assertEqual('STATUS_INSTALL_FAILURE_INVALID'); + done(); }); - async function getInfo() { - var datainfo = await demo.getBundleArchiveInfo(PATH + BMSJSTEST4, 1) - expect(datainfo.name).assertEqual(NAME3) - expect(datainfo.vendor).assertEqual("example") - expect(datainfo.versionCode).assertEqual(1) - expect(datainfo.versionName).assertLarger(0) - expect(datainfo.entryModuleName).assertEqual("entry") - expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.appInfo.descriptionId >= 0).assertTrue() - expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() - expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() - expect(datainfo.appInfo.systemApp).assertEqual(false) - installData.uninstall(NAME3, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); - }); - }); - } }) /** - * @tc.number getBundleArchiveInfo_0800 - * @tc.name BUNDLE::getBundleArchiveInfo - * @tc.desc Test getBundleArchiveInfo interfaces with three hap. + * @tc.number getBundleInfos_0300 + * @tc.name BUNDLE::getBundleInfos + * @tc.desc Test getBundleInfos interfaces with three haps. */ - it('getBundleArchiveInfo_0800', 0, async function (done) { + it('getBundleInfos_0300', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); + expect(err.code).assertEqual(-1); + expect(data.status).assertEqual(3); + expect(data.statusMessage).assertEqual('STATUS_INSTALL_FAILURE_INVALID'); getInfo(); }); async function getInfo() { - await demo.getBundleArchiveInfo(PATH + BMSJSTEST4, 1, OnReceiveEvent) + var data = await demo.getAllBundleInfo(0) - function OnReceiveEvent(err, datainfo) { - expect(datainfo.name).assertEqual(NAME3) - expect(datainfo.vendor).assertEqual("example") - expect(datainfo.versionCode).assertEqual(1) - expect(datainfo.versionName).assertLarger(0) - expect(datainfo.entryModuleName).assertEqual("entry") - expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.appInfo.descriptionId >= 0).assertTrue() - expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() - expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() - expect(datainfo.appInfo.systemApp).assertEqual(false) - installData.uninstall(NAME3, { - param: { + for (var i = 0; i < data.length; i++) { + expect(data[i].name.length).assertLarger(0) + expect(data[i].appInfo.name.length).assertLarger(0) + if (data[i].name == NAME1 || data[i].name == NAME2 + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + expect(data[i].appInfo.description.length).assertLarger(0) + expect(data[i].appInfo.icon.length).assertLarger(0) + expect(data[i].appInfo.label.length).assertLarger(0) + } + expect(data[i].appInfo.supportedModes).assertEqual(0) + expect(data[i].appInfo.moduleInfos.length).assertLarger(0) + } + installData.uninstall(NAME3, { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + installData.uninstall(NAME4, { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + installData.uninstall(NAME5, { userId: 0, installFlag: 0, isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); + done(); }); }); - } + }); } }) /** - * @tc.number queryAbilityByWant_0300 - * @tc.name BUNDLE::queryAbilityByWant - * @tc.desc Test queryAbilityByWant interfaces with three haps. + * @tc.number getBundleInfos_0500 + * @tc.name BUNDLE::getBundleInfos + * @tc.desc Test getBundleInfos interfaces with three haps and different param. */ - it('queryAbilityByWant_0300', 0, async function (done) { + it('getBundleInfos_0500', 0, async function (done) { let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - var data = - await demo.queryAbilityByWant({ - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "com.example.myapplication4", - abilityName: "com.example.myapplication.MainAbility", - uri: "", - shortName: "" - }, - } - }, 0, 0) - var data1 = - await demo.queryAbilityByWant({ - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "com.example.myapplication5", - abilityName: "com.example.myapplication.MainAbility", - uri: "", - shortName: "" - }, - } - }, 0, 0) - expect(data1.length).assertLarger(0); - for (let i = 0, len = data1.length; i < len; i++) { - var datainfo = data1[i]; - expect(datainfo.type).assertEqual(demo.AbilityType.DATA) - expect(datainfo.orientation).assertEqual(demo.DisplayOrientation.FOLLOWRECENT) - } - expect(data.length).assertLarger(0); - for (let i = 0, len = data.length; i < len; i++) { - var datainfo = data[i]; - expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility") - expect(datainfo.label).assertEqual("$string:app_name") - expect(datainfo.description).assertEqual("$string:mainability_description") - expect(datainfo.icon).assertEqual("$media:icon") - expect(datainfo.moduleName).assertEqual("entry") - expect(datainfo.bundleName).assertEqual(NAME3) - expect(datainfo.type).assertEqual(demo.AbilityType.PAGE) - expect(datainfo.orientation).assertEqual(demo.DisplayOrientation.PORTRAIT) - expect(datainfo.applicationInfo.name).assertEqual(NAME3) - expect(datainfo.applicationInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue() - expect(datainfo.applicationInfo.icon).assertEqual("$media:icon") - expect(datainfo.applicationInfo.iconId >= 0).assertTrue() - expect(datainfo.applicationInfo.label).assertEqual("$string:app_name") - expect(datainfo.applicationInfo.labelId >= 0).assertTrue() - expect(datainfo.applicationInfo.systemApp).assertEqual(true) - expect(datainfo.applicationInfo.supportedModes).assertEqual(0) - expect(datainfo.applicationInfo.enabled).assertEqual(true) - for (var j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { - expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") + installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { + userId: 0, + installFlag: 0, + isKeepData: false + }, async (err, data) => { + expect(err.code).assertEqual(-1); + expect(data.status).assertEqual(3); + expect(data.statusMessage).assertEqual('STATUS_INSTALL_FAILURE_INVALID'); + getInfo(); + }); + async function getInfo() { + var data = await demo.getAllBundleInfo(1) + + for (var i = 0; i < data.length; i++) { + expect(data[i].name.length).assertLarger(0) + expect(data[i].appInfo.name.length).assertLarger(0) + if (data[i].name == NAME1 || data[i].name == NAME2 + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + expect(data[i].appInfo.description.length).assertLarger(0) + expect(data[i].appInfo.icon.length).assertLarger(0) + expect(data[i].appInfo.label.length).assertLarger(0) } + expect(data[i].appInfo.supportedModes).assertEqual(0) + expect(data[i].appInfo.moduleInfos.length).assertLarger(0) + } installData.uninstall(NAME3, { - param: { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + installData.uninstall(NAME4, { userId: 0, installFlag: 0, isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME4, { - param: { + }, (err, data) => { + installData.uninstall(NAME5, { userId: 0, installFlag: 0, isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } }, (err, data) => { done(); }); @@ -2884,89 +1862,113 @@ describe('ActsBundleManagerTest', function () { }) /** - * @tc.number queryAbilityByWant_0800 - * @tc.name BUNDLE::queryAbilityByWant - * @tc.desc Test queryAbilityByWant interfaces with three haps. + * @tc.number getBundleInfos_0800 + * @tc.name BUNDLE::getBundleInfos + * @tc.desc Test getBundleInfos interfaces with three haps. */ - it('queryAbilityByWant_0800', 0, async function (done) { + it('getBundleInfos_0800', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); + expect(err.code).assertEqual(-1); + expect(data.status).assertEqual(3); + expect(data.statusMessage).assertEqual('STATUS_INSTALL_FAILURE_INVALID'); getInfo(); }); async function getInfo() { - await demo.queryAbilityByWant({ - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "com.example.myapplication4", - abilityName: "com.example.myapplication.MainAbility", - uri: "", - shortName: "" - }, - } - }, 0, 0, OnReceiveEvent) + await demo.getAllBundleInfo(0, (error, data) => { - function OnReceiveEvent(err, data) { - expect(data.length).assertLarger(0); - for (let i = 0, len = data.length; i < len; i++) { - var datainfo = data[i]; - expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility") - expect(datainfo.label).assertEqual("$string:app_name") - expect(datainfo.description).assertEqual("$string:mainability_description") - expect(datainfo.icon).assertEqual("$media:icon") - expect(datainfo.moduleName).assertEqual("entry") - expect(datainfo.bundleName).assertEqual(NAME3) - expect(datainfo.applicationInfo.name).assertEqual(NAME3) - expect(datainfo.applicationInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue() - expect(datainfo.applicationInfo.icon).assertEqual("$media:icon") - expect(datainfo.applicationInfo.iconId >= 0).assertTrue() - expect(datainfo.applicationInfo.label).assertEqual("$string:app_name") - expect(datainfo.applicationInfo.labelId >= 0).assertTrue() - expect(datainfo.applicationInfo.systemApp).assertEqual(true) - expect(datainfo.applicationInfo.supportedModes).assertEqual(0) - expect(datainfo.applicationInfo.enabled).assertEqual(true) - for (var j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { - expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") + for (var i = 0; i < data.length; i++) { + expect(data[i].name.length).assertLarger(0) + expect(data[i].appInfo.name.length).assertLarger(0) + if (data[i].name == NAME1 || data[i].name == NAME2 + || data[i].name == NAME3 || data[i].name == NAME4 || data[i].name == NAME5) { + expect(data[i].appInfo.description.length).assertLarger(0) + expect(data[i].appInfo.icon.length).assertLarger(0) + expect(data[i].appInfo.label.length).assertLarger(0) } + expect(data[i].appInfo.supportedModes).assertEqual(0) + expect(data[i].appInfo.moduleInfos.length).assertLarger(0) } installData.uninstall(NAME3, { - param: { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + installData.uninstall(NAME4, { userId: 0, installFlag: 0, isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME4, { - param: { + }, (err, data) => { + installData.uninstall(NAME5, { userId: 0, installFlag: 0, isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } }, (err, data) => { done(); }); }); }); - } + }) + } + }) + + /** + * @tc.number getApplicationInfo_0300 + * @tc.name BUNDLE::getApplicationInfo + * @tc.desc Test getApplicationInfo interfaces with three haps. + */ + it('getApplicationInfo_0300', 0, async function (done) { + let installData = await demo.getBundleInstaller() + installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { + userId: 0, + installFlag: 0, + isKeepData: false + }, async (err, data) => { + expect(err.code).assertEqual(-1); + expect(data.status).assertEqual(3); + expect(data.statusMessage).assertEqual('STATUS_INSTALL_FAILURE_INVALID'); + getInfo(); + }); + async function getInfo() { + demo.getApplicationInfo(NAME3, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => { + expect(datainfo.name).assertEqual(NAME3) + expect(datainfo.label).assertEqual("$string:app_name") + expect(datainfo.description).assertEqual("$string:mainability_description") + expect(datainfo.icon).assertEqual("$media:icon") + expect(datainfo.name).assertEqual(NAME3) + expect(datainfo.description).assertEqual("$string:mainability_description") + expect(datainfo.descriptionId >= 0).assertTrue() + expect(datainfo.icon).assertEqual("$media:icon") + expect(datainfo.iconId >= 0).assertTrue() + expect(datainfo.label).assertEqual("$string:app_name") + expect(datainfo.labelId >= 0).assertTrue() + expect(datainfo.systemApp).assertEqual(true) + expect(datainfo.supportedModes).assertEqual(0) + }); + installData.uninstall(NAME3, { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + installData.uninstall(NAME4, { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + installData.uninstall(NAME5, { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + done(); + }); + }); + }); } }) @@ -2976,7 +1978,7 @@ describe('ActsBundleManagerTest', function () { * @tc.desc Test getBundleInfo interfaces with error hap. */ it('getBundleInfo_0400', 0, async function (done) { - var datainfo = await demo.getBundleInfo('error', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES); + var datainfo = await demo.getBundleInfo('error', BundleFlag.GET_BUNDLE_WITH_ABILITIES); expect(datainfo.name.length).assertEqual(0) done(); }) @@ -2987,7 +1989,7 @@ describe('ActsBundleManagerTest', function () { * @tc.desc Test getBundleInfo interfaces with error hap. */ it('getBundleInfo_0900', 0, async function (done) { - await demo.getBundleInfo('error', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent) + await demo.getBundleInfo('error', BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent) function OnReceiveEvent(err, datainfo) { expect(datainfo.name.length).assertEqual(0) done(); @@ -3000,9 +2002,10 @@ describe('ActsBundleManagerTest', function () { * @tc.desc Test getApplicationInfo interfaces with error hap. */ it('getApplicationInfo_0400', 0, async function (done) { - var datainfo = await demo.getApplicationInfo(ERROR, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES) - checkgetApplicationInfoe(datainfo) + demo.getApplicationInfo(ERROR, BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => { + checkgetApplicationInfoe(datainfo) + }); done() }) function checkgetApplicationInfoe(datainfo) { @@ -3015,45 +2018,20 @@ describe('ActsBundleManagerTest', function () { * @tc.desc Test getApplicationInfo interfaces with error hap. */ it('getApplicationInfo_0900', 0, async function (done) { - await demo.getApplicationInfo(ERROR, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, (error, datainfo) => { + demo.getApplicationInfo(ERROR, BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + BundleFlag.GET_BUNDLE_WITH_ABILITIES, (error, datainfo) => { expect(datainfo.name.length).assertEqual(0) - done() }) - }) - - /** - * @tc.number getBundleArchiveInfo_0400 - * @tc.name BUNDLE::getBundleArchiveInfo - * @tc.desc Test getBundleArchiveInfo interfaces with error hap. - */ - it('getBundleArchiveInfo_0400', 0, async function (done) { - var datainfo = await demo.getBundleArchiveInfo(PATH + ERROR, 1) - expect(datainfo.name.length).assertEqual(0) done() }) - /** - * @tc.number getBundleArchiveInfo_0900 - * @tc.name BUNDLE::getBundleArchiveInfo - * @tc.desc Test getBundleArchiveInfo interfaces with error hap. - */ - it('getBundleArchiveInfo_0900', 0, async function (done) { - await demo.getBundleArchiveInfo(PATH + ERROR, 1, OnReceiveEvent) - - function OnReceiveEvent(err, datainfo) { - expect(datainfo.name.length).assertEqual(0) - done() - } - }) - /** * @tc.number getBundleInfo_1000 * @tc.name BUNDLE::getBundleInfo * @tc.desc Test getBundleInfo interfaces with none hap. */ it('getBundleInfo_1000', 0, async function (done) { - await demo.getBundleInfo(' ', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent) + await demo.getBundleInfo(' ', BundleFlag.GET_BUNDLE_WITH_ABILITIES, OnReceiveEvent) function OnReceiveEvent(err, datainfo) { expect(datainfo.name.length).assertEqual(0) @@ -3067,11 +2045,11 @@ describe('ActsBundleManagerTest', function () { * @tc.desc Test getApplicationInfo interfaces with none hap. */ it('getApplicationInfo_0500', 0, async function (done) { - await demo.getApplicationInfo('', demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, (error, datainfo) => { + demo.getApplicationInfo('', BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + BundleFlag.GET_BUNDLE_WITH_ABILITIES, (error, datainfo) => { expect(datainfo.name.length).assertEqual(0) - done() }) + done() }) /** @@ -3080,8 +2058,9 @@ describe('ActsBundleManagerTest', function () { * @tc.desc Test getBundleInfo interfaces with none hap. */ it('getBundleInfo_0500', 0, async function (done) { - var datainfo = await demo.getBundleInfo(' ', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES); - expect(datainfo.name.length).assertEqual(0) + demo.getBundleInfo(' ', BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => { + expect(datainfo.name.length).assertEqual(0) + }); done(); }) @@ -3090,117 +2069,25 @@ describe('ActsBundleManagerTest', function () { * @tc.name BUNDLE::getApplicationInfo * @tc.desc Test getApplicationInfo interfaces with none hap. */ - it('getApplicationInfo_1000', 0, async function (done) { - await demo.getApplicationInfo('', demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, - demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES, (error, datainfo) => { - expect(datainfo.name.length).assertEqual(0) - done() - }) - }) - - /** - * @tc.number getBundleArchiveInfo_0500 - * @tc.name BUNDLE::getBundleArchiveInfo - * @tc.desc Test getBundleArchiveInfo interfaces with none hap. - */ - it('getBundleArchiveInfo_0500', 0, async function (done) { - var datainfo = await demo.getBundleArchiveInfo(' ', 1) - expect(datainfo.name.length).assertEqual(0) - done() - }) - - /** - * @tc.number getBundleArchiveInfo_0600 - * @tc.name BUNDLE::getBundleArchiveInfo - * @tc.desc Test getBundleArchiveInfo interfaces with none hap. - */ - it('getBundleArchiveInfo_0600', 0, async function (done) { - let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - await demo.getBundleArchiveInfo(PATH + BMSJSTEST1, 1, OnReceiveEvent) - - function OnReceiveEvent(err, datainfo) { - expect(datainfo.name).assertEqual(NAME1) - expect(datainfo.vendor).assertEqual("example") - expect(datainfo.versionCode).assertEqual(1) - expect(datainfo.versionName).assertLarger(0) - expect(datainfo.entryModuleName).assertEqual("entry") - expect(datainfo.appInfo.name).assertEqual(NAME1) - expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.appInfo.descriptionId >= 0).assertTrue() - expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() - expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() - expect(datainfo.appInfo.systemApp).assertEqual(false) - expect(datainfo.appInfo.supportedModes).assertEqual(0) - for (var j = 0; j < datainfo.appInfo.moduleInfos; j++) { - expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") - } - for (var j = 0; j < datainfo.abilityInfos; j++) { - expect(datainfo.abilityInfos[j].name).assertEqual(".MainAbility") - expect(datainfo.abilityInfos[j].label).assertEqual("$string:app_name") - expect(datainfo.abilityInfos[j].description).assertEqual("$string:mainability_description") - expect(datainfo.abilityInfos[j].icon).assertEqual("$media:icon") - expect(datainfo.abilityInfos[j].isVisible).assertEqual(false) - expect(datainfo.abilityInfos[j].bundleName).assertEqual(NAME1) - expect(datainfo.abilityInfos[j].moduleName).assertEqual("entry") - } - installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } - } - }) - - /** - * @tc.number getBundleArchiveInfo_1000 - * @tc.name BUNDLE::getBundleArchiveInfo - * @tc.desc Test getBundleArchiveInfo interfaces with none hap. - */ - it('getBundleArchiveInfo_1000', 0, async function (done) { - await demo.getBundleArchiveInfo(' ', 1, OnReceiveEvent) - - function OnReceiveEvent(err, datainfo) { + it('getApplicationInfo_1000', 0, async function (done) { + demo.getApplicationInfo('', BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, + BundleFlag.GET_BUNDLE_WITH_ABILITIES, (error, datainfo) => { expect(datainfo.name.length).assertEqual(0) - done() - } + }) + done() }) /** - * @tc.number getBundleArchiveInfo_1100 - * @tc.name BUNDLE::getBundleArchiveInfo - * @tc.desc Test getBundleArchiveInfo interfaces with none hap. + * @tc.number queryAbilityByWant_0100 + * @tc.name BUNDLE::queryAbilityByWant + * @tc.desc Test queryAbilityByWant interfaces with none hap. */ - it('getBundleArchiveInfo_1100', 0, async function (done) { + it('queryAbilityByWant_0100', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -3208,129 +2095,61 @@ describe('ActsBundleManagerTest', function () { getInfo(); }); async function getInfo() { - await demo.getBundleArchiveInfo(PATH + BMSJSTEST1, 0, OnReceiveEvent) - - function OnReceiveEvent(err, datainfo) { - expect(datainfo.name).assertEqual(NAME1) - expect(datainfo.vendor).assertEqual("example") - expect(datainfo.versionCode).assertEqual(1) - expect(datainfo.versionName).assertLarger(0) - expect(datainfo.entryModuleName).assertEqual("entry") - expect(datainfo.appInfo.name).assertEqual(NAME1) - expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.appInfo.descriptionId >= 0).assertTrue() - expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() - expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() - expect(datainfo.appInfo.systemApp).assertEqual(false) - expect(datainfo.appInfo.supportedModes).assertEqual(0) - for (var j = 0; j < datainfo.appInfo.moduleInfos; j++) { - expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") - } - for (var j = 0; j < datainfo.abilityInfos; j++) { - expect(datainfo.abilityInfos[j].name).assertEqual(".MainAbility") - expect(datainfo.abilityInfos[j].label).assertEqual("$string:app_name") - expect(datainfo.abilityInfos[j].description).assertEqual("$string:mainability_description") - expect(datainfo.abilityInfos[j].icon).assertEqual("$media:icon") - expect(datainfo.abilityInfos[j].isVisible).assertEqual(false) - expect(datainfo.abilityInfos[j].bundleName).assertEqual(NAME1) - expect(datainfo.abilityInfos[j].moduleName).assertEqual("entry") - } - installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false + demo.queryAbilityByWant( + { + "bundleName": "com.example.myapplication1", + "abilityName": "com.example.myapplication1.MainAbility", + }, 4, 0).then(data => { + expect(data.length).assertLarger(0); + for (let i = 0, len = data.length; i < len; i++) { + var datainfo = data[i]; + expect(datainfo.name).assertEqual("com.example.myapplication1.MainAbility") + expect(datainfo.label).assertEqual("$string:app_name") + expect(datainfo.description).assertEqual("$string:mainability_description") + expect(datainfo.icon).assertEqual("$media:icon") + expect(datainfo.moduleName).assertEqual("entry") + expect(datainfo.bundleName).assertEqual(NAME1) + expect(datainfo.applicationInfo.name).assertEqual(NAME1) + expect(datainfo.applicationInfo.description).assertEqual("$string:mainability_description") + expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue() + expect(datainfo.applicationInfo.icon).assertEqual("$media:icon") + expect(datainfo.applicationInfo.iconId >= 0).assertTrue() + expect(datainfo.applicationInfo.label).assertEqual("$string:app_name") + expect(datainfo.applicationInfo.labelId >= 0).assertTrue() + expect(datainfo.applicationInfo.systemApp).assertEqual(true) + expect(datainfo.applicationInfo.supportedModes).assertEqual(0) + expect(datainfo.applicationInfo.enabled).assertEqual(true) + expect(datainfo.metaData.customizeDatas.length).assertLarger(0) + for (var j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { + expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") + expect(datainfo.applicationInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1) } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } - } - }) - - /** - * @tc.number getBundleArchiveInfo_1200 - * @tc.name BUNDLE::getBundleArchiveInfo - * @tc.desc Test getBundleArchiveInfo interfaces with none hap. - */ - it('getBundleArchiveInfo_1200', 0, async function (done) { - let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST1], { - param: { + } + }) + installData.uninstall(NAME1, { userId: 0, installFlag: 0, isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - await demo.getBundleArchiveInfo(PATH + BMSJSTEST1, 0, OnReceiveEvent) - - function OnReceiveEvent(err, datainfo) { - expect(datainfo.name).assertEqual(NAME1) - expect(datainfo.vendor).assertEqual("example") - expect(datainfo.versionCode).assertEqual(1) - expect(datainfo.versionName).assertLarger(0) - expect(datainfo.entryModuleName).assertEqual("entry") - expect(datainfo.appInfo.name).assertEqual(NAME1) - expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.appInfo.descriptionId >= 0).assertTrue() - expect(datainfo.appInfo.icon).assertEqual("$media:icon") - expect(datainfo.appInfo.iconId >= 0).assertTrue() - expect(datainfo.appInfo.label).assertEqual("$string:app_name") - expect(datainfo.appInfo.labelId >= 0).assertTrue() - expect(datainfo.appInfo.systemApp).assertEqual(false) - expect(datainfo.appInfo.supportedModes).assertEqual(0) - for (var j = 0; j < datainfo.appInfo.moduleInfos; j++) { - expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") - } - for (var j = 0; j < datainfo.abilityInfos; j++) { - expect(datainfo.abilityInfos[j].name).assertEqual(".MainAbility") - expect(datainfo.abilityInfos[j].label).assertEqual("$string:app_name") - expect(datainfo.abilityInfos[j].description).assertEqual("$string:mainability_description") - expect(datainfo.abilityInfos[j].icon).assertEqual("$media:icon") - expect(datainfo.abilityInfos[j].isVisible).assertEqual(false) - expect(datainfo.abilityInfos[j].bundleName).assertEqual(NAME1) - expect(datainfo.abilityInfos[j].moduleName).assertEqual("entry") - } - installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - done(); - }); - } + }, async (err, data) => { + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); + }); } }) /** - * @tc.number queryAbilityByWant_0100 + * @tc.number queryAbilityByWant_0200 * @tc.name BUNDLE::queryAbilityByWant - * @tc.desc Test queryAbilityByWant interfaces with none hap. + * @tc.desc Test queryAbilityByWant interfaces with two haps. */ - it('queryAbilityByWant_0100', 0, async function (done) { - let installData = await demo.getBundleInstaller() - installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + it('queryAbilityByWant_0200', 0, async function (done) { + let installData = await demo.getBundleInstaller(); + installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -3339,31 +2158,21 @@ describe('ActsBundleManagerTest', function () { }); async function getInfo() { var data = - await demo.queryAbilityByWant({ - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "com.example.myapplication1", - abilityName: "com.example.myapplication1.MainAbility", - uri: "", - shortName: "" - }, - } - }, 0, 0) + await demo.queryAbilityByWant( + { + "bundleName": "com.example.myapplication2", + "abilityName": "com.example.myapplication1.MainAbility", + }, 4, 0) expect(data.length).assertLarger(0); for (let i = 0, len = data.length; i < len; i++) { var datainfo = data[i]; - expect(datainfo.name).assertEqual("com.example.myapplication1.MainAbility") + expect(datainfo.name.length).assertLarger(0) expect(datainfo.label).assertEqual("$string:app_name") expect(datainfo.description).assertEqual("$string:mainability_description") expect(datainfo.icon).assertEqual("$media:icon") expect(datainfo.moduleName).assertEqual("entry") - expect(datainfo.bundleName).assertEqual(NAME1) - expect(datainfo.launchMode).assertEqual(demo.LaunchMode.STANDARD) - expect(datainfo.orientation).assertEqual(demo.DisplayOrientation.UNSPECIFIED) - expect(datainfo.applicationInfo.name).assertEqual(NAME1) + expect(datainfo.bundleName).assertEqual(NAME2) + expect(datainfo.applicationInfo.name).assertEqual(NAME2) expect(datainfo.applicationInfo.description).assertEqual("$string:mainability_description") expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue() expect(datainfo.applicationInfo.icon).assertEqual("$media:icon") @@ -3373,19 +2182,122 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.applicationInfo.systemApp).assertEqual(true) expect(datainfo.applicationInfo.supportedModes).assertEqual(0) expect(datainfo.applicationInfo.enabled).assertEqual(true) - expect(datainfo.metaData.customizeDatas.length).assertLarger(0) for (var j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") - expect(datainfo.applicationInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR1) + expect(datainfo.applicationInfo.moduleInfos[j].moduleSourceDir).assertEqual(DIR2) } } - installData.uninstall(NAME1, { - param: { + installData.uninstall(NAME2, { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + done(); + }); + } + }) + + /** + * @tc.number queryAbilityByWant_0300 + * @tc.name BUNDLE::queryAbilityByWant + * @tc.desc Test queryAbilityByWant interfaces with three haps. + */ + it('queryAbilityByWant_0300', 0, async function (done) { + let installData = await demo.getBundleInstaller() + installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { + userId: 0, + installFlag: 0, + isKeepData: false + }, async (err, data) => { + expect(err.code).assertEqual(-1); + expect(data.status).assertEqual(3); + expect(data.statusMessage).assertEqual('STATUS_INSTALL_FAILURE_INVALID'); + getInfo(); + }); + async function getInfo() { + demo.queryAbilityByWant( + { + "bundleName": "com.example.myapplication4", + "abilityName": "com.example.myapplication.MainAbility", + }, 4, 0).then(data => { + for (let i = 0, len = data.length; i < len; i++) { + var datainfo = data[i]; + expect(datainfo.name).assertEqual("com.example.myapplication.MainAbility") + expect(datainfo.label).assertEqual("$string:app_name") + expect(datainfo.description).assertEqual("$string:mainability_description") + expect(datainfo.icon).assertEqual("$media:icon") + expect(datainfo.moduleName).assertEqual("entry") + expect(datainfo.bundleName).assertEqual(NAME3) + expect(datainfo.applicationInfo.name).assertEqual(NAME3) + expect(datainfo.applicationInfo.description).assertEqual("$string:mainability_description") + expect(datainfo.applicationInfo.descriptionId >= 0).assertTrue() + expect(datainfo.applicationInfo.icon).assertEqual("$media:icon") + expect(datainfo.applicationInfo.iconId >= 0).assertTrue() + expect(datainfo.applicationInfo.label).assertEqual("$string:app_name") + expect(datainfo.applicationInfo.labelId >= 0).assertTrue() + expect(datainfo.applicationInfo.systemApp).assertEqual(true) + expect(datainfo.applicationInfo.supportedModes).assertEqual(0) + expect(datainfo.applicationInfo.enabled).assertEqual(true) + for (var j = 0; j < datainfo.applicationInfo.moduleInfos; j++) { + expect(datainfo.applicationInfo.moduleInfos[j].moduleName).assertEqual("entry") + } + } + }) + installData.uninstall(NAME3, { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + installData.uninstall(NAME4, { userId: 0, installFlag: 0, isKeepData: false - } - }, async (err, data) => { + }, (err, data) => { + installData.uninstall(NAME5, { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + done(); + }); + }); + }); + } + }) + + /** + * @tc.number queryAbilityByWant_0400 + * @tc.name BUNDLE::queryAbilityByWant + * @tc.desc Test queryAbilityByWant interfaces with one hap. + */ + it('queryAbilityByWant_0400', 0, async function (done) { + let installData = await demo.getBundleInstaller() + installData.install([PATH + BMSJSTEST1], { + userId: 0, + installFlag: 0, + isKeepData: false + }, async (err, data) => { + expect(err.code).assertEqual(0); + expect(data.status).assertEqual(0); + expect(data.statusMessage).assertEqual('SUCCESS'); + getInfo(); + }); + async function getInfo() { + demo.queryAbilityByWant( + { + "bundleName": "wrong name", + "abilityName": "com.example.myapplication1.MainAbility", + }, 0, 0).then(datainfo => { + expect(datainfo.length).assertEqual(0) + }) + installData.uninstall(NAME1, { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); expect(data.statusMessage).assertEqual('SUCCESS'); @@ -3400,18 +2312,19 @@ describe('ActsBundleManagerTest', function () { * @tc.desc Test getBundleInfo interfaces with LAUNCHER hap. */ it('getBundleInfo_1300', 0, async function (done) { - var datainfo = await demo.getBundleInfo(LAUNCHER, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES) - expect(datainfo.name).assertEqual(LAUNCHER) - expect(datainfo.vendor).assertEqual("ohos") - expect(datainfo.versionCode).assertEqual(1000000) - expect(datainfo.versionName.length).assertLarger(0) - expect(datainfo.uid).assertLarger(2099) - expect(datainfo.appInfo.name).assertEqual(LAUNCHER) - expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") - expect(datainfo.appInfo.systemApp).assertEqual(true) - expect(datainfo.appInfo.supportedModes).assertEqual(0) - expect(datainfo.appInfo.moduleInfos.length).assertLarger(0) - expect(datainfo.appInfo.enabled).assertEqual(true) + demo.getBundleInfo(LAUNCHER, BundleFlag.GET_BUNDLE_WITH_ABILITIES).then(datainfo => { + expect(datainfo.name).assertEqual(LAUNCHER) + expect(datainfo.vendor).assertEqual("ohos") + expect(datainfo.versionCode).assertEqual(1000000) + expect(datainfo.versionName.length).assertLarger(0) + expect(datainfo.uid).assertLarger(2099) + expect(datainfo.appInfo.name).assertEqual(LAUNCHER) + expect(datainfo.appInfo.description).assertEqual("$string:mainability_description") + expect(datainfo.appInfo.systemApp).assertEqual(true) + expect(datainfo.appInfo.supportedModes).assertEqual(0) + expect(datainfo.appInfo.moduleInfos.length).assertLarger(0) + expect(datainfo.appInfo.enabled).assertEqual(true) + }) done() }) @@ -3421,22 +2334,14 @@ describe('ActsBundleManagerTest', function () { * @tc.desc Test queryAbilityByWant interfaces with system hap. */ it('queryAbilityByWant_1000', 0, async function (done) { - await demo.queryAbilityByWant({ - want: { - action: "action.system.home", - entities: ["entity.system.home"], - elementName: { - deviceId: "0", - bundleName: "", - abilityName: "", - uri: "", - shortName: "" - }, - } - }, 0, 0, OnReceiveEvent) + demo.queryAbilityByWant( + { + bundleName: "wrong name", + abilityName: "wrong name", + }, 0, 0, OnReceiveEvent) function OnReceiveEvent(err, datainfo) { - expect(datainfo.length).assertEqual(0) + expect(datainfo.length).assertLarger(0) done() } }) @@ -3449,11 +2354,9 @@ describe('ActsBundleManagerTest', function () { it('getPermissionDef_0100', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -3468,11 +2371,9 @@ describe('ActsBundleManagerTest', function () { expect(infos.label).assertEqual("BMS_PERMISSION_CAMERA permission"); expect(infos.description).assertEqual("BMS_PERMISSION_CAMERA permission in detail"); installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -3491,11 +2392,9 @@ describe('ActsBundleManagerTest', function () { it('getPermissionDef_0200', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -3517,11 +2416,9 @@ describe('ActsBundleManagerTest', function () { expect(infos.label).assertEqual("BMS_PERMISSION_MUSIC permission"); expect(infos.description).assertEqual("BMS_PERMISSION_MUSIC permission in detail"); installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -3541,54 +2438,50 @@ describe('ActsBundleManagerTest', function () { let installData = await demo.getBundleInstaller() await demo.getBundleInstaller().then((data) => { data.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { getInfo(); }); }); async function getInfo() { demo.getPermissionDef(CAMERA).then((infos) => { - expect(infos.name).assertEqual("com.permission.BMS_PERMISSION_CAMERA"); - expect(infos.grantMode).assertEqual(1); - expect(infos.availableScope).assertEqual(2); - expect(infos.label).assertEqual("BMS_PERMISSION_CAMERA permission"); - expect(infos.description).assertEqual("BMS_PERMISSION_CAMERA permission in detail"); + expect(infos.name).assertEqual(''); + expect(infos.grantMode).assertEqual(0); + expect(infos.availableScope).assertEqual(0); + expect(infos.label).assertEqual(''); + expect(infos.description).assertEqual(''); }); demo.getPermissionDef(MUSIC).then((infos) => { - expect(infos.name).assertEqual("com.permission.BMS_PERMISSION_MUSIC"); - expect(infos.grantMode).assertEqual(1); - expect(infos.availableScope).assertEqual(2); - expect(infos.label).assertEqual("BMS_PERMISSION_MUSIC permission"); - expect(infos.description).assertEqual("BMS_PERMISSION_MUSIC permission in detail"); + expect(infos.name).assertEqual(''); + expect(infos.grantMode).assertEqual(0); + expect(infos.availableScope).assertEqual(0); + expect(infos.label).assertEqual(''); + expect(infos.description).assertEqual(''); }); demo.getPermissionDef(WECHAT).then((infos) => { - expect(infos.name).assertEqual("com.permission.BMS_PERMISSION_WECHAT"); - expect(infos.grantMode).assertEqual(1); - expect(infos.availableScope).assertEqual(2); - expect(infos.label).assertEqual("BMS_PERMISSION_WECHAT permission"); - expect(infos.description).assertEqual("BMS_PERMISSION_WECHAT permission in detail"); + expect(infos.name).assertEqual(''); + expect(infos.grantMode).assertEqual(0); + expect(infos.availableScope).assertEqual(0); + expect(infos.label).assertEqual(''); + expect(infos.description).assertEqual(''); installData.uninstall(NAME3, { - param: { - userId: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { installData.uninstall(NAME4, { - param: { - userId: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { installData.uninstall(NAME5, { - param: { - userId: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { done(); }); @@ -3639,11 +2532,9 @@ describe('ActsBundleManagerTest', function () { it('getPermissionDef_0600', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -3660,11 +2551,9 @@ describe('ActsBundleManagerTest', function () { expect(data.label).assertEqual("BMS_PERMISSION_CAMERA permission"); expect(data.description).assertEqual("BMS_PERMISSION_CAMERA permission in detail"); installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -3683,11 +2572,9 @@ describe('ActsBundleManagerTest', function () { it('getPermissionDef_0700', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -3711,11 +2598,9 @@ describe('ActsBundleManagerTest', function () { expect(data.label).assertEqual("BMS_PERMISSION_MUSIC permission"); expect(data.description).assertEqual("BMS_PERMISSION_MUSIC permission in detail"); installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -3732,77 +2617,6 @@ describe('ActsBundleManagerTest', function () { * @tc.desc Test getPermissionDef interfaces. */ it('getPermissionDef_0800', 0, async function (done) { - let installData = await demo.getBundleInstaller(); - installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); - getInfo(); - }); - async function getInfo() { - await demo.getPermissionDef(CAMERA, OnReceiveEvent1); - async function OnReceiveEvent1(err, data) { - expect(data.name).assertEqual("com.permission.BMS_PERMISSION_CAMERA"); - expect(data.grantMode).assertEqual(1); - expect(data.availableScope).assertEqual(2); - expect(data.label).assertEqual("BMS_PERMISSION_CAMERA permission"); - expect(data.description).assertEqual("BMS_PERMISSION_CAMERA permission in detail"); - await demo.getPermissionDef(MUSIC, OnReceiveEvent2); - } - async function OnReceiveEvent2(err, data) { - expect(data.name).assertEqual("com.permission.BMS_PERMISSION_MUSIC"); - expect(data.grantMode).assertEqual(1); - expect(data.availableScope).assertEqual(2); - expect(data.label).assertEqual("BMS_PERMISSION_MUSIC permission"); - expect(data.description).assertEqual("BMS_PERMISSION_MUSIC permission in detail"); - await demo.getPermissionDef(WECHAT, OnReceiveEvent3); - } - async function OnReceiveEvent3(err, data) { - expect(data.name).assertEqual("com.permission.BMS_PERMISSION_WECHAT"); - expect(data.grantMode).assertEqual(1); - expect(data.availableScope).assertEqual(2); - expect(data.label).assertEqual("BMS_PERMISSION_WECHAT permission"); - expect(data.description).assertEqual("BMS_PERMISSION_WECHAT permission in detail"); - installData.uninstall(NAME3, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } - }, (err, data) => { - done(); - }); - }); - }); - } - } - }) - /** - * @tc.number getPermissionDef_0900 - * @tc.name BUNDLE::getPermissionDef - * @tc.desc Test getPermissionDef interfaces. - */ - it('getPermissionDef_0900', 0, async function (done) { await demo.getPermissionDef('', OnReceiveEvent); function OnReceiveEvent(err, data) { @@ -3816,11 +2630,11 @@ describe('ActsBundleManagerTest', function () { }) /** - * @tc.number getPermissionDef_1000 + * @tc.number getPermissionDef_0900 * @tc.name BUNDLE::getPermissionDef * @tc.desc Test getPermissionDef interfaces. */ - it('getPermissionDef_1000', 0, async function (done) { + it('getPermissionDef_0900', 0, async function (done) { await demo.getPermissionDef('error', OnReceiveEvent); function OnReceiveEvent(err, data) { expect(data.name).assertEqual(""); @@ -3840,21 +2654,17 @@ describe('ActsBundleManagerTest', function () { it('install_0100', 0, async function (done) { let installData = await demo.getBundleInstaller(); installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { var datainfo = await demo.getBundleInfo(NAME1, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES); expect(datainfo.name).assertEqual(NAME1); expect(datainfo.uid < UIDMINVALUE).assertTrue(); installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -3872,21 +2682,17 @@ describe('ActsBundleManagerTest', function () { it('install_0200', 0, async function (done) { let installData = await demo.getBundleInstaller(); installData.install([PATH + BMSJSTEST2], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { var datainfo = await demo.getBundleInfo(NAME2, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES); expect(datainfo.name).assertEqual(NAME2); expect(datainfo.uid < UIDMINVALUE).assertTrue(); installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -3905,54 +2711,46 @@ describe('ActsBundleManagerTest', function () { it('install_0300', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); + expect(err.code).assertEqual(-1); + expect(data.status).assertEqual(3); + expect(data.statusMessage).assertEqual('STATUS_INSTALL_FAILURE_INVALID'); getInfo(); }); async function getInfo() { var datainfo1 = await demo.getBundleInfo(NAME3, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES); - expect(datainfo1.name).assertEqual(NAME3); + expect(datainfo1.name).assertEqual(''); expect(datainfo1.uid < UIDMINVALUE).assertTrue(); var datainfo2 = await demo.getBundleInfo(NAME4, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES); - expect(datainfo2.name).assertEqual(NAME4); + expect(datainfo2.name).assertEqual(''); expect(datainfo2.uid < UIDMINVALUE).assertTrue(); var datainfo3 = await demo.getBundleInfo(NAME5, demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES); - expect(datainfo3.name).assertEqual(NAME5); + expect(datainfo3.name).assertEqual(''); expect(datainfo3.uid < UIDMINVALUE).assertTrue(); installData.uninstall(NAME3, { - param: { + userId: 0, + installFlag: 0, + isKeepData: false + }, (err, data) => { + installData.uninstall(NAME4, { userId: 0, installFlag: 0, isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME4, { - param: { + }, (err, data) => { + installData.uninstall(NAME5, { userId: 0, installFlag: 0, isKeepData: false - } - }, (err, data) => { - installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } }, (err, data) => { done(); }); }); - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); + expect(err.code).assertEqual(-1); + expect(data.status).assertEqual(7); + expect(data.statusMessage).assertEqual('STATUS_UNINSTALL_FAILURE'); }); } }) @@ -3965,11 +2763,9 @@ describe('ActsBundleManagerTest', function () { it('install_0400', 0, async function (done) { demo.getBundleInstaller().then(async (data) => { await data.install([PATH + ERROR], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, OnReceiveinstallEvent); function OnReceiveinstallEvent(err, data) { @@ -3991,11 +2787,9 @@ describe('ActsBundleManagerTest', function () { it('install_0500', 0, async function (done) { demo.getBundleInstaller().then((data) => { data.install([''], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, OnReceiveinstallEvent); function OnReceiveinstallEvent(err, data) { @@ -4019,11 +2813,9 @@ describe('ActsBundleManagerTest', function () { it('install_0600', 0, async function (done) { let installData = await demo.getBundleInstaller(); installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, OnReceiveInstallEvent); async function OnReceiveInstallEvent(err, data) { expect(typeof data).assertEqual(OBJECT); @@ -4032,11 +2824,9 @@ describe('ActsBundleManagerTest', function () { expect(datainfo1.name).assertEqual(NAME1); expect(datainfo1.uid < UIDMINVALUE).assertTrue(); installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -4054,11 +2844,9 @@ describe('ActsBundleManagerTest', function () { it('install_0700', 0, async function (done) { demo.getBundleInstaller().then((data) => { data.install([PATH + BMSJSTEST7], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, OnReceiveinstallEvent); function OnReceiveinstallEvent(err, data) { @@ -4081,11 +2869,9 @@ describe('ActsBundleManagerTest', function () { it('install_0800', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST8], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -4099,11 +2885,9 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.versionCode).assertEqual(VERSIONCODE1); expect(datainfo.versionName).assertLarger(0); installData.install([PATH + BMSJSTEST9], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -4118,11 +2902,9 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.versionCode).assertEqual(VERSIONCODE2); expect(datainfo.versionName).assertLarger(0); installData.uninstall(THIRD1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -4140,11 +2922,9 @@ describe('ActsBundleManagerTest', function () { it('install_0900', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST9], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(typeof data).assertEqual(OBJECT); expect(data.statusMessage).assertEqual(SUCCESS); @@ -4152,11 +2932,9 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.versionCode).assertEqual(VERSIONCODE2); expect(datainfo.versionName).assertLarger(0); installData.install([PATH + BMSJSTEST8], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, OnReceiveinstallEvent); }); async function OnReceiveinstallEvent(err, data) { @@ -4166,11 +2944,9 @@ describe('ActsBundleManagerTest', function () { expect(datainfo.versionCode).assertEqual(VERSIONCODE2); expect(datainfo.versionName).assertLarger(0); installData.uninstall(THIRD1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -4204,11 +2980,9 @@ describe('ActsBundleManagerTest', function () { } let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST8], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -4241,11 +3015,9 @@ describe('ActsBundleManagerTest', function () { let uid = bundleInfo.uid; expect(processMap1.has(uid)).assertTrue(); installData.install([PATH + BMSJSTEST9], { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -4258,11 +3030,9 @@ describe('ActsBundleManagerTest', function () { expect(processMap2.has(uid)).assertFalse(); commonEvent.unsubscribe(Subscriber, UnSubscribeCallback) installData.uninstall(THIRD1, { - param: { - userId: 0, - installFlag: 0, - isKeepData: false - } + userId: 0, + installFlag: 0, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageruninstall/entry/src/main/js/test/ExampleJsunit.test.js b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageruninstall/entry/src/main/js/test/ExampleJsunit.test.js old mode 100755 new mode 100644 index b75db0e22..b11e49542 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageruninstall/entry/src/main/js/test/ExampleJsunit.test.js +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageruninstall/entry/src/main/js/test/ExampleJsunit.test.js @@ -37,11 +37,14 @@ const LAUNCHER = "com.ohos.launcher" const OBJECT = "object" const SUCCESS = "SUCCESS" const START_ABILITY_TIMEOUT = 3000; +const ERR_CODE = -1; +const STATUS_INSTALL_FAILURE_INVALID = 3; +const STATUS_INSTALL_FAILURE_CONFLICT = 4; var subscriberInfoEvent_0100 = { events: ['Third1_Publish_CommonEvent'], }; -describe('ActsBundleManagerTest', function () { +describe('ActsBundleManagerUninstall', function () { /** * @tc.number uninstall_0100 * @tc.name BUNDLE::uninstall @@ -50,11 +53,9 @@ describe('ActsBundleManagerTest', function () { it('uninstall_0100', 0, async function (done) { let installData = await demo.getBundleInstaller(); installData.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { expect(err.code).assertEqual(0); expect(data.status).assertEqual(0); @@ -62,11 +63,9 @@ describe('ActsBundleManagerTest', function () { var datainfo1 = await demo.getBundleInfo(NAME1, 1); expect(datainfo1.name).assertEqual(NAME1); installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { var datainfo2 = await demo.getBundleInfo(NAME1, 1); expect(datainfo2.name).assertEqual(''); @@ -83,34 +82,28 @@ describe('ActsBundleManagerTest', function () { it('uninstall_0200', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST1, PATH + BMSJSTEST3], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); + expect(err.code).assertEqual(ERR_CODE); + expect(data.status).assertEqual(STATUS_INSTALL_FAILURE_CONFLICT); + expect(data.statusMessage).assertEqual('STATUS_INSTALL_FAILURE_CONFLICT'); var datainfo1 = await demo.getBundleInfo(NAME1, 1); var datainfo2 = await demo.getBundleInfo(NAME2, 1); - expect(datainfo1.name).assertEqual(NAME1); - expect(datainfo2.name).assertEqual(NAME2); + expect(datainfo1.name).assertEqual(''); + expect(datainfo2.name).assertEqual(''); installData.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async(err, data) => { var datainfo3 = await demo.getBundleInfo(NAME1, 1); expect(datainfo3.name).assertEqual(''); installData.uninstall(NAME2, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async(err, data) => { var datainfo4 = await demo.getBundleInfo(NAME2, 1); expect(datainfo4.name).assertEqual(''); @@ -128,45 +121,37 @@ describe('ActsBundleManagerTest', function () { it('uninstall_0300', 0, async function (done) { let installData = await demo.getBundleInstaller() installData.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { - expect(err.code).assertEqual(0); - expect(data.status).assertEqual(0); - expect(data.statusMessage).assertEqual('SUCCESS'); + expect(err.code).assertEqual(ERR_CODE); + expect(data.status).assertEqual(STATUS_INSTALL_FAILURE_INVALID); + expect(data.statusMessage).assertEqual('STATUS_INSTALL_FAILURE_INVALID'); var datainfo1 = await demo.getBundleInfo(NAME3, 1); - expect(datainfo1.name).assertEqual(NAME3); + expect(datainfo1.name).assertEqual(''); var datainfo2 = await demo.getBundleInfo(NAME4, 1); - expect(datainfo2.name).assertEqual(NAME4); + expect(datainfo2.name).assertEqual(''); var datainfo3 = await demo.getBundleInfo(NAME5, 1); - expect(datainfo3.name).assertEqual(NAME5); + expect(datainfo3.name).assertEqual(''); installData.uninstall(NAME3, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async(err, data) => { var datainfo4 = await demo.getBundleInfo(NAME3, 1); expect(datainfo4.name).assertEqual(''); installData.uninstall(NAME4, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async(err, data) => { var datainfo5 = await demo.getBundleInfo(NAME4, 1); expect(datainfo5.name).assertEqual(''); installData.uninstall(NAME5, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async(err, data) => { var datainfo6 = await demo.getBundleInfo(NAME5, 1); expect(datainfo6.name).assertEqual(''); @@ -185,11 +170,9 @@ describe('ActsBundleManagerTest', function () { it('uninstall_0400', 0, async function (done) { demo.getBundleInstaller().then((data) => { data.uninstall(ERROR, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, OnReceiveinstallEvent); function OnReceiveinstallEvent(err, data) { @@ -208,11 +191,9 @@ describe('ActsBundleManagerTest', function () { it('uninstall_0500', 0, async function (done) { demo.getBundleInstaller().then((data) => { data.uninstall('', { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, OnReceiveinstallEvent); function OnReceiveinstallEvent(err, data) { @@ -232,11 +213,9 @@ describe('ActsBundleManagerTest', function () { it('uninstall_0600', 0, async function (done) { demo.getBundleInstaller().then((data) => { data.uninstall(LAUNCHER, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, OnReceiveinstallEvent); function OnReceiveinstallEvent(err, data) { @@ -256,11 +235,9 @@ describe('ActsBundleManagerTest', function () { it('uninstall_0700', 0, async function (done) { let result = await demo.getBundleInstaller(); result.install([PATH + BMSJSTEST1], { - param: { - userId: 0, - installFlag: 1, - isKeepData: true - } + userId: 0, + installFlag: 1, + isKeepData: true }, OnReceiveinstallEvent); async function OnReceiveinstallEvent(err, data) { expect(typeof data).assertEqual(OBJECT); @@ -268,11 +245,9 @@ describe('ActsBundleManagerTest', function () { var datainfo1 = await demo.getBundleInfo(NAME1, 1); expect(datainfo1.name).assertEqual(NAME1); result.uninstall(NAME1, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async(err, data) => { var datainfo2 = await demo.getBundleInfo(NAME1, 1); expect(datainfo2.name).assertEqual(''); @@ -306,11 +281,9 @@ describe('ActsBundleManagerTest', function () { } let installData = await demo.getBundleInstaller(); installData.install([PATH + BMSJSTEST8], { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async (err, data) => { id = setTimeout(timeout, START_ABILITY_TIMEOUT); console.debug('=======start ability========') @@ -340,11 +313,9 @@ describe('ActsBundleManagerTest', function () { let uid = bundleInfo.uid; expect(processMap1.has(uid)).assertTrue(); installData.uninstall(THIRD1, { - param: { - userId: 0, - installFlag: 1, - isKeepData: false - } + userId: 0, + installFlag: 1, + isKeepData: false }, async(err, data) => { let processInfos2 = await abilityManager.getActiveProcessInfos(); for (var i = 0, len = processInfos2.length; i < len; i++) { -- GitLab