提交 465d48d2 编写于 作者: Z zhaoyuan17

Modify test code

Signed-off-by: Nzhaoyuan17 <zhaoyuan17@huawei.com>
上级 057edcb9
......@@ -26,7 +26,8 @@ group("bundlemanager") {
"actsbmsmoduleusagerecordtest:ActsBmsModuleUsageRecordTest",
"actsbundlemanagertest:ActsBundleManagerTest",
"actsbundlemanageruninstall:ActsBundleManagerUninstall",
"bmscheckpermissiontest:BmsCheckPermissionTest",
# "bmscheckpermissiontest:BmsCheckPermissionTest",
"sceneProject/bmsgetinfosfifthscene:bmsThirdBundleTest5",
"sceneProject/bmsgetinfosfirstscene:bmsThirdBundleTest1",
"sceneProject/bmsgetinfosfirstsceneupdate:bmsThirdBundleTestA1",
......
......@@ -19,7 +19,6 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
const BUNDLE_NAME = 'com.example.actsbmscheckpermissiontest';
const PERMISSION_ONE = 'com.permission.PERMISSION_A';
const PERMISSION_TWO = 'com.permission.PERMISSION_B';
const TIMEOUT = 1000;
const NAMECOUNT = 10000;
describe('ActsBmsCheckPermissionTest', function () {
......@@ -34,9 +33,6 @@ describe('ActsBmsCheckPermissionTest', function () {
var data = await bundle.checkPermission(BUNDLE_NAME, PERMISSION_ONE)
expect(data).assertEqual(0);
done();
setTimeout(function () {
console.info('=====================bms_checkPermission_0100==================end');
}, TIMEOUT)
})
/*
......@@ -51,9 +47,6 @@ describe('ActsBmsCheckPermissionTest', function () {
expect(data).assertEqual(0);
done();
})
setTimeout(function () {
console.info('=====================bms_checkPermission_0200==================end');
}, TIMEOUT)
})
/*
......@@ -67,9 +60,6 @@ describe('ActsBmsCheckPermissionTest', function () {
var data = await bundle.checkPermission('', PERMISSION_ONE)
expect(data).assertEqual(-1);
done();
setTimeout(function () {
console.info('=====================bms_checkPermission_0300==================end');
}, TIMEOUT)
})
/*
......@@ -85,9 +75,6 @@ describe('ActsBmsCheckPermissionTest', function () {
expect(data).assertEqual(-1);
done();
})
setTimeout(function () {
console.info('=====================bms_checkPermission_0400==================end');
}, TIMEOUT)
})
/*
......@@ -101,9 +88,6 @@ describe('ActsBmsCheckPermissionTest', function () {
var data = await bundle.checkPermission(BUNDLE_NAME, '')
expect(data).assertEqual(-1);
done();
setTimeout(function () {
console.info('=====================bms_checkPermission_0500==================end');
}, TIMEOUT)
})
/*
......@@ -119,9 +103,6 @@ describe('ActsBmsCheckPermissionTest', function () {
expect(data).assertEqual(-1);
done();
})
setTimeout(function () {
console.info('=====================bms_checkPermission_0600==================end');
}, TIMEOUT)
})
/*
......@@ -135,9 +116,6 @@ describe('ActsBmsCheckPermissionTest', function () {
var data = await bundle.checkPermission(BUNDLE_NAME, '@\n,. 。测试@abc1^%12345')
expect(data).assertEqual(-1);
done();
setTimeout(function () {
console.info('=====================bms_checkPermission_0700==================end');
}, TIMEOUT)
})
/*
......@@ -153,9 +131,6 @@ describe('ActsBmsCheckPermissionTest', function () {
expect(data).assertEqual(-1);
done();
})
setTimeout(function () {
console.info('=====================bms_checkPermission_0800==================end');
}, TIMEOUT)
})
/*
......@@ -169,9 +144,6 @@ describe('ActsBmsCheckPermissionTest', function () {
var data = await bundle.checkPermission('@\n,. 。测试@abc1^%12345', PERMISSION_ONE)
expect(data).assertEqual(-1);
done();
setTimeout(function () {
console.info('=====================bms_checkPermission_0900==================end');
}, TIMEOUT)
})
/*
......@@ -187,9 +159,6 @@ describe('ActsBmsCheckPermissionTest', function () {
expect(data).assertEqual(-1);
done();
})
setTimeout(function () {
console.info('=====================bms_checkPermission_1000==================end');
}, TIMEOUT)
})
/*
......@@ -207,9 +176,6 @@ describe('ActsBmsCheckPermissionTest', function () {
var data = await bundle.checkPermission(BUNDLE_NAME, permissionName)
expect(data).assertEqual(-1);
done();
setTimeout(function () {
console.info('=====================bms_checkPermission_1100==================end');
}, TIMEOUT)
})
/*
......@@ -229,9 +195,6 @@ describe('ActsBmsCheckPermissionTest', function () {
expect(data).assertEqual(-1);
done();
})
setTimeout(function () {
console.info('=====================bms_checkPermission_1200==================end');
}, TIMEOUT)
})
/*
......@@ -249,9 +212,6 @@ describe('ActsBmsCheckPermissionTest', function () {
var data = await bundle.checkPermission(bundleName, PERMISSION_ONE)
expect(data).assertEqual(-1);
done();
setTimeout(function () {
console.info('=====================bms_checkPermission_1300==================end');
}, TIMEOUT)
})
/*
......@@ -271,9 +231,6 @@ describe('ActsBmsCheckPermissionTest', function () {
expect(data).assertEqual(-1);
done();
})
setTimeout(function () {
console.info('=====================bms_checkPermission_1400==================end');
}, TIMEOUT)
})
/*
......@@ -287,9 +244,6 @@ describe('ActsBmsCheckPermissionTest', function () {
var data = await bundle.checkPermission(BUNDLE_NAME, PERMISSION_TWO)
expect(data).assertEqual(0);
done();
setTimeout(function () {
console.info('=====================bms_checkPermission_1500==================end');
}, TIMEOUT)
})
/*
......@@ -305,8 +259,5 @@ describe('ActsBmsCheckPermissionTest', function () {
expect(data).assertEqual(0);
done();
})
setTimeout(function () {
console.info('=====================bms_checkPermission_1600==================end');
}, TIMEOUT)
})
})
\ No newline at end of file
......@@ -14,11 +14,7 @@
*/
import bundle from '@ohos.bundle'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
const TIMEOUT = 3000;
describe('ActsBmsJsTest', function () {
/*
* @tc.number: bms_getJsAbility_0100
* @tc.name: test the multi js ability
......@@ -29,20 +25,43 @@ describe('ActsBmsJsTest', function () {
console.info('=====================bms_getJsAbility_0100==================');
let bundleName = 'com.example.third2';
let abilityName = 'com.example.third2.MainAbility';
await install(['/data/test/bmsThirdBundleTest2.hap']);
let data = await bundle.getBundleInfo(bundleName, 1);
expect(data.abilityInfo.length).assertEqual(1);
if(data.abilityInfo.length == 1){
console.debug('========check abilityName ========' + JSON.stringify(data.abilityInfo));
expect(data.abilityInfo[0].name).assertEqual(abilityName);
expect(data.abilityInfo[0].srcLanguage).assertEqual('js');
expect(data.abilityInfo[0].srcPath).assertEqual('');
var installer = await bundle.getBundleInstaller();
installer.install(['/data/test/bmsThirdBundleTest2.hap'], {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, onReceiveInstallEvent);
async function onReceiveInstallEvent(err, data) {
console.info('========install Finish========');
expect(typeof err).assertEqual('object');
expect(err.code).assertEqual(0);
expect(typeof data).assertEqual('object');
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
let result = await bundle.getBundleInfo(bundleName, 1);
expect(result.abilityInfo.length).assertEqual(1);
if (result.abilityInfo.length == 1) {
console.debug('========check abilityName ========' + JSON.stringify(result.abilityInfo));
expect(result.abilityInfo[0].name).assertEqual(abilityName);
expect(result.abilityInfo[0].srcLanguage).assertEqual('js');
expect(result.abilityInfo[0].srcPath).assertEqual('');
}
installer.uninstall(bundleName, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, (err, data) => {
console.info('========uninstall Finish========');
expect(err.code).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
}
await uninstall(bundleName);
done();
setTimeout(function () {
console.info('=====================bms_getJsAbility_0100==================end');
}, TIMEOUT)
})
/*
......@@ -56,24 +75,46 @@ describe('ActsBmsJsTest', function () {
var bundleName = 'com.example.third5';
let abilityName1 = 'com.example.third5.AMainAbility';
let abilityName2 = 'com.example.third5.BMainAbility';
await install(['/data/test/bmsThirdBundleTest5.hap']);
let data = await bundle.getBundleInfo(bundleName, 1)
console.debug('==========bundleInfo==========' + JSON.stringify(data))
expect(data.abilityInfo.length).assertEqual(2);
if(data.abilityInfo.length == 2){
console.debug('========check abilityName ========' + JSON.stringify(data.abilityInfo));
expect(data.abilityInfo[0].name).assertEqual(abilityName1);
expect(data.abilityInfo[0].srcLanguage).assertEqual('js');
expect(data.abilityInfo[0].srcPath).assertEqual('');
expect(data.abilityInfo[1].name).assertEqual(abilityName2);
expect(data.abilityInfo[1].srcLanguage).assertEqual('js');
expect(data.abilityInfo[1].srcPath).assertEqual('');
var installer = await bundle.getBundleInstaller();
installer.install(['/data/test/bmsThirdBundleTest5.hap'], {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, onReceiveInstallEvent);
async function onReceiveInstallEvent(err, data) {
console.info('========install Finish========');
expect(typeof err).assertEqual('object');
expect(err.code).assertEqual(0);
expect(typeof data).assertEqual('object');
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
let result = await bundle.getBundleInfo(bundleName, 1)
console.debug('==========bundleInfo==========' + JSON.stringify(result))
expect(result.abilityInfo.length).assertEqual(2);
if (result.abilityInfo.length == 2) {
console.debug('========check abilityName ========' + JSON.stringify(result.abilityInfo));
expect(result.abilityInfo[0].name).assertEqual(abilityName1);
expect(result.abilityInfo[0].srcLanguage).assertEqual('js');
expect(result.abilityInfo[0].srcPath).assertEqual('');
expect(result.abilityInfo[1].name).assertEqual(abilityName2);
expect(result.abilityInfo[1].srcLanguage).assertEqual('js');
expect(result.abilityInfo[1].srcPath).assertEqual('');
}
installer.uninstall(bundleName, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
}
await uninstall(bundleName);
done();
setTimeout(function () {
console.info('=====================bms_getJsAbility_0200==================end');
}, TIMEOUT)
})
/*
......@@ -86,20 +127,43 @@ describe('ActsBmsJsTest', function () {
console.info('=====================bms_getJsAbility_0300==================');
let bundleName = 'com.example.js';
let abilityName = 'com.example.js.MainAbility';
await install(['/data/test/bmsThirdBundleJs.hap']);
let data = await bundle.getBundleInfo(bundleName, 1);
expect(data.abilityInfo.length).assertEqual(1);
if(data.abilityInfo.length == 1){
console.debug('========check abilityName ========' + JSON.stringify(data.abilityInfo));
expect(data.abilityInfo[0].name).assertEqual(abilityName);
expect(data.abilityInfo[0].srcLanguage).assertEqual('js');
expect(data.abilityInfo[0].srcPath).assertEqual('default');
var installer = await bundle.getBundleInstaller();
installer.install(['/data/test/bmsThirdBundleJs.hap'], {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, onReceiveInstallEvent);
async function onReceiveInstallEvent(err, data) {
console.info('========install Finish========');
expect(typeof err).assertEqual('object');
expect(err.code).assertEqual(0);
expect(typeof data).assertEqual('object');
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
let result = await bundle.getBundleInfo(bundleName, 1);
expect(result.abilityInfo.length).assertEqual(1);
if (result.abilityInfo.length == 1) {
console.debug('========check abilityName ========' + JSON.stringify(result.abilityInfo));
expect(result.abilityInfo[0].name).assertEqual(abilityName);
expect(result.abilityInfo[0].srcLanguage).assertEqual('js');
expect(result.abilityInfo[0].srcPath).assertEqual('default');
}
installer.uninstall(bundleName, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, (err, data) => {
console.info('========uninstall Finish========');
expect(err.code).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
}
await uninstall(bundleName);
done();
setTimeout(function () {
console.info('=====================bms_getJsAbility_0300==================end');
}, TIMEOUT)
})
/*
......@@ -112,25 +176,8 @@ describe('ActsBmsJsTest', function () {
console.info('=====================bms_getJsAbility_0400==================');
let bundleName = 'com.example.c';
let abilityName = '.MainAbility';
await install(['/data/test/bmsThirdBundleC.hap']);
let data = await bundle.getBundleInfo(bundleName, 1);
expect(data.abilityInfo.length).assertEqual(1);
if(data.abilityInfo.length == 1){
console.debug('========check abilityName ========' + JSON.stringify(data.abilityInfo));
expect(data.abilityInfo[0].name).assertEqual(abilityName);
expect(data.abilityInfo[0].srcLanguage).assertEqual('c++');
expect(data.abilityInfo[0].srcPath).assertEqual('default/c++/');
}
await uninstall(bundleName);
done();
setTimeout(function () {
console.info('=====================bms_getJsAbility_0300==================end');
}, TIMEOUT)
})
async function install(bundlePath) {
var installer = await bundle.getBundleInstaller();
installer.install(bundlePath, {
installer.install(['/data/test/bmsThirdBundleC.hap'], {
param: {
userId: 0,
installFlag: 1,
......@@ -138,33 +185,33 @@ describe('ActsBmsJsTest', function () {
}
}, onReceiveInstallEvent);
function onReceiveInstallEvent(err, data) {
async function onReceiveInstallEvent(err, data) {
console.info('========install Finish========');
expect(typeof err).assertEqual('object');
expect(err.code).assertEqual(0);
expect(typeof data).assertEqual('object');
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
}
}
async function uninstall(bundleName)
{
var installer = await bundle.getBundleInstaller();
installer.uninstall(bundleName, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
let result = await bundle.getBundleInfo(bundleName, 1);
expect(result.abilityInfo.length).assertEqual(1);
if (result.abilityInfo.length == 1) {
console.debug('========check abilityName ========' + JSON.stringify(result.abilityInfo));
expect(result.abilityInfo[0].name).assertEqual(abilityName);
expect(result.abilityInfo[0].srcLanguage).assertEqual('c++');
expect(result.abilityInfo[0].srcPath).assertEqual('default/c++/');
}
}, onReceiveUninstallEvent);
function onReceiveUninstallEvent(err, data) {
console.info('========uninstall Finish========');
expect(typeof err).assertEqual('object');
expect(err.code).assertEqual(0);
expect(typeof data).assertEqual('object');
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
installer.uninstall(bundleName, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, (err, data) => {
console.info('========uninstall Finish========');
expect(err.code).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
}
}
})
})
\ No newline at end of file
......@@ -9,8 +9,8 @@
"kits": [
{
"test-file-name": [
"ActsBmsKitTest.hap",
"bmsThirdBundleTest1.hap"
"bmsThirdBundleTest1.hap",
"ActsBmsKitTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
......
......@@ -18,7 +18,6 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from
import featureAbility from '@ohos.ability.featureability'
import commonEvent from '@ohos.commonevent'
const TIMEOUT = 2000;
const STRESSLEVEL = 20;
const BUNDLE_NAME = 'com.example.actsbmskittest';
const PERMISSION_NAME = 'com.permission.PERMISSION_A';
......@@ -64,9 +63,6 @@ describe('ActsBmsKitTest', function () {
}
}
)
setTimeout(function () {
console.info('==================beforeAll==================end');
}, TIMEOUT)
})
/*
* @tc.number: ActsBmsKit_getAllShortcutInfo_0100
......@@ -85,9 +81,6 @@ describe('ActsBmsKitTest', function () {
break;
}
done();
setTimeout(function () {
console.info('==================ActsBmsKit_getAllShortcutInfo_0100==================end');
}, TIMEOUT)
});
/*
......@@ -112,9 +105,6 @@ describe('ActsBmsKitTest', function () {
}
})
}
setTimeout(function () {
console.info('=====================ActsBmsKit_getAllShortcutInfo_0200==================end');
}, TIMEOUT)
})
/*
......@@ -133,9 +123,6 @@ describe('ActsBmsKitTest', function () {
}
}
done();
setTimeout(function () {
console.info('=====================ActsBmsKit_checkPermission_0100==================end');
}, TIMEOUT)
})
/*
......@@ -159,9 +146,6 @@ describe('ActsBmsKitTest', function () {
}
})
}
setTimeout(function () {
console.info('=====================ActsBmsKit_checkPermission_0200==================end');
}, TIMEOUT)
})
/*
......@@ -213,9 +197,6 @@ describe('ActsBmsKitTest', function () {
count++;
});
}
setTimeout(function () {
console.debug('==========ActsBmsKit_getModuleUsageRecordTest_0200==================end');
}, TIMEOUT)
})
function checkModuleUsageRecord(data, caseName) {
console.debug('======================check ModuleUsageRecord begin==========================');
......@@ -226,21 +207,21 @@ describe('ActsBmsKitTest', function () {
console.debug('=============bundleName is=========' + JSON.stringify(data[i].bundleName));
expect(data[i].bundleName.length).assertLarger(0);
console.debug('=============appLabelId==============' + JSON.stringify(data[i].appLabelId));
expect(data[i].appLabelId).assertLarger(0);
expect(data[i].appLabelId >= 0).assertTrue();
console.debug('=============name==============' + JSON.stringify(data[i].name));
expect(data[i].name.length).assertLarger(0);
console.debug('=============labelId==============' + JSON.stringify(data[i].labelId));
expect(data[i].labelId >=0 ).assertTrue();
expect(data[i].labelId >= 0).assertTrue();
console.debug('=============descriptionId==============' + JSON.stringify(data[i].descriptionId));
expect(data[i].descriptionId).assertEqual(0);
console.debug('=============abilityName==============' + JSON.stringify(data[i].abilityName));
expect(data[i].abilityName.length).assertLarger(0);
console.debug('=============abilityLabelId==============' + JSON.stringify(data[i].abilityLabelId));
expect(data[i].abilityLabelId).assertLarger(0);
expect(data[i].abilityLabelId >= 0).assertTrue();
console.debug('===========abilityDescriptionId===========' + JSON.stringify(data[i].abilityDescriptionId));
expect(data[i].abilityDescriptionId).assertLarger(0);
expect(data[i].abilityDescriptionId >= 0).assertTrue();
console.debug('=============abilityIconId==============' + JSON.stringify(data[i].abilityIconId));
expect(data[i].abilityIconId).assertLarger(0);
expect(data[i].abilityIconId >= 0).assertTrue();
console.debug('=============launchedCount==============' + JSON.stringify(data[i].launchedCount));
expect(data[i].launchedCount).assertLarger(0);
console.debug('=============lastLaunchTime==============' + JSON.stringify(data[i].lastLaunchTime));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册