diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/ets/test/GetProfileByAbility.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/ets/test/GetProfileByAbility.test.ets index a617984f79d257d557d97226e52e1da2befd4634..383d09bd93279a8a3c087eafd5024616bfd1fe81 100644 --- a/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/ets/test/GetProfileByAbility.test.ets +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/ets/test/GetProfileByAbility.test.ets @@ -25,6 +25,7 @@ const METADATA_NAME = "ohos.ability.form" const METADATA_NAME1 = "ohos.ability.form1" const METADATA_NAME2 = "ohos.ability.form2" const METADATA_NAME3 = "ohos.ability.form3" +const METADATA_NAME4 = "ohos.ability.form4" const METADATA_NAME_TEST = "ohos.test.form" const PROFILE_JSON_STRING = "{\"src\":[\"MainAbility/pages/index/index\",\"MainAbility/pages/second/second\"]}" @@ -379,7 +380,7 @@ export default function getProfileByAbility() { /* * @tc.number: getProfileByAbility_2200 * @tc.name: getProfileByAbility : The profile is obtained by specified ability - * @tc.desc: profile is .txt (by promise) + * @tc.desc: profile is .txt suffix (by promise) * @tc.level 0 */ it('getProfileByAbility_2200', 0, async function (done) { @@ -398,7 +399,7 @@ export default function getProfileByAbility() { /* * @tc.number: getProfileByAbility_2300 * @tc.name: getProfileByAbility : The profile is obtained by specified ability - * @tc.desc: profile is .txt (by callback) + * @tc.desc: profile is .txt suffix (by callback) * @tc.level 0 */ it('getProfileByAbility_2300', 0, async function (done) { @@ -413,5 +414,42 @@ export default function getProfileByAbility() { done(); }); }) + + /* + * @tc.number: getProfileByAbility_2400 + * @tc.name: getProfileByAbility : The profile is obtained by specified ability + * @tc.desc: profile is invalid json format (by promise) + * @tc.level 0 + */ + it('getProfileByAbility_2400', 0, async function (done) { + await bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME4).then(data => { + console.info('[getProfileByAbility_2400] data is: ' + JSON.stringify(data)); + expect().assertFail(); + done(); + }).catch(err => { + console.error('[getProfileByAbility_2400] Operation failed. Cause: ' + JSON.stringify(err)); + expect(err).assertEqual(1); + done(); + }) + }) + + /* + * @tc.number: getProfileByAbility_2500 + * @tc.name: getProfileByAbility : The profile is obtained by specified ability + * @tc.desc: profile is invalid json format (by callback) + * @tc.level 0 + */ + it('getProfileByAbility_2500', 0, async function (done) { + bundle.getProfileByAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME4, (err, data) => { + if (err) { + console.error('[getProfileByAbility_2500] Operation failed. Cause: ' + JSON.stringify(err)); + expect(err).assertEqual(1); + } + console.info('[getProfileByAbility_2500] data is: ' + JSON.stringify(data)); + expect(typeof data).assertEqual("string"); + expect(data).assertEqual("GetProfile failed"); + done(); + }); + }) }) } \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/ets/test/GetProfileByExtensionAbility.test.ets b/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/ets/test/GetProfileByExtensionAbility.test.ets index 65d7a3bf0b041d435892f4e196fdf70eb4eaec68..3572d7b016ae78d5418be631400e299e5a7d2f3e 100644 --- a/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/ets/test/GetProfileByExtensionAbility.test.ets +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/ets/test/GetProfileByExtensionAbility.test.ets @@ -25,6 +25,7 @@ const METADATA_NAME = "ohos.extension.form" const METADATA_NAME1 = "ohos.extension.form1" const METADATA_NAME2 = "ohos.extension.form2" const METADATA_NAME3 = "ohos.extension.form3" +const METADATA_NAME3 = "ohos.extension.form4" const METADATA_NAME_TEST = "ohos.test.form" const PROFILE_JSON_STRING = "{\"src\":[\"MainAbility/pages/index/index\",\"MainAbility/pages/second/second\"]}" @@ -379,7 +380,7 @@ export default function getProfileByExtensionAbility() { /* * @tc.number: getProfileByExtensionAbility_2200 * @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability - * @tc.desc: profile is .txt (by promise) + * @tc.desc: profile is .txt suffix (by promise) * @tc.level 0 */ it('getProfileByExtensionAbility_2200', 0, async function (done) { @@ -398,7 +399,7 @@ export default function getProfileByExtensionAbility() { /* * @tc.number: getProfileByExtensionAbility_2300 * @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability - * @tc.desc: profile is .txt (by callback) + * @tc.desc: profile is invalid json format (by callback) * @tc.level 0 */ it('getProfileByExtensionAbility_2300', 0, async function (done) { @@ -413,5 +414,42 @@ export default function getProfileByExtensionAbility() { done(); }); }) + + /* + * @tc.number: getProfileByExtensionAbility_2400 + * @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability + * @tc.desc: profile is invalid json format (by promise) + * @tc.level 0 + */ + it('getProfileByExtensionAbility_2400', 0, async function (done) { + await bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME4).then(data => { + console.info('[getProfileByExtensionAbility_2400] data is: ' + JSON.stringify(data)); + expect().assertFail(); + done(); + }).catch(err => { + console.error('[getProfileByExtensionAbility_2400] Operation failed. Cause: ' + JSON.stringify(err)); + expect(err).assertEqual(1); + done(); + }) + }) + + /* + * @tc.number: getProfileByExtensionAbility_2500 + * @tc.name: getProfileByExtensionAbility : The profile is obtained by specified ability + * @tc.desc: profile is invalid json format (by callback) + * @tc.level 0 + */ + it('getProfileByExtensionAbility_2500', 0, async function (done) { + bundle.getProfileByExtensionAbility(MODULE_NAME, ABILITY_NAME, METADATA_NAME4, (err, data) => { + if (err) { + console.error('[getProfileByExtensionAbility_2500] Operation failed. Cause: ' + JSON.stringify(err)); + expect(err).assertEqual(1); + } + console.info('[getProfileByExtensionAbility_2500] data is: ' + JSON.stringify(data)); + expect(typeof data).assertEqual("string"); + expect(data).assertEqual("GetProfile failed"); + done(); + }); + }) }) } \ No newline at end of file diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/module.json b/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/module.json index 4412bd29f7a455446996c4f36b6b51b0ee746a5a..7c6599d81198b57e5626ec40af99d0231d0ed72c 100644 --- a/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/module.json +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/module.json @@ -51,6 +51,11 @@ "name": "ohos.ability.form3", "value": "", "resource": "$profile:form_config1" + }, + { + "name": "ohos.ability.form4", + "value": "", + "resource": "$profile:invalid" } ] }, @@ -91,6 +96,11 @@ "name": "ohos.extension.form3", "value": "", "resource": "$profile:form_config1" + }, + { + "name": "ohos.extension.form4", + "value": "", + "resource": "$profile:invalid" } ], "name": "Form", diff --git a/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/resources/base/profile/invalid.json b/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/resources/base/profile/invalid.json new file mode 100644 index 0000000000000000000000000000000000000000..cdca51a17bcbc5128c3b424ef9467ecd68b98737 --- /dev/null +++ b/bundlemanager/bundle_standard/bundlemanager/actsbmsstageetstest/entry/src/main/resources/base/profile/invalid.json @@ -0,0 +1,5 @@ +{ + "src": [ + "MainAbility/pages/index/index", + "MainAbility/pages/second/second" +} \ No newline at end of file