提交 9c270f77 编写于 作者: I inter515

新增xts用例

Signed-off-by: Ninter515 <ry.renyi@huawei.com>
上级 659e7596
...@@ -24,503 +24,635 @@ const MODULE_NAME1 = ''; ...@@ -24,503 +24,635 @@ const MODULE_NAME1 = '';
const MODULE_NAME2 = 'noModule'; const MODULE_NAME2 = 'noModule';
const MODULE_NAME3 = 'entry'; const MODULE_NAME3 = 'entry';
const MODULE_NAME4 = undefined; const MODULE_NAME4 = undefined;
const MODULE_NAME5 = null;
const DEFAULT_FLAG = bundle.BundleFlag.GET_BUNDLE_DEFAULT; const DEFAULT_FLAG = bundle.BundleFlag.GET_BUNDLE_DEFAULT;
const SUCCESS_CODE = 0; const SUCCESS_CODE = 0;
const INVALID_CODE = 1; const INVALID_CODE = 1;
const INVALID_PARAM = 2; const INVALID_PARAM = 2;
const ABILITY_INFO_ONE = { const ABILITY_INFO_ONE = {
bundleName: BUNDLE_NAME, bundleName: BUNDLE_NAME,
moduleName: MODULE_NAME1, moduleName: MODULE_NAME1,
name: ABILITY_NAME name: ABILITY_NAME
}; };
const ABILITY_INFO_TWO = { const ABILITY_INFO_TWO = {
bundleName: BUNDLE_NAME, bundleName: BUNDLE_NAME,
moduleName: MODULE_NAME2, moduleName: MODULE_NAME2,
name: ABILITY_NAME name: ABILITY_NAME
}; };
const ABILITY_INFO_THREE = { const ABILITY_INFO_THREE = {
bundleName: BUNDLE_NAME, bundleName: BUNDLE_NAME,
moduleName: MODULE_NAME3, moduleName: MODULE_NAME3,
name: ABILITY_NAME name: ABILITY_NAME
}; };
const ABILITY_INFO_FOUR = { const ABILITY_INFO_FOUR = {
bundleName: BUNDLE_NAME, bundleName: BUNDLE_NAME,
moduleName: MODULE_NAME4, moduleName: MODULE_NAME4,
name: ABILITY_NAME name: ABILITY_NAME
}; };
let userId = 0; let userId = 0;
export default function actsBmsJsModuleNameTest() { export default function actsBmsJsModuleNameTest() {
describe('actsBmsJsModuleNameTest', function () { describe('actsBmsJsModuleNameTest', function () {
beforeAll(async function (done) { beforeAll(async function (done) {
await account.getAccountManager().getOsAccountLocalIdFromProcess().then(account => { await account.getAccountManager().getOsAccountLocalIdFromProcess().then(account => {
console.info("getOsAccountLocalIdFromProcess userid ==========" + account); console.info("getOsAccountLocalIdFromProcess userid ==========" + account);
userId = account; userId = account;
done(); done();
}).catch(err => { }).catch(err => {
console.info("getOsAccountLocalIdFromProcess err ==========" + JSON.stringify(err)); console.info("getOsAccountLocalIdFromProcess err ==========" + JSON.stringify(err));
done(); done();
}) })
});
/*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0030
* @tc.name: getAbilityInfoEmptyModule
* @tc.desc: test empty moduleName
*/
it('getAbilityInfoEmptyModule', 0, async function (done) {
await bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME)
.then(data => {
expect(data).assertFail();
}).catch((err) => {
console.error('[getAbilityInfoEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
expect(err).assertEqual(INVALID_CODE);
}); });
bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
if (err) {
console.error('[getAbilityInfoEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityInfoEmptyModule]Return data: " + JSON.stringify(data));
done();
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0030 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0020
* @tc.name: getAbilityInfoEmptyModule * @tc.name: getAbilityInfoInvalidModule
* @tc.desc: test empty moduleName * @tc.desc: test non-existent moduleName
*/ */
it('getAbilityInfoEmptyModule', 0, async function (done) { it('getAbilityInfoInvalidModule', 0, async function (done) {
await bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME) await bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME)
.then(data => { .then(data => {
expect(data).assertFail(); expect(data).assertFail();
}).catch((err) => { }).catch((err) => {
console.error('[getAbilityInfoEmptyModule]Operation failed. Err: ' + JSON.stringify(err)); console.error('[getAbilityInfoInvalidModule]Operation failed. Err: ' + JSON.stringify(err));
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
});
bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
if (err) {
console.error('[getAbilityInfoEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityInfoEmptyModule]Return data: " + JSON.stringify(data));
done();
});
}); });
bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
if (err) {
console.error('[getAbilityInfoInvalidModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityInfoInvalidModule]Return data : " + JSON.stringify(data));
done();
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0020 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0018
* @tc.name: getAbilityInfoInvalidModule * @tc.name: getAbilityInfoHasModule
* @tc.desc: test non-existent moduleName * @tc.desc: test existent moduleName
*/ */
it('getAbilityInfoInvalidModule', 0, async function (done) { it('getAbilityInfoHasModule', 0, async function (done) {
await bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME) await bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME)
.then(data => { .then(data => {
expect(data).assertFail(); console.info('[getAbilityInfoHasModule]Return data successful: ' + JSON.stringify(data));
}).catch((err) => { checkDataInfo(data);
console.error('[getAbilityInfoInvalidModule]Operation failed. Err: ' + JSON.stringify(err)); }).catch((err) => {
expect(err).assertEqual(INVALID_CODE); console.error('[getAbilityInfoHasModule]Operation . Err: ' + JSON.stringify(err));
}); expect(err).assertFail();
bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
if (err) {
console.error('[getAbilityInfoInvalidModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityInfoInvalidModule]Return data : " + JSON.stringify(data));
done();
});
}); });
bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME, (err, data) => {
checkDataInfo(data);
expect(err).assertEqual(SUCCESS_CODE);
if (err) {
console.error('[getAbilityInfoHasModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityInfoHasModule]Return data: " + JSON.stringify(data));
done();
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0018 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0031
* @tc.name: getAbilityInfoHasModule * @tc.name: getAbilityIconEmptyModule
* @tc.desc: test existent moduleName * @tc.desc: test empty moduleName
*/ */
it('getAbilityInfoHasModule', 0, async function (done) { it('getAbilityIconEmptyModule', 0, async function (done) {
await bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME) await bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME)
.then(data => { .then(data => {
console.info('[getAbilityInfoHasModule]Return data successful: ' + JSON.stringify(data)); expect(data).assertFail();
checkDataInfo(data); }).catch((err) => {
}).catch((err) => { console.error('[getAbilityIconEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
console.error('[getAbilityInfoHasModule]Operation . Err: ' + JSON.stringify(err)); expect(err).assertEqual(INVALID_CODE);
expect(err).assertFail();
});
bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME, (err, data) => {
checkDataInfo(data);
expect(err).assertEqual(SUCCESS_CODE);
if (err) {
console.error('[getAbilityInfoHasModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityInfoHasModule]Return data: " + JSON.stringify(data));
done();
});
}); });
bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
if (err) {
console.error('[getAbilityIconEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityIconEmptyModule]Return data: " + JSON.stringify(data));
done();
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0031 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0028
* @tc.name: getAbilityIconEmptyModule * @tc.name: getAbilityIconInvalidModule
* @tc.desc: test empty moduleName * @tc.desc: test non-existent moduleName
*/ */
it('getAbilityIconEmptyModule', 0, async function (done) { it('getAbilityIconInvalidModule', 0, async function (done) {
await bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME) await bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME)
.then(data => { .then(data => {
expect(data).assertFail(); expect(data).assertFail();
}).catch((err) => { }).catch((err) => {
console.error('[getAbilityIconEmptyModule]Operation failed. Err: ' + JSON.stringify(err)); console.error('[getAbilityIconInvalidModule]Operation successful. Err: ' + JSON.stringify(err));
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
});
bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
if (err) {
console.error('[getAbilityIconEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityIconEmptyModule]Return data: " + JSON.stringify(data));
done();
});
}); });
bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
if (err) {
console.error('[getAbilityIconInvalidModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityIconInvalidModule]Return data: " + JSON.stringify(data));
done();
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0028 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0026
* @tc.name: getAbilityIconInvalidModule * @tc.name: getAbilityIconHasModule
* @tc.desc: test non-existent moduleName * @tc.desc: test existent moduleName
*/ */
it('getAbilityIconInvalidModule', 0, async function (done) { it('getAbilityIconHasModule', 0, async function (done) {
await bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME) await bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME)
.then(data => { .then(data => {
expect(data).assertFail(); console.info('[getAbilityIconHasModule]Return data successful: ' + JSON.stringify(data));
}).catch((err) => { expect(data.getBytesNumberPerRow()).assertLarger(0);
console.error('[getAbilityIconInvalidModule]Operation successful. Err: ' + JSON.stringify(err)); }).catch((err) => {
expect(err).assertEqual(INVALID_CODE); console.error('[getAbilityIconHasModule]Operation failed. Err: ' + JSON.stringify(err));
}); expect(err).assertFail();
bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
if (err) {
console.error('[getAbilityIconInvalidModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityIconInvalidModule]Return data: " + JSON.stringify(data));
done();
});
}); });
bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(SUCCESS_CODE);
expect(data.getBytesNumberPerRow()).assertLarger(0);
if (err) {
console.error('[getAbilityIconHasModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityIconHasModule]Return data: " + JSON.stringify(data));
done();
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0026 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0032
* @tc.name: getAbilityIconHasModule * @tc.name: getAbilityLabelEmptyModule
* @tc.desc: test existent moduleName * @tc.desc: test empty moduleName
*/ */
it('getAbilityIconHasModule', 0, async function (done) { it('getAbilityLabelEmptyModule', 0, async function (done) {
await bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME) await bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME)
.then(data => { .then(data => {
console.info('[getAbilityIconHasModule]Return data successful: ' + JSON.stringify(data)); expect(data).assertFail();
expect(data.getBytesNumberPerRow()).assertLarger(0); }).catch((err) => {
}).catch((err) => { console.error('[getAbilityLabelEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
console.error('[getAbilityIconHasModule]Operation failed. Err: ' + JSON.stringify(err)); expect(err).assertEqual(INVALID_CODE);
expect(err).assertFail();
});
bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(SUCCESS_CODE);
expect(data.getBytesNumberPerRow()).assertLarger(0);
if (err) {
console.error('[getAbilityIconHasModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityIconHasModule]Return data: " + JSON.stringify(data));
done();
});
}); });
bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
if (err) {
console.error('[getAbilityLabelEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityLabelEmptyModule]Return data: " + JSON.stringify(data));
done();
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0032 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0024
* @tc.name: getAbilityLabelEmptyModule * @tc.name: getAbilityLabelInvalidModule
* @tc.desc: test empty moduleName * @tc.desc: test non-existent moduleName
*/ */
it('getAbilityLabelEmptyModule', 0, async function (done) { it('getAbilityLabelInvalidModule', 0, async function (done) {
await bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME) await bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME)
.then(data => { .then(data => {
expect(data).assertFail(); expect(data).assertFail();
}).catch((err) => { }).catch((err) => {
console.error('[getAbilityLabelEmptyModule]Operation failed. Err: ' + JSON.stringify(err)); console.error('[getAbilityLabelInvalidModule]Operation . Err: ' + JSON.stringify(err));
expect(err).assertEqual(INVALID_CODE); expect(err).assertEqual(INVALID_CODE);
});
bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME1, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
if (err) {
console.error('[getAbilityLabelEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityLabelEmptyModule]Return data: " + JSON.stringify(data));
done();
});
}); });
bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
if (err) {
console.error('[getAbilityLabelInvalidModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityLabelInvalidModule]Return data: " + JSON.stringify(data));
done();
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0024 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0022
* @tc.name: getAbilityLabelInvalidModule * @tc.name: getAbilityLabelHasModule
* @tc.desc: test non-existent moduleName * @tc.desc: test existent moduleName
*/ */
it('getAbilityLabelInvalidModule', 0, async function (done) { it('getAbilityLabelHasModule', 0, async function (done) {
await bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME) await bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME)
.then(data => { .then(data => {
expect(data).assertFail(); console.info('[getAbilityLabelHasModule]Return data successful: ' + JSON.stringify(data));
}).catch((err) => { expect(data).assertEqual("bmsfirstright");
console.error('[getAbilityLabelInvalidModule]Operation . Err: ' + JSON.stringify(err)); }).catch((err) => {
expect(err).assertEqual(INVALID_CODE); console.error('[getAbilityLabelHasModule]Operation failed. Err: ' + JSON.stringify(err));
}); expect(err).assertFail();
bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME2, ABILITY_NAME, (err, data) => {
expect(err).assertEqual(INVALID_CODE);
if (err) {
console.error('[getAbilityLabelInvalidModule]Operation failed. Err: ' + JSON.stringify(err));
}
console.info("'[getAbilityLabelInvalidModule]Return data: " + JSON.stringify(data));
done();
});
}); });
bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME, (err, data) => {
expect(err).assertNull();
if (err) {
console.error('[getAbilityLabelHasModule]Operation failed. Err: ' + JSON.stringify(err));
}
expect(data).assertEqual("bmsfirstright");
console.info("'[getAbilityLabelHasModule]Return data: " + JSON.stringify(data));
done();
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0022 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0010
* @tc.name: getAbilityLabelHasModule * @tc.name: isAbilityEnabledEmptyModule
* @tc.desc: test existent moduleName * @tc.desc: test empty moduleName
*/ */
it('getAbilityLabelHasModule', 0, async function (done) { it('isAbilityEnabledEmptyModule', 0, async function (done) {
await bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME) let abilityInfo = generateAbilityInfoForTest(ABILITY_INFO_ONE.bundleName, ABILITY_INFO_ONE.name, ABILITY_INFO_ONE.moduleName);
.then(data => { await bundle.isAbilityEnabled(abilityInfo)
console.info('[getAbilityLabelHasModule]Return data successful: ' + JSON.stringify(data)); .then(data => {
expect(data).assertEqual("bmsfirstright"); console.info('[isAbilityEnabledEmptyModule]Return data successful: ' + JSON.stringify(data));
}).catch((err) => { expect(data).assertTrue();
console.error('[getAbilityLabelHasModule]Operation failed. Err: ' + JSON.stringify(err)); }).catch((err) => {
expect(err).assertFail(); console.error('[isAbilityEnabledEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
}); expect(err).assertFail();
bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME3, ABILITY_NAME, (err, data) => {
expect(err).assertNull();
if (err) {
console.error('[getAbilityLabelHasModule]Operation failed. Err: ' + JSON.stringify(err));
}
expect(data).assertEqual("bmsfirstright");
console.info("'[getAbilityLabelHasModule]Return data: " + JSON.stringify(data));
done();
});
}); });
bundle.isAbilityEnabled(abilityInfo, (err, data) => {
expect(err).assertEqual(SUCCESS_CODE);
if (err) {
console.error('[isAbilityEnabledEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
}
expect(data).assertTrue();
console.info("'[isAbilityEnabledEmptyModule]Return data: " + JSON.stringify(data));
done();
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0010 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0011
* @tc.name: isAbilityEnabledEmptyModule * @tc.name: isAbilityEnabledInvalidModule
* @tc.desc: test empty moduleName * @tc.desc: test non-existent moduleName
*/ */
it('isAbilityEnabledEmptyModule', 0, async function (done) { it('isAbilityEnabledInvalidModule', 0, async function (done) {
let abilityInfo = generateAbilityInfoForTest(ABILITY_INFO_ONE.bundleName, ABILITY_INFO_ONE.name, ABILITY_INFO_ONE.moduleName); let abilityInfo = generateAbilityInfoForTest(ABILITY_INFO_TWO.bundleName, ABILITY_INFO_TWO.name, ABILITY_INFO_TWO.moduleName);
await bundle.isAbilityEnabled(abilityInfo) await bundle.isAbilityEnabled(abilityInfo)
.then(data => { .then(data => {
console.info('[isAbilityEnabledEmptyModule]Return data successful: ' + JSON.stringify(data)); expect(data).assertEqual(false);
expect(data).assertTrue(); }).catch((err) => {
}).catch((err) => { console.error('[isAbilityEnabledInvalidModule]Operation failed. Err: ' + JSON.stringify(err));
console.error('[isAbilityEnabledEmptyModule]Operation failed. Err: ' + JSON.stringify(err)); expect(err).assertFail();
expect(err).assertFail();
});
bundle.isAbilityEnabled(abilityInfo, (err, data) => {
expect(err).assertEqual(SUCCESS_CODE);
if (err) {
console.error('[isAbilityEnabledEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
}
expect(data).assertTrue();
console.info("'[isAbilityEnabledEmptyModule]Return data: " + JSON.stringify(data));
done();
});
}); });
bundle.isAbilityEnabled(abilityInfo, (err, data) => {
expect(data).assertEqual(false);
if (err) {
console.error('[isAbilityEnabledInvalidModule]Operation failed. Err: ' + JSON.stringify(err));
}
expect(err).assertEqual(SUCCESS_CODE);
console.info("'[isAbilityEnabledInvalidModule]Return data: " + JSON.stringify(data));
done();
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0011 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0008
* @tc.name: isAbilityEnabledInvalidModule * @tc.name: isAbilityEnabledHasModule
* @tc.desc: test non-existent moduleName * @tc.desc: test existent moduleName
*/ */
it('isAbilityEnabledInvalidModule', 0, async function (done) { it('isAbilityEnabledHasModule', 0, async function (done) {
let abilityInfo = generateAbilityInfoForTest(ABILITY_INFO_TWO.bundleName, ABILITY_INFO_TWO.name, ABILITY_INFO_TWO.moduleName); let abilityInfo = generateAbilityInfoForTest(ABILITY_INFO_THREE.bundleName, ABILITY_INFO_THREE.name, ABILITY_INFO_THREE.moduleName);
await bundle.isAbilityEnabled(abilityInfo) await bundle.isAbilityEnabled(abilityInfo)
.then(data => { .then(data => {
expect(data).assertEqual(false); console.info('[isAbilityEnabledHasModule]Return data successful: ' + JSON.stringify(data));
}).catch((err) => { expect(data).assertTrue();
console.error('[isAbilityEnabledInvalidModule]Operation failed. Err: ' + JSON.stringify(err)); }).catch((err) => {
expect(err).assertFail(); console.error('[isAbilityEnabledHasModule]Operation failed. Err: ' + JSON.stringify(err));
}); expect(err).assertFail();
bundle.isAbilityEnabled(abilityInfo, (err, data) => {
expect(data).assertEqual(false);
if (err) {
console.error('[isAbilityEnabledInvalidModule]Operation failed. Err: ' + JSON.stringify(err));
}
expect(err).assertEqual(SUCCESS_CODE);
console.info("'[isAbilityEnabledInvalidModule]Return data: " + JSON.stringify(data));
done();
});
}); });
bundle.isAbilityEnabled(abilityInfo, (err, data) => {
expect(err).assertEqual(SUCCESS_CODE);
if (err) {
console.error('[isAbilityEnabledHasModule]Operation failed. Err: ' + JSON.stringify(err));
}
expect(data).assertTrue();
console.info("'[isAbilityEnabledHasModule]Return data: " + JSON.stringify(data));
done();
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0008 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0012
* @tc.name: isAbilityEnabledHasModule * @tc.name: isAbilityEnabledUndefinedModule
* @tc.desc: test existent moduleName * @tc.desc: test empty moduleName
*/ */
it('isAbilityEnabledHasModule', 0, async function (done) { it('isAbilityEnabledUndefinedModule', 0, async function (done) {
let abilityInfo = generateAbilityInfoForTest(ABILITY_INFO_THREE.bundleName, ABILITY_INFO_THREE.name, ABILITY_INFO_THREE.moduleName); let abilityInfo = generateAbilityInfoForTest(ABILITY_INFO_FOUR.bundleName, ABILITY_INFO_FOUR.name, ABILITY_INFO_FOUR.moduleName);
await bundle.isAbilityEnabled(abilityInfo) await bundle.isAbilityEnabled(abilityInfo)
.then(data => { .then(data => {
console.info('[isAbilityEnabledHasModule]Return data successful: ' + JSON.stringify(data)); expect(data).assertFail();
expect(data).assertTrue(); }).catch((err) => {
}).catch((err) => { console.error('[isAbilityEnabledUndefinedModule]Operation failed. Err: ' + JSON.stringify(err));
console.error('[isAbilityEnabledHasModule]Operation failed. Err: ' + JSON.stringify(err)); expect(err).assertEqual(INVALID_PARAM);
expect(err).assertFail();
});
bundle.isAbilityEnabled(abilityInfo, (err, data) => {
expect(err).assertEqual(SUCCESS_CODE);
if (err) {
console.error('[isAbilityEnabledHasModule]Operation failed. Err: ' + JSON.stringify(err));
}
expect(data).assertTrue();
console.info("'[isAbilityEnabledHasModule]Return data: " + JSON.stringify(data));
done();
});
}); });
bundle.isAbilityEnabled(abilityInfo, (err, data) => {
expect(data).assertEqual(undefined);
if (err) {
console.error('[isAbilityEnabledUndefinedModule]Operation failed. Err: ' + JSON.stringify(err));
}
expect(err).assertEqual(INVALID_PARAM);
console.info("'[isAbilityEnabledUndefinedModule]Return data: " + JSON.stringify(data));
done();
});
});
/*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0033
* @tc.name: queryAbilityByWantEmptyModule
* @tc.desc: test empty moduleName
*/
it('queryAbilityByWantEmptyModule', 0, async function (done) {
await bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME,
abilityName: ABILITY_NAME,
moduleName: MODULE_NAME1
}, DEFAULT_FLAG, userId).then(data => {
checkDataInfo(data[0]);
console.info("'[queryAbilityByWantEmptyModule]Return data : " + JSON.stringify(data));
}).catch(err => {
console.info("[queryAbilityByWantEmptyModule]Operation failed. Err: " + JSON.stringify(err));
expect(err).assertFail();
});
bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME,
abilityName: ABILITY_NAME,
moduleName: MODULE_NAME1
}, DEFAULT_FLAG, userId, (err, data) => {
expect(err).assertEqual(SUCCESS_CODE);
if (err) {
console.error('[queryAbilityByWantEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
}
checkDataInfo(data[0]);
console.info("'[queryAbilityByWantEmptyModule]Return data : " + JSON.stringify(data));
done();
});
});
/*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0002
* @tc.name: queryAbilityByWantInvalidModule
* @tc.desc: test non-existent moduleName
*/
it('queryAbilityByWantInvalidModule', 0, async function (done) {
await bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME,
abilityName: ABILITY_NAME,
moduleName: MODULE_NAME2
}, DEFAULT_FLAG, userId).then(data => {
expect(data).assertFail();
}).catch(err => {
console.error('[queryAbilityByWantInvalidModule]Operation failed. Err: ' + JSON.stringify(err));
expect(err).assertEqual(INVALID_CODE);
});
bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME,
abilityName: ABILITY_NAME,
moduleName: MODULE_NAME2
}, DEFAULT_FLAG, userId, (err, data) => {
console.info("'[queryAbilityByWantInvalidModule]Return data " + JSON.stringify(data));
expect(data).assertEqual("QueryAbilityInfos failed");
console.error('[queryAbilityByWantInvalidModule]Operation failed. Err: ' + JSON.stringify(err));
expect(err).assertEqual(INVALID_CODE);
done();
});
});
/*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0001
* @tc.name: queryAbilityByWantHasModule
* @tc.desc: test existent moduleName
*/
it('queryAbilityByWantHasModule', 0, async function (done) {
await bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME,
abilityName: ABILITY_NAME,
moduleName: MODULE_NAME3
}, DEFAULT_FLAG, userId).then(data => {
checkDataInfo(data[0]);
console.info("'[queryAbilityByWantHasModule]Return data : " + JSON.stringify(data));
}).catch(err => {
console.info("[queryAbilityByWantHasModule]Operation failed. Err: " + JSON.stringify(err));
expect(err).assertFail();
});
bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME,
abilityName: ABILITY_NAME,
moduleName: MODULE_NAME3
}, DEFAULT_FLAG, userId, (err, data) => {
expect(err).assertEqual(SUCCESS_CODE);
if (err) {
console.error('[queryAbilityByWantHasModule]Operation failed. Err: ' + JSON.stringify(err));
}
checkDataInfo(data[0]);
console.info("'[queryAbilityByWantHasModule]Return data : " + JSON.stringify(data));
done();
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0012 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0022
* @tc.name: isAbilityEnabledUndefinedModule * @tc.name: getAbilityInfoUndefinedModule
* @tc.desc: test empty moduleName * @tc.desc: test undefined moduleName
*/ */
it('isAbilityEnabledUndefinedModule', 0, async function (done) { it('getAbilityInfoUndefinedModule', 0, async function (done) {
let abilityInfo = generateAbilityInfoForTest(ABILITY_INFO_FOUR.bundleName, ABILITY_INFO_FOUR.name, ABILITY_INFO_FOUR.moduleName); await bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME4, ABILITY_NAME)
await bundle.isAbilityEnabled(abilityInfo) .then(data => {
.then(data => { expect(data).assertFail();
expect(data).assertFail(); }).catch((err) => {
}).catch((err) => { expect(err).assertEqual(INVALID_PARAM);
console.error('[isAbilityEnabledUndefinedModule]Operation failed. Err: ' + JSON.stringify(err)); bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME4, ABILITY_NAME, (error, data) => {
expect(err).assertEqual(INVALID_PARAM); expect(error).assertEqual(INVALID_PARAM);
}); });
bundle.isAbilityEnabled(abilityInfo, (err, data) => {
expect(data).assertEqual(undefined);
if (err) {
console.error('[isAbilityEnabledUndefinedModule]Operation failed. Err: ' + JSON.stringify(err));
}
expect(err).assertEqual(INVALID_PARAM);
console.info("'[isAbilityEnabledUndefinedModule]Return data: " + JSON.stringify(data));
done();
});
}); });
await bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME5, ABILITY_NAME)
.then(data => {
expect(data).assertFail();
done();
}).catch((err) => {
expect(err).assertEqual(INVALID_PARAM);
bundle.getAbilityInfo(BUNDLE_NAME, MODULE_NAME5, ABILITY_NAME, (error, data) => {
expect(error).assertEqual(INVALID_PARAM);
done();
});
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0033 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0029
* @tc.name: queryAbilityByWantEmptyModule * @tc.name: getAbilityIconUndefinedModule
* @tc.desc: test empty moduleName * @tc.desc: test undefined moduleName
*/ */
it('queryAbilityByWantEmptyModule', 0, async function (done) { it('getAbilityIconUndefinedModule', 0, async function (done) {
await bundle.queryAbilityByWant({ await bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME4, ABILITY_NAME)
bundleName: BUNDLE_NAME, .then(data => {
abilityName: ABILITY_NAME, expect(data).assertFail();
moduleName: MODULE_NAME1 }).catch((err) => {
}, DEFAULT_FLAG, userId).then(data => { expect(err).assertEqual(INVALID_PARAM);
checkDataInfo(data[0]); bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME4, ABILITY_NAME, (error, data) => {
console.info("'[queryAbilityByWantEmptyModule]Return data : " + JSON.stringify(data)); expect(error).assertEqual(INVALID_PARAM);
}).catch(err => { });
console.info("[queryAbilityByWantEmptyModule]Operation failed. Err: " + JSON.stringify(err));
expect(err).assertFail();
});
bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME,
abilityName: ABILITY_NAME,
moduleName: MODULE_NAME1
}, DEFAULT_FLAG, userId, (err, data) => {
expect(err).assertEqual(SUCCESS_CODE);
if (err) {
console.error('[queryAbilityByWantEmptyModule]Operation failed. Err: ' + JSON.stringify(err));
}
checkDataInfo(data[0]);
console.info("'[queryAbilityByWantEmptyModule]Return data : " + JSON.stringify(data));
done();
});
}); });
await bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME5, ABILITY_NAME)
.then(data => {
expect(data).assertFail();
done();
}).catch((err) => {
expect(err).assertEqual(INVALID_PARAM);
bundle.getAbilityIcon(BUNDLE_NAME, MODULE_NAME5, ABILITY_NAME, (error, data) => {
expect(error).assertEqual(INVALID_PARAM);
done();
});
});
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0002 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0025
* @tc.name: queryAbilityByWantInvalidModule * @tc.name: getAbilityLabelUndefinedModule
* @tc.desc: test non-existent moduleName * @tc.desc: test undefined moduleName
*/ */
it('queryAbilityByWantInvalidModule', 0, async function (done) { it('getAbilityLabelUndefinedModule', 0, async function (done) {
await bundle.queryAbilityByWant({ await bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME4, ABILITY_NAME)
bundleName: BUNDLE_NAME, .then(data => {
abilityName: ABILITY_NAME, expect(data).assertFail();
moduleName: MODULE_NAME2 }).catch((err) => {
}, DEFAULT_FLAG, userId).then(data => { expect(err).assertEqual(INVALID_PARAM);
expect(data).assertFail(); bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME4, ABILITY_NAME, (error, data) => {
}).catch(err => { expect(error).assertEqual(INVALID_PARAM);
console.error('[queryAbilityByWantInvalidModule]Operation failed. Err: ' + JSON.stringify(err)); });
expect(err).assertEqual(INVALID_CODE); });
}); await bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME5, ABILITY_NAME)
bundle.queryAbilityByWant({ .then(data => {
bundleName: BUNDLE_NAME, expect(data).assertFail();
abilityName: ABILITY_NAME, done();
moduleName: MODULE_NAME2 }).catch((err) => {
}, DEFAULT_FLAG, userId, (err, data) => { expect(err).assertEqual(INVALID_PARAM);
console.info("'[queryAbilityByWantInvalidModule]Return data " + JSON.stringify(data)); bundle.getAbilityLabel(BUNDLE_NAME, MODULE_NAME5, ABILITY_NAME, (error, data) => {
expect(data).assertEqual("QueryAbilityInfos failed"); expect(error).assertEqual(INVALID_PARAM);
console.error('[queryAbilityByWantInvalidModule]Operation failed. Err: ' + JSON.stringify(err)); done();
expect(err).assertEqual(INVALID_CODE); });
done();
});
}); });
});
/* /*
* @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0001 * @tc.number: SUB_BMS_APPINFO_QUERYMODULE_0004
* @tc.name: queryAbilityByWantHasModule * @tc.name: queryAbilityByWantUndefinedModule
* @tc.desc: test existent moduleName * @tc.desc: test undefined moduleName
*/ */
it('queryAbilityByWantHasModule', 0, async function (done) { it('queryAbilityByWantUndefinedModule', 0, async function (done) {
await bundle.queryAbilityByWant({ await bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME, bundleName: BUNDLE_NAME,
abilityName: ABILITY_NAME, abilityName: ABILITY_NAME,
moduleName: MODULE_NAME3 moduleName: MODULE_NAME4
}, DEFAULT_FLAG, userId).then(data => { }, DEFAULT_FLAG, userId).then(data => {
checkDataInfo(data[0]); checkDataInfo(data[0]);
console.info("'[queryAbilityByWantHasModule]Return data : " + JSON.stringify(data)); bundle.queryAbilityByWant({
}).catch(err => { bundleName: BUNDLE_NAME,
console.info("[queryAbilityByWantHasModule]Operation failed. Err: " + JSON.stringify(err)); abilityName: ABILITY_NAME,
expect(err).assertFail(); moduleName: MODULE_NAME4
}); }, DEFAULT_FLAG, userId, (err1, data1) => {
bundle.queryAbilityByWant({ checkDataInfo(data1[0]);
bundleName: BUNDLE_NAME, expect(err1).assertEqual(SUCCESS_CODE);
abilityName: ABILITY_NAME, });
moduleName: MODULE_NAME3 }).catch(err => {
}, DEFAULT_FLAG, userId, (err, data) => { expect().assertFail();
expect(err).assertEqual(SUCCESS_CODE); });
if (err) { await bundle.queryAbilityByWant({
console.error('[queryAbilityByWantHasModule]Operation failed. Err: ' + JSON.stringify(err)); bundleName: BUNDLE_NAME,
} abilityName: ABILITY_NAME,
checkDataInfo(data[0]); moduleName: MODULE_NAME5
console.info("'[queryAbilityByWantHasModule]Return data : " + JSON.stringify(data)); }, DEFAULT_FLAG, userId).then(data => {
done(); checkDataInfo(data[0]);
}); bundle.queryAbilityByWant({
bundleName: BUNDLE_NAME,
abilityName: ABILITY_NAME,
moduleName: MODULE_NAME5
}, DEFAULT_FLAG, userId, (err1, data1) => {
checkDataInfo(data1[0]);
expect(err1).assertEqual(SUCCESS_CODE);
done();
}); });
}).catch(err => {
expect().assertFail();
done();
});
});
function checkDataInfo(data) {
expect(typeof (data.bundleName)).assertEqual("string"); function checkDataInfo(data) {
expect(data.bundleName).assertEqual("com.example.bmsmodulename"); expect(typeof (data.bundleName)).assertEqual("string");
expect(typeof (data.name)).assertEqual("string"); expect(data.bundleName).assertEqual("com.example.bmsmodulename");
expect(data.name).assertEqual("com.example.bmsmodulename.MainAbility"); expect(typeof (data.name)).assertEqual("string");
expect(data.label).assertEqual("$string:app_name"); expect(data.name).assertEqual("com.example.bmsmodulename.MainAbility");
expect(typeof (data.label)).assertEqual("string"); expect(data.label).assertEqual("$string:app_name");
expect(data.description).assertEqual("$string:mainability_description"); expect(typeof (data.label)).assertEqual("string");
expect(typeof (data.description)).assertEqual("string"); expect(data.description).assertEqual("$string:mainability_description");
expect(data.icon).assertEqual("$media:icon"); expect(typeof (data.description)).assertEqual("string");
expect(typeof (data.icon)).assertEqual("string"); expect(data.icon).assertEqual("$media:icon");
expect(data.isVisible).assertEqual(false); expect(typeof (data.icon)).assertEqual("string");
expect(data.deviceTypes[0]).assertEqual("default"); expect(data.isVisible).assertEqual(false);
expect(typeof (data.process)).assertEqual("string"); expect(data.deviceTypes[0]).assertEqual("default");
expect(data.process).assertEqual("com.example.bmsmodulename"); expect(typeof (data.process)).assertEqual("string");
expect(typeof (data.uri)).assertEqual("string"); expect(data.process).assertEqual("com.example.bmsmodulename");
expect(data.uri).assertEqual(""); expect(typeof (data.uri)).assertEqual("string");
expect(data.moduleName).assertEqual("entry"); expect(data.uri).assertEqual("");
expect(typeof (data.moduleName)).assertEqual("string"); expect(data.moduleName).assertEqual("entry");
expect(typeof (data.applicationInfo)).assertEqual("object"); expect(typeof (data.moduleName)).assertEqual("string");
let info = data.applicationInfo; expect(typeof (data.applicationInfo)).assertEqual("object");
expect(typeof (info)).assertEqual("object"); let info = data.applicationInfo;
expect(typeof (info.name)).assertEqual("string"); expect(typeof (info)).assertEqual("object");
expect(info.name).assertEqual("com.example.bmsmodulename"); expect(typeof (info.name)).assertEqual("string");
expect(typeof (info.codePath)).assertEqual("string"); expect(info.name).assertEqual("com.example.bmsmodulename");
expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.example.bmsmodulename"); expect(typeof (info.codePath)).assertEqual("string");
expect(typeof (info.accessTokenId)).assertEqual("number"); expect(info.codePath).assertEqual("/data/app/el1/bundle/public/com.example.bmsmodulename");
expect(info.accessTokenId > 0).assertTrue(); expect(typeof (info.accessTokenId)).assertEqual("number");
expect(typeof (info.description)).assertEqual("string"); expect(info.accessTokenId > 0).assertTrue();
expect(info.description).assertEqual(""); expect(typeof (info.description)).assertEqual("string");
expect(typeof (info.descriptionId)).assertEqual("number"); expect(info.description).assertEqual("");
expect(info.descriptionId).assertEqual(0); expect(typeof (info.descriptionId)).assertEqual("number");
expect(typeof (info.icon)).assertEqual("string"); expect(info.descriptionId).assertEqual(0);
expect(info.icon).assertEqual("$media:icon"); expect(typeof (info.icon)).assertEqual("string");
expect(typeof (info.iconId)).assertEqual("number"); expect(info.icon).assertEqual("$media:icon");
expect(info.iconId > 0).assertTrue(); expect(typeof (info.iconId)).assertEqual("number");
expect(typeof (info.label)).assertEqual("string"); expect(info.iconId > 0).assertTrue();
expect(info.label).assertEqual("$string:app_name"); expect(typeof (info.label)).assertEqual("string");
expect(typeof (info.labelId)).assertEqual("number"); expect(info.label).assertEqual("$string:app_name");
expect(info.labelId > 0).assertTrue(); expect(typeof (info.labelId)).assertEqual("number");
expect(info.systemApp).assertEqual(false); expect(info.labelId > 0).assertTrue();
expect(typeof (info.entryDir)).assertEqual("string"); expect(info.systemApp).assertEqual(false);
expect(info.entryDir).assertEqual("/data/app/el1/bundle/public/com.example.bmsmodulename/com.example.bmsmodulenamedentry"); expect(typeof (info.entryDir)).assertEqual("string");
expect(typeof (info.process)).assertEqual("string"); expect(info.entryDir)
expect(info.process).assertEqual("com.example.bmsmodulename"); .assertEqual("/data/app/el1/bundle/public/com.example.bmsmodulename/com.example.bmsmodulenamedentry");
expect(Array.isArray(info.permissions)).assertEqual(true); expect(typeof (info.process)).assertEqual("string");
console.log("---checkDataInfo End--- "); expect(info.process).assertEqual("com.example.bmsmodulename");
} expect(Array.isArray(info.permissions)).assertEqual(true);
console.log("---checkDataInfo End--- ");
}
function generateAbilityInfoForTest(bundleName, name, moduleName) { function generateAbilityInfoForTest(bundleName, name, moduleName) {
let map1 = new Map([ let map1 = new Map([
...@@ -570,5 +702,5 @@ export default function actsBmsJsModuleNameTest() { ...@@ -570,5 +702,5 @@ export default function actsBmsJsModuleNameTest() {
return abilityInfo; return abilityInfo;
} }
}); });
} }
/**
* 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, it, expect, beforeAll, beforeEach, afterEach, afterAll } from 'hypium/index';
import bundleManager from '@ohos.bundle';
import account from '@ohos.account.osAccount'
const BUNDLE_NAME = 'com.example.myapplication1';
const MODULE_NAME = 'entry';
const ABILITY_NAME = 'com.example.myapplication1.MainAbility';
const PATH = '/data/test/bmsJstest1.hap';
const FLAG1 = bundleManager.BundleFlag.GET_BUNDLE_WITH_ABILITIES;
const FLAG2 = bundleManager.BundleFlag.GET_ALL_APPLICATION_INFO;
const FLAG3 = bundleManager.BundleFlag.GET_BUNDLE_DEFAULT;
let userId = 0;
export default function GetResourceTest() {
describe('GetResourceTest', function () {
beforeAll(async function (done) {
await account.getAccountManager().getOsAccountLocalIdFromProcess().then(account => {
console.info("getOsAccountLocalIdFromProcess userid ==========" + account);
userId = account;
done();
}).catch(err => {
console.info("getOsAccountLocalIdFromProcess err ==========" + JSON.stringify(err));
done();
})
});
/*
* @tc.number: SUB_BMS_APPINFO_GETAPPICON_0001
* @tc.name: getBundleInfoForResource
* @tc.desc: get Resource by getBundleInfo
*/
it('getBundleInfoForResource', 0, async function (done) {
await bundleManager.getBundleInfo(BUNDLE_NAME, FLAG1).then(data => {
let applicationInfo = data.appInfo;
expect(applicationInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.iconResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.iconResource.id).assertLarger(0)
expect(applicationInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.labelResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.labelResource.id).assertLarger(0)
expect(applicationInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.descriptionResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.descriptionResource.id).assertLarger(0)
}).catch(err => {
expect().assertFail();
})
bundleManager.getBundleInfo(BUNDLE_NAME, FLAG1, (err, data) => {
let applicationInfo = data.appInfo;
expect(applicationInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.iconResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.iconResource.id).assertLarger(0)
expect(applicationInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.labelResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.labelResource.id).assertLarger(0)
expect(applicationInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.descriptionResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.descriptionResource.id).assertLarger(0)
expect(err).assertEqual(0)
done()
})
});
/*
* @tc.number: SUB_BMS_APPINFO_GETAPPICON_0002
* @tc.name: getAllBundleInfoForResource
* @tc.desc: get Resource by getAllBundleInfo
*/
it('getAllBundleInfoForResource', 0, async function (done) {
await bundleManager.getAllBundleInfo(FLAG1).then(data => {
for (let i = 0; i < data.length; i++) {
if (data[i].name == BUNDLE_NAME) {
let applicationInfo = data[i].appInfo;
expect(applicationInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.iconResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.iconResource.id).assertLarger(0)
expect(applicationInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.labelResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.labelResource.id).assertLarger(0)
expect(applicationInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.descriptionResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.descriptionResource.id).assertLarger(0)
}
}
}).catch(err => {
expect().assertFail();
});
bundleManager.getAllBundleInfo(FLAG1, (err, data) => {
for (let i = 0; i < data.length; i++) {
if (data[i].name == BUNDLE_NAME) {
let applicationInfo = data[i].appInfo;
expect(applicationInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.iconResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.iconResource.id).assertLarger(0)
expect(applicationInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.labelResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.labelResource.id).assertLarger(0)
expect(applicationInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.descriptionResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.descriptionResource.id).assertLarger(0)
}
}
expect(err).assertEqual(0)
done();
})
});
/*
* @tc.number: SUB_BMS_APPINFO_GETAPPICON_0004
* @tc.name: getAllApplicationInfoForResource
* @tc.desc: get Resource by getAllApplicationInfo
*/
it('getAllApplicationInfoForResource', 0, async function (done) {
await bundleManager.getAllApplicationInfo(FLAG2).then(data => {
for (let i = 0; i < data.length; i++) {
if (data[i].name == BUNDLE_NAME) {
let applicationInfo = data[i];
expect(applicationInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.iconResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.iconResource.id).assertLarger(0)
expect(applicationInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.labelResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.labelResource.id).assertLarger(0)
expect(applicationInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.descriptionResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.descriptionResource.id).assertLarger(0)
}
}
}).catch(err => {
expect().assertFail();
});
bundleManager.getAllApplicationInfo(FLAG2, (err, data) => {
for (let i = 0; i < data.length; i++) {
if (data[i].name == BUNDLE_NAME) {
let applicationInfo = data[i];
expect(applicationInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.iconResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.iconResource.id).assertLarger(0)
expect(applicationInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.labelResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.labelResource.id).assertLarger(0)
expect(applicationInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.descriptionResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.descriptionResource.id).assertLarger(0)
}
}
expect(err).assertEqual(0)
done();
})
});
/*
* @tc.number: SUB_BMS_APPINFO_GETAPPICON_0005
* @tc.name: getAbilityInfoForResource
* @tc.desc: get Resource by getAbilityInfo
*/
it('getAbilityInfoForResource', 0, async function (done) {
await bundleManager.getAbilityInfo(BUNDLE_NAME, ABILITY_NAME).then(data => {
let applicationInfo = data.applicationInfo;
expect(applicationInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.iconResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.iconResource.id).assertLarger(0)
expect(applicationInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.labelResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.labelResource.id).assertLarger(0)
expect(applicationInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.descriptionResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.descriptionResource.id).assertLarger(0)
}).catch(error => {
expect().assertFail();
});
bundleManager.getAbilityInfo(BUNDLE_NAME, ABILITY_NAME, (err, data) => {
let applicationInfo = data.applicationInfo;
expect(applicationInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.iconResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.iconResource.id).assertLarger(0)
expect(applicationInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.labelResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.labelResource.id).assertLarger(0)
expect(applicationInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.descriptionResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.descriptionResource.id).assertLarger(0)
expect(err).assertEqual(0)
done();
})
});
/*
* @tc.number: SUB_BMS_APPINFO_GETAPPICON_0006
* @tc.name: queryAbilityByWantForResource
* @tc.desc: get Resource by queryAbilityByWant
*/
it('queryAbilityByWantForResource', 0, async function (done) {
await bundleManager.queryAbilityByWant({
bundleName: BUNDLE_NAME,
abilityName: ABILITY_NAME
}, FLAG3, userId).then((data) => {
let applicationInfo = data[0].applicationInfo;
expect(applicationInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.iconResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.iconResource.id).assertLarger(0)
expect(applicationInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.labelResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.labelResource.id).assertLarger(0)
expect(applicationInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.descriptionResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.descriptionResource.id).assertLarger(0)
}).catch((error) => {
expect().assertFail();
});
bundleManager.queryAbilityByWant({
bundleName: BUNDLE_NAME,
abilityName: ABILITY_NAME
}, FLAG3, userId , (err,data) => {
let applicationInfo = data[0].applicationInfo;
expect(applicationInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.iconResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.iconResource.id).assertLarger(0)
expect(applicationInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.labelResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.labelResource.id).assertLarger(0)
expect(applicationInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.descriptionResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.descriptionResource.id).assertLarger(0)
expect(err).assertEqual(0)
done();
})
});
/*
* @tc.number: SUB_BMS_APPINFO_GETAPPICON_0007
* @tc.name: getBundleArchiveInfoForResource
* @tc.desc: get Resource by getBundleArchiveInfo
*/
it('getBundleArchiveInfoForResource', 0, async function (done) {
await bundleManager.getBundleArchiveInfo(PATH, FLAG1).then((data) => {
let applicationInfo = data.appInfo;
expect(applicationInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.iconResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.iconResource.id).assertLarger(0)
expect(applicationInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.labelResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.labelResource.id).assertLarger(0)
expect(applicationInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.descriptionResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.descriptionResource.id).assertLarger(0)
}).catch((err) => {
expect().assertFail();
})
bundleManager.getBundleArchiveInfo(PATH, FLAG1,(err,data) => {
let applicationInfo = data.appInfo;
expect(applicationInfo.iconResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.iconResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.iconResource.id).assertLarger(0)
expect(applicationInfo.labelResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.labelResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.labelResource.id).assertLarger(0)
expect(applicationInfo.descriptionResource.bundleName).assertEqual(BUNDLE_NAME)
expect(applicationInfo.descriptionResource.moduleName).assertEqual(MODULE_NAME)
expect(applicationInfo.descriptionResource.id).assertLarger(0)
expect(err).assertEqual(0)
done();
})
});
});
}
\ No newline at end of file
...@@ -28,6 +28,7 @@ import isDefaultApplicationTest from './IsDefaultApplication.test.ets'; ...@@ -28,6 +28,7 @@ import isDefaultApplicationTest from './IsDefaultApplication.test.ets';
import getWindowPorperties from './getWindowProperties.test.ets'; import getWindowPorperties from './getWindowProperties.test.ets';
import GetSecondModuleTest from './GetSecondModule.test.ets'; import GetSecondModuleTest from './GetSecondModule.test.ets';
import GetInfoSync from './GetInfoSync.test.ets'; import GetInfoSync from './GetInfoSync.test.ets';
import GetResourceTest from './GetResourceTest.test.ets';
export default function testsuite() { export default function testsuite() {
getBundleArchiveInfo(); getBundleArchiveInfo();
...@@ -50,4 +51,5 @@ export default function testsuite() { ...@@ -50,4 +51,5 @@ export default function testsuite() {
getWindowPorperties(); getWindowPorperties();
GetSecondModuleTest(); GetSecondModuleTest();
GetInfoSync(); GetInfoSync();
GetResourceTest();
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册