提交 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);
expect(mError).assertEqual(1);
getAbilityLabelFailure('[context_getAbilityLabel_test_0500]', mError);
});
if (mError != null) {
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;
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 error: ' + error);
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
......@@ -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');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册