提交 3d211a97 编写于 作者: R r00559040

xts update

Signed-off-by: Nr00559040 <ry.renyi@huawei.com>
上级 44b25e27
/*
* 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 bundle from '@ohos.bundle'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit'
const BUNDLE_PATH1 = '/data/test/bmsThirdBundleTest1.hap';
const BUNDLE_PATH2 = '/data/test/bmsThirdBundleTest2.hap';
const BUNDLE_PATH3 = '/data/test/bmsThirdBundleTest3.hap';
const BUNDLE_PATH4 = '/data/test/bmsThirdBundleTest4.hap';
const BUNDLE_PATH5 = '/data/test/bmsThirdBundleTest5.hap';
const BUNDLE_PATH6 = '/data/test/bmsThirdBundleTest6.hap';
const BUNDLE_PATHUPDATE = '/data/test/bmsThirdBundleTestA1.hap';
const SYSTEM_PATH = '/data/test/bmsSystemBundleTest2.hap';
const SYSTEM_FEATURE_PATH = '/data/test/bmsSystemBundleTest2Feature.hap';
const SYSTEM_UPDATE_PATH = '/data/test/bmsSystemBundleTest2Update.hap';
const BUNDLE_NAME1 = 'com.example.third1';
const BUNDLE_NAME2 = 'com.example.third2';
const BUNDLE_NAME4 = 'com.example.third4';
const BUNDLE_NAME5 = 'com.example.third5';
const BUNDLE_NAME6 = 'com.example.third6';
const SYSTEM_NAME = 'com.example.system2';
const NUM_ONE = 1;
const NUM_TWO = 2;
const NUM_THREE = 3;
const NUM_FOUR = 4;
const NUM_NINE = 9;
let dataTransfer = 1;
let audioPlayback = 2;
let audioRecording = 4;
let location = 8;
let bluetoothInteraction = 16;
let multiDeviceConnection = 32;
let wifiInteraction = 64;
let voip = 128;
let taskKeeping = 256;
describe('ActsBmsGetBackGroundModes', function () {
/*
* @tc.number: bms_backGroundModes_0100
* @tc.name: Get the backgroundModes information of the application through queryAbilityByWant
* @tc.desc: Get the information of the background modes from multi-ability application
*/
it('bms_backGroundModes_0100', 0, async function (done) {
console.info('=====================bms_backGroundModes_0100==================');
var bundlePath = [BUNDLE_PATH5]
var installer = await bundle.getBundleInstaller();
installer.install(bundlePath, {
userId: 0,
installFlag: 1,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
var dataInfos = await bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME5,
action: 'action.system.home',
entities: ['entity.system.home'],
}, bundle.BundleFlag.GET_BUNDLE_DEFAULT, 0)
let queryResult = 0
for (let infoCount = 0; infoCount < dataInfos.length; infoCount++){
if(dataInfos[infoCount].name == "com.example.third5.MainAbilityA"){
expect(dataInfos[infoCount].backgroundModes).assertEqual(dataTransfer + audioPlayback + audioRecording +
location + bluetoothInteraction + multiDeviceConnection + wifiInteraction + voip + taskKeeping);
queryResult++
}
if(dataInfos[infoCount].name == "com.example.third5.MainAbilityB"){
expect(dataInfos[infoCount].backgroundModes).assertEqual(dataTransfer + voip);
queryResult++
}
}
expect(queryResult).assertEqual(NUM_TWO);
installer.uninstall(BUNDLE_NAME5, {
userId: 0,
installFlag: 1,
isKeepData: false
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
})
})
/*
* @tc.number: bms_backGroundModes_0200
* @tc.name: Get the backgroundModes information of the application through queryAbilityByWant
* @tc.desc: Get all background modes information, and each ability of the application
* contains one of the background mode
*/
it('bms_backGroundModes_0200', 0, async function (done) {
console.info('=====================bms_backGroundModes_0200==================');
var bundlePath = [BUNDLE_PATH6]
var installer = await bundle.getBundleInstaller();
installer.install(bundlePath, {
userId: 0,
installFlag: 1,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
var dataInfos = await bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME6,
abilityName: '',
action: 'action.system.home',
entities: ['entity.system.home']
}, bundle.BundleFlag.GET_BUNDLE_DEFAULT, 0)
expect(dataInfos.length).assertEqual(NUM_NINE);
for (let i = 0, len = dataInfos.length; i < len; i++) {
expect(dataInfos[i].backgroundModes).assertEqual(1 << i);
console.info("==========dataInfos[i].backgroundModes=========" + dataInfos[i].backgroundModes);
console.info("==========dataInfos[1].name=========" + dataInfos[i].name);
}
installer.uninstall(BUNDLE_NAME6, {
userId: 0,
installFlag: 1,
isKeepData: false
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
})
})
/*
* @tc.number: bms_backGroundModes_0300
* @tc.name: Get the backgroundModes information of the application through queryAbilityByWant
* @tc.desc: Read the backgroundModes information of the app's ability and replace invalid attributes
*/
it('bms_backGroundModes_0300', 0, async function (done) {
console.info('=====================bms_backGroundModes_0300==================');
var bundlePath = [BUNDLE_PATH2]
var installer = await bundle.getBundleInstaller();
installer.install(bundlePath, {
userId: 0,
installFlag: 1,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
var dataInfos = await bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME2,
abilityName: 'com.example.third2.MainAbilityA',
action: 'action.system.home',
entities: ['entity.system.home']
}, bundle.BundleFlag.GET_BUNDLE_DEFAULT, 0)
expect(dataInfos.length).assertEqual(NUM_ONE);
expect(dataInfos[0].name).assertEqual("com.example.third2.MainAbilityA")
expect(dataInfos[0].backgroundModes).assertEqual(audioPlayback + audioRecording + location
+ bluetoothInteraction + multiDeviceConnection + wifiInteraction + voip + taskKeeping)
installer.uninstall(BUNDLE_NAME2, {
userId: 0,
installFlag: 1,
isKeepData: false
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
})
})
/*
* @tc.number: bms_backGroundModes_0400
* @tc.name: Get the backgroundModes information of the application through queryAbilityByWant
* @tc.desc: Read the backgroundModes information of the app's ability and replace invalid attributes
*/
it('bms_backGroundModes_0400', 0, async function (done) {
console.info('=====================bms_backGroundModes_0400==================');
var bundlePath1 = [BUNDLE_PATH4]
var installer = await bundle.getBundleInstaller();
installer.install(bundlePath1, {
userId: 0,
installFlag: 1,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
var dataInfos = await bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME4,
abilityName: 'com.example.third4.MainAbility',
action: 'action.system.home',
entities: ['entity.system.home']
}, bundle.BundleFlag.GET_BUNDLE_DEFAULT, 0)
expect(dataInfos.length).assertEqual(NUM_ONE);
if (dataInfos.length == 1) {
expect(dataInfos[0].name).assertEqual("com.example.third4.MainAbility")
expect(dataInfos[0].backgroundModes).assertEqual(0)
}
installer.uninstall(BUNDLE_NAME4, {
userId: 0,
installFlag: 1,
isKeepData: false
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
})
})
/*
* @tc.number: bms_backGroundModes_0500
* @tc.name: Get the backgroundModes information of the application through queryAbilityByWant
* @tc.desc: Get the backgroundModes information of the multi-hap package of the application
*/
it('bms_backGroundModes_0500', 0, async function (done) {
console.info('=====================bms_backGroundModes_0500==================');
var bundlePath = [BUNDLE_PATH1, BUNDLE_PATH3];
var installer = await bundle.getBundleInstaller();
installer.install(bundlePath, {
userId: 0,
installFlag: 1,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
var dataInfos = await bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME1,
abilityName: 'com.example.third1.MainAbilityA',
action: 'action.system.home',
entities: ['entity.system.home']
}, bundle.BundleFlag.GET_BUNDLE_DEFAULT, 0)
expect(dataInfos.length).assertEqual(NUM_ONE);
expect(dataInfos[0].name).assertEqual("com.example.third1.MainAbilityA")
expect(dataInfos[0].backgroundModes).assertEqual(dataTransfer + audioPlayback + audioRecording +
location + bluetoothInteraction + multiDeviceConnection + wifiInteraction + voip + taskKeeping)
console.info("========dataInfos[0].backgroundModes=======>" + dataInfos[0].backgroundModes)
installer.uninstall(BUNDLE_NAME1, {
userId: 0,
installFlag: 1,
isKeepData: false
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
})
})
/*
* @tc.number: bms_backGroundModes_0600
* @tc.name: Get the backgroundModes information of the application through queryAbilityByWant
* @tc.desc: Get the backgroundModes information of the upgraded application's ability
*/
it('bms_backGroundModes_0600', 0, async function (done) {
console.info('=====================bms_backGroundModes_0600==================');
var bundlePath1 = [BUNDLE_PATH1]
var bundlePath2 = [BUNDLE_PATHUPDATE]
var installer = await bundle.getBundleInstaller();
installer.install(bundlePath1, {
userId: 0,
installFlag: 1,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
var dataInfos = await bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME1,
abilityName: 'com.example.third1.MainAbilityA',
action: 'action.system.home',
entities: ['entity.system.home']
}, bundle.BundleFlag.GET_BUNDLE_DEFAULT, 0)
expect(dataInfos.length).assertEqual(NUM_ONE);
expect(dataInfos[0].name).assertEqual("com.example.third1.MainAbilityA")
expect(dataInfos[0].backgroundModes).assertEqual(dataTransfer + audioPlayback + audioRecording +
location + bluetoothInteraction + multiDeviceConnection + wifiInteraction + voip + taskKeeping)
installer.install(bundlePath2, {
userId: 0,
installFlag: 1,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
var dataInfos = await bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME1,
abilityName: 'com.example.third1.AMainAbilityA',
action: 'action.system.home',
entities: ['entity.system.home']
}, bundle.BundleFlag.GET_BUNDLE_DEFAULT, 0)
expect(dataInfos.length).assertEqual(NUM_ONE);
expect(dataInfos[0].name).assertEqual("com.example.third1.AMainAbilityA");
expect(dataInfos[0].backgroundModes).assertEqual(audioRecording + location + bluetoothInteraction +
multiDeviceConnection + wifiInteraction + voip + taskKeeping);
installer.uninstall(BUNDLE_NAME1, {
userId: 0,
installFlag: 1,
isKeepData: false
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
})
})
})
/*
* @tc.number: bms_backGroundModes_0700
* @tc.name: Get the backgroundModes information of the application through queryAbilityByWant
* @tc.desc: Uninstall the application, get the backgroundModes information of the upgraded application's ability
*/
it('bms_backGroundModes_0700', 0, async function (done) {
console.info('=====================bms_backGroundModes_0700==================');
var bundlePath = [BUNDLE_PATH1]
var installer = await bundle.getBundleInstaller();
installer.install(bundlePath, {
userId: 0,
installFlag: 1,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
var dataInfos = await bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME1,
abilityName: 'com.example.third1.MainAbilityA',
action: 'action.system.home',
entities: ['entity.system.home']
}, bundle.BundleFlag.GET_BUNDLE_DEFAULT, 0)
expect(dataInfos.length).assertEqual(NUM_ONE);
expect(dataInfos[0].name).assertEqual("com.example.third1.MainAbilityA")
expect(dataInfos[0].backgroundModes).assertEqual(dataTransfer + audioPlayback + audioRecording +
location + bluetoothInteraction + multiDeviceConnection + wifiInteraction + voip + taskKeeping)
installer.uninstall(BUNDLE_NAME1, {
userId: 0,
installFlag: 1,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
await bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME1,
abilityName: 'com.example.third1.MainAbility',
action: 'action.system.home',
entities: ['entity.system.home'],
}, bundle.BundleFlag.GET_BUNDLE_DEFAULT, 0).then(dataInfo => {
expect(dataInfo).assertFail();
done();
}).catch(error => {
expect(error).assertEqual(1);
done();
})
});
})
})
/*
* @tc.number: bms_getIsKeepAliveAndSingleUser_0100
* @tc.name: Get the isKeepAlive and singleUser information of the third-party application
* @tc.desc: Get the isKeepAlive and singleUser information of the third-party application by getBundleInfo
*/
it('bms_getIsKeepAliveAndSingleUser_0100', 0, async function (done) {
console.info('===========begin bms_getIsKeepAliveAndSingleUser_0100===========');
var installer = await bundle.getBundleInstaller();
installer.install([BUNDLE_PATH1], {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
bundle.getBundleInfo(BUNDLE_NAME1, 1, (err, bundleInfo) => {
expect(err.code).assertEqual(0);
expect(bundleInfo.isKeepAlive).assertFalse();
expect(bundleInfo.singleUser).assertFalse();
installer.uninstall(BUNDLE_NAME1, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
});
})
})
/*
* @tc.number: bms_getIsKeepAliveAndSingleUser_0200
* @tc.name: Get the isKeepAlive and singleUser information of the application which doesn't config those fields
* @tc.desc: Get the isKeepAlive and singleUser information of the application which doesn't config those fields
* by getBundleInfo(application is system)
*/
it('bms_getIsKeepAliveAndSingleUser_0200', 0, async function (done) {
console.info('=====================bms_getIsKeepAliveAndSingleUser_0200==================');
var bundleInfo = await bundle.getBundleInfo('com.example.system1', 1);
console.info('========bundleInfo is=====' + JSON.stringify(bundleInfo));
expect(bundleInfo.isKeepAlive).assertFalse();
expect(bundleInfo.singleUser).assertFalse();
done();
})
/*
* @tc.number: bms_getIsKeepAliveAndSingleUser_0300
* @tc.name: Get the isKeepAlive and singleUser information of the application includes two haps
* @tc.desc: Get the isKeepAlive and singleUser information of the application includes two haps, the attribute value
* will remain the same as the attribute value of the first installed hap(application is system)
*/
it('bms_getIsKeepAliveAndSingleUser_0300', 0, async function (done) {
console.info('===========begin bms_getIsKeepAliveAndSingleUser_0300===========');
let installer = await bundle.getBundleInstaller()
installer.install([SYSTEM_PATH, SYSTEM_FEATURE_PATH], {
param: {
userId: 0,
isKeepData: false
}
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
var bundleInfo = await bundle.getBundleInfo(SYSTEM_NAME, 1);
expect(bundleInfo.singleUser).assertTrue();
expect(bundleInfo.isKeepAlive).assertFalse();
installer.uninstall(SYSTEM_NAME, {
param: {
userId: 0,
isKeepData: false
}
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
});
})
/*
* @tc.number: bms_getIsKeepAliveAndSingleUser_0400
* @tc.name: Update application, get the isKeepAlive and singleUser information of the application
* @tc.desc: Update application, get the isKeepAlive and singleUser information of the application whether update
* (application is system)
*/
it('bms_getIsKeepAliveAndSingleUser_0400', 0, async function (done) {
console.info('=====================bms_getIsKeepAliveAndSingleUser_0400==================');
var installer = await bundle.getBundleInstaller();
installer.install([SYSTEM_PATH], {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
var bundleInfo = await bundle.getBundleInfo(SYSTEM_NAME, 1);
expect(bundleInfo.singleUser).assertTrue();
expect(bundleInfo.isKeepAlive).assertFalse();
installer.install([SYSTEM_UPDATE_PATH], {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
var bundleInfo = await bundle.getBundleInfo(SYSTEM_NAME, 1);
console.info('========bundleInfo is=====' + JSON.stringify(bundleInfo));
expect(bundleInfo.name).assertEqual(SYSTEM_NAME);
expect(bundleInfo.isKeepAlive).assertTrue();
expect(bundleInfo.singleUser).assertTrue();
installer.uninstall(SYSTEM_NAME, {
param: {
userId: 0,
installFlag: 1,
isKeepData: false
}
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
})
})
})
})
\ No newline at end of file
......@@ -12,7 +12,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./ActsBmsGetBackGroundModes.test.js')
require('./ActsBmsFormsInfoTest.test.js')
require('./ActsBmsPermissionChange.test.js')
require('./ActsBmsQueryAbilityByWant.test.js')
\ No newline at end of file
......@@ -673,12 +673,9 @@ describe('ActsBundleManagerTest', function () {
it('getBundleArchiveInfo_0100', 0, async function (done) {
let installData = await demo.getBundleInstaller()
installData.install([PATH + BMSJSTEST1], installParam, async (err, data) => {
console.err("install result" + JSON.stringify(err))
console.err("install result" + JSON.stringify(data))
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
console.err("getBundleArchiveInfo begin")
getInfo();
});
async function getInfo() {
......@@ -2394,305 +2391,7 @@ describe('ActsBundleManagerTest', function () {
}
})
/**
* @tc.number getPermissionDef_0100
* @tc.name BUNDLE::getPermissionDef
* @tc.desc Test getPermissionDef interfaces.
*/
it('getPermissionDef_0100', 0, async function (done) {
let installData = await demo.getBundleInstaller()
installData.install([PATH + BMSJSTEST1], {
userId: 0,
installFlag: 0,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
getInfo();
});
async function getInfo() {
demo.getPermissionDef(CAMERA).then((infos) => {
expect(infos.name).assertEqual("com.permission.BMS_PERMISSION_CAMERA");
expect(infos.grantMode).assertEqual(1);
expect(infos.availableScope).assertEqual(2);
expect(infos.label).assertEqual("BMS_PERMISSION_CAMERA permission");
expect(infos.description).assertEqual("BMS_PERMISSION_CAMERA permission in detail");
installData.uninstall(NAME1, {
userId: 0,
installFlag: 0,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
});
}
})
/**
* @tc.number getPermissionDef_0200
* @tc.name BUNDLE::getPermissionDef
* @tc.desc Test getPermissionDef interfaces.
*/
it('getPermissionDef_0200', 0, async function (done) {
let installData = await demo.getBundleInstaller()
installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], {
userId: 0,
installFlag: 0,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
getInfo();
});
async function getInfo() {
demo.getPermissionDef(CAMERA).then((infos) => {
expect(infos.name).assertEqual("com.permission.BMS_PERMISSION_CAMERA");
expect(infos.grantMode).assertEqual(1);
expect(infos.availableScope).assertEqual(2);
expect(infos.label).assertEqual("BMS_PERMISSION_CAMERA permission");
expect(infos.description).assertEqual("BMS_PERMISSION_CAMERA permission in detail");
});
demo.getPermissionDef(MUSIC).then((infos) => {
expect(infos.name).assertEqual("com.permission.BMS_PERMISSION_MUSIC");
expect(infos.grantMode).assertEqual(1);
expect(infos.availableScope).assertEqual(2);
expect(infos.label).assertEqual("BMS_PERMISSION_MUSIC permission");
expect(infos.description).assertEqual("BMS_PERMISSION_MUSIC permission in detail");
installData.uninstall(NAME2, {
userId: 0,
installFlag: 0,
isKeepData: false
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
});
}
})
/**
* @tc.number getPermissionDef_0300
* @tc.name BUNDLE::getPermissionDef
* @tc.desc Test getPermissionDef interfaces.
*/
it('getPermissionDef_0300', 0, async function (done) {
let installData = await demo.getBundleInstaller()
await demo.getBundleInstaller().then((data) => {
data.install([PATH + BMSJSTEST4, PATH + BMSJSTEST5, PATH + BMSJSTEST6], {
userId: 0,
installFlag: 0,
isKeepData: false
}, async (err, data) => {
getInfo();
});
});
async function getInfo() {
demo.getPermissionDef(CAMERA).then((infos) => {
expect(infos.name).assertEqual('');
expect(infos.grantMode).assertEqual(0);
expect(infos.availableScope).assertEqual(0);
expect(infos.label).assertEqual('');
expect(infos.description).assertEqual('');
});
demo.getPermissionDef(MUSIC).then((infos) => {
expect(infos.name).assertEqual('');
expect(infos.grantMode).assertEqual(0);
expect(infos.availableScope).assertEqual(0);
expect(infos.label).assertEqual('');
expect(infos.description).assertEqual('');
});
demo.getPermissionDef(WECHAT).then((infos) => {
expect(infos.name).assertEqual('');
expect(infos.grantMode).assertEqual(0);
expect(infos.availableScope).assertEqual(0);
expect(infos.label).assertEqual('');
expect(infos.description).assertEqual('');
installData.uninstall(NAME3, {
userId: 0,
installFlag: 0,
isKeepData: false
}, (err, data) => {
installData.uninstall(NAME4, {
userId: 0,
installFlag: 0,
isKeepData: false
}, (err, data) => {
installData.uninstall(NAME5, {
userId: 0,
installFlag: 0,
isKeepData: false
}, (err, data) => {
done();
});
});
});
});
}
})
/**
* @tc.number getPermissionDef_0400
* @tc.name BUNDLE::getPermissionDef
* @tc.desc Test getPermissionDef interfaces.
*/
it('getPermissionDef_0400', 0, async function (done) {
demo.getPermissionDef('').then((infos) => {
expect(infos.name).assertEqual("");
expect(infos.grantMode).assertEqual(0);
expect(infos.availableScope).assertEqual(0);
expect(infos.label).assertEqual("");
expect(infos.description).assertEqual("");
done();
});
})
/**
* @tc.number getPermissionDef_0500
* @tc.name BUNDLE::getPermissionDef
* @tc.desc Test getPermissionDef interfaces.
*/
it('getPermissionDef_0500', 0, async function (done) {
demo.getPermissionDef('error').then((infos) => {
expect(infos.name).assertEqual("");
expect(infos.grantMode).assertEqual(0);
expect(infos.availableScope).assertEqual(0);
expect(infos.label).assertEqual("");
expect(infos.description).assertEqual("");
done();
});
})
/**
* @tc.number getPermissionDef_0600
* @tc.name BUNDLE::getPermissionDef
* @tc.desc Test getPermissionDef interfaces.
*/
it('getPermissionDef_0600', 0, async function (done) {
let installData = await demo.getBundleInstaller()
installData.install([PATH + BMSJSTEST1], {
userId: 0,
installFlag: 0,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
getInfo();
});
async function getInfo() {
await demo.getPermissionDef(CAMERA, OnReceiveEvent);
function OnReceiveEvent(err, data) {
expect(data.name).assertEqual("com.permission.BMS_PERMISSION_CAMERA");
expect(data.grantMode).assertEqual(1);
expect(data.availableScope).assertEqual(2);
expect(data.label).assertEqual("BMS_PERMISSION_CAMERA permission");
expect(data.description).assertEqual("BMS_PERMISSION_CAMERA permission in detail");
installData.uninstall(NAME1, {
userId: 0,
installFlag: 0,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
}
}
})
/**
* @tc.number getPermissionDef_0700
* @tc.name BUNDLE::getPermissionDef
* @tc.desc Test getPermissionDef interfaces.
*/
it('getPermissionDef_0700', 0, async function (done) {
let installData = await demo.getBundleInstaller()
installData.install([PATH + BMSJSTEST2, PATH + BMSJSTEST3], {
userId: 0,
installFlag: 0,
isKeepData: false
}, async (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
getInfo();
});
async function getInfo() {
await demo.getPermissionDef(CAMERA, OnReceiveEvent1);
await demo.getPermissionDef(MUSIC, OnReceiveEvent2);
function OnReceiveEvent1(err, data) {
expect(data.name).assertEqual("com.permission.BMS_PERMISSION_CAMERA");
expect(data.grantMode).assertEqual(1);
expect(data.availableScope).assertEqua(2);
expect(data.label).assertEqual("BMS_PERMISSION_CAMERA permission");
expect(data.description).assertEqual("BMS_PERMISSION_CAMERA permission in detail");
}
function OnReceiveEvent2(err, data) {
expect(data.name).assertEqual("com.permission.BMS_PERMISSION_MUSIC");
expect(data.grantMode).assertEqual(1);
expect(data.availableScope).assertEqual(2);
expect(data.label).assertEqual("BMS_PERMISSION_MUSIC permission");
expect(data.description).assertEqual("BMS_PERMISSION_MUSIC permission in detail");
installData.uninstall(NAME2, {
userId: 0,
installFlag: 0,
isKeepData: false
}, (err, data) => {
expect(err.code).assertEqual(0);
expect(data.status).assertEqual(0);
expect(data.statusMessage).assertEqual('SUCCESS');
done();
});
}
}
})
/**
* @tc.number getPermissionDef_0800
* @tc.name BUNDLE::getPermissionDef
* @tc.desc Test getPermissionDef interfaces.
*/
it('getPermissionDef_0800', 0, async function (done) {
await demo.getPermissionDef('', OnReceiveEvent);
function OnReceiveEvent(err, data) {
expect(data.name).assertEqual("");
expect(data.availableScope).assertEqual(0);
expect(data.grantMode).assertEqual(0);
expect(data.label).assertEqual("");
expect(data.description).assertEqual("");
done();
}
})
/**
* @tc.number getPermissionDef_0900
* @tc.name BUNDLE::getPermissionDef
* @tc.desc Test getPermissionDef interfaces.
*/
it('getPermissionDef_0900', 0, async function (done) {
await demo.getPermissionDef('error', OnReceiveEvent);
function OnReceiveEvent(err, data) {
expect(data.name).assertEqual("");
expect(data.availableScope).assertEqual(0);
expect(data.grantMode).assertEqual(0);
expect(data.label).assertEqual("");
expect(data.description).assertEqual("");
done();
}
})
/**
* @tc.number install_0100
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册