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

新增queryExtensionAbilityInfos接口6条用例

Signed-off-by: Ninter515 <ry.renyi@huawei.com>
上级 1b278639
......@@ -20,6 +20,7 @@ const BUNDLE_NAME1 = "ohos.acts.bundle.stage";
const BUNDLE_NAME2 = "com.noexit.com";
const ABILITY_NAME1 = "ExtensionAbility1";
const ABILITY_NAME2 = "noexitAbility";
const ABILITY_NAME3 = "ServiceAbility";
export default function QueryExtensionAbilityInfos() {
......@@ -79,14 +80,14 @@ export default function QueryExtensionAbilityInfos() {
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata.length).assertEqual(0);
}).catch(err => {
expect(err).assertEqual(1);
expect(err).assertFail();
});
bundle.queryExtensionAbilityInfos({
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_PERMISSION, 100, (err, data) => {
if (err) {
expect(err).assertEqual(1);
expect(err).assertFail();
done();
return;
}
......@@ -134,7 +135,7 @@ export default function QueryExtensionAbilityInfos() {
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata.length).assertEqual(0);
}).catch(err => {
expect(err).assertEqual(1);
expect(err).assertFail();
});
bundle.queryExtensionAbilityInfos(
{
......@@ -143,7 +144,7 @@ export default function QueryExtensionAbilityInfos() {
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT,
100, (err, data) => {
if (err) {
expect(err).assertEqual(1);
expect(err).assertFail();
done();
return;
}
......@@ -172,9 +173,9 @@ export default function QueryExtensionAbilityInfos() {
it('SUB_BMS_APPINFO_EXTENSION_0004', 0, async function (done) {
await bundle.queryExtensionAbilityInfos({
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_APPLICATION,
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_APPLICATION,
100).then(data => {
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
......@@ -194,9 +195,9 @@ export default function QueryExtensionAbilityInfos() {
expect(err).assertFail();
});
bundle.queryExtensionAbilityInfos({
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_APPLICATION,
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME1
}, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_APPLICATION,
100, (err, data) => {
if (err) {
expect(err).assertFail();
......@@ -372,6 +373,263 @@ export default function QueryExtensionAbilityInfos() {
})
})
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0009
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos get service extensionAbility
*/
it('SUB_BMS_APPINFO_EXTENSION_0009', 0, async function (done) {
await bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME3
}, bundle.ExtensionAbilityType.SERVICE, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT,
100).then(data => {
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual(ABILITY_NAME3);
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(3);
expect(data[0].permissions.length).assertEqual(0);
expect(data[0].enabled).assertTrue();
expect(data[0].readPermission).assertEqual("");
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata.length).assertEqual(0);
}).catch(err => {
expect(err).assertEqual(1);
});
bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"abilityName": ABILITY_NAME3
}, bundle.ExtensionAbilityType.SERVICE, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT,
100, (err, data) => {
if (err) {
expect(err).assertEqual(1);
done();
return;
}
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual(ABILITY_NAME3);
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(3);
expect(data[0].permissions.length).assertEqual(0);
expect(data[0].enabled).assertTrue();
expect(data[0].readPermission).assertEqual("");
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata.length).assertEqual(0);
done();
})
})
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0010
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos with invalid bundleName
*/
it('SUB_BMS_APPINFO_EXTENSION_0010', 0, async function (done) {
await bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME2
}, bundle.ExtensionAbilityType.UNSPECIFIED, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, 100).then(data => {
expect(data).assertFail();
}).catch(err => {
expect(err).assertEqual(1);
});
bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME2
}, bundle.ExtensionAbilityType.UNSPECIFIED, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, 100, (err, data) => {
if (err) {
expect(err).assertEqual(1);
done();
return;
}
expect(data).assertFail();
done();
})
})
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0011
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos of Implicit query with get permission flag
*/
it('SUB_BMS_APPINFO_EXTENSION_0011', 0, async function (done) {
await bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"action": "actionY"
}, bundle.ExtensionAbilityType.UNSPECIFIED, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_PERMISSION,
100).then(data => {
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual("ExtensionAbility1");
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(0);
expect(data[0].permissions[0]).assertEqual("ohos.permission.GET_BUNDLE_INFO");
expect(data[0].enabled).assertTrue();
expect(data[0].readPermission).assertEqual("");
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata.length).assertEqual(0);
}).catch(err => {
expect(err).assertFail();
});
bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"action": "actionY"
}, bundle.ExtensionAbilityType.UNSPECIFIED, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_PERMISSION,
100, (err, data) => {
if (err) {
expect(err).assertFail();
done();
return;
}
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual("ExtensionAbility1");
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(0);
expect(data[0].permissions[0]).assertEqual("ohos.permission.GET_BUNDLE_INFO");
expect(data[0].enabled).assertTrue();
expect(data[0].readPermission).assertEqual("");
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata.length).assertEqual(0);
done();
})
})
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0012
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos of Implicit query with get permission flag
*/
it('SUB_BMS_APPINFO_EXTENSION_0012', 0, async function (done) {
await bundle.queryExtensionAbilityInfos({
"bundleName": BUNDLE_NAME1,
"action": "actionY12", "uri": "https://www.test.com/query/student/name"
}, bundle.ExtensionAbilityType.UNSPECIFIED, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_METADATA,
100).then(data => {
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual("ExtensionAbility1");
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(0);
expect(data[0].permissions.length).assertEqual(0);
expect(data[0].enabled).assertTrue();
expect(data[0].readPermission).assertEqual("");
expect(data[0].metadata[0].name).assertEqual("ohos.extension.form");
expect(data[0].metadata[0].value).assertEqual("");
expect(data[0].metadata[0].resource).assertEqual("$profile:form_config");
}).catch(err => {
expect(err).assertFail();
});
bundle.queryExtensionAbilityInfos({
"bundleName": BUNDLE_NAME1,
"action": "actionY12", "uri": "https://www.test.com/query/student/name"
}, bundle.ExtensionAbilityType.UNSPECIFIED, bundle.ExtensionFlag.GET_EXTENSION_INFO_WITH_METADATA,
100, (err, data) => {
if (err) {
expect(err).assertFail();
done();
return;
}
expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage");
expect(data[0].moduleName).assertEqual("phone");
expect(data[0].name).assertEqual("ExtensionAbility1");
expect(data[0].labelId).assertLarger(0);
expect(data[0].descriptionId).assertLarger(0);
expect(data[0].iconId).assertEqual(0);
expect(data[0].isVisible).assertFalse();
expect(data[0].extensionAbilityType).assertEqual(0);
expect(data[0].permissions.length).assertEqual(0);
expect(data[0].enabled).assertTrue();
expect(data[0].writePermission).assertEqual("");
expect(data[0].metadata[0].name).assertEqual("ohos.extension.form");
expect(data[0].metadata[0].value).assertEqual("");
expect(data[0].metadata[0].resource).assertEqual("$profile:form_config");
done();
})
})
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0013
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos of Implicit query with get permission flag
*/
it('SUB_BMS_APPINFO_EXTENSION_0013', 0, async function (done) {
await bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"action": "actionY12",
"uri": "https://www.test.com/query/teacher/name"
}, bundle.ExtensionAbilityType.UNSPECIFIED, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT,
100).then(data => {
expect(data).assertFail();
}).catch(err => {
expect(err).assertEqual(1);
});
bundle.queryExtensionAbilityInfos(
{
"bundleName": BUNDLE_NAME1,
"action": "actionY12",
"uri": "https://www.test.com/query/teacher/name"
}, bundle.ExtensionAbilityType.UNSPECIFIED, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT,
100, (err, data) => {
if (err) {
expect(err).assertEqual(1);
done();
return;
}
expect(data).assertFail();
done();
})
})
/*
* @tc.number: SUB_BMS_APPINFO_EXTENSION_0015
* @tc.name: test queryExtensionAbilityInfos api
* @tc.desc: test queryExtensionAbilityInfos of Implicit query with invalid param
*/
it('SUB_BMS_APPINFO_EXTENSION_0015', 0, async function (done) {
await bundle.queryExtensionAbilityInfos(
null, bundle.ExtensionAbilityType.UNSPECIFIED, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT,
100).then(data => {
expect(data).assertFail();
}).catch(err => {
expect(err).assertEqual(1);
});
bundle.queryExtensionAbilityInfos(
{}, bundle.ExtensionAbilityType.UNSPECIFIED, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT,
100, (err, data) => {
if (err) {
expect(err).assertEqual(1);
done();
return;
}
expect(data).assertFail();
done();
})
})
function checkApplication(data) {
expect(data[0].applicationInfo.name).assertEqual("ohos.acts.bundle.stage");
expect(data[0].applicationInfo.codePath).assertEqual("/data/app/el1/bundle/public/ohos.acts.bundle.stage");
......
......@@ -13,16 +13,18 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("bmsStageDemo1") {
ohos_hap("bmsStageDemo1") {
hap_profile = "entry/src/main/module.json"
hap_name = "bmsStageDemo1"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":bmsstagedemoone_js_assets",
":bmsstagedemoone_resources",
":hjs_demo_js_assets",
":hjs_demo_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "bmsStageDemo1"
testonly = true
}
ohos_app_scope("bmsstagedemoone_app_profile") {
......@@ -30,11 +32,11 @@ ohos_app_scope("bmsstagedemoone_app_profile") {
sources = [ "AppScope/resources" ]
}
ohos_js_assets("bmsstagedemoone_js_assets") {
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("bmsstagedemoone_resources") {
ohos_resources("hjs_demo_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":bmsstagedemoone_app_profile" ]
hap_profile = "entry/src/main/module.json"
......
......@@ -40,13 +40,27 @@
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "form",
"skills": [
{
"actions": ["actionZ"]
},
{
"actions": ["actionZ12"],
"uris": [
{
"scheme": "https",
"host": "www.test.com",
"pathStartWith": "query/teacher"
}
]
}
],
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
],
"permissions": ["ohos.permission.GET_BUNDLE_INFO"]
]
},
{
"name": "ExtensionAbility1",
......@@ -54,6 +68,21 @@
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "form",
"skills": [
{
"actions": ["actionY"]
},
{
"actions": ["actionY12"],
"uris": [
{
"scheme": "https",
"host": "www.test.com",
"path": "query/student/name"
}
]
}
],
"metadata": [
{
"name": "ohos.extension.form",
......@@ -61,6 +90,19 @@
}
],
"permissions": ["ohos.permission.GET_BUNDLE_INFO"]
},
{
"name": "ServiceAbility",
"srcEntrance": "./ets/ServiceAbility/FormAbility.ts",
"label": "$string:form_FormAbility_label",
"description": "$string:form_FormAbility_desc",
"type": "service",
"metadata": [
{
"name": "ohos.extension.form",
"resource": "$profile:form_config"
}
]
}
]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册