提交 1990daa1 编写于 作者: D dy

update bundlemanger ets test

Signed-off-by: Ndy <dingyao5@huawei.com>
上级 d3c65292
......@@ -46,7 +46,6 @@ export default function getAbilityLabelJsUnit() {
* @tc.level 0
*/
it('context_getAbilityLabel_test_0100', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0100] promise START');
await Utils.sleep(1000);
let mData;
var timeOldStamp = await Utils.getNowTime();
......@@ -60,6 +59,7 @@ export default function getAbilityLabelJsUnit() {
})
.catch((error) => {
console.info('[context_getAbilityLabel_test_0100] promise error is: ' + error);
expect(error).assertFail();
});
getAbilityLabelSuccess('[context_getAbilityLabel_test_0100]', mData);
done();
......@@ -72,11 +72,14 @@ export default function getAbilityLabelJsUnit() {
* @tc.level 0
*/
it('context_getAbilityLabel_test_0200', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0200] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.getAbilityLabel(BUNDLE_NAME, ABILITY_NAME, (error, data) => {
if(error){
console.error('[context_getAbilityLabel_test_0200]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0200]', timeOldStamp, timeNewStamp);
mData = data;
......@@ -96,7 +99,6 @@ export default function getAbilityLabelJsUnit() {
* @tc.level 0
*/
it('context_getAbilityLabel_test_0300', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0300] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mError;
......@@ -104,7 +106,6 @@ export default function getAbilityLabelJsUnit() {
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityLabel_test_0300] promise in ');
console.info('[context_getAbilityLabel_test_0300] promise data is: ' + JSON.stringify(data));
})
......@@ -113,6 +114,7 @@ export default function getAbilityLabelJsUnit() {
mError = error;
Utils.getDurationTime('[context_getAbilityLabel_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getAbilityLabel_test_0300] promise error is: ' + error);
expect(mError).assertEqual(1);
});
await Utils.sleep(2000);
getAbilityLabelFailure('[context_getAbilityLabel_test_0300]', mError);
......@@ -126,18 +128,19 @@ export default function getAbilityLabelJsUnit() {
* @tc.level 0
*/
it('context_getAbilityLabel_test_0400', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0400] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mError;
Bundle.getAbilityLabel(BUNDLE_NAME_ERROR, ABILITY_NAME_ERROR, (error, data) => {
if(error !== null){
console.info('[context_getAbilityLabel_test_0400] callBack error: ' + error);
expect(error).assertEqual(1);
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0400]', timeOldStamp, timeNewStamp);
mError = error;
console.info('[context_getAbilityLabel_test_0400] callBack in');
console.info('[context_getAbilityLabel_test_0400] callBack error: ' + error);
console.info('[context_getAbilityLabel_test_0400] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getAbilityLabelFailure('[context_getAbilityLabel_test_0400]', mError);
......@@ -151,7 +154,6 @@ export default function getAbilityLabelJsUnit() {
* @tc.level 0
*/
it('context_getAbilityLabel_test_0500', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0500] promise START');
await Utils.sleep(1000);
let mData;
let mError = null;
......@@ -161,48 +163,42 @@ export default function getAbilityLabelJsUnit() {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0500]', timeOldStamp, timeNewStamp);
mData = data;
expect(mData).assertFail();
console.info('[context_getAbilityLabel_test_0500] promise in ');
console.info('[context_getAbilityLabel_test_0500] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
mError = error;
console.info('[context_getAbilityLabel_test_0500] promise error is: ' + error);
});
if (mError != null) {
expect(mError).assertEqual(1);
getAbilityLabelFailure('[context_getAbilityLabel_test_0500]', mError);
} else {
getAbilityLabelSuccess('[context_getAbilityLabel_test_0500]', mData);
}
});
done();
});
/*
* @tc.number: context_getAbilityLabel_test_0600
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callbac)
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0600', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0600] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
let mError = null;
Bundle.getAbilityLabel(OTHER_BUNDLE_NAME, OTHER_ABILITY_NAME, (error, data) => {
mError = error;
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0600]', timeOldStamp, timeNewStamp);
mData = data;
mError = error;
console.info('[context_getAbilityLabel_test_0600] callBack in');
if(mError !== null){
console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error);
expect(mError).assertEqual(1);
getAbilityLabelFailure('[context_getAbilityLabel_test_0600]', mError);
}
console.info('[context_getAbilityLabel_test_0600] callBack in');
console.info('[context_getAbilityLabel_test_0600] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
if (mError != null) {
getAbilityLabelFailure('[context_getAbilityLabel_test_0600]', mError);
} else {
getAbilityLabelSuccess('[context_getAbilityLabel_test_0600]', mData);
}
done();
});
......@@ -210,11 +206,10 @@ export default function getAbilityLabelJsUnit() {
/*
* @tc.number: context_getAbilityLabel_test_0700
* @tc.name: getAbilityLabel : Gets the specified ability label
* @tc.desc: Check the return value of the interface (by callbac)
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getAbilityLabel_test_0700', 0, async function (done) {
console.info('[context_getAbilityLabel_test_0700] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mError;
......@@ -222,6 +217,10 @@ export default function getAbilityLabelJsUnit() {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getAbilityLabel_test_0700]', timeOldStamp, timeNewStamp);
mError = error;
if(mError !== null){
console.info('[context_getAbilityLabel_test_0600] callBack error: ' + error);
expect(mError).assertEqual(1);
}
console.info('[context_getAbilityLabel_test_0700] callBack in');
console.info('[context_getAbilityLabel_test_0700] callBack error: ' + error);
console.info('[context_getAbilityLabel_test_0700] callBack data is:' + JSON.stringify(data));
......@@ -235,14 +234,14 @@ export default function getAbilityLabelJsUnit() {
console.log(msg + ' start ' + JSON.stringify(data));
console.log(msg + ' result ' + data);
expect(typeof (data)).assertEqual('string');
expect(data).assertEqual("entry_MainAbility");
}
function getAbilityLabelFailure(msg, error) {
console.log(msg + ' Failure ');
console.log(msg + ' error ' + JSON.stringify(error));
expect(typeof (error)).assertEqual('number');
expect(error).assertEqual(1)
}
})
}
\ No newline at end of file
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index.ets';
import Utils from './Utils';
import Bundle from '@ohos.bundle';
const BUNDLE_NAME = 'com.open.harmony.packagemag'
const OTHER_BUNDLE_NAME = 'com.ohos.acepackage'
const BUNDLE_NAME_ERROR = 'com.ohos.acepackage.error'
export default function bundleGidsJsUnit() {
describe('context_getBundleGids_test', function () {
beforeEach(async function (done) {
console.info('context_getBundleGids_test before each called');
done()
});
afterEach(async function () {
await Utils.sleep(2000);
console.info('context_getBundleGids_test after each called');
});
/*
* @tc.number: context_getBundleGids_test_0100
* @tc.name: getBundleGids : Gets the lists of bundle with gids
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getBundleGids_test_0100', 0, async function (done) {
console.info('[context_getBundleGids_test_0100] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
await Bundle.getBundleGids(BUNDLE_NAME)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getBundleGids_test_0100]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getBundleGids_test_0100] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
console.info('[context_getBundleGids_test_0100] promise error is: ' + error);
});
getGidsSuccess('[context_getBundleGids_test_0100]', mData);
done();
});
/*
* @tc.number: context_getBundleGids_test_0200
* @tc.name: getBundleGids : Gets the lists of bundle with gids
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getBundleGids_test_0200', 0, async function (done) {
console.info('[context_getBundleGids_test_0200] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.getBundleGids(BUNDLE_NAME, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getBundleGids_test_0200]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getBundleGids_test_0200] callBack in');
console.info('[context_getBundleGids_test_0200] callBack error: ' + error);
console.info('[context_getBundleGids_test_0200] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getGidsSuccess('[context_getBundleGids_test_0200]', mData);
done();
});
/*
* @tc.number: context_getBundleGids_test_0300
* @tc.name: getBundleGids : Gets the lists of bundle with gids
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getBundleGids_test_0300', 0, async function (done) {
console.info('[context_getBundleGids_test_0300] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mError;
await Bundle.getBundleGids(BUNDLE_NAME_ERROR)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getBundleGids_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getBundleGids_test_0300] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
var timeNewStamp = Utils.getNowTime();
mError = error;
Utils.getDurationTime('[context_getBundleGids_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_getBundleGids_test_0300] promise error is: ' + error);
});
getGidsFailure('[context_getBundleGids_test_0300]', mError);
done();
});
/*
* @tc.number: context_getBundleGids_test_0400
* @tc.name: getBundleGids : Gets the lists of bundle with gids
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getBundleGids_test_0400', 0, async function (done) {
console.info('[context_getBundleGids_test_0400] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mError;
Bundle.getBundleGids(BUNDLE_NAME_ERROR, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getBundleGids_test_0400]', timeOldStamp, timeNewStamp);
mError = error;
console.info('[context_getBundleGids_test_0400] callBack in');
console.info('[context_getBundleGids_test_0400] callBack error: ' + error);
console.info('[context_getBundleGids_test_0400] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
getGidsFailure('[context_getBundleGids_test_0400]', mError);
done();
});
/*
* @tc.number: context_getBundleGids_test_0500
* @tc.name: getBundleGids : Gets the lists of bundle with gids
* @tc.desc: Check the return value of the interface (by promise)
* @tc.level 0
*/
it('context_getBundleGids_test_0500', 0, async function (done) {
console.info('[context_getBundleGids_test_0500] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
let mError;
await Bundle.getBundleGids(OTHER_BUNDLE_NAME)
.then((data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getBundleGids_test_0500]', timeOldStamp, timeNewStamp);
mData = data;
console.info('[context_getBundleGids_test_0500] promise data is: ' + JSON.stringify(data));
})
.catch((error) => {
mError = error;
console.info('[context_getBundleGids_test_0500] promise error is: ' + error);
});
if (mError != null) {
getGidsFailure('[context_getBundleGids_test_0500]', mError);
} else {
getGidsSuccess('[context_getBundleGids_test_0500]', mData);
}
done();
});
/*
* @tc.number: context_getBundleGids_test_0600
* @tc.name: getBundleGids : Gets the lists of bundle with gids
* @tc.desc: Check the return value of the interface (by callback)
* @tc.level 0
*/
it('context_getBundleGids_test_0600', 0, async function (done) {
console.info('[context_getBundleGids_test_0600] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
let mError = null;
Bundle.getBundleGids(OTHER_BUNDLE_NAME, (error, data) => {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_getBundleGids_test_0600]', timeOldStamp, timeNewStamp);
mData = data;
mError = error;
console.info('[context_getBundleGids_test_0600] callBack in');
console.info('[context_getBundleGids_test_0600] callBack error: ' + error);
console.info('[context_getBundleGids_test_0600] callBack data is:' + JSON.stringify(data));
});
await Utils.sleep(2000);
if (mError != null) {
getGidsFailure('[context_getBundleGids_test_0600]', mError);
} else {
getGidsSuccess('[context_getBundleGids_test_0600]', mData);
}
done();
});
function getGidsSuccess(msg, data) {
console.log(msg + ' start ' + JSON.stringify(data));
for (var j = 0; j < data.length; j++) {
console.log(msg + 'data[' + j + '] : ' + data[j]);
expect((data[j] > 0)).assertEqual(true);
}
expect(Array.isArray(data)).assertEqual(true);
}
function getGidsFailure(msg, error) {
console.log(msg + ' Failure ');
expect(typeof (error)).assertEqual('number');
}
})
}
\ No newline at end of file
......@@ -43,7 +43,6 @@ export default function GetabilityInfo() {
* @tc.level 0
*/
it('bundle_GetabilityInfo_test_0100', 0, async function (done) {
console.info('[bundle_GetabilityInfo_test_0100] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
bundleManager.getAbilityInfo(bundleName, abilityName)
......@@ -55,6 +54,7 @@ export default function GetabilityInfo() {
expect(typeof (data)).assertEqual("object");
}).catch((error) => {
console.error('[bundle_GetabilityInfo_test_0100]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
})
var promise = await bundleManager.getAbilityInfo(bundleName, abilityName);
checkAbilityInfo(promise);
......@@ -68,7 +68,6 @@ export default function GetabilityInfo() {
* @tc.level 0
*/
it('bundle_GetabilityInfo_test_0200', 0, async function (done) {
console.info('[bundle_GetabilityInfo_test_0200] START');
await Utils.sleep(1000);
let mData;
var timeOldStamp = await Utils.getNowTime();
......@@ -77,6 +76,7 @@ export default function GetabilityInfo() {
Utils.getDurationTime('bundle_GetabilityInfo_test_0200', timeOldStamp, timeNewStamp)
if (err) {
console.error('[bundle_GetabilityInfo_test_0200]Operation failed. Cause: ' + JSON.stringify(err));
expect(err).assertFail();
}
console.info('[bundle_GetabilityInfo_test_0200] getApplicationInfo callback data is: ' + JSON.stringify(data));
mData = data;
......@@ -93,7 +93,6 @@ export default function GetabilityInfo() {
* @tc.level 0
*/
it('bundle_GetabilityInfo_test_0300', 0, async function (done) {
console.info('[bundle_GetabilityInfo_test_0300] START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let err = null
......@@ -125,7 +124,6 @@ export default function GetabilityInfo() {
* @tc.level 0
*/
it('bundle_GetabilityInfo_test_0400', 0, async function (done) {
console.info('[bundle_GetabilityInfo_test_0400] START');
let error1;
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
......@@ -152,7 +150,6 @@ export default function GetabilityInfo() {
* @tc.level 0
*/
it('bundle_GetabilityInfo_test_0500', 0, async function (done) {
console.info('[bundle_GetabilityInfo_test_0500] START');
let error
await bundleManager.getAbilityInfo(bundleName, abilityName1).then((data) => {
console.info('[bundle_GetabilityInfo_test_0500] START' + JSON.stringify(data));
......@@ -173,7 +170,6 @@ export default function GetabilityInfo() {
*/
let bundleName2 = "";
it('bundle_GetabilityInfo_test_0600', 0, async function (done) {
console.info('[bundle_GetabilityInfo_test_0600] START');
let error1;
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
......@@ -198,49 +194,17 @@ export default function GetabilityInfo() {
* @param data
*/
function checkAbilityInfo(data) {
console.log("checkAbilityInfo start " + JSON.stringify(data));
console.log("checkAbilityInfo bundleName : " + data.bundleName);
console.log("checkAbilityInfo name : " + data.name);
console.log("checkAbilityInfo label : " + data.label);
console.log("checkAbilityInfo description : " + data.description);
console.log("checkAbilityInfo icon : " + data.icon);
console.log("checkAbilityInfo descriptionId : " + data.descriptionId);
console.log("checkAbilityInfo iconId : " + data.iconId);
console.log("checkAbilityInfo moduleName : " + data.moduleName);
console.log("checkAbilityInfo process : " + data.process);
console.log("checkAbilityInfo targetAbility : " + data.targetAbility);
console.log("checkAbilityInfo backgroundModes : " + data.backgroundModes);
console.log("checkAbilityInfo isVisible : " + data.isVisible);
console.log("checkAbilityInfo formEnabled : " + data.formEnabled);
console.log("checkAbilityInfo type : " + data.type)
console.log("checkAbilityInfo orientation : " + data.orientation);
console.log("checkAbilityInfo launchMode : " + data.launchMode);
console.log("checkAbilityInfo permissions length : " + data.permissions.length);
for (var j = 0; j < data.permissions.length; j++) {
console.log("getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]);
}
console.log("checkAbilityInfo deviceTypes length : " + data.deviceTypes.length);
for (var k = 0; k < data.deviceTypes.length; k++) {
console.log("getAbilityInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]);
}
console.log("checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length);
for (var i = 0; i < data.deviceCapabilities.length; i++) {
console.log("getAbilityInfo data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]);
}
console.log("checkAbilityInfo readPermission : " + data.readPermission);
console.log("checkAbilityInfo writePermission : " + data.writePermission);
console.log("checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth);
console.log("checkAbilityInfo uri : " + data.uri);
console.log("checkAbilityInfo labelId : " + data.labelId);
console.log("checkAbilityInfo subType : " + data.subType);
expect(typeof (data.bundleName)).assertEqual("string");
expect(data.bundleName).assertEqual("com.open.harmony.packagemag")
expect(typeof (data.name)).assertEqual("string");
expect(data.name).assertEqual("com.open.harmony.packagemag.MainAbility");
expect(data.label).assertEqual("$string:entry_MainAbility");
expect(typeof (data.label)).assertEqual("string");
expect(data.description).assertEqual("$string:mainability_description");
expect(typeof (data.description)).assertEqual("string");
expect(data.icon).assertEqual("$media:icon");
expect(typeof (data.icon)).assertEqual("string");
expect(data.srcPath).assertEqual("MainAbility");
expect(typeof (data.srcPath)).assertEqual("string");
expect(data.srcLanguage).assertEqual("ets");
expect(typeof (data.srcLanguage)).assertEqual("string");
......@@ -249,14 +213,12 @@ export default function GetabilityInfo() {
expect(Array.isArray(data.deviceCapabilities)).assertEqual(true);
expect(data.deviceTypes[0]).assertEqual("phone");
expect(typeof (data.process)).assertEqual("string");
expect(data.process).assertEqual("");
expect(typeof (data.uri)).assertEqual("string");
expect(data.uri).assertEqual("");
expect(typeof (data.uri)).assertEqual("string");
expect(data.moduleName).assertEqual("entry");
expect(typeof (data.moduleName)).assertEqual("string");
expect(typeof (data.applicationInfo)).assertEqual("object");
expect(data.bundleName).assertEqual("com.open.harmony.packagemag")
expect(data.name).assertEqual("com.open.harmony.packagemag.MainAbility");
checkApplicationInfo(data.applicationInfo);
console.log("---checkAbilityInfo End--- ");
}
......@@ -266,67 +228,35 @@ export default function GetabilityInfo() {
* @param data
*/
function checkApplicationInfo(info) {
console.log("checkApplicationInfo getApplicationInfo : " + JSON.stringify(info));
console.log("checkApplicationInfo name : " + info.name);
console.log("checkApplicationInfo description : " + info.description);
console.log("checkApplicationInfo descriptionId : " + info.descriptionId);
console.log("checkApplicationInfo systemApp : " + info.systemApp);
console.log("checkApplicationInfo enabled : " + info.enabled);
console.log("checkApplicationInfo label : " + info.label);
console.log("checkApplicationInfo labelId : " + info.labelId);
console.log("checkApplicationInfo icon : " + info.icon);
console.log("checkApplicationInfo process : " + info.process);
console.log("checkApplicationInfo supportedModes : " + info.supportedModes);
console.log("checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length);
for (var j = 0; j < info.moduleSourceDirs.length; j++) {
console.log("checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]);
}
console.log("checkApplicationInfo permissions length : " + info.permissions.length);
for (var j = 0; j < info.permissions.length; j++) {
console.log("checkApplicationInfo info.permissions[" + j + "] : " + info.permissions[j]);
}
console.log("checkApplicationInfo moduleInfos length : " + info.moduleInfos.length);
for (var j = 0; j < info.moduleInfos.length; j++) {
console.log("checkApplicationInfo info.moduleInfos[" + j + "].moduleName : " + info.moduleInfos[j].moduleName);
console.log("checkApplicationInfo info.moduleInfos[" + j + "].moduleSourceDir : " + info.moduleInfos[j].moduleSourceDir);
}
console.log("checkApplicationInfo entryDir : " + info.entryDir);
expect(typeof (info)).assertEqual("object")
expect(typeof (info.name)).assertEqual("string")
expect(info.name).assertEqual("com.open.harmony.packagemag");
expect(typeof (info.codePath)).assertEqual("string")
expect(info.accessTokenId > 0).assertTrue()
expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag");
expect(typeof (info.accessTokenId)).assertEqual("number")
expect(info.accessTokenId > 0).assertTrue()
expect(typeof (info.description)).assertEqual("string")
expect(info.description).assertEqual("$string:mainability_description")
expect(info.descriptionId > 0).assertTrue()
expect(typeof (info.descriptionId)).assertEqual("number")
expect(info.descriptionId > 0).assertTrue()
expect(typeof (info.icon)).assertEqual("string")
expect(info.icon).assertEqual("$media:icon")
expect(info.iconId > 0).assertTrue()
expect(typeof (info.iconId)).assertEqual("number")
expect(info.iconId > 0).assertTrue()
expect(typeof (info.label)).assertEqual("string")
expect(info.label).assertEqual("$string:entry_MainAbility")
expect(info.labelId > 0).assertTrue()
expect(typeof (info.labelId)).assertEqual("number")
expect(info.labelId > 0).assertTrue()
expect(info.systemApp).assertEqual(true)
expect(typeof (info.entryDir)).assertEqual("string")
expect(info.supportedModes).assertEqual(0)
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag");
expect(typeof (info.supportedModes)).assertEqual("number")
expect(info.supportedModes).assertEqual(0)
expect(typeof (info.process)).assertEqual("string")
expect(info.process).assertEqual("")
expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true);
expect(info.entryDir)
.assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag");
expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag");
expect(Array.isArray(info.permissions)).assertEqual(true);
expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag");
expect(info.moduleSourceDirs[0])
.assertEqual("/data/app/el1/bundle/public/com.open.harmony.packagemag/com.open.harmony.packagemag");
expect(info.enabled).assertEqual(true);
expect(info.flags).assertEqual(0);
expect(info.uid > 0).assertTrue()
expect(info.entityType).assertEqual("unspecified");
expect(info.removable).assertEqual(true);
expect(info.accessTokenId > 0).assertTrue()
}
/**
......@@ -334,49 +264,17 @@ export default function GetabilityInfo() {
* @param data
*/
function checkAbilityInfo_other(data) {
console.log("checkAbilityInfo start " + JSON.stringify(data));
console.log("checkAbilityInfo bundleName : " + data.bundleName);
console.log("checkAbilityInfo name : " + data.name);
console.log("checkAbilityInfo label : " + data.label);
console.log("checkAbilityInfo description : " + data.description);
console.log("checkAbilityInfo icon : " + data.icon);
console.log("checkAbilityInfo descriptionId : " + data.descriptionId);
console.log("checkAbilityInfo iconId : " + data.iconId);
console.log("checkAbilityInfo moduleName : " + data.moduleName);
console.log("checkAbilityInfo process : " + data.process);
console.log("checkAbilityInfo targetAbility : " + data.targetAbility);
console.log("checkAbilityInfo backgroundModes : " + data.backgroundModes);
console.log("checkAbilityInfo isVisible : " + data.isVisible);
console.log("checkAbilityInfo formEnabled : " + data.formEnabled);
console.log("checkAbilityInfo type : " + data.type)
console.log("checkAbilityInfo orientation : " + data.orientation);
console.log("checkAbilityInfo launchMode : " + data.launchMode);
console.log("checkAbilityInfo permissions length : " + data.permissions.length);
for (var j = 0; j < data.permissions.length; j++) {
console.log("getAbilityInfo data.permissions[" + j + "] : " + data.permissions[j]);
}
console.log("checkAbilityInfo deviceTypes length : " + data.deviceTypes.length);
for (var k = 0; k < data.deviceTypes.length; k++) {
console.log("getAbilityInfo data.deviceTypes[" + k + "] : " + data.deviceTypes[k]);
}
console.log("checkAbilityInfo deviceCapabilities length : " + data.deviceCapabilities.length);
for (var i = 0; i < data.deviceCapabilities.length; i++) {
console.log("getAbilityInfo data.deviceCapabilities[" + i + "] : " + data.deviceCapabilities[i]);
}
console.log("checkAbilityInfo readPermission : " + data.readPermission);
console.log("checkAbilityInfo writePermission : " + data.writePermission);
console.log("checkAbilityInfo defaultFormWidth : " + data.defaultFormWidth);
console.log("checkAbilityInfo uri : " + data.uri);
console.log("checkAbilityInfo labelId : " + data.labelId);
console.log("checkAbilityInfo subType : " + data.subType);
expect(typeof (data.bundleName)).assertEqual("string");
expect(data.bundleName).assertEqual("com.ohos.acecollaboration");
expect(typeof (data.name)).assertEqual("string");
expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility");
expect(data.label).assertEqual("$string:entry_MainAbility");
expect(typeof (data.label)).assertEqual("string");
expect(data.description).assertEqual("$string:mainability_description");
expect(typeof (data.description)).assertEqual("string");
expect(data.icon).assertEqual("$media:icon");
expect(typeof (data.icon)).assertEqual("string");
expect(data.srcPath).assertEqual("MainAbility");
expect(typeof (data.srcPath)).assertEqual("string");
expect(data.srcLanguage).assertEqual("ets");
expect(typeof (data.srcLanguage)).assertEqual("string");
......@@ -385,16 +283,14 @@ export default function GetabilityInfo() {
expect(Array.isArray(data.deviceCapabilities)).assertEqual(true);
expect(data.deviceTypes[0]).assertEqual("phone");
expect(typeof (data.process)).assertEqual("string");
expect(data.process).assertEqual("");
expect(typeof (data.uri)).assertEqual("string");
expect(data.uri).assertEqual("");
expect(typeof (data.uri)).assertEqual("string");
expect(data.moduleName).assertEqual("entry");
expect(typeof (data.moduleName)).assertEqual("string");
expect(typeof (data.applicationInfo)).assertEqual("object");
expect(data.bundleName).assertEqual("com.ohos.acecollaboration");
expect(data.name).assertEqual("com.ohos.acecollaboration.MainAbility");
checkApplicationInfo_other(data.applicationInfo);
console.log("---checkAbilityInfo End--- ");
console.log("---checkAbilityInfo_other End--- ");
}
/**
......@@ -402,67 +298,35 @@ export default function GetabilityInfo() {
* @param data
*/
function checkApplicationInfo_other(info) {
console.log("checkApplicationInfo getApplicationInfo : " + JSON.stringify(info));
console.log("checkApplicationInfo name : " + info.name);
console.log("checkApplicationInfo description : " + info.description);
console.log("checkApplicationInfo descriptionId : " + info.descriptionId);
console.log("checkApplicationInfo systemApp : " + info.systemApp);
console.log("checkApplicationInfo enabled : " + info.enabled);
console.log("checkApplicationInfo label : " + info.label);
console.log("checkApplicationInfo labelId : " + info.labelId);
console.log("checkApplicationInfo icon : " + info.icon);
console.log("checkApplicationInfo process : " + info.process);
console.log("checkApplicationInfo supportedModes : " + info.supportedModes);
console.log("checkApplicationInfo moduleSourceDirs length : " + info.moduleSourceDirs.length);
for (var j = 0; j < info.moduleSourceDirs.length; j++) {
console.log("checkApplicationInfo info.moduleSourceDirs[" + j + "] : " + info.moduleSourceDirs[j]);
}
console.log("checkApplicationInfo permissions length : " + info.permissions.length);
for (var j = 0; j < info.permissions.length; j++) {
console.log("checkApplicationInfo info.permissions[" + j + "] : " + info.permissions[j]);
}
console.log("checkApplicationInfo moduleInfos length : " + info.moduleInfos.length);
for (var j = 0; j < info.moduleInfos.length; j++) {
console.log("checkApplicationInfo info.moduleInfos[" + j + "].moduleName : " + info.moduleInfos[j].moduleName);
console.log("checkApplicationInfo info.moduleInfos[" + j + "].moduleSourceDir : " + info.moduleInfos[j].moduleSourceDir);
}
console.log("checkApplicationInfo entryDir : " + info.entryDir);
expect(typeof (info)).assertEqual("object")
expect(typeof (info.name)).assertEqual("string")
expect(info.name).assertEqual("com.ohos.acecollaboration");
expect(typeof (info.codePath)).assertEqual("string")
expect(info.accessTokenId > 0).assertTrue()
expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration");
expect(typeof (info.accessTokenId)).assertEqual("number")
expect(info.accessTokenId > 0).assertTrue()
expect(typeof (info.description)).assertEqual("string")
expect(info.description).assertEqual("$string:mainability_description")
expect(info.descriptionId > 0).assertTrue()
expect(typeof (info.descriptionId)).assertEqual("number")
expect(info.descriptionId > 0).assertTrue()
expect(typeof (info.icon)).assertEqual("string")
expect(info.icon).assertEqual("$media:icon")
expect(info.iconId > 0).assertTrue()
expect(typeof (info.iconId)).assertEqual("number")
expect(info.iconId > 0).assertTrue()
expect(typeof (info.label)).assertEqual("string")
expect(info.label).assertEqual("$string:entry_MainAbility")
expect(info.labelId > 0).assertTrue()
expect(typeof (info.labelId)).assertEqual("number")
expect(info.labelId > 0).assertTrue()
expect(info.systemApp).assertEqual(true)
expect(typeof (info.entryDir)).assertEqual("string")
expect(info.supportedModes).assertEqual(0)
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration/com.ohos.acecollaboration");
expect(typeof (info.supportedModes)).assertEqual("number")
expect(info.supportedModes).assertEqual(0)
expect(typeof (info.process)).assertEqual("string")
expect(info.process).assertEqual("")
expect(Array.isArray(info.moduleSourceDirs)).assertEqual(true);
expect(info.entryDir)
.assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration/com.ohos.acecollaboration");
expect(info.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration/com.ohos.acecollaboration");
expect(Array.isArray(info.permissions)).assertEqual(true);
expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration");
expect(info.moduleSourceDirs[0])
.assertEqual("/data/app/el1/bundle/public/com.ohos.acecollaboration/com.ohos.acecollaboration");
expect(info.enabled).assertEqual(true);
expect(info.flags).assertEqual(0);
expect(info.uid > 0).assertTrue()
expect(info.entityType).assertEqual("unspecified");
expect(info.removable).assertEqual(true);
expect(info.accessTokenId > 0).assertTrue()
}
});
}
\ No newline at end of file
......@@ -51,7 +51,6 @@ export default function isAbilityEnabledETSUnit() {
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0100', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0100] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
......@@ -65,6 +64,7 @@ export default function isAbilityEnabledETSUnit() {
})
.catch((error) => {
console.info('[context_isAbilityEnabled_test_0100] promise error is: ' + error);
expect(error).assertFail();
});
getAbilityEnabledSuccess('[context_isAbilityEnabled_test_0100]', mData);
done();
......@@ -77,11 +77,14 @@ export default function isAbilityEnabledETSUnit() {
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0200', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0200] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isAbilityEnabled(ABILITY, (error, data) => {
if(error){
console.error('[context_isAbilityEnabled_test_0200]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0200]', timeOldStamp, timeNewStamp);
mData = data;
......@@ -101,7 +104,6 @@ export default function isAbilityEnabledETSUnit() {
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0300', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0300] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
......@@ -117,6 +119,7 @@ export default function isAbilityEnabledETSUnit() {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_isAbilityEnabled_test_0300] promise error is: ' + error);
expect(error).assertFail();
});
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0300]', mData);
done();
......@@ -129,12 +132,15 @@ export default function isAbilityEnabledETSUnit() {
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0400', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0400] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
console.info('[context_isAbilityEnabled_test_0400] start c++ callBack ');
Bundle.isAbilityEnabled(ABILITY_ERROR, (error, data) => {
if(error){
console.error('[context_isAbilityEnabled_test_0400]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_isAbilityEnabled_test_0400] callBack in');
......@@ -157,15 +163,14 @@ export default function isAbilityEnabledETSUnit() {
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0500', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0500] promise START');
await Utils.sleep(1000);
await Bundle.setAbilityEnabled(ABILITY, true)
.then((data) => {
console.info('[context_isAbilityEnabled_test_0500] set enable true ');
console.info('[context_isAbilityEnabled_test_0500] set enable true data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isAbilityEnabled_test_0500] set enable true error is: ' + error);
expect(error).assertFail();
})
var timeOldStamp = await Utils.getNowTime();
......@@ -180,6 +185,7 @@ export default function isAbilityEnabledETSUnit() {
})
.catch((error) => {
console.info('[context_isAbilityEnabled_test_0500] promise error is: ' + error);
expect(error).assertFail();
});
getAbilityEnabledTrue('[context_isAbilityEnabled_test_0500]', mData);
done();
......@@ -192,7 +198,6 @@ export default function isAbilityEnabledETSUnit() {
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0600', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0600] promise START');
await Utils.sleep(1000);
await Bundle.setAbilityEnabled(ABILITY, false)
......@@ -201,6 +206,7 @@ export default function isAbilityEnabledETSUnit() {
console.info('[context_isAbilityEnabled_test_0600] set enable false data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isAbilityEnabled_test_0600] set enable false error is: ' + error);
expect(error).assertFail();
})
var timeOldStamp = await Utils.getNowTime();
......@@ -215,6 +221,7 @@ export default function isAbilityEnabledETSUnit() {
})
.catch((error) => {
console.info('[context_isAbilityEnabled_test_0600] promise error is: ' + error);
expect(error).assertFail();
});
getAbilityEnabledFalse('[context_isAbilityEnabled_test_0600]', mData);
done();
......@@ -227,20 +234,23 @@ export default function isAbilityEnabledETSUnit() {
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0700', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0700] callBack START');
await Utils.sleep(1000);
await Bundle.setAbilityEnabled(ABILITY, true)
.then((data) => {
console.info('[context_isAbilityEnabled_test_0700] set enable true ');
console.info('[context_isAbilityEnabled_test_0700] set enable true data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isAbilityEnabled_test_0700] set enable true error is: ' + error);
expect(error).assertFail();
})
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isAbilityEnabled(ABILITY, (error, data) => {
if(error){
console.error('[context_isAbilityEnabled_test_0700]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0700]', timeOldStamp, timeNewStamp);
mData = data;
......@@ -260,20 +270,23 @@ export default function isAbilityEnabledETSUnit() {
* @tc.level 0
*/
it('context_isAbilityEnabled_test_0800', 0, async function (done) {
console.info('[context_isAbilityEnabled_test_0800] callBack START');
await Utils.sleep(1000);
await Bundle.setAbilityEnabled(ABILITY, false)
.then((data) => {
console.info('[context_isAbilityEnabled_test_0800] set enable false ');
console.info('[context_isAbilityEnabled_test_0800] set enable false data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isAbilityEnabled_test_0800] set enable false error is: ' + error);
expect(error).assertFail();
})
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isAbilityEnabled(ABILITY, (error, data) => {
if(error){
console.error('[context_isAbilityEnabled_test_0800]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isAbilityEnabled_test_0800]', timeOldStamp, timeNewStamp);
mData = data;
......@@ -303,11 +316,5 @@ export default function isAbilityEnabledETSUnit() {
expect(data).assertEqual(false);
}
function getAbilityEnabledFailure(msg, error) {
console.log(msg + ' Failure ');
console.log(msg + ' error : ' + error);
expect(typeof (error)).assertEqual('number')
}
})
}
\ No newline at end of file
......@@ -39,7 +39,6 @@ export default function IsApplicationEnabledETSUnit() {
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0100', 0, async function (done) {
console.info('[context_isApplicationEnabled_test_0100] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
......@@ -53,6 +52,7 @@ export default function IsApplicationEnabledETSUnit() {
})
.catch((error) => {
console.info('[context_isApplicationEnabled_test_0100] promise error is: ' + error);
expect(error).assertFail();
});
getApplicationEnabledSuccess('[context_isApplicationEnabled_test_0100]', mData);
done();
......@@ -65,11 +65,14 @@ export default function IsApplicationEnabledETSUnit() {
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0200', 0, async function (done) {
console.info('[context_isApplicationEnabled_test_0200] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => {
if(error){
console.error('[context_isApplicationEnabled_test_0200]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0200]', timeOldStamp, timeNewStamp);
mData = data;
......@@ -89,7 +92,6 @@ export default function IsApplicationEnabledETSUnit() {
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0300', 0, async function (done) {
console.info('[context_isApplicationEnabled_test_0300] promise START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
......@@ -105,6 +107,7 @@ export default function IsApplicationEnabledETSUnit() {
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0300]', timeOldStamp, timeNewStamp);
console.info('[context_isApplicationEnabled_test_0300] promise error is: ' + error);
expect(error).assertFail();
});
getApplicationEnabledFalse('[context_isApplicationEnabled_test_0300]', mData);
done();
......@@ -117,11 +120,14 @@ export default function IsApplicationEnabledETSUnit() {
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0400', 0, async function (done) {
console.info('[context_isApplicationEnabled_test_0400] callBack START');
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isApplicationEnabled(BUNDLE_NAME_ERROR, (error, data) => {
if(error){
console.error('[context_isApplicationEnabled_test_0400]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0400]', timeOldStamp, timeNewStamp);
mData = data;
......@@ -142,14 +148,13 @@ export default function IsApplicationEnabledETSUnit() {
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0500', 0, async function (done) {
console.info('[context_isApplicationEnabled_test_0500] promise START');
await Bundle.setApplicationEnabled(BUNDLE_NAME, true)
.then((data) => {
console.info('[context_isApplicationEnabled_test_0500] set enable true ');
console.info('[context_isApplicationEnabled_test_0500] set enable true data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isApplicationEnabled_test_0500] set enable true error is: ' + error);
expect(error).assertFail();
});
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
......@@ -164,6 +169,7 @@ export default function IsApplicationEnabledETSUnit() {
})
.catch((error) => {
console.info('[context_isApplicationEnabled_test_0500] promise error is: ' + error);
expect(error).assertFail();
});
getApplicationEnabledTrue('[context_isApplicationEnabled_test_0500]', mData);
done();
......@@ -176,20 +182,23 @@ export default function IsApplicationEnabledETSUnit() {
* @tc.level 0
*/
it('context_isApplicationEnabled_test_0600', 0, async function (done) {
console.info('[context_isApplicationEnabled_test_0600] callBack START');
await Bundle.setApplicationEnabled(BUNDLE_NAME, false)
.then((data) => {
console.info('[context_isApplicationEnabled_test_0600] set enable false ');
console.info('[context_isApplicationEnabled_test_0600] set enable false data is: ' + JSON.stringify(data));
}).catch((error) => {
console.info('[context_isApplicationEnabled_test_0600] set enable false error is: ' + error);
expect(error).assertFail();
});
await Utils.sleep(1000);
var timeOldStamp = await Utils.getNowTime();
let mData;
Bundle.isApplicationEnabled(BUNDLE_NAME, (error, data) => {
if(error){
console.error('[context_isApplicationEnabled_test_0600]Operation failed. Cause: ' + JSON.stringify(error));
expect(error).assertFail();
}
var timeNewStamp = Utils.getNowTime();
Utils.getDurationTime('[context_isApplicationEnabled_test_0600]', timeOldStamp, timeNewStamp);
mData = data;
......
......@@ -49,20 +49,19 @@ export default function applicationBundleJsunit() {
* @tc.level 0
*/
it(TAG_TEST_0100_001, 0, async function (done) {
console.info(TAG_TEST_0100_001 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
var startTime = await Utils.getNowTime();
let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100)
.catch((error) => {
console.info(TAG_TEST_0100_001 + 'UserId promise error is: ' + error);
expect(error).assertFail();
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_001, startTime, endTime);
console.info(TAG_TEST_0100_001 + ' UserId promise data is: ' + JSON.stringify(data));
commonTest(TAG_TEST_0100_001, data)
expectData(TAG_TEST_0100_001, data)
getApplicationInfoSuccess(TAG_TEST_0100_001, data);
done();
console.log('------------------ ' + TAG_TEST_0100_001 + ' end -------------------');
});
/**
......@@ -72,20 +71,19 @@ export default function applicationBundleJsunit() {
* @tc.level 0
*/
it(TAG_TEST_0100_002, 0, async function (done) {
console.info(TAG_TEST_0100_002 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
var startTime = await Utils.getNowTime();
let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_ALL_APPLICATION_INFO, USER_ID_100)
.catch((error) => {
console.info(TAG_TEST_0100_002 + 'UserId promise error is: ' + error);
expect(error).assertFail();
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_002, startTime, endTime);
console.info(TAG_TEST_0100_002 + ' UserId promise data is: ' + JSON.stringify(data));
commonTest(TAG_TEST_0100_002, data)
expectData(TAG_TEST_0100_002, data)
getApplicationInfoSuccess(TAG_TEST_0100_002, data);
done();
console.log('------------------ ' + TAG_TEST_0100_002 + ' end -------------------');
});
/**
......@@ -95,20 +93,19 @@ export default function applicationBundleJsunit() {
* @tc.level 0
*/
it(TAG_TEST_0100_003, 0, async function (done) {
console.info(TAG_TEST_0100_003 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
var startTime = await Utils.getNowTime();
let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE, USER_ID_100)
.catch((error) => {
console.info(TAG_TEST_0100_003 + 'UserId promise error is: ' + error);
expect(error).assertFail();
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_003, startTime, endTime);
console.info(TAG_TEST_0100_003 + ' UserId promise data is: ' + JSON.stringify(data));
commonTest(TAG_TEST_0100_003, data)
expectData(TAG_TEST_0100_003, data)
getApplicationInfoSuccess(TAG_TEST_0100_003, data);
done();
console.log('------------------ ' + TAG_TEST_0100_003 + ' end -------------------');
});
......@@ -119,20 +116,19 @@ export default function applicationBundleJsunit() {
* @tc.level 0
*/
it(TAG_TEST_0200_001, 0, async function (done) {
console.info(TAG_TEST_0200_001 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
var startTime = await Utils.getNowTime();
let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION)
.catch((error) => {
console.info(TAG_TEST_0200_001 + 'onUserId promise error is: ' + error);
expect(error).assertFail();
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_001, startTime, endTime);
console.info(TAG_TEST_0200_001 + ' onUserId promise data is: ' + JSON.stringify(data));
commonTest(TAG_TEST_0200_001, data)
expectData(TAG_TEST_0200_001, data)
getApplicationInfoSuccess(TAG_TEST_0200_001, data);
done();
console.log('------------------ ' + TAG_TEST_0200_001 + ' end -------------------');
});
/**
......@@ -142,20 +138,19 @@ export default function applicationBundleJsunit() {
* @tc.level 0
*/
it(TAG_TEST_0200_002, 0, async function (done) {
console.info(TAG_TEST_0200_002 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
var startTime = await Utils.getNowTime();
let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_ALL_APPLICATION_INFO)
.catch((error) => {
console.info(TAG_TEST_0200_002 + 'onUserId promise error is: ' + error);
expect(error).assertFail();
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_002, startTime, endTime);
console.info(TAG_TEST_0200_002 + ' onUserId promise data is: ' + JSON.stringify(data));
commonTest(TAG_TEST_0200_002, data)
expectData(TAG_TEST_0200_002, data)
getApplicationInfoSuccess(TAG_TEST_0200_002, data);
done();
console.log('------------------ ' + TAG_TEST_0200_002 + ' end -------------------');
});
/**
......@@ -165,20 +160,19 @@ export default function applicationBundleJsunit() {
* @tc.level 0
*/
it(TAG_TEST_0200_003, 0, async function (done) {
console.info(TAG_TEST_0200_003 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
var startTime = await Utils.getNowTime();
let data = await Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE)
.catch((error) => {
console.info(TAG_TEST_0200_003 + 'onUserId promise error is: ' + error);
expect(error).assertFail();
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_003, startTime, endTime);
console.info(TAG_TEST_0200_003 + ' onUserId promise data is: ' + JSON.stringify(data));
commonTest(TAG_TEST_0200_003, data)
expectData(TAG_TEST_0200_003, data)
getApplicationInfoSuccess(TAG_TEST_0200_003, data);
done();
console.log('------------------ ' + TAG_TEST_0200_003 + ' end -------------------');
});
/**
......@@ -188,7 +182,6 @@ export default function applicationBundleJsunit() {
* @tc.level 0
*/
it(TAG_TEST_0300_001, 0, async function (done) {
console.info(TAG_TEST_0300_001 + 'callBack START');
await Utils.sleep(SLEEP_TIME_1000);
let datas;
var startTime = await Utils.getNowTime();
......@@ -196,6 +189,10 @@ export default function applicationBundleJsunit() {
(error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0300_001, startTime, endTime);
if(error){
expect(error).assertFail();
console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error);
}
console.info(TAG_TEST_0300_001 + 'UserId callBack in');
console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error);
console.info(TAG_TEST_0300_001 + 'UserId callBack data is:' + JSON.stringify(data));
......@@ -203,10 +200,9 @@ export default function applicationBundleJsunit() {
});
await Utils.sleep(2000);
console.info(TAG_TEST_0300_001 + 'UserId callBack datas is:' + JSON.stringify(datas));
commonTest(TAG_TEST_0300_001, datas)
expectData(TAG_TEST_0300_001, datas)
getApplicationInfoSuccess(TAG_TEST_0300_001, datas);
done();
console.log('------------------ ' + TAG_TEST_0300_001 + ' end -------------------');
});
/**
......@@ -216,12 +212,15 @@ export default function applicationBundleJsunit() {
* @tc.level 0
*/
it(TAG_TEST_0400_001, 0, async function (done) {
console.info(TAG_TEST_0400_001 + 'callBack START');
let datas;
var startTime = await Utils.getNowTime();
Bundle.getAllApplicationInfo(Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, (error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0400_001, startTime, endTime);
if(error){
expect(error).assertFail();
console.info(TAG_TEST_0400_001 + 'UserId callBack error: ' + error);
}
console.info(TAG_TEST_0400_001 + 'noUserId callBack in');
console.info(TAG_TEST_0400_001 + 'noUserId callBack error: ' + error);
console.info(TAG_TEST_0400_001 + 'noUserId callBack data is:' + JSON.stringify(data));
......@@ -229,10 +228,9 @@ export default function applicationBundleJsunit() {
});
await Utils.sleep(2000);
console.info(TAG_TEST_0400_001 + 'noUserId callBack datas is:' + JSON.stringify(datas));
commonTest(TAG_TEST_0400_001, datas)
expectData(TAG_TEST_0400_001, datas)
getApplicationInfoSuccess(TAG_TEST_0400_001, datas);
done();
console.log('------------------ ' + TAG_TEST_0400_001 + ' end -------------------');
});
/**
......@@ -242,21 +240,22 @@ export default function applicationBundleJsunit() {
* @tc.level 0
*/
it(TAG_TEST_0500_001, 0, async function (done) {
console.info(TAG_TEST_0500_001 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
let errors;
var startTime = await Utils.getNowTime();
let data = await Bundle.getAllApplicationInfo('0')
await Bundle.getAllApplicationInfo('0')
.then((data) => {
console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data);
expect(data).assertFail();
})
.catch((error) => {
console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error);
errors = error;
expect(errors).assertEqual(1);
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime);
console.info(TAG_TEST_0500_001 + ' noUserId promise data is: ' + JSON.stringify(data));
expect(errors).assertEqual(1);
done();
console.log('------------------ ' + TAG_TEST_0500_001 + ' end -------------------');
});
/**
......@@ -266,68 +265,24 @@ export default function applicationBundleJsunit() {
* @tc.level 0
*/
it(TAG_TEST_0500_002, 0, async function (done) {
console.info(TAG_TEST_0500_002 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
let errors;
var startTime = await Utils.getNowTime();
let data = await Bundle.getAllApplicationInfo('0', USER_ID_100)
await Bundle.getAllApplicationInfo('0', USER_ID_100)
.then((data) => {
console.info(TAG_TEST_0500_002 + 'noUserId promise data is: ' + data);
expect(data).assertFail();
})
.catch((error) => {
console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error);
errors = error;
expect(errors).assertEqual(1);
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime);
console.info(TAG_TEST_0500_002 + ' UserId promise data is: ' + JSON.stringify(data));
expect(errors).assertEqual(1);
done();
console.log('------------------ ' + TAG_TEST_0500_002 + ' end -------------------');
});
/**
* 打印单个属性
* @param msg log信息
* @param data 数据源
*/
function commonTest(msg, data) {
console.info(msg + 'commonTest data length [' + data.length + ']');
for (var i = 0; i < data.length; i++) {
console.info(msg + i + ' [ + data[i] + ] :' + JSON.stringify(data[i]));
console.info(msg + '[' + i + '].name:' + data[i].name);
console.info(msg + '[' + i + '].codePath:' + data[i].codePath);
console.info(msg + '[' + i + '].accessTokenId:' + data[i].accessTokenId);
console.info(msg + '[' + i + '].description:' + data[i].description);
console.info(msg + '[' + i + '].descriptionId:' + data[i].descriptionId);
console.info(msg + '[' + i + '].icon:' + data[i].icon);
console.info(msg + '[' + i + '].iconId:' + data[i].iconId);
console.info(msg + '[' + i + '].label:' + data[i].label);
console.info(msg + '[' + i + '].labelId:' + data[i].labelId);
console.info(msg + '[' + i + '].systemApp:' + data[i].systemApp);
console.info(msg + '[' + i + '].supportedModes:' + data[i].supportedModes);
console.info(msg + '[' + i + '].process:' + data[i].process);
console.info(msg + '[' + i + '].entryDir:' + data[i].entryDir);
console.info('getAllApplicationInfo Async permissions length [' + data[i].permissions.length + ']');
for (var j = 0; j < data[i].permissions.length; j++) {
console.info(msg + '[' + i + ']permissions[' + j + ']:' + data[i].permissions[j]);
}
console.info('getAllApplicationInfo Async moduleSourceDirs length [' + data[i].moduleSourceDirs.length + ']');
for (var l = 0; l < data[i].moduleSourceDirs.length; l++) {
console.info(msg + '[' + i + ']moduleSourceDirs[' + l + ']:' + data[i].moduleSourceDirs[l]);
}
console.info('getAllApplicationInfo Async moduleInfos length [' + data[i].moduleInfos.length + ']');
for (var k = 0; k < data[i].moduleInfos.length; k++) {
console.info(msg + '[' + i + ']moduleInfos[' + k + ']moduleName:' + data[i].moduleInfos[k].moduleName);
console.info(msg + '[' + i + ']moduleInfos[' + k + ']moduleSourceDir:' + data[i].moduleInfos[k].moduleSourceDir);
}
console.info(msg + '[' + i + '].metaData:' + data[i].metaData);
console.info(msg + '[' + i + '].metadata:' + data[i].metadata);
console.info(msg + '[' + i + '].enabled:' + data[i].enabled);
console.info(msg + '[' + i + '].flags:' + data[i].flags);
console.info(msg + '[' + i + '].uid:' + data[i].uid);
console.info(msg + '[' + i + '].entityType:' + data[i].entityType);
console.info(msg + '[' + i + '].removable:' + data[i].removable);
}
expectData(msg, data);
}
/**
* expect属性
......@@ -349,6 +304,7 @@ export default function applicationBundleJsunit() {
expect(typeof (data[i].labelId)).assertEqual('number');
expect(typeof (data[i].systemApp)).assertEqual('boolean')
expect(typeof (data[i].supportedModes)).assertEqual('number');
expect(typeof (data[i].process)).assertEqual('string');
expect(typeof (data[i].entryDir)).assertEqual('string');
expect(typeof (data[i].metaData)).assertEqual('object');
expect(typeof (data[i].metadata)).assertEqual('object');
......@@ -382,14 +338,20 @@ export default function applicationBundleJsunit() {
expect(data[i].icon).assertEqual('$media:icon');
expect(data[i].iconId > 0).assertEqual(true);
expect(data[i].label).assertEqual('$string:entry_MainAbility');
expect(data[i].accessTokenId > 0).assertEqual(true);
if (data[i].label !== 0) {
expect(data[i].labelId > 0).assertEqual(true);
}
};
if (data[i].uid !== 0) {
expect(data[i].uid > 0).assertEqual(true);
};
expect(data[i].systemApp).assertEqual(true);
expect(data[i].supportedModes).assertEqual(0);
expect(data[i].process).assertEqual("");
expect(data[i].entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' +
'/com.open.harmony.packagemag');
expect(data[i].enabled).assertEqual(true);
expect(data[i].flags).assertEqual(0);
expect(data[i].entityType).assertEqual('unspecified');
expect(data[i].removable).assertEqual(true);
expect(data[i].moduleInfos[0].moduleName).assertEqual('entry');
......
......@@ -56,23 +56,18 @@ export default function applicationBundleJsunit() {
it(TAG_TEST_0100_001, 0, async function (done) {
console.info(TAG_TEST_0100_001 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
let errors;
var startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
USER_ID_100)
.catch((error) => {
console.info(TAG_TEST_0100_001 + 'UserId promise error is: ' + error);
errors = error;
expect(error).assertFail();
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_001, startTime, endTime);
console.info(TAG_TEST_0100_001 + ' UserId promise data is: ' + JSON.stringify(data));
if (1 === errors) {
expect(errors).assertEqual(1);
} else {
commonTest(TAG_TEST_0100_001, data);
expectData(TAG_TEST_0100_001, data);
getApplicationInfoSuccess(TAG_TEST_0100_001, data);
}
done();
console.log('------------------ ' + TAG_TEST_0100_001 + ' end -------------------');
});
......@@ -86,22 +81,17 @@ export default function applicationBundleJsunit() {
it(TAG_TEST_0100_002, 0, async function (done) {
console.info(TAG_TEST_0100_002 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
let errors;
var startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_ALL_APPLICATION_INFO, USER_ID_100)
.catch((error) => {
console.info(TAG_TEST_0100_002 + 'UserId promise error is: ' + error);
errors = error;
expect(error).assertFail();
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_002, startTime, endTime);
console.info(TAG_TEST_0100_002 + ' UserId promise data is: ' + JSON.stringify(data));
if (1 === errors) {
expect(errors).assertEqual(1);
} else {
commonTest(TAG_TEST_0100_002, data);
getApplicationInfoSuccess(TAG_TEST_0100_002, data);
}
expectData(TAG_TEST_0100_002, data);
getApplicationInfoSuccess_plus(TAG_TEST_0100_002, data);
done();
console.log('------------------ ' + TAG_TEST_0100_002 + ' end -------------------');
});
......@@ -115,26 +105,21 @@ export default function applicationBundleJsunit() {
it(TAG_TEST_0100_003, 0, async function (done) {
console.info(TAG_TEST_0100_003 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
let errors;
var startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE,
USER_ID_100)
.catch((error) => {
console.info(TAG_TEST_0100_003 + 'UserId promise error is: ' + error);
errors = error;
expect(error).assertFail();
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0100_003, startTime, endTime);
console.info(TAG_TEST_0100_003 + ' UserId promise data is: ' + JSON.stringify(data));
if (1 === errors) {
expect(errors).assertEqual(1);
} else {
commonTest(TAG_TEST_0100_003, data);
expectData(TAG_TEST_0100_003, data);
if ('' === data.name) {
getApplicationInfoFial(TAG_TEST_0100_003, data);
getApplicationInfoFail(TAG_TEST_0100_003, data);
} else {
getApplicationInfoSuccess(TAG_TEST_0100_003, data);
}
getApplicationInfoSuccess_plus(TAG_TEST_0100_003, data);
}
done();
console.log('------------------ ' + TAG_TEST_0100_003 + ' end -------------------');
......@@ -149,23 +134,18 @@ export default function applicationBundleJsunit() {
*/
it(TAG_TEST_0200_001, 0, async function (done) {
console.info(TAG_TEST_0200_001 + 'promise START');
let errors;
await Utils.sleep(SLEEP_TIME_1000);
var startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION)
.catch((error) => {
console.info(TAG_TEST_0200_001 + 'onUserId promise error is: ' + error);
errors = error;
expect(error).assertFail();
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_001, startTime, endTime);
console.info(TAG_TEST_0200_001 + ' onUserId promise data is: ' + JSON.stringify(data));
if (1 === errors) {
expect(errors).assertEqual(1);
} else {
commonTest(TAG_TEST_0200_001, data);
expectData(TAG_TEST_0200_001, data);
getApplicationInfoSuccess(TAG_TEST_0200_001, data);
}
done();
console.log('------------------ ' + TAG_TEST_0200_001 + ' end -------------------');
});
......@@ -179,22 +159,17 @@ export default function applicationBundleJsunit() {
it(TAG_TEST_0200_002, 0, async function (done) {
console.info(TAG_TEST_0200_002 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
let errors;
var startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_ALL_APPLICATION_INFO)
.catch((error) => {
console.info(TAG_TEST_0200_002 + 'onUserId promise error is: ' + error);
errors = error;
expect(error).assertFail();
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_002, startTime, endTime);
console.info(TAG_TEST_0200_002 + ' onUserId promise data is: ' + JSON.stringify(data));
if (1 === errors) {
expect(errors).assertEqual(1);
} else {
commonTest(TAG_TEST_0200_002, data);
getApplicationInfoSuccess(TAG_TEST_0200_002, data);
}
expectData(TAG_TEST_0200_002, data);
getApplicationInfoSuccess_plus(TAG_TEST_0200_002, data);
done();
console.log('------------------ ' + TAG_TEST_0200_002 + ' end -------------------');
});
......@@ -208,22 +183,17 @@ export default function applicationBundleJsunit() {
it(TAG_TEST_0200_003, 0, async function (done) {
console.info(TAG_TEST_0200_003 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
let errors;
var startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_DISABLE)
.catch((error) => {
console.info(TAG_TEST_0200_003 + 'onUserId promise error is: ' + error);
errors = error;
expect(error).assertFail();
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0200_003, startTime, endTime);
console.info(TAG_TEST_0200_003 + ' onUserId promise data is: ' + JSON.stringify(data));
if (1 === errors) {
expect(errors).assertEqual(1);
} else {
commonTest(TAG_TEST_0200_003, data);
getApplicationInfoSuccess(TAG_TEST_0200_003, data);
}
expectData(TAG_TEST_0200_003, data);
getApplicationInfoSuccess_plus(TAG_TEST_0200_003, data);
done();
console.log('------------------ ' + TAG_TEST_0200_003 + ' end -------------------');
});
......@@ -244,20 +214,19 @@ export default function applicationBundleJsunit() {
USER_ID_100, (error, data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0300_001, startTime, endTime);
console.info(TAG_TEST_0300_001 + 'UserId callBack in');
console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error);
errors = error;
if(errors){
expect(errors).assertFail();
console.info(TAG_TEST_0300_001 + 'UserId callBack error: ' + error);
}
console.info(TAG_TEST_0300_001 + 'UserId callBack in');
console.info(TAG_TEST_0300_001 + 'UserId callBack data is:' + JSON.stringify(data));
datas = data;
});
await Utils.sleep(2000);
console.info(TAG_TEST_0300_001 + 'UserId callBack data is: ' + JSON.stringify(datas));
if (1 === errors) {
expect(errors).assertEqual(1);
} else {
commonTest(TAG_TEST_0300_001, datas);
expectData(TAG_TEST_0300_001, datas);
getApplicationInfoSuccess(TAG_TEST_0300_001, datas);
}
done();
console.log('------------------ ' + TAG_TEST_0300_001 + ' end -------------------');
});
......@@ -275,21 +244,20 @@ export default function applicationBundleJsunit() {
var startTime = await Utils.getNowTime();
Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, (error, data) => {
var endTime = Utils.getNowTime();
errors = error;
if(errors){
expect(errors).assertFail();
console.info(TAG_TEST_0400_001 + 'UserId callBack error: ' + error);
}
Utils.getDurationTime(TAG_TEST_0400_001, startTime, endTime);
console.info(TAG_TEST_0400_001 + 'noUserId callBack in');
console.info(TAG_TEST_0400_001 + 'noUserId callBack error: ' + error);
errors = error;
console.info(TAG_TEST_0400_001 + 'noUserId callBack data is:' + JSON.stringify(data));
datas = data;
});
await Utils.sleep(2000);
console.info(TAG_TEST_0400_001 + 'noUserId callBack data is: ' + JSON.stringify(datas));
if (1 === errors) {
expect(errors).assertEqual(1);
} else {
commonTest(TAG_TEST_0400_001, datas);
expectData(TAG_TEST_0400_001, datas);
getApplicationInfoSuccess(TAG_TEST_0400_001, datas);
}
done();
console.log('------------------ ' + TAG_TEST_0400_001 + ' end -------------------');
});
......@@ -303,19 +271,18 @@ export default function applicationBundleJsunit() {
it(TAG_TEST_0500_001, 0, async function (done) {
console.info(TAG_TEST_0500_001 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
let errors;
var startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo('', 0)
await Bundle.getApplicationInfo('', 0)
.then((data) => {
console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data);
expect(data).assertFail();
})
.catch((error) => {
console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error);
errors = error;
expect(error).assertEqual(1);
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime);
console.info(TAG_TEST_0500_001 + ' noUserId promise data is: ' + JSON.stringify(data));
if (1 === errors) {
expect(errors).assertEqual(1);
}
done();
console.log('------------------ ' + TAG_TEST_0500_001 + ' end -------------------');
});
......@@ -329,19 +296,18 @@ export default function applicationBundleJsunit() {
it(TAG_TEST_0500_002, 0, async function (done) {
console.info(TAG_TEST_0500_002 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
let errors;
var startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo('', '0', USER_ID_100)
await Bundle.getApplicationInfo('', '0', USER_ID_100)
.then((data) => {
console.info(TAG_TEST_0500_002 + 'UserId promise data is: ' + data);
expect(data).assertFail();
})
.catch((error) => {
console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error);
errors = error;
expect(error).assertEqual(1);
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime);
console.info(TAG_TEST_0500_002 + ' UserId promise data is: ' + JSON.stringify(data));
if (1 === errors) {
expect(errors).assertEqual(1);
}
done();
console.log('------------------ ' + TAG_TEST_0500_002 + ' end -------------------');
});
......@@ -355,24 +321,21 @@ export default function applicationBundleJsunit() {
it(TAG_TEST_0600_001, 0, async function (done) {
console.info(TAG_TEST_0600_001 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
let errors;
let errors
var startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER,
await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER,
Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION)
.then((data) => {
console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise data is: ' + data);
expect(data).assertFail();
})
.catch((error) => {
console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise error is: ' + error);
errors = error;
errors = error
expect(errors).assertEqual(1);
});
console.info(TAG_TEST_0600_001 + ' other bundleName noUserId promise errors is: ' + JSON.stringify(errors));
console.info(TAG_TEST_0600_001 + ' other bundleName noUserId promise data is: ' + JSON.stringify(data));
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime);
if (1 === errors) {
expect(errors).assertEqual(1);
} else {
commonTest(TAG_TEST_0600_001, data);
getApplicationInfoOtherSuccess(TAG_TEST_0600_001, data);
}
done();
console.log('------------------ ' + TAG_TEST_0600_001 + ' end -------------------');
});
......@@ -386,25 +349,21 @@ export default function applicationBundleJsunit() {
it(TAG_TEST_0600_002, 0, async function (done) {
console.info(TAG_TEST_0600_002 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
let errors;
var startTime = await Utils.getNowTime();
let data =
let errors
await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION,
USER_ID_100)
.then((data) => {
console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise data is: ' + data);
expect(data).assertFail();
})
.catch((error) => {
console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise error is: ' + error);
errors = error;
errors = error
expect(errors).assertEqual(1);
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_002, startTime, endTime);
console.info(TAG_TEST_0600_002 + ' other bundleName UserId promise errors is: ' + JSON.stringify(errors));
console.info(TAG_TEST_0600_002 + ' other bundleName UserId promise data is: ' + JSON.stringify(data));
if (1 === errors) {
expect(errors).assertEqual(1);
} else {
commonTest(TAG_TEST_0600_002, data);
getApplicationInfoOtherSuccess(TAG_TEST_0600_002, data);
}
done();
console.log('------------------ ' + TAG_TEST_0600_002 + ' end -------------------');
});
......@@ -418,66 +377,24 @@ export default function applicationBundleJsunit() {
it(TAG_TEST_0600_003, 0, async function (done) {
console.info(TAG_TEST_0600_003 + 'promise START');
await Utils.sleep(SLEEP_TIME_1000);
let errors;
var startTime = await Utils.getNowTime();
let data = await Bundle.getApplicationInfo(BUNDLE_NAME, 0)
await Bundle.getApplicationInfo(BUNDLE_NAME, 0)
.then((data) => {
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_003, startTime, endTime);
console.info(TAG_TEST_0600_003 + 'noUserId promise data is: ' + data);
expect(typeof (data)).assertEqual("object");
expectData(TAG_TEST_0600_003, data);
getApplicationInfoSuccess_plus(TAG_TEST_0600_003, data);
})
.catch((error) => {
console.info(TAG_TEST_0600_003 + 'noUserId promise error is: ' + error);
errors = error;
expect(error).assertFail();
});
var endTime = Utils.getNowTime();
Utils.getDurationTime(TAG_TEST_0600_003, startTime, endTime);
console.info(TAG_TEST_0600_003 + ' noUserId promise data is: ' + JSON.stringify(data));
if (1 === errors) {
expect(errors).assertEqual(1);
} else {
commonTest(TAG_TEST_0600_003, data);
getApplicationInfoSuccess(TAG_TEST_0600_003, data);
}
done();
console.log('------------------ ' + TAG_TEST_0600_003 + ' end -------------------');
});
/**
* 打印单和expect个属性
* @param msg log信息
* @param data 数据源
*/
function commonTest(msg, data) {
console.log(msg + ' commonTest start ' + JSON.stringify(data));
console.log(msg + ' name : ' + data.name);
console.log(msg + ' codePath : ' + data.codePath);
console.log(msg + ' accessTokenId : ' + data.accessTokenId);
console.log(msg + ' description : ' + data.description);
console.log(msg + ' descriptionId : ' + data.descriptionId);
console.log(msg + ' icon : ' + data.icon);
console.log(msg + ' iconId : ' + data.iconId);
console.log(msg + ' label : ' + data.label);
console.log(msg + ' labelId : ' + data.labelId);
console.log(msg + ' systemApp : ' + data.systemApp);
console.log(msg + ' supportedModes : ' + data.supportedModes);
console.log(msg + ' entryDir : ' + data.entryDir);
console.log(msg + ' metaData : ' + data.metaData);
console.log(msg + ' metadata : ' + data.metadata);
console.log(msg + ' enabled : ' + data.enabled);
console.log(msg + ' flags : ' + data.flags);
console.log(msg + ' uid : ' + data.uid);
console.log(msg + ' removable : ' + data.removable);
console.log(msg + ' permissions length : ' + data.permissions.length);
for (var j = 0; j < data.permissions.length; j++) {
console.log('getApplicationInfo0001 data.permissions[' + j + '] : ' + data.permissions[j]);
}
console.log(msg + ' moduleSourceDirs length : ' + data.moduleSourceDirs.length);
for (var i = 0; i < data.moduleSourceDirs.length; i++) {
console.log('getApplicationInfo0001 data.moduleSourceDirs[' + i + '] : ' + data.moduleSourceDirs[i]);
}
console.log(msg + ' moduleInfos length : ' + data.moduleInfos.length);
for (var k = 0; k < data.moduleInfos.length; k++) {
console.log('getApplicationInfo0001 data.moduleInfos[' + k + '] : ' + data.moduleInfos[k].moduleName);
console.log('getApplicationInfo0001 data.moduleInfos[' + k + '] : ' + data.moduleInfos[k].moduleSourceDir);
}
expectData(msg, data);
}
/**
* expect属性
......@@ -497,6 +414,7 @@ export default function applicationBundleJsunit() {
expect(typeof (data.labelId)).assertEqual('number');
expect(typeof (data.systemApp)).assertEqual('boolean')
expect(typeof (data.supportedModes)).assertEqual('number');
expect(typeof (data.process)).assertEqual('string');
expect(typeof (data.entryDir)).assertEqual('string');
expect(typeof (data.metaData)).assertEqual('object');
expect(typeof (data.metadata)).assertEqual('object');
......@@ -518,14 +436,18 @@ export default function applicationBundleJsunit() {
function getApplicationInfoSuccess(msg, data) {
expect(data.name).assertEqual('com.open.harmony.packagemag');
expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag');
expect(data.accessTokenId > 0).assertEqual(true);
expect(data.description).assertEqual('$string:mainability_description');
// expect(data.descriptionId).assertEqual(16777217);
expect(data.descriptionId > 0).assertEqual(true);
expect(data.icon).assertEqual('$media:icon');
// expect(data.iconId).assertEqual(16777218);
expect(data.iconId > 0).assertEqual(true);
expect(data.uid > 0).assertEqual(true);
expect(data.label).assertEqual('$string:entry_MainAbility');
// expect(data.labelId).assertEqual(16777216);
expect(data.labelId > 0).assertEqual(true);
expect(data.systemApp).assertEqual(true);
expect(data.supportedModes).assertEqual(0);
expect(data.flags).assertEqual(0);
expect(data.process).assertEqual("");
expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' +
'/com.open.harmony.packagemag');
expect(data.enabled).assertEqual(true);
......@@ -536,6 +458,9 @@ export default function applicationBundleJsunit() {
'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data.permissions[0]).assertEqual("ohos.permission.CHANGE_ABILITY_ENABLED_STATE");
expect(data.permissions[1]).assertEqual("ohos.permission.GET_BUNDLE_INFO");
expect(data.permissions[2]).assertEqual("ohos.permission.GET_BUNDLE_INFO_PRIVILEGED");
console.log(msg + ' end ' + JSON.stringify(data));
}
......@@ -544,7 +469,40 @@ export default function applicationBundleJsunit() {
* @param msg log信息
* @param data 数据源
*/
function getApplicationInfoFial(msg, data) {
function getApplicationInfoSuccess_plus(msg, data) {
expect(data.name).assertEqual('com.open.harmony.packagemag');
expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag');
expect(data.accessTokenId > 0).assertEqual(true);
expect(data.description).assertEqual('$string:mainability_description');
expect(data.descriptionId > 0).assertEqual(true);
expect(data.icon).assertEqual('$media:icon');
expect(data.iconId > 0).assertEqual(true);
expect(data.uid > 0).assertEqual(true);
expect(data.label).assertEqual('$string:entry_MainAbility');
expect(data.labelId > 0).assertEqual(true);
expect(data.systemApp).assertEqual(true);
expect(data.supportedModes).assertEqual(0);
expect(data.flags).assertEqual(0);
expect(data.process).assertEqual("");
expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' +
'/com.open.harmony.packagemag');
expect(data.enabled).assertEqual(true);
expect(data.entityType).assertEqual('unspecified');
expect(data.removable).assertEqual(true);
expect(data.moduleInfos[0].moduleName).assertEqual('entry');
expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' +
'com.open.harmony.packagemag/com.open.harmony.packagemag');
console.log(msg + ' end ' + JSON.stringify(data));
}
/**
* expect属性值
* @param msg log信息
* @param data 数据源
*/
function getApplicationInfoFail(msg, data) {
expect(data.name).assertEqual('');
expect(data.codePath).assertEqual('');
expect(data.description).assertEqual('');
......@@ -561,35 +519,5 @@ export default function applicationBundleJsunit() {
expect(data.removable).assertEqual(true);
console.log(msg + ' end ' + JSON.stringify(data));
}
/**
* expect属性值
* @param msg log信息
* @param data 数据源
*/
function getApplicationInfoOtherSuccess(msg, data) {
expect(data.name).assertEqual('com.ohos.acepackage');
expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.ohos.acepackage');
expect(data.description).assertEqual('$string:description_mainability');
expect(data.descriptionId > 0).assertEqual(true);
expect(data.icon).assertEqual('$media:icon');
expect(data.iconId > 0).assertEqual(true);
expect(data.label).assertEqual('$string:entry_MainAbility');
expect(data.labelId > 0).assertEqual(true);
expect(data.systemApp).assertEqual(true);
expect(data.supportedModes).assertEqual(0);
expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.ohos.acepackage' +
'/com.ohos.acepackage');
expect(data.enabled).assertEqual(true);
expect(data.entityType).assertEqual('unspecified');
expect(data.removable).assertEqual(true);
expect(data.moduleInfos[0].moduleName).assertEqual('entry');
expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' +
'com.ohos.acepackage/com.ohos.acepackage');
expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' +
'com.ohos.acepackage/com.ohos.acepackage');
console.log(msg + ' end ' + JSON.stringify(data));
}
});
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册