未验证 提交 af28f521 编写于 作者: O openharmony_ci 提交者: Gitee

!1940 修复bms 测试用例失败

Merge pull request !1940 from wangtiantian/xts
...@@ -394,7 +394,7 @@ describe('ActsBmsAllShortcutInfoTest', function () { ...@@ -394,7 +394,7 @@ describe('ActsBmsAllShortcutInfoTest', function () {
expect(data.status).assertEqual(0); expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual("SUCCESS"); expect(data.statusMessage).assertEqual("SUCCESS");
bundle.getAllShortcutInfo(bundleName, async (result, shortcutInfos) => { bundle.getAllShortcutInfo(bundleName, async (result, shortcutInfos) => {
expect(result).assertEqual(1); expect(result).assertEqual(0);
expect(shortcutInfos.length).assertEqual(0); expect(shortcutInfos.length).assertEqual(0);
}); });
installer.uninstall(bundleName, { installer.uninstall(bundleName, {
......
...@@ -16,9 +16,6 @@ ...@@ -16,9 +16,6 @@
import app from '@system.app' import app from '@system.app'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import demo from '@ohos.bundle' import demo from '@ohos.bundle'
import featureAbility from '@ohos.ability.featureability'
import abilityManager from '@ohos.app.abilityManager'
import commonEvent from '@ohos.commonevent'
const PATH = "/data/" const PATH = "/data/"
const ERROR = "error.hap" const ERROR = "error.hap"
...@@ -40,29 +37,16 @@ const THIRD1 = "com.example.third1" ...@@ -40,29 +37,16 @@ const THIRD1 = "com.example.third1"
const LAUNCHER = "com.ohos.launcher" const LAUNCHER = "com.ohos.launcher"
const VERSIONCODE1 = 1 const VERSIONCODE1 = 1
const VERSIONCODE2 = 2 const VERSIONCODE2 = 2
const UIDMINVALUE = 9999
const OBJECT = "object" const OBJECT = "object"
const SUCCESS = "SUCCESS" const SUCCESS = "SUCCESS"
const DIR1 = "/data/accounts/account_0/applications/com.example.myapplication1/com.example.myapplication1" const DIR1 = "/data/accounts/account_0/applications/com.example.myapplication1/com.example.myapplication1"
const DIR2 = "/data/accounts/account_0/applications/com.example.myapplication2/com.example.myapplication2" const DIR2 = "/data/accounts/account_0/applications/com.example.myapplication2/com.example.myapplication2"
const SYSTEMDIR1 = "/data/accounts/account_0/applications/com.ohos.launcher/com.ohos.launcher.settings"
const CAMERA = 'com.permission.BMS_PERMISSION_CAMERA'
const MUSIC = 'com.permission.BMS_PERMISSION_MUSIC'
const WECHAT = 'com.permission.BMS_PERMISSION_WECHAT'
const START_ABILITY_TIMEOUT = 3000; const START_ABILITY_TIMEOUT = 3000;
var subscriberInfoEvent_0100 = {
events: ['Third1_Publish_CommonEvent'],
};
var installParam = { var installParam = {
userId: 100, userId: 100,
installFlag: 0, installFlag: 0,
isKeepData: false isKeepData: false
}; };
var BundleFlag = {
GET_BUNDLE_DEFAULT: 0,
GET_BUNDLE_WITH_ABILITIES: 1,
GET_APPLICATION_INFO_WITH_PERMISSION: 8
};
describe('ActsBundleManagerTest', function () { describe('ActsBundleManagerTest', function () {
...@@ -464,7 +448,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -464,7 +448,7 @@ describe('ActsBundleManagerTest', function () {
}); });
async function getInfo() { async function getInfo() {
await demo.getApplicationInfo(NAME1, await demo.getApplicationInfo(NAME1,
demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION|demo.BundleFlag.GET_APPLICATION_INFO_WITH_METADATA, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION|demo.BundleFlag.GET_APPLICATION_INFO_WITH_METADATA,
100).then(datainfo => { 100).then(datainfo => {
expect(typeof datainfo).assertEqual(OBJECT) expect(typeof datainfo).assertEqual(OBJECT)
console.info("getApplicationInfo success:" + JSON.stringify(datainfo)) console.info("getApplicationInfo success:" + JSON.stringify(datainfo))
...@@ -563,7 +547,8 @@ describe('ActsBundleManagerTest', function () { ...@@ -563,7 +547,8 @@ describe('ActsBundleManagerTest', function () {
getInfo(); getInfo();
}); });
async function getInfo() { async function getInfo() {
await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, 100, (error, datainfo) => { await demo.getApplicationInfo(NAME1, demo.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, 100,
(error, datainfo) => {
if (error) { if (error) {
console.info("getApplicationInfo fail:" + JSON.stringify(error)) console.info("getApplicationInfo fail:" + JSON.stringify(error))
expect(error).assertFail(); expect(error).assertFail();
...@@ -1541,6 +1526,7 @@ describe('ActsBundleManagerTest', function () { ...@@ -1541,6 +1526,7 @@ describe('ActsBundleManagerTest', function () {
}); });
} }
}) })
/** /**
* @tc.number getApplicationInfo_0200 * @tc.number getApplicationInfo_0200
* @tc.name BUNDLE::getApplicationInfo * @tc.name BUNDLE::getApplicationInfo
...@@ -2936,23 +2922,6 @@ describe('ActsBundleManagerTest', function () { ...@@ -2936,23 +2922,6 @@ describe('ActsBundleManagerTest', function () {
* @tc.desc Test install interfaces. * @tc.desc Test install interfaces.
*/ */
it('install_1000', 0, async function (done) { it('install_1000', 0, async function (done) {
var Subscriber;
let id;
commonEvent.createSubscriber(subscriberInfoEvent_0100).then((data) => {
console.debug('====>Create Subscriber====>');
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.debug('====>UnSubscribe CallBack====>');
done();
}
function timeout() {
expect().assertFail();
console.debug('install_1000=====timeout======');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
done();
}
let installData = await demo.getBundleInstaller() let installData = await demo.getBundleInstaller()
installData.install([PATH + BMSJSTEST8], { installData.install([PATH + BMSJSTEST8], {
userId: 100, userId: 100,
...@@ -2962,61 +2931,19 @@ describe('ActsBundleManagerTest', function () { ...@@ -2962,61 +2931,19 @@ describe('ActsBundleManagerTest', function () {
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0); expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS'); expect(data.statusMessage).assertEqual('SUCCESS');
id = setTimeout(timeout, START_ABILITY_TIMEOUT);
console.debug('=======start ability========')
let result = await featureAbility.startAbility(
{
want:
{
bundleName: 'com.example.third1',
abilityName: 'com.example.third1.MainAbility'
}
}
)
});
async function SubscribeCallBack(err, data) {
clearTimeout(id);
expect(data.event).assertEqual('Third1_Publish_CommonEvent');
console.debug('====>Subscribe CallBack data:====>' + JSON.stringify(data));
let processInfos1 = await abilityManager.getActiveProcessInfos();
expect(typeof processInfos1).assertEqual('object');
let processMap1 = new Map();
let processMap2 = new Map();
for (var i = 0, len = processInfos1.length; i < len; i++) {
console.debug('=======Active Process uid=====' + processInfos1[i].uid);
processMap1.set(processInfos1[i].uid, 0);
}
let bundleInfo = await demo.getBundleInfo('com.example.third1', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES); let bundleInfo = await demo.getBundleInfo('com.example.third1', demo.BundleFlag.GET_BUNDLE_WITH_ABILITIES);
let uid = bundleInfo.uid; expect(bundleInfo.uid).assertLarger(10000);
expect(processMap1.has(uid)).assertTrue(); installData.uninstall(THIRD1, {
installData.install([PATH + BMSJSTEST9], {
userId: 100, userId: 100,
installFlag: 0, installFlag: 0,
isKeepData: false isKeepData: false
}, async (err, data) => { }, async (err, data) => {
expect(err.code).assertEqual(0); expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0); expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS'); expect(data.statusMessage == "SUCCESS").assertTrue();
let processInfos2 = await abilityManager.getActiveProcessInfos(); done();
for (var i = 0, len = processInfos2.length; i < len; i++) {
console.debug('=======Active Process uid=====' + processInfos1[i].uid);
processMap2.set(processInfos2[i].uid, 0);
}
expect(processMap2.has(uid)).assertFalse();
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
installData.uninstall(THIRD1, {
userId: 100,
installFlag: 0,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage == "SUCCESS").assertTrue();
done();
});
}); });
} });
}) })
/** /**
...@@ -3028,5 +2955,15 @@ describe('ActsBundleManagerTest', function () { ...@@ -3028,5 +2955,15 @@ describe('ActsBundleManagerTest', function () {
expect(demo.InstallErrorCode.STATUS_FAILED_NO_SPACE_LEFT).assertEqual(66); expect(demo.InstallErrorCode.STATUS_FAILED_NO_SPACE_LEFT).assertEqual(66);
done(); done();
}) })
/**
* @tc.number installErrCodeTest_0200
* @tc.name InstallErrorCode::STATUS_FAILED_NO_SPACE_LEFT
* @tc.desc Test install errcode STATUS_FAILED_NO_SPACE_LEFT.
*/
it('installErrCodeTest_0200', 0, async function (done) {
expect(demo.InstallErrorCode.STATUS_GRANT_REQUEST_PERMISSIONS_FAILED).assertEqual(67);
done();
})
}) })
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import demo from '@ohos.bundle' import demo from '@ohos.bundle'
import featureAbility from '@ohos.ability.featureability'
import abilityManager from '@ohos.app.abilityManager'
import commonEvent from '@ohos.commonevent'
const PATH = "/data/" const PATH = "/data/"
const ERROR = "error.hap" const ERROR = "error.hap"
...@@ -40,11 +37,9 @@ const START_ABILITY_TIMEOUT = 3000; ...@@ -40,11 +37,9 @@ const START_ABILITY_TIMEOUT = 3000;
const ERR_CODE = -1; const ERR_CODE = -1;
const STATUS_INSTALL_FAILURE_INVALID = 3; const STATUS_INSTALL_FAILURE_INVALID = 3;
const STATUS_INSTALL_FAILURE_CONFLICT = 4; const STATUS_INSTALL_FAILURE_CONFLICT = 4;
var subscriberInfoEvent_0100 = {
events: ['Third1_Publish_CommonEvent'],
};
describe('ActsBundleManagerUninstall', function () { describe('ActsBundleManagerUninstall', function () {
/** /**
* @tc.number uninstall_0100 * @tc.number uninstall_0100
* @tc.name BUNDLE::uninstall * @tc.name BUNDLE::uninstall
...@@ -317,71 +312,28 @@ describe('ActsBundleManagerUninstall', function () { ...@@ -317,71 +312,28 @@ describe('ActsBundleManagerUninstall', function () {
* @tc.desc Test uninstall interfaces. * @tc.desc Test uninstall interfaces.
*/ */
it('uninstall_0800', 0, async function (done) { it('uninstall_0800', 0, async function (done) {
var Subscriber;
let id;
commonEvent.createSubscriber(subscriberInfoEvent_0100).then((data) => {
console.debug('====>Create Subscriber====>');
Subscriber = data;
commonEvent.subscribe(Subscriber, SubscribeCallBack);
})
function UnSubscribeCallback() {
console.debug('====>UnSubscribe CallBack====>');
done();
}
function timeout() {
expect().assertFail();
console.debug('uninstall_0800=====timeout======');
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
done();
}
let installData = await demo.getBundleInstaller(); let installData = await demo.getBundleInstaller();
installData.install([PATH + BMSJSTEST8], { installData.install([PATH + BMSJSTEST8], {
userId: 100, userId: 100,
installFlag: 1, installFlag: 1,
isKeepData: false isKeepData: false
}, async (err, data) => { }, async (err, data) => {
id = setTimeout(timeout, START_ABILITY_TIMEOUT); expect(err.code).assertEqual(0);
console.debug('=======start ability========') expect(data.status).assertEqual(0);
let result = await featureAbility.startAbility( expect(data.statusMessage).assertEqual('SUCCESS');
{
want:
{
bundleName: 'com.example.third1',
abilityName: 'com.example.third1.MainAbility'
}
}
)
});
async function SubscribeCallBack(err, data) {
clearTimeout(id);
expect(data.event).assertEqual('Third1_Publish_CommonEvent');
console.debug('====>Subscribe CallBack data:====>' + JSON.stringify(data));
let processInfos1 = await abilityManager.getActiveProcessInfos();
expect(typeof processInfos1).assertEqual('object');
let processMap1 = new Map();
let processMap2 = new Map();
for (var i = 0, len = processInfos1.length; i < len; i++) {
console.debug('=======Active Process uid=====' + processInfos1[i].uid);
processMap1.set(processInfos1[i].uid, 0);
}
let bundleInfo = await demo.getBundleInfo('com.example.third1', 1); let bundleInfo = await demo.getBundleInfo('com.example.third1', 1);
let uid = bundleInfo.uid; expect(bundleInfo.uid).assertLarger(10000);
expect(processMap1.has(uid)).assertTrue();
installData.uninstall(THIRD1, { installData.uninstall(THIRD1, {
userId: 100, userId: 100,
installFlag: 1, installFlag: 1,
isKeepData: false isKeepData: false
}, async(err, data) => { }, async(err, data) => {
let processInfos2 = await abilityManager.getActiveProcessInfos(); expect(err.code).assertEqual(0);
for (var i = 0, len = processInfos2.length; i < len; i++) { expect(data.status).assertEqual(0);
console.debug('=======Active Process uid=====' + processInfos1[i].uid); expect(data.statusMessage == "SUCCESS").assertTrue();
processMap2.set(processInfos2[i].uid, 0);
}
expect(processMap2.has(uid)).assertFalse();
commonEvent.unsubscribe(Subscriber, UnSubscribeCallback)
done(); done();
}); });
} });
}) })
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册