提交 7497785f 编写于 作者: R r00559040

add getAbilityIcon test and add getmetadata callback test

Signed-off-by: Nr00559040 <ry.renyi@huawei.com>
上级 0780e13d
......@@ -22,6 +22,8 @@ const INVALID_CODE = 1;
const LAUNCHER_BUNDLE_NAME = "com.ohos.launcher";
const SELF_BUNDLENAME = "com.example.actsbmsetsunpermissiontest";
const SELF_ABILITYNAME = "com.example.actsbmsetsunpermissiontest.MainAbility";
const BUNDLE_SETTINGS = "com.ohos.settings";
const ABILITIY_SETTINGS = "com.ohos.settings.MainAbility";
export default function actsBmsJsUnPermissionTest() {
describe('actsBmsJsUnPermissionTest', function () {
......@@ -34,10 +36,8 @@ export default function actsBmsJsUnPermissionTest() {
it('getApplicationInfos_1300', 0, async function (done) {
await bundle.getAllApplicationInfo(DEFAULT_FLAG).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
bundle.getAllApplicationInfo(DEFAULT_FLAG, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
......@@ -54,10 +54,8 @@ export default function actsBmsJsUnPermissionTest() {
it('getBundleInfo_2000', 0, async function (done) {
await bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, { userId: 100 }).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
bundle.getBundleInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, { userId: 100 }, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
......@@ -74,10 +72,8 @@ export default function actsBmsJsUnPermissionTest() {
it('getApplicationInfo_1800', 0, async function (done) {
await bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG).then(data => {
expect().assertFail();
done();
}).catch(err => {
expect(err).assertEqual(INVALID_CODE);
done();
});
bundle.getApplicationInfo(LAUNCHER_BUNDLE_NAME, DEFAULT_FLAG, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
......@@ -138,6 +134,23 @@ export default function actsBmsJsUnPermissionTest() {
})
});
/*
* @tc.number: SUB_BMS_APPINFO_GETABILITYICON_0006
* @tc.name: test getAbilityIcon
* @tc.desc: test getAbilityIcon without permission
*/
it('SUB_BMS_APPINFO_GETABILITYICON_0006', 0, async function (done) {
await bundle.getAbilityIcon(BUNDLE_SETTINGS, ABILITIY_SETTINGS).then(pixelmap => {
expect(pixelmap).assertFail();
}).catch(err => {
expect(err).assertEqual(1);
});
bundle.getAbilityIcon(BUNDLE_SETTINGS, ABILITIY_SETTINGS, (err, pixelmap) => {
expect(err).assertEqual(1);
done();
});
});
/*
* @tc.number: getAbilityInfo_100
* @tc.name: test getAbilityInfo
......
......@@ -27,24 +27,31 @@
"type": "PushKit",
"push": [
"bmsThirdBundleTest1.hap->/data/test/bmsThirdBundleTest1.hap",
"bmsThirdBundleTestA1.hap->/data/test/bmsThirdBundleTestA1.hap",
"bmsThirdBundleTest5.hap->/data/test/bmsThirdBundleTest5.hap",
"bmsSystemBundleTest1.hap->/data/test/bmsSystemBundleTest1.hap",
"bmsVendorBundleTest1.hap->/data/test/bmsVendorBundleTest1.hap"
"bmsVendorBundleTest1.hap->/data/test/bmsVendorBundleTest1.hap",
"first_right.hap->/data/test/first_right.hap",
"second_right.hap->/data/test/second_right.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"bm install -p /data/test/bmsThirdBundleTest1.hap",
"bm install -p /data/test/bmsThirdBundleTestA1.hap",
"bm install -p /data/test/bmsSystemBundleTest1.hap",
"bm install -p /data/test/bmsVendorBundleTest1.hap",
"bm install -p /data/test/bmsThirdBundleTest5.hap"
"bm install -p /data/test/bmsThirdBundleTest5.hap",
"bm install -p /data/test/first_right.hap",
"bm install -p /data/test/second_right.hap"
],
"teardown-command":[
"bm uninstall -n com.example.third1",
"bm uninstall -n com.example.system1",
"bm uninstall -n com.example.vendor1",
"bm uninstall -n com.example.third5",
"bm uninstall -n com.example.l3jsdemo",
"rm -rf /data/test/"
]
}
......
......@@ -21,11 +21,13 @@ const BUNDLE_NAME2 = 'com.example.third5';
const BUNDLE_NAME3 = 'com.example.noexist';
const BUNDLE_NAME4 = 'com.example.system1';
const BUNDLE_NAME5 = 'com.example.vendor1';
const BUNDLE_NAME6 = 'com.example.l3jsdemo';
const ABILITY_NAME1 = 'com.example.third1.MainAbility';
const ABILITY_NAME3 = 'com.example.third5.AMainAbility';
const ABILITY_NAME4 = 'com.example.noexist.MainAbility';
const ABILITY_NAME5 = 'com.example.system1.MainAbility';
const ABILITY_NAME6 = 'com.example.vendor1.MainAbility';
const ABILITY_NAME2 = 'com.example.third5.AMainAbility';
const ABILITY_NAME3 = 'com.example.noexist.MainAbility';
const ABILITY_NAME4 = 'com.example.system1.MainAbility';
const ABILITY_NAME5 = 'com.example.vendor1.MainAbility';
const ABILITY_NAME6 = 'com.example.l3jsdemo.MainAbility';
const USERID = 100;
describe('ActsBmsMetaDataTest', function () {
......@@ -33,7 +35,7 @@ describe('ActsBmsMetaDataTest', function () {
/*
* @tc.number: bms_getMetaData_0100
* @tc.name: test to get meta data for an application.
* @tc.desc: get an application's meta data which contains two HAP packages.
* @tc.desc: get an ability's meta data when update.
*/
it('bms_getMetaData_0100', 0, async function (done) {
await bundle.queryAbilityByWant(
......@@ -41,105 +43,173 @@ describe('ActsBmsMetaDataTest', function () {
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
console.info("dataInfos[0].metaData" + JSON.stringify(dataInfos[0].metaData));
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("Data1");
expect(metaData[0].value).assertEqual("float");
expect(metaData[0].extra).assertEqual("$string:mainability_description");
done();
}).catch(err => {
expect(err).assertFail();
done();
});
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("DataA1");
expect(metaData[0].value).assertEqual("float");
expect(metaData[0].extra).assertEqual("$string:mainability_description");
}).catch(err => {
expect(err).assertFail();
});
bundle.queryAbilityByWant(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID, (err, dataInfos) => {
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("DataA1");
expect(metaData[0].value).assertEqual("float");
expect(metaData[0].extra).assertEqual("$string:mainability_description");
done();
});
});
/*
* @tc.number: bms_getMetaData_0200
* @tc.name: test to get meta data for an application.
* @tc.desc: get an ability's meta data which contains two HAP packages.
*/
it('bms_getMetaData_0200', 0, async function (done) {
await bundle.queryAbilityByWant(
{
"bundleName": BUNDLE_NAME6,
"abilityName": ABILITY_NAME6
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
let metaDataInfo = dataInfos[0].metaData;
expect(metaDataInfo[0].name).assertEqual("Data3");
expect(metaDataInfo[0].value).assertEqual("float");
expect(metaDataInfo[0].extra).assertEqual("$string:mainability_description");
}).catch(err => {
expect(err).assertFail();
});
bundle.queryAbilityByWant(
{
"bundleName": BUNDLE_NAME6,
"abilityName": ABILITY_NAME6
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID, (err, dataInfos) => {
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("Data3");
expect(metaData[0].value).assertEqual("float");
expect(metaData[0].extra).assertEqual("$string:mainability_description");
done();
});
});
/*
* @tc.number: bms_getMetaData_0400
* @tc.name: test to get meta data for an application.
* @tc.desc: get an application's meta data which has one ability.
* @tc.desc: get an ability's meta data which has two ability.
*/
it('bms_getMetaData_0400', 0, async function (done) {
await bundle.queryAbilityByWant(
{
bundleName: BUNDLE_NAME2,
abilityName: ABILITY_NAME3,
abilityName: ABILITY_NAME2,
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
console.info("dataInfos[0].metaData" + JSON.stringify(dataInfos[0].metaData));
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("Data5A");
expect(metaData[0].value).assertEqual("float");
expect(metaData[0].extra).assertEqual("$string:mainability_description");
done();
}).catch(err => {
expect(err).assertFail();
done();
});
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("Data5A");
expect(metaData[0].value).assertEqual("float");
expect(metaData[0].extra).assertEqual("$string:mainability_description");
}).catch(err => {
expect(err).assertFail();
});
bundle.queryAbilityByWant(
{
"bundleName": BUNDLE_NAME2,
"abilityName": ABILITY_NAME2
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID, (err, dataInfos) => {
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("Data5A");
expect(metaData[0].value).assertEqual("float");
expect(metaData[0].extra).assertEqual("$string:mainability_description");
done();
});
});
/*
* @tc.number: bms_getMetaData_0500
* @tc.name: test to get meta data for an application that does not exist.
* @tc.desc: get an application's meta data which does not exist.
* @tc.desc: get an ability's meta data which does not exist.
*/
it('bms_getMetaData_0500', 0, async function (done) {
await bundle.queryAbilityByWant(
{
bundleName: BUNDLE_NAME3,
abilityName: ABILITY_NAME4,
abilityName: ABILITY_NAME3,
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
expect(dataInfos.length).assertEqual(0);
done();
}).catch(err => {
console.info("err====: " + err);
expect(err).assertEqual(1);
done();
});
expect(dataInfos).assertFail();
}).catch(err => {
expect(err).assertEqual(1);
});
bundle.queryAbilityByWant(
{
"bundleName": BUNDLE_NAME3,
"abilityName": ABILITY_NAME3
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID, (err, dataInfos) => {
expect(err).assertEqual(1);
expect(dataInfos).assertEqual("QueryAbilityInfos failed");
done();
});
});
/*
* @tc.number: bms_getMetaData_0600
* @tc.name: test to get meta data for a system application.
* @tc.desc: get a system application's meta data.
* @tc.desc: get a system ability's meta data.
*/
it('bms_getMetaData_0600', 0, async function (done) {
await bundle.queryAbilityByWant(
{
bundleName: BUNDLE_NAME4,
abilityName: ABILITY_NAME5,
abilityName: ABILITY_NAME4,
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
console.info("dataInfos[0].metaData" + JSON.stringify(dataInfos[0].metaData));
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("Data1S");
expect(metaData[0].value).assertEqual("float");
expect(metaData[0].extra).assertEqual("$string:mainability_description");
done();
}).catch(err => {
expect(err).assertFail();
done();
});
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("Data1S");
expect(metaData[0].value).assertEqual("float");
expect(metaData[0].extra).assertEqual("$string:mainability_description");
}).catch(err => {
expect(err).assertFail();
});
bundle.queryAbilityByWant(
{
"bundleName": BUNDLE_NAME4,
"abilityName": ABILITY_NAME4
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID, (err, dataInfos) => {
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("Data1S");
expect(metaData[0].value).assertEqual("float");
expect(metaData[0].extra).assertEqual("$string:mainability_description");
done();
});
});
/*
* @tc.number: bms_getMetaData_0700
* @tc.name: test to get meta data for a vendor application.
* @tc.desc: get a vendor application's meta data.
* @tc.desc: get a vendor ability's meta data.
*/
it('bms_getMetaData_0700', 0, async function (done) {
await bundle.queryAbilityByWant(
{
bundleName: BUNDLE_NAME5,
abilityName: ABILITY_NAME6,
abilityName: ABILITY_NAME5,
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID).then(dataInfos => {
console.info("dataInfos[0].metaData" + JSON.stringify(dataInfos[0].metaData));
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("");
expect(metaData[0].value).assertEqual("");
expect(metaData[0].extra).assertEqual("");
done();
}).catch(err => {
expect(err).assertFail();
done();
});
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("vendorName");
expect(metaData[0].value).assertEqual("vendorValue");
expect(metaData[0].extra).assertEqual("vendorcustomizeData");
}).catch(err => {
expect(err).assertFail();
});
bundle.queryAbilityByWant(
{
"bundleName": BUNDLE_NAME5,
"abilityName": ABILITY_NAME5
}, bundle.BundleFlag.GET_ABILITY_INFO_WITH_METADATA, USERID, (err, dataInfos) => {
let metaData = dataInfos[0].metaData;
expect(metaData[0].name).assertEqual("vendorName");
expect(metaData[0].value).assertEqual("vendorValue");
expect(metaData[0].extra).assertEqual("vendorcustomizeData");
done();
});
});
})
\ No newline at end of file
......@@ -39,7 +39,16 @@
"label": "$string:app_name",
"type": "page",
"homeAbility": true,
"launchType": "standard"
"launchType": "standard",
"metaData": {
"customizeData": [
{
"name": "Data3",
"value": "float",
"extra": "$string:mainability_description"
}
]
}
}
],
"deviceType": [
......
......@@ -18,7 +18,7 @@
"module": {
"package": "com.example.third1.entry",
"name": "com.example.third1.BmsThirdBundle1",
"mainAbility": "com.example.third1.AMainAbility",
"mainAbility": "com.example.third1.MainAbility",
"colorMode": "dark",
"deviceType": [
"phone"
......@@ -40,7 +40,7 @@
]
}
],
"name": "com.example.third1.AMainAbility",
"name": "com.example.third1.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
......@@ -128,7 +128,7 @@
"voip",
"taskKeeping"
],
"name": "com.example.third1.AMainAbilityA",
"name": "com.example.third1.MainAbilityA",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
......@@ -144,7 +144,7 @@
"label": "$string:shortcut",
"intents": [
{
"targetClass": "com.example.third1.AMainAbility",
"targetClass": "com.example.third1.MainAbility",
"targetBundle": "com.example.third1"
}
]
......
......@@ -106,8 +106,13 @@
"type": "float",
"description": "$string:mainability_description"
}],
"customizeData": [{
}]
"customizeData": [
{
"name": "vendorName",
"value": "vendorValue",
"extra": "vendorcustomizeData"
}
]
}
}
],
......
......@@ -34,7 +34,16 @@
"label": "$string:app_name",
"type": "page",
"homeAbility": false,
"launchType": "standard"
"launchType": "standard",
"metaData": {
"customizeData": [
{
"name": "Data2",
"value": "float",
"extra": "$string:mainability_description"
}
]
}
}
],
"deviceType": [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册