diff --git a/appexecfwk/bundle_standard/bundlemanager/BUILD.gn b/appexecfwk/bundle_standard/bundlemanager/BUILD.gn index 46c174c9fa70b59500311afaa02ed829debd6ee8..6e968e26f6323c774137dabcbd05147cfbaac3e7 100644 --- a/appexecfwk/bundle_standard/bundlemanager/BUILD.gn +++ b/appexecfwk/bundle_standard/bundlemanager/BUILD.gn @@ -57,6 +57,7 @@ group("bundlemanager") { "sceneProject/bmsscenetwo:bmsJstest2", "sceneProject/bmssecondright:second_right", "sceneProject/bmsstagedemoone:bmsStageDemo1", + "sceneProject/bmsstagedemotwo:bmsStageDemo2", ] } } diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/test/ActsBmsEtsUnPermissionTest.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/test/ActsBmsEtsUnPermissionTest.test.ets index 724107a0d7a8704d34acdd7d0ee06de2c0df4641..ba83901b4f389b26e0f525545ddf01fb334bc0fd 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/test/ActsBmsEtsUnPermissionTest.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbmsetsunpermissiontest/entry/src/main/ets/test/ActsBmsEtsUnPermissionTest.test.ets @@ -24,6 +24,8 @@ 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"; +const BUNDLE_NAME1 = "ohos.acts.bundle.stage"; +const ABILITY_NAME1 = "ExtensionAbility1"; export default function actsBmsJsUnPermissionTest() { describe('actsBmsJsUnPermissionTest', function () { @@ -183,6 +185,38 @@ export default function actsBmsJsUnPermissionTest() { }); }); + /* + * @tc.number: SUB_BMS_APPINFO_EXTENSION_0019 + * @tc.name: test queryExtensionAbilityInfos api + * @tc.desc: test queryExtensionAbilityInfos no permission + */ + it('SUB_BMS_APPINFO_EXTENSION_0019', 0, async function (done) { + await bundle.queryExtensionAbilityInfos( + { + "bundleName": BUNDLE_NAME1, + "abilityName": ABILITY_NAME1 + }, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, + 100).then(data => { + expect(data).assertFail(); + }).catch(err => { + expect(err).assertEqual(1); + }); + bundle.queryExtensionAbilityInfos( + { + "bundleName": BUNDLE_NAME1, + "abilityName": ABILITY_NAME1 + }, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, + 100, (err, data) => { + if (err) { + expect(err).assertEqual(1); + done(); + return; + } + expect(data).assertFail(); + done(); + }) + }) + async function checkAbilityInfo(data) { console.info("checkAbilityInfo start !!!"); expect(data.bundleName).assertEqual("com.example.actsbmsetsunpermissiontest"); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json index 56ad127d85571fe9790b26b3474f63f6368bba8e..11e749abee7ca2a31ea6f2b6d7cfa0337a20ec83 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/Test.json @@ -28,7 +28,8 @@ "bmsThirdBundleTest1.hap -> /data/bmsThirdBundleTest1.hap ", "first_right.hap -> /data/test/first_right.hap", "second_right.hap -> /data/second_right.hap", - "bmsStageDemo1.hap -> /data/test/bmsStageDemo1.hap" + "bmsStageDemo1.hap -> /data/test/bmsStageDemo1.hap", + "bmsStageDemo2.hap -> /data/test/bmsStageDemo2.hap" ] }, { @@ -37,11 +38,13 @@ "bm install -p /data/bmsThirdBundleTest1.hap", "bm install -p /data/test/first_right.hap", "bm install -p /data/second_right.hap", - "bm install -p /data/test/bmsStageDemo1.hap" + "bm install -p /data/test/bmsStageDemo1.hap", + "bm install -p /data/test/bmsStageDemo2.hap" ], "teardown-command":[ "bm uninstall -n com.example.third1", - "bm uninstall -n com.example.l3jsdemo" + "bm uninstall -n com.example.l3jsdemo", + "bm uninstall -n ohos.acts.bundle.stage" ] } ] diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetabilityInfo.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetabilityInfo.test.ets index 06023349c22ebbf4ff1c54f74d96b9d731073f1e..9c8e326fa9a65fa95763fc02360d9f4c2574bacb 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetabilityInfo.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/GetabilityInfo.test.ets @@ -227,10 +227,6 @@ export default function GetabilityInfo() { expect(typeof (data.description)).assertEqual("string"); expect(data.icon).assertEqual("$media:icon"); expect(typeof (data.icon)).assertEqual("string"); - expect(data.srcPath).assertEqual("MainAbility"); - expect(typeof (data.srcPath)).assertEqual("string"); - expect(data.srcLanguage).assertEqual("ets"); - expect(typeof (data.srcLanguage)).assertEqual("string"); expect(data.isVisible).assertEqual(true); expect(Array.isArray(data.permissions)).assertEqual(true); expect(Array.isArray(data.deviceCapabilities)).assertEqual(true); @@ -284,8 +280,6 @@ export default function GetabilityInfo() { expect(data.label).assertEqual("$string:app_name"); expect(data.description).assertEqual("$string:mainability_description"); expect(data.icon).assertEqual("$media:icon"); - expect(data.srcPath).assertEqual(""); - expect(data.srcLanguage).assertEqual("js"); expect(data.isVisible).assertEqual(true); expect(data.deviceTypes[0]).assertEqual("phone"); expect(data.process).assertEqual(""); @@ -304,7 +298,6 @@ export default function GetabilityInfo() { expect(data.readPermission).assertEqual(""); expect(data.writePermission).assertEqual(""); expect(data.targetAbility).assertEqual(""); - expect(data.theme).assertEqual(""); expect(data.metaData.length).assertEqual(0); expect(data.metadata.length).assertEqual(0); checkApplicationInfo_other(data.applicationInfo); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/QueryExtensionAbilityInfos.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/QueryExtensionAbilityInfos.test.ets index 5a27e61c801359ffefbdc5c2533077ef0a3e63cd..2ce98e53f69bd12bb5c15bc39864fc707bd54fc7 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/QueryExtensionAbilityInfos.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/QueryExtensionAbilityInfos.test.ets @@ -18,8 +18,10 @@ import { describe, it, expect } from 'hypium/index'; const BUNDLE_NAME1 = "ohos.acts.bundle.stage"; const BUNDLE_NAME2 = "com.noexit.com"; +const BUNDLE_NAME3 = 'com.example.third1'; const ABILITY_NAME1 = "ExtensionAbility1"; const ABILITY_NAME2 = "noexitAbility"; +const ABILITY_NAME3 = "ServiceAbility"; export default function QueryExtensionAbilityInfos() { @@ -79,14 +81,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; } @@ -112,7 +114,6 @@ export default function QueryExtensionAbilityInfos() { * @tc.name: test queryExtensionAbilityInfos api * @tc.desc: test queryExtensionAbilityInfos with default flag */ - it('SUB_BMS_APPINFO_EXTENSION_0003', 0, async function (done) { await bundle.queryExtensionAbilityInfos( { @@ -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; } @@ -169,12 +170,11 @@ export default function QueryExtensionAbilityInfos() { * @tc.name: test queryExtensionAbilityInfos api * @tc.desc: test queryExtensionAbilityInfos with get application flag */ - 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 +194,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(); @@ -339,7 +339,7 @@ export default function QueryExtensionAbilityInfos() { expect(data[0].readPermission).assertEqual(""); 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].value).assertEqual("testExtensionAbilities"); expect(data[0].metadata[0].resource).assertEqual("$profile:form_config"); }).catch(err => { expect(err).assertFail(); @@ -366,12 +366,469 @@ export default function QueryExtensionAbilityInfos() { expect(data[0].readPermission).assertEqual(""); 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].value).assertEqual("testExtensionAbilities"); expect(data[0].metadata[0].resource).assertEqual("$profile:form_config"); done(); }) }) + /* + * @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("testExtensionAbilities"); + 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("testExtensionAbilities"); + 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 uri get failed + */ + 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_0014 + * @tc.name: test queryExtensionAbilityInfos api + * @tc.desc: test queryExtensionAbilityInfos of Implicit query with entities + */ + it('SUB_BMS_APPINFO_EXTENSION_0014', 0, async function (done) { + await bundle.queryExtensionAbilityInfos({ + "bundleName": BUNDLE_NAME1, + "action": "", + "entities": ["entitiesCommon"], + }, bundle.ExtensionAbilityType.UNSPECIFIED, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, + 100).then(data => { + expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage"); + expect(data[0].moduleName).assertEqual("myfeature"); + expect(data[0].name).assertEqual("ExtensionAbilityW"); + 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).assertFail(); + }); + bundle.queryExtensionAbilityInfos({ + "bundleName": BUNDLE_NAME1, + "action": "", + "entities": ["entitiesCommon"] + }, bundle.ExtensionAbilityType.UNSPECIFIED, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, + 100, (err, data) => { + if (err) { + expect(err).assertFail(); + done(); + return; + } + expect(data[0].bundleName).assertEqual("ohos.acts.bundle.stage"); + expect(data[0].moduleName).assertEqual("myfeature"); + expect(data[0].name).assertEqual("ExtensionAbilityW"); + 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_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(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_EXTENSION_0016 + * @tc.name: test queryExtensionAbilityInfos api + * @tc.desc: test queryExtensionAbilityInfos of Implicit query with entities + */ + it('SUB_BMS_APPINFO_EXTENSION_0016', 0, async function (done) { + await bundle.queryExtensionAbilityInfos({ + "bundleName": BUNDLE_NAME1, + "action": "", + "entities": ["entitiesCommon"], + }, bundle.ExtensionAbilityType.FORM, 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("FormAbility"); + 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].writePermission).assertEqual(""); + expect(data[0].metadata.length).assertEqual(0); + }).catch(err => { + expect(err).assertFail(); + }); + bundle.queryExtensionAbilityInfos({ + "bundleName": BUNDLE_NAME1, + "action": "", + "entities": ["entitiesCommon"] + }, bundle.ExtensionAbilityType.FORM, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, + 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("FormAbility"); + 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].writePermission).assertEqual(""); + expect(data[0].metadata.length).assertEqual(0); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_EXTENSION_0017 + * @tc.name: test queryExtensionAbilityInfos api + * @tc.desc: test queryExtensionAbilityInfos of Implicit query with uri get failed + */ + it('SUB_BMS_APPINFO_EXTENSION_0017', 0, async function (done) { + await bundle.queryExtensionAbilityInfos( + { + "type": "", + "uri": "https://www.test.com/abbc" + }, bundle.ExtensionAbilityType.WINDOW, bundle.ExtensionFlag.GET_EXTENSION_INFO_DEFAULT, + 100).then(data => { + expect(data).assertFail(); + }).catch(err => { + expect(err).assertEqual(1); + }); + bundle.queryExtensionAbilityInfos( + { + "type": "", + "uri": "https://www.test.com/abbc" + }, bundle.ExtensionAbilityType.WINDOW, 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_0020 + * @tc.name: test getBundleInfo api + * @tc.desc: test getBundleInfo get extensionAbilityInfos success + */ + it('SUB_BMS_APPINFO_EXTENSION_0020', 0, async function (done) { + await bundle.getBundleInfo(BUNDLE_NAME1, bundle.BundleFlag.GET_BUNDLE_WITH_EXTENSION_ABILITY).then(data => { + expect(data.extensionAbilityInfo.length).assertEqual(7); + expect(data.extensionAbilityInfo[0].name).assertEqual("ExtensionAbilityA"); + expect(data.extensionAbilityInfo[1].name).assertEqual("ExtensionAbilityB"); + expect(data.extensionAbilityInfo[2].name).assertEqual("ExtensionAbilityQ"); + expect(data.extensionAbilityInfo[3].name).assertEqual("ExtensionAbilityW"); + expect(data.extensionAbilityInfo[4].name).assertEqual("ExtensionAbility1"); + expect(data.extensionAbilityInfo[5].name).assertEqual("FormAbility"); + expect(data.extensionAbilityInfo[6].name).assertEqual("ServiceAbility"); + }).catch(err => { + expect(err).assertFail(); + }); + bundle.getBundleInfo(BUNDLE_NAME1, bundle.BundleFlag.GET_BUNDLE_WITH_EXTENSION_ABILITY, (err, data) => { + if (err) { + expect(err).assertFail(); + done(); + return; + } + expect(data.extensionAbilityInfo.length).assertEqual(7); + expect(data.extensionAbilityInfo[0].name).assertEqual("ExtensionAbilityA"); + expect(data.extensionAbilityInfo[1].name).assertEqual("ExtensionAbilityB"); + expect(data.extensionAbilityInfo[2].name).assertEqual("ExtensionAbilityQ"); + expect(data.extensionAbilityInfo[3].name).assertEqual("ExtensionAbilityW"); + expect(data.extensionAbilityInfo[4].name).assertEqual("ExtensionAbility1"); + expect(data.extensionAbilityInfo[5].name).assertEqual("FormAbility"); + expect(data.extensionAbilityInfo[6].name).assertEqual("ServiceAbility"); + done(); + }) + }) + + /* + * @tc.number: SUB_BMS_APPINFO_EXTENSION_0021 + * @tc.name: test getBundleInfo api + * @tc.desc: test getBundleInfo with extensionAbilityInfos flag get failed + */ + it('SUB_BMS_APPINFO_EXTENSION_0021', 0, async function (done) { + await bundle.getBundleInfo(BUNDLE_NAME3, bundle.BundleFlag.GET_BUNDLE_WITH_EXTENSION_ABILITY).then(data => { + expect(data.extensionAbilityInfo.length).assertEqual(0); + }).catch(err => { + expect(err).assertEqual(1); + }); + bundle.getBundleInfo(BUNDLE_NAME3, bundle.BundleFlag.GET_BUNDLE_WITH_EXTENSION_ABILITY, (err, data) => { + if (err) { + expect(err).assertEqual(1); + done(); + return; + } + expect(data.extensionAbilityInfo.length).assertEqual(0); + 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"); @@ -387,9 +844,9 @@ export default function QueryExtensionAbilityInfos() { expect(data[0].applicationInfo.process).assertEqual(""); expect(data[0].applicationInfo.entryDir).assertEqual("/data/app/el1/bundle/public/ohos.acts.bundle.stage/phone"); expect(data[0].applicationInfo.permissions.length).assertEqual(0); - expect(data[0].applicationInfo.moduleSourceDirs[0]).assertEqual("/data/app/el1/bundle/public/ohos.acts.bundle.stage/phone"); - expect(data[0].applicationInfo.moduleInfos[0].moduleName).assertEqual("phone"); - expect(data[0].applicationInfo.moduleInfos[0].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/ohos.acts.bundle.stage/phone"); + expect(data[0].applicationInfo.moduleSourceDirs[1]).assertEqual("/data/app/el1/bundle/public/ohos.acts.bundle.stage/phone"); + expect(data[0].applicationInfo.moduleInfos[1].moduleName).assertEqual("phone"); + expect(data[0].applicationInfo.moduleInfos[1].moduleSourceDir).assertEqual("/data/app/el1/bundle/public/ohos.acts.bundle.stage/phone"); expect(JSON.stringify(data[0].applicationInfo.metaData)).assertEqual("{}"); expect(JSON.stringify(data[0].applicationInfo.metadata)).assertEqual("{}"); expect(data[0].applicationInfo.enabled).assertTrue(); diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getAllApplicationInfoJsunit.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getAllApplicationInfoJsunit.test.ets index 3dbdc59999a3f4ea0245a5b28b35cc2944cc2ee9..579dd64ccfaff31e27ae4879ad51af5bca99afd5 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getAllApplicationInfoJsunit.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getAllApplicationInfoJsunit.test.ets @@ -26,9 +26,12 @@ const TAG_TEST_0300_001 = ' bundle_getAllApplicationInfo_test_0300_007 '; const TAG_TEST_0400_001 = ' bundle_getAllApplicationInfo_test_0400_008 '; const TAG_TEST_0500_001 = ' bundle_getAllApplicationInfo_test_0500_009 '; const TAG_TEST_0500_002 = ' bundle_getAllApplicationInfo_test_0500_0010 '; +const DEFAULT_FLAG = Bundle.BundleFlag.GET_BUNDLE_DEFAULT; +const BUNDLE_OTHER = 'com.example.third1'; +const PATH = "/data/app/el1/bundle/public"; const USER_ID_100 = 100; -export default function applicationBundleJsunit() { +export default function getAllApplicationBundleTest() { describe('appInfoTest', function () { @@ -215,47 +218,95 @@ export default function applicationBundleJsunit() { }); /** - * @tc.number: bundle_getApplicationInfo_test_0500_009 + * @tc.number: bundle_getApplicationInfo_test_0500_0010 * @tc.name: getApplicationInfo : Obtains based on a given bundle name. * @tc.desc: Check the return value of the interface (by promise) * @tc.level 0 */ - it(TAG_TEST_0500_001, 0, async function (done) { + it(TAG_TEST_0500_002, 0, async function (done) { let errors; let startTime = await Utils.getNowTime(); - await Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT').then((data) => { - console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data); + await Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT', USER_ID_100).then((data) => { + console.info(TAG_TEST_0500_002 + 'noUserId promise data is: ' + data); expect(data).assertFail(); }).catch((error) => { - console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error); + console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error); errors = error; expect(errors).assertEqual(1); }); let endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime); + Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime); done(); }); /** - * @tc.number: bundle_getApplicationInfo_test_0500_0010 + * @tc.number: getApplicationInfos_1000 * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 + * @tc.desc: Check the return value of the interface */ - it(TAG_TEST_0500_002, 0, async function (done) { - let errors; - let startTime = await Utils.getNowTime(); - await Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT', USER_ID_100).then((data) => { - console.info(TAG_TEST_0500_002 + 'noUserId promise data is: ' + data); + it('getApplicationInfos_1000', 0, async function (done) { + await Bundle.getAllApplicationInfo(DEFAULT_FLAG).then((data) => { + expect(data.length).assertLarger(10); + let flag = 0; + for(let i in data){ + if (data[i].name == BUNDLE_OTHER){ + flag = 1; + getApplicationInfoSuccessOther(data[i]); + } + } + expect(flag).assertEqual(1); + }).catch((error) => { + expect(error).assertFail(); + }); + Bundle.getAllApplicationInfo(DEFAULT_FLAG, (err, data) => { + expect(err).assertEqual(0); + expect(data.length).assertLarger(10); + let flag = 0; + for(let i in data){ + if (data[i].name == BUNDLE_OTHER){ + flag = 1; + getApplicationInfoSuccessOther(data[i]); + } + } + expect(flag).assertEqual(1); + done(); + }); + }); + + /** + * @tc.number: getApplicationInfos_1200 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface + */ + it('getApplicationInfos_1200', 0, async function (done) { + await Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT').then((data) => { expect(data).assertFail(); }).catch((error) => { - console.info(TAG_TEST_0500_002 + 'UserId promise error is: ' + error); - errors = error; - expect(errors).assertEqual(1); + expect(error).assertEqual(1); + }); + await Bundle.getAllApplicationInfo(null).then((data) => { + expect(data).assertFail(); + }).catch((error) => { + expect(error).assertEqual(1); + }); + await Bundle.getAllApplicationInfo(undefined).then((data) => { + expect(data).assertFail(); + }).catch((error) => { + expect(error).assertEqual(1); + }); + Bundle.getAllApplicationInfo(undefined, (err, data) => { + expect(err).assertEqual(1); + expect(data).assertEqual("type mismatch"); + Bundle.getAllApplicationInfo('Bundle.BundleFlag.GET_BUNDLE_DEFAULT', (err, data) => { + expect(err).assertEqual(1); + expect(data).assertEqual("type mismatch"); + Bundle.getAllApplicationInfo(null, (err, data) => { + expect(err).assertEqual(1); + expect(data).assertEqual("type mismatch"); + done(); + }); + }); }); - let endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0500_002, startTime, endTime); - done(); }); function expectData(msg, data) { @@ -326,6 +377,38 @@ export default function applicationBundleJsunit() { } } + function getApplicationInfoSuccessOther(data) { + expect(data.name).assertEqual(BUNDLE_OTHER); + expect(data.codePath).assertEqual(PATH + '/' + BUNDLE_OTHER); + expect(data.accessTokenId).assertLarger(0); + expect(data.description).assertEqual('$string:mainability_description'); + expect(data.descriptionId).assertLarger(0); + expect(data.icon).assertEqual('$media:icon'); + expect(data.iconId).assertLarger(0); + expect(data.label).assertEqual('$string:app_name'); + expect(data.labelId).assertLarger(0); + expect(data.systemApp).assertFalse(); + expect(data.supportedModes).assertEqual(0); + expect(data.process).assertEqual(""); + expect(data.entryDir).assertEqual(PATH + '/' + BUNDLE_OTHER + '/' + BUNDLE_OTHER + '.entry'); + expect(data.permissions.length).assertEqual(0); + expect(data.moduleSourceDirs.length).assertEqual(1); + expect(data.moduleSourceDirs[0]).assertEqual(PATH + '/' + BUNDLE_OTHER + '/' + BUNDLE_OTHER + '.entry'); + expect(data.moduleInfos.length).assertEqual(1); + expect(data.moduleInfos[0].moduleName).assertEqual('entry'); + expect(data.moduleInfos[0].moduleSourceDir).assertEqual(PATH + '/' + + BUNDLE_OTHER + '/' + BUNDLE_OTHER + '.entry'); + expect(JSON.stringify(data.metaData)).assertEqual("{}"); + expect(JSON.stringify(data.metadata)).assertEqual("{}"); + expect(data.enabled).assertTrue(); + expect(data.flags).assertEqual(0); + expect(data.uid).assertLarger(0); + expect(data.entityType).assertEqual('unspecified'); + expect(data.removable).assertTrue(); + expect(data.fingerprint).assertEqual(""); + console.info('check end'); + } + }); } \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getApplicationInfoJsunit.test.ets b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getApplicationInfoJsunit.test.ets index 3c2e73bf05f8ffe8bc0097bab8a82cab04a6a7a4..e054e3f0bb801a68429b4f531189d02325def3be 100644 --- a/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getApplicationInfoJsunit.test.ets +++ b/appexecfwk/bundle_standard/bundlemanager/actsbundlemanageretstest/entry/src/main/ets/test/getApplicationInfoJsunit.test.ets @@ -30,10 +30,13 @@ const TAG_TEST_0600_001 = ' bundle_getApplicationInfo_test_0600_0011 '; const TAG_TEST_0600_002 = ' bundle_getApplicationInfo_test_0600_0012 '; const TAG_TEST_0600_003 = ' bundle_getApplicationInfo_test_0600_0013 '; const BUNDLE_NAME = 'com.open.harmony.packagemag'; -const BUNDLE_NAME_OTHER = 'com.ohos.acepackage'; +const BUNDLE_OTHER = 'com.example.third1'; +const BUNDLE_NOTEXIST = 'com.ohos.package'; +const FLAG_DEFAULT = Bundle.BundleFlag.GET_BUNDLE_DEFAULT; +const PATH = "/data/app/el1/bundle/public"; const USER_ID_100 = 100; -export default function getApplicationInfoJsunit() { +export default function applicationBundleJsunit() { describe('appInfoTest', function () { @@ -222,26 +225,6 @@ export default function getApplicationInfoJsunit() { done(); }); - /** - * @tc.number: bundle_getApplicationInfo_test_0500_001 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0500_001, 0, async function (done) { - let startTime = await Utils.getNowTime(); - await Bundle.getApplicationInfo('', Bundle.BundleFlag.GET_BUNDLE_DEFAULT).then((data) => { - console.info(TAG_TEST_0500_001 + 'noUserId promise data is: ' + data); - expect(data).assertFail(); - }).catch((error) => { - console.info(TAG_TEST_0500_001 + 'noUserId promise error is: ' + error); - expect(error).assertEqual(1); - }); - let endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0500_001, startTime, endTime); - done(); - }); - /** * @tc.number: bundle_getApplicationInfo_test_0500_002 * @tc.name: getApplicationInfo : Obtains based on a given bundle name. @@ -262,29 +245,6 @@ export default function getApplicationInfoJsunit() { done(); }); - /** - * @tc.number: bundle_getApplicationInfo_test_0600_001 - * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 - */ - it(TAG_TEST_0600_001, 0, async function (done) { - let errors - let startTime = await Utils.getNowTime(); - await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER, - Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION).then((data) => { - console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise data is: ' + data); - expect(data).assertFail(); - }).catch((error) => { - console.info(TAG_TEST_0600_001 + 'other bundleName noUserId promise error is: ' + error); - errors = error - expect(errors).assertEqual(1); - }); - let endTime = Utils.getNowTime(); - Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime); - done(); - }); - /** * @tc.number: bundle_getApplicationInfo_test_0600_002 * @tc.name: getApplicationInfo : Obtains based on a given bundle name. @@ -294,7 +254,7 @@ export default function getApplicationInfoJsunit() { it(TAG_TEST_0600_002, 0, async function (done) { let startTime = await Utils.getNowTime(); let errors - await Bundle.getApplicationInfo(BUNDLE_NAME_OTHER, + await Bundle.getApplicationInfo(BUNDLE_NOTEXIST, Bundle.BundleFlag.GET_APPLICATION_INFO_WITH_PERMISSION, USER_ID_100).then((data) => { console.info(TAG_TEST_0600_002 + 'other bundleName UserId promise data is: ' + data); expect(data).assertFail(); @@ -309,25 +269,111 @@ export default function getApplicationInfoJsunit() { }); /** - * @tc.number: bundle_getApplicationInfo_test_0600_003 + * @tc.number: getApplicationInfo_1300 * @tc.name: getApplicationInfo : Obtains based on a given bundle name. - * @tc.desc: Check the return value of the interface (by promise) - * @tc.level 0 + * @tc.desc: Check the return value of the interface */ - it(TAG_TEST_0600_003, 0, async function (done) { + it('getApplicationInfo_1300', 0, async function (done) { let startTime = await Utils.getNowTime(); - await Bundle.getApplicationInfo(BUNDLE_NAME, Bundle.BundleFlag.GET_BUNDLE_DEFAULT).then((data) => { + await Bundle.getApplicationInfo(BUNDLE_NAME, FLAG_DEFAULT).then((data) => { let endTime = Utils.getNowTime(); Utils.getDurationTime(TAG_TEST_0600_003, startTime, endTime); - console.info(TAG_TEST_0600_003 + 'noUserId promise data is: ' + data); - expect(typeof (data)).assertEqual("object"); expectData(TAG_TEST_0600_003, data); getApplicationInfoSuccess_plus(TAG_TEST_0600_003, data); }).catch((error) => { console.info(TAG_TEST_0600_003 + 'noUserId promise error is: ' + error); expect(error).assertFail(); }); + startTime = await Utils.getNowTime(); + Bundle.getApplicationInfo(BUNDLE_NAME, FLAG_DEFAULT, (err, data) => { + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0600_003, startTime, endTime); + console.info(TAG_TEST_0600_003 + 'noUserId promise data is: ' + data); + expectData(TAG_TEST_0600_003, data); + getApplicationInfoSuccess_plus(TAG_TEST_0600_003, data); + expect(err).assertEqual(0); + done(); + }); + }); + + /** + * @tc.number: getApplicationInfo_1400 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface + */ + it('getApplicationInfo_1400', 0, async function (done) { + await Bundle.getApplicationInfo(BUNDLE_OTHER, FLAG_DEFAULT).then((data) => { + console.info('noUserId promise data is: ' + data); + getApplicationInfoSuccessOther(data); + }).catch((error) => { + expect(error).assertFail(); + }); + Bundle.getApplicationInfo(BUNDLE_OTHER, FLAG_DEFAULT, (err, data) => { + console.info('noUserId promise data is: ' + data); + expect(err).assertEqual(0); + getApplicationInfoSuccessOther(data); done(); + }); + }); + + /** + * @tc.number: getApplicationInfo_1500 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface + */ + it('getApplicationInfo_1500', 0, async function (done) { + let startTime = await Utils.getNowTime(); + await Bundle.getApplicationInfo(BUNDLE_NOTEXIST, FLAG_DEFAULT).then((data) => { + expect(data).assertFail(); + }).catch((error) => { + expect(error).assertEqual(1); + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime); + }); + startTime = await Utils.getNowTime(); + await Bundle.getApplicationInfo(BUNDLE_NOTEXIST, FLAG_DEFAULT, (err, data) => { + let endTime = Utils.getNowTime(); + Utils.getDurationTime(TAG_TEST_0600_001, startTime, endTime); + expect(err).assertEqual(1); + expect(JSON.stringify(data)).assertEqual(undefined); + done(); + }); + }); + + /** + * @tc.number: getApplicationInfo_1700 + * @tc.name: getApplicationInfo : Obtains based on a given bundle name. + * @tc.desc: Check the return value of the interface + */ + it('getApplicationInfo_1700', 0, async function (done) { + await Bundle.getApplicationInfo('', FLAG_DEFAULT).then((data) => { + expect(data).assertFail(); + }).catch((error) => { + expect(error).assertEqual(1); + }); + await Bundle.getApplicationInfo(null, FLAG_DEFAULT).then((data) => { + expect(data).assertFail(); + }).catch((error) => { + expect(error).assertEqual(1); + }); + await Bundle.getApplicationInfo(BUNDLE_NAME, null).then((data) => { + expect(data).assertFail(); + }).catch((error) => { + expect(error).assertEqual(1); + }); + Bundle.getApplicationInfo('', FLAG_DEFAULT, (err, data) => { + expect(err).assertEqual(1); + expect(JSON.stringify(data)).assertEqual(undefined); + Bundle.getApplicationInfo(null, FLAG_DEFAULT, (err, data) => { + expect(err).assertEqual(1); + expect(data).assertEqual("type mismatch"); + Bundle.getApplicationInfo(BUNDLE_NAME, null, (err, data) => { + expect(err).assertEqual(1); + expect(data).assertEqual("type mismatch"); + done(); + }); + }); + }); }); function expectData(msg, data) { @@ -358,8 +404,8 @@ export default function getApplicationInfoJsunit() { } function getApplicationInfoSuccess(msg, data) { - expect(data.name).assertEqual('com.open.harmony.packagemag'); - expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag'); + expect(data.name).assertEqual(BUNDLE_NAME); + expect(data.codePath).assertEqual(PATH + '/' + BUNDLE_NAME); expect(data.accessTokenId > 0).assertEqual(true); expect(data.description).assertEqual('$string:mainability_description'); expect(data.descriptionId > 0).assertEqual(true); @@ -372,16 +418,13 @@ export default function getApplicationInfoJsunit() { expect(data.supportedModes).assertEqual(0); expect(data.flags).assertEqual(0); expect(data.process).assertEqual(""); - expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' + - '/com.open.harmony.packagemag'); + expect(data.entryDir).assertEqual(PATH + '/' + BUNDLE_NAME + '/' + BUNDLE_NAME); expect(data.enabled).assertEqual(true); expect(data.entityType).assertEqual('unspecified'); expect(data.removable).assertEqual(true); expect(data.moduleInfos[0].moduleName).assertEqual('entry'); - expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' + - 'com.open.harmony.packagemag/com.open.harmony.packagemag'); - expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' + - 'com.open.harmony.packagemag/com.open.harmony.packagemag'); + expect(data.moduleInfos[0].moduleSourceDir).assertEqual(PATH + '/' + BUNDLE_NAME + '/' + BUNDLE_NAME); + expect(data.moduleSourceDirs[0]).assertEqual(PATH + '/' + BUNDLE_NAME + '/' + BUNDLE_NAME); expect(data.permissions[0]).assertEqual("ohos.permission.CHANGE_ABILITY_ENABLED_STATE"); expect(data.permissions[1]).assertEqual("ohos.permission.GET_BUNDLE_INFO"); expect(data.permissions[2]).assertEqual("ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"); @@ -389,31 +432,67 @@ export default function getApplicationInfoJsunit() { } function getApplicationInfoSuccess_plus(msg, data) { - expect(data.name).assertEqual('com.open.harmony.packagemag'); - expect(data.codePath).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag'); - expect(data.accessTokenId > 0).assertEqual(true); + expect(data.name).assertEqual(BUNDLE_NAME); + expect(data.codePath).assertEqual(PATH + '/' + BUNDLE_NAME); + expect(data.accessTokenId).assertLarger(0); expect(data.description).assertEqual('$string:mainability_description'); - expect(data.descriptionId > 0).assertEqual(true); + expect(data.descriptionId).assertLarger(0); expect(data.icon).assertEqual('$media:icon'); - expect(data.iconId > 0).assertEqual(true); - expect(data.uid > 0).assertEqual(true); + expect(data.iconId).assertLarger(0); expect(data.label).assertEqual('$string:entry_MainAbility'); - expect(data.labelId > 0).assertEqual(true); - expect(data.systemApp).assertEqual(true); + expect(data.labelId).assertLarger(0); + expect(data.systemApp).assertTrue(); expect(data.supportedModes).assertEqual(0); - expect(data.flags).assertEqual(0); expect(data.process).assertEqual(""); - expect(data.entryDir).assertEqual('/data/app/el1/bundle/public/com.open.harmony.packagemag' + - '/com.open.harmony.packagemag'); - expect(data.enabled).assertEqual(true); - expect(data.entityType).assertEqual('unspecified'); - expect(data.removable).assertEqual(true); + expect(data.entryDir).assertEqual(PATH + '/' + BUNDLE_NAME + '/' + BUNDLE_NAME); + expect(data.permissions.length).assertEqual(0); + expect(data.moduleSourceDirs.length).assertEqual(1); + expect(data.moduleSourceDirs[0]).assertEqual(PATH + '/' + BUNDLE_NAME + '/' + BUNDLE_NAME); + expect(data.moduleInfos.length).assertEqual(1); expect(data.moduleInfos[0].moduleName).assertEqual('entry'); - expect(data.moduleInfos[0].moduleSourceDir).assertEqual('/data/app/el1/bundle/public/' + - 'com.open.harmony.packagemag/com.open.harmony.packagemag'); - expect(data.moduleSourceDirs[0]).assertEqual('/data/app/el1/bundle/public/' + - 'com.open.harmony.packagemag/com.open.harmony.packagemag'); - console.log(msg + ' end ' + JSON.stringify(data)); + expect(data.moduleInfos[0].moduleSourceDir).assertEqual(PATH + '/' + + BUNDLE_NAME + '/' + BUNDLE_NAME); + expect(JSON.stringify(data.metaData)).assertEqual("{}"); + expect(JSON.stringify(data.metadata)).assertEqual("{}"); + expect(data.enabled).assertTrue(); + expect(data.flags).assertEqual(0); + expect(data.uid).assertLarger(0); + expect(data.entityType).assertEqual('unspecified'); + expect(data.removable).assertTrue(); + expect(data.fingerprint).assertEqual(""); + console.info(msg + ' end '); + } + + function getApplicationInfoSuccessOther(data) { + expect(data.name).assertEqual(BUNDLE_OTHER); + expect(data.codePath).assertEqual(PATH + '/' + BUNDLE_OTHER); + expect(data.accessTokenId).assertLarger(0); + expect(data.description).assertEqual('$string:mainability_description'); + expect(data.descriptionId).assertLarger(0); + expect(data.icon).assertEqual('$media:icon'); + expect(data.iconId).assertLarger(0); + expect(data.label).assertEqual('$string:app_name'); + expect(data.labelId).assertLarger(0); + expect(data.systemApp).assertFalse(); + expect(data.supportedModes).assertEqual(0); + expect(data.process).assertEqual(""); + expect(data.entryDir).assertEqual(PATH + '/' + BUNDLE_OTHER + '/' + BUNDLE_OTHER + '.entry'); + expect(data.permissions.length).assertEqual(0); + expect(data.moduleSourceDirs.length).assertEqual(1); + expect(data.moduleSourceDirs[0]).assertEqual(PATH + '/' + BUNDLE_OTHER + '/' + BUNDLE_OTHER + '.entry'); + expect(data.moduleInfos.length).assertEqual(1); + expect(data.moduleInfos[0].moduleName).assertEqual('entry'); + expect(data.moduleInfos[0].moduleSourceDir).assertEqual(PATH + '/' + + BUNDLE_OTHER + '/' + BUNDLE_OTHER + '.entry'); + expect(JSON.stringify(data.metaData)).assertEqual("{}"); + expect(JSON.stringify(data.metadata)).assertEqual("{}"); + expect(data.enabled).assertTrue(); + expect(data.flags).assertEqual(0); + expect(data.uid).assertLarger(0); + expect(data.entityType).assertEqual('unspecified'); + expect(data.removable).assertTrue(); + expect(data.fingerprint).assertEqual(""); + console.info('check end'); } }); diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/BUILD.gn b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/BUILD.gn index d5a079d99a374802ba307a6fd9cac4cc128eeb24..3fc26e5fd41753b258677fd1878231f30809a3ec 100644 --- a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/BUILD.gn +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/BUILD.gn @@ -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" diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/entry/src/main/ets/ServiceAbility/FormAbility.ts b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/entry/src/main/ets/ServiceAbility/FormAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f94ce17654ff7562d7bc9878961bbab2219fe92 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/entry/src/main/ets/ServiceAbility/FormAbility.ts @@ -0,0 +1,37 @@ +import FormExtension from '@ohos.application.FormExtension'; +import formBindingData from '@ohos.application.formBindingData'; +import formInfo from '@ohos.application.formInfo'; + +export default class FormAbility extends FormExtension { + onCreate(want) { + // Called to return a FormBindingData object. + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormal(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + + onUpdate(formId) { + // Called to notify the form provider to update a specified form. + } + + onVisibilityChange(newStatus) { + // Called when the form provider receives form events from the system. + } + + onEvent(formId, message) { + // Called when a specified message event defined by the form provider is triggered. + } + + onDestroy(formId) { + // Called to notify the form provider that a specified form has been destroyed. + } + + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } +}; \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/entry/src/main/module.json b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/entry/src/main/module.json index 2cb80f071885c3d62794e73f87d104cf58569f61..f52baf98453a0f317536ce9edfc4555f4e8f4964 100644 --- a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/entry/src/main/module.json +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemoone/entry/src/main/module.json @@ -40,13 +40,41 @@ "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" + } + ] + }, + { + "actions": ["action_1"], + "uris": [ + { + "scheme": "https", + "host": "www.test.com", + "path": "query/student/name" + } + ] + }, + { + "actions": ["actionZ14"], + "entities": ["entitiesZ14","entitiesCommon","entitiesZZ"] + } + ], "metadata": [ { "name": "ohos.extension.form", "resource": "$profile:form_config" } - ], - "permissions": ["ohos.permission.GET_BUNDLE_INFO"] + ] }, { "name": "ExtensionAbility1", @@ -54,13 +82,56 @@ "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" + } + ] + }, + { + "actions": ["action_2"], + "uris": [ + { + "scheme": "https", + "host": "www.test.com", + "pathStartWith": "query/teacher" + } + ] + }, + { + "actions": ["actionY14"], + "entities": ["entitiesY14"] + } + ], "metadata": [ { "name": "ohos.extension.form", + "value": "testExtensionAbilities", "resource": "$profile:form_config" } ], "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" + } + ] } ] diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/AppScope/app.json b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..3c2c2b076c74b5aa64e39d16cb7ecec00ee2ae3d --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app":{ + "bundleName":"ohos.acts.bundle.stage", + "vendor":"huawei", + "versionCode":1000000, + "versionName":"1.0.0", + "debug":false, + "icon":"$media:icon", + "label":"$string:app_name", + "description":"$string:description_application", + "distributedNotificationEnabled":true, + "keepAlive":true, + "singleUser":true, + "minAPIVersion":8, + "targetAPIVersion":8, + "car":{ + "apiCompatibleVersion":8, + "singleUser":false + } + } +} diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/AppScope/resources/base/element/string.json b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/BUILD.gn b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d47f5f2c8d62beb72da3da77b49c2da95bc8cfdc --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/BUILD.gn @@ -0,0 +1,43 @@ +# 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("//test/xts/tools/build/suite.gni") + +ohos_hap("bmsStageDemo2") { + hap_profile = "entry/src/main/module.json" + hap_name = "bmsStageDemo2" + subsystem_name = XTS_SUITENAME + final_hap_path = + "${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap" + testonly = true + deps = [ + ":hjs_demo_js_assets", + ":hjs_demo_resources", + ] + certificate_profile = "signature/openharmony_sx.p7b" +} + +ohos_app_scope("bmsstagedemoone_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("hjs_demo_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("hjs_demo_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":bmsstagedemoone_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/Test.json b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..26909f2889de98a479f076f87725fed805c7a343 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/Test.json @@ -0,0 +1,4 @@ +{ + "description": "Configuration for hjunit demo Tests", +} + diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/Application/AbilityStage.ts b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..51cb02ba3f5c7011c1cd433d07deebd47a195704 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,9 @@ +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/FormAbility/FormAbility.ts b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/FormAbility/FormAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f94ce17654ff7562d7bc9878961bbab2219fe92 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/FormAbility/FormAbility.ts @@ -0,0 +1,37 @@ +import FormExtension from '@ohos.application.FormExtension'; +import formBindingData from '@ohos.application.formBindingData'; +import formInfo from '@ohos.application.formInfo'; + +export default class FormAbility extends FormExtension { + onCreate(want) { + // Called to return a FormBindingData object. + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormal(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + + onUpdate(formId) { + // Called to notify the form provider to update a specified form. + } + + onVisibilityChange(newStatus) { + // Called when the form provider receives form events from the system. + } + + onEvent(formId, message) { + // Called when a specified message event defined by the form provider is triggered. + } + + onDestroy(formId) { + // Called to notify the form provider that a specified form has been destroyed. + } + + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } +}; \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/MainAbility/MainAbility.ts b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f9d6d1f23f95d9fc891fbc550cd5a589cfb6c89 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,36 @@ +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want,launchParam){ + // Ability is creating, initialize resources for this ability + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "pages/index/index", null) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/ServiceAbility/FormAbility.ts b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/ServiceAbility/FormAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..2f94ce17654ff7562d7bc9878961bbab2219fe92 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/ServiceAbility/FormAbility.ts @@ -0,0 +1,37 @@ +import FormExtension from '@ohos.application.FormExtension'; +import formBindingData from '@ohos.application.formBindingData'; +import formInfo from '@ohos.application.formInfo'; + +export default class FormAbility extends FormExtension { + onCreate(want) { + // Called to return a FormBindingData object. + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormal(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + + onUpdate(formId) { + // Called to notify the form provider to update a specified form. + } + + onVisibilityChange(newStatus) { + // Called when the form provider receives form events from the system. + } + + onEvent(formId, message) { + // Called when a specified message event defined by the form provider is triggered. + } + + onDestroy(formId) { + // Called to notify the form provider that a specified form has been destroyed. + } + + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } +}; \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/pages/index/index.ets b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/pages/index/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7974e5d93b5154d6fdf9609f18c2168ff4fd7d60 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/pages/index/index.ets @@ -0,0 +1,66 @@ +/* + * 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 file from '@system.file'; + +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" +import testsuite from "../../test/List.test.ets" + + +@Entry +@Component +struct Index { + + aboutToAppear(){ + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + core.subscribeEvent('task', reportExtend) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + globalThis.abilityWant.parameters.timeout = 70000; + configService.setConfig(globalThis.abilityWant.parameters) + testsuite(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/pages/second/second.ets b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/pages/second/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..1c1c727ff11ecc97909f482c35268db87ae23bb4 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/pages/second/second.ets @@ -0,0 +1,43 @@ +/* + * 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 router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column,alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/test/List.test.ets b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..193419242c9869f76b7cb16e2999f5d76ec6da9c --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * 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. + */ + + +export default function testsuite(context) { + + +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/module.json b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..3596a43a0504cbf4ce139586300bb4cb1814172c --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/module.json @@ -0,0 +1,132 @@ +{ + "module": { + "name": "myfeature", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility1", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ohos.acts.bundle.stage.MainAbility1", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "orientation": "portrait", + "visible": true, + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities":[ + "entity.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "ExtensionAbilityQ", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "label": "$string:form_FormAbility_label", + "description": "$string:form_FormAbility_desc", + "type": "form", + "skills": [ + { + "actions": ["actionQ"], + "entities": ["entitiesQ"] + } + ], + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } + ] + }, + { + "name": "ExtensionAbilityW", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "label": "$string:form_FormAbility_label", + "description": "$string:form_FormAbility_desc", + "type": "service", + "skills": [ + { + "actions": ["actionW"], + "entities": ["entitiesW","entitiesCommon"] + } + ], + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } + ], + "permissions": ["ohos.permission.GET_BUNDLE_INFO"] + }, + { + "name": "ExtensionAbilityA", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "label": "$string:form_FormAbility_label", + "description": "$string:form_FormAbility_desc", + "type": "wallpaper", + "skills": [ + { + "actions": ["action_3"], + "uris": [ + { + "scheme": "https", + "host": "www.test.com", + "pathRegex": "ab*c" + } + ] + } + ], + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } + ] + }, + { + "name": "ExtensionAbilityB", + "srcEntrance": "./ets/FormAbility/FormAbility.ts", + "label": "$string:form_FormAbility_label", + "description": "$string:form_FormAbility_desc", + "type": "workScheduler", + "skills": [ + { + "actions": ["action_4"], + "uris": [ + { + "scheme": "https", + "host": "www.test.com", + "path": "query/student/name", + "pathRegex": "ab*c", + "pathStartWith": "query/teacher" + } + ] + } + ], + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } + ], + "permissions": ["ohos.permission.GET_BUNDLE_INFO"] + } + ] + + } +} diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/element/string.json b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c9962d9e060b2701436e65408ad934b871cd1867 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/element/string.json @@ -0,0 +1,40 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + }, + { + "name": "form_FormAbility_desc", + "value": "form_description" + }, + { + "name": "form_FormAbility_label", + "value": "form_label" + } + ] +} diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/media/icon.png b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/media/icon.png differ diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/profile/form_config.json b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/profile/form_config.json new file mode 100644 index 0000000000000000000000000000000000000000..d468824a7bec4668668459e107e018f5c89792f3 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/profile/form_config.json @@ -0,0 +1,81 @@ +{ + "forms": [ + { + "isDefault": true, + "src": "./js/widget/pages/index/index", + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "widget", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "isDefault": true, + "src": "./js/widget1/pages/index/index", + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "widget1", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "1*2", + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "isDefault": true, + "src": "./js/widget2/pages/index/index", + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "widget2", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "isDefault": true, + "src": "./js/widget3/pages/index/index", + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "widget3", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + } + ] +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/profile/main_pages.json b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..6898b31d2085f478ee1ed9d933a5910cbf901d92 --- /dev/null +++ b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index/index", + "pages/second/second" + ] +} \ No newline at end of file diff --git a/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/signature/openharmony_sx.p7b b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/appexecfwk/bundle_standard/bundlemanager/sceneProject/bmsstagedemotwo/signature/openharmony_sx.p7b differ