diff --git a/BUILD.gn b/BUILD.gn
index 8eb3fe2a4f848fb9be3f655b1ade2db3f3ff4e26..bffc9e7e9b53224f1edb2e64d02bc6c9272cf25f 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -35,6 +35,7 @@ group("test_target") {
testonly = true
deps = [
"services/dbms/test:unittest",
+ "services/dbms/test/sceneProject:test_hap",
"test/fuzztest:fuzztest",
]
}
diff --git a/services/dbms/test/sceneProject/BUILD.gn b/services/dbms/test/sceneProject/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..e501acd4a656091fe1c88d7b26f4bcd85b3cc9e1
--- /dev/null
+++ b/services/dbms/test/sceneProject/BUILD.gn
@@ -0,0 +1,22 @@
+# Copyright (c) 2023 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.
+
+group("test_hap") {
+ testonly = true
+ deps = []
+
+ deps += [
+ # deps file
+ "unittest:unittest_hap",
+ ]
+}
diff --git a/services/dbms/test/sceneProject/signature/com.query.test.p7b b/services/dbms/test/sceneProject/signature/com.query.test.p7b
new file mode 100644
index 0000000000000000000000000000000000000000..4440231e360e150a9e2c02c2583da6c5feaf0f6d
Binary files /dev/null and b/services/dbms/test/sceneProject/signature/com.query.test.p7b differ
diff --git a/services/dbms/test/sceneProject/unittest/BUILD.gn b/services/dbms/test/sceneProject/unittest/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..2c628adced755144509a547ef1299b45be3212f5
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/BUILD.gn
@@ -0,0 +1,22 @@
+# Copyright (c) 2023 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.
+
+group("unittest_hap") {
+ testonly = true
+ deps = []
+
+ deps += [
+ # deps file
+ "system_module:distributed_system_module",
+ ]
+}
diff --git a/services/dbms/test/sceneProject/unittest/ohos_test/BUILD.gn b/services/dbms/test/sceneProject/unittest/ohos_test/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..a3f0394397b8cec31336cf79e23c81e7b1ab0606
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/ohos_test/BUILD.gn
@@ -0,0 +1,22 @@
+# Copyright (c) 2023 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("//build/ohos.gni")
+import("../../../../../../dbms.gni")
+
+ohos_copy("copy_ohos_test") {
+ part_name = "distributed_bundle_framework"
+ subsystem_name = "bundlemanager"
+ sources = [ "./ohos_test.xml" ]
+ outputs = [ "$root_out_dir/tests/unittest/bundle_framework/distributedbundleservice/resource/ohos_test.xml" ]
+}
diff --git a/services/dbms/test/sceneProject/unittest/ohos_test/ohos_test.xml b/services/dbms/test/sceneProject/unittest/ohos_test/ohos_test.xml
new file mode 100644
index 0000000000000000000000000000000000000000..b4ba60c598e630a5aa5303e15f35ac5fbad7bd51
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/ohos_test/ohos_test.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/services/dbms/test/sceneProject/unittest/system_module/AppScope/app.json b/services/dbms/test/sceneProject/unittest/system_module/AppScope/app.json
new file mode 100644
index 0000000000000000000000000000000000000000..309d304163a6f0221d28b5f5bcf955eef1d7ed16
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/system_module/AppScope/app.json
@@ -0,0 +1,23 @@
+{
+ "app": {
+ "bundleName": "com.query.test",
+ "debug": true,
+ "icon": "$media:app_icon",
+ "iconId": 16777217,
+ "label": "$string:app_name",
+ "labelId": 16777216,
+ "description":"$string:description_application",
+ "descriptionId":1010,
+ "vendor": "huawei",
+ "versionCode": 1,
+ "versionName": "1.0",
+ "minCompatibleVersionCode":1,
+ "minAPIVersion": 8,
+ "targetAPIVersion":8,
+ "apiReleaseType":"Beta2",
+ "keepAlive":true,
+ "removable":false,
+ "userDataClearable":false,
+ "accessible":true
+ }
+}
diff --git a/services/dbms/test/sceneProject/unittest/system_module/AppScope/resources/base/element/string.json b/services/dbms/test/sceneProject/unittest/system_module/AppScope/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..8b99306e5e9a491d8d3ae5f43851155bd63e0808
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/system_module/AppScope/resources/base/element/string.json
@@ -0,0 +1,12 @@
+{
+ "string":[
+ {
+ "name":"app_name",
+ "value":"16777216"
+ },
+ {
+ "name":"description_application",
+ "value":"1010"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/services/dbms/test/sceneProject/unittest/system_module/BUILD.gn b/services/dbms/test/sceneProject/unittest/system_module/BUILD.gn
new file mode 100644
index 0000000000000000000000000000000000000000..c532a55ee52938a95685a4bf2943d4bd6209b8e9
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/system_module/BUILD.gn
@@ -0,0 +1,44 @@
+# Copyright (c) 2023 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("//build/ohos.gni")
+import("../../../../../../dbms.gni")
+
+ohos_hap("distributed_system_module") {
+ hap_profile = "entry/src/main/module.json"
+ hap_name = "distributed_system_module"
+ subsystem_name = "bundlemanager"
+ final_hap_path = "$root_out_dir/tests/unittest/bundle_framework/distributedbundleservice/resource/test_bundle/${hap_name}.hap"
+ testonly = true
+ deps = [
+ ":hjs_demo_js_assets",
+ ":hjs_demo_resources",
+ ]
+ certificate_profile =
+ "${dbms_services_path}/test/sceneProject/signature/com.query.test.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/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/MainAbility/MainAbility.ts b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/MainAbility/MainAbility.ts
new file mode 100644
index 0000000000000000000000000000000000000000..ab702584a26a5c89f994c0c5d757620ff33cc756
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/MainAbility/MainAbility.ts
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2023 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 Ability from '@ohos.app.ability.UIAbility'
+
+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/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/pages/index/index.ets b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/pages/index/index.ets
new file mode 100644
index 0000000000000000000000000000000000000000..9917acdeae8f18df41910e6f52b13075bd8ec99d
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/pages/index/index.ets
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2023 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/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/test/List.test.ets b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/test/List.test.ets
new file mode 100644
index 0000000000000000000000000000000000000000..3e6bb1b0df3d58e322a8573c7ba1016c5f53fcae
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/ets/test/List.test.ets
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2023 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/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/module.json b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/module.json
new file mode 100644
index 0000000000000000000000000000000000000000..390c6a2708a8201524c2fdb21cde908db7185fa4
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/module.json
@@ -0,0 +1,190 @@
+{
+ "module": {
+ "name":"module01",
+ "type":"entry",
+ "srcEntry":"./MyAbilityStage.ts",
+ "description":"$string:description_application",
+ "descriptionId": 2020,
+ "process":"bba",
+ "mainElement":"MainAbility",
+ "deviceTypes":[
+ "2in1",
+ "tablet",
+ "default",
+ "car",
+ "liteWearable",
+ "phone",
+ "smartVision",
+ "tablet",
+ "tv",
+ "wearable",
+ "router"
+ ],
+ "deliveryWithInstall":true,
+ "installationFree":false,
+ "virtualMachine":"ark",
+ "pages":"$profile:page_config",
+ "metadata":[
+ {
+ "name":"string",
+ "value":"string",
+ "resource":"@profile:config_file"
+ },
+ {
+ "name":"string",
+ "value":"string",
+ "resource":"@profile:config_file"
+ }
+ ],
+ "abilities": [
+ {
+ "name": "MainAbility",
+ "srcEntry": "./login/MyLoginAbility.ts",
+ "description": "$string:description_main_ability",
+ "descriptionId": 3030,
+ "icon": "$media:icon",
+ "iconId": 4040,
+ "label": "Login",
+ "labelId": 16777216,
+ "permissions":["ext","sql"],
+ "metadata":[
+ {
+ "name":"a01",
+ "value":"v01",
+ "resource":"hello"
+ },
+ {
+ "name":"a02",
+ "value":"v02",
+ "resource":"world"
+ }
+ ],
+ "exported": true,
+ "skills": [
+ {
+ "actions": [
+ "action.system.home"
+ ],
+ "entities": [
+ "entity.system.home"
+ ],
+ "uris":[
+ {
+ "scheme":"content",
+ "host":"www.test.com",
+ "port":"8080",
+ "pathRegex":"query/.*/name",
+ "path":"hello",
+ "pathStartWith":"cc/jac"
+ },
+ {
+ "scheme":"aaaaa",
+ "host":"bbbbb",
+ "port":"10",
+ "pathRegex":"ccc",
+ "path":"ddd",
+ "pathStartWith":"eee"
+ }
+ ]
+ }
+ ],
+ "backgroundModes":[
+ "dataTransfer",
+ "audioPlayback",
+ "audioRecording",
+ "location",
+ "bluetoothInteraction",
+ "multDeviceConnection",
+ "wifiInteraction",
+ "voip",
+ "taskKeeping"
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "FormName",
+ "srcEntry": "./form/MyForm.ts",
+ "icon": "$media:icon",
+ "iconId": 16777223,
+ "label": "$string:extension_name",
+ "labelId": 6060,
+ "description": "$string:form_description",
+ "descriptionId": 7070,
+ "type": "form",
+ "readPermission":"readPermission---",
+ "writePermission":"writePermission---",
+ "permissions":["aaa","ccc"],
+ "exported": true,
+ "skills": [
+ {
+ "actions": ["action001"],
+ "entities": ["entity001"],
+ "uris":[
+ {
+ "scheme":"content",
+ "host":"www.test.com",
+ "pathRegex":"query/.*/name",
+ "port":"8080",
+ "path":"hello",
+ "pathStartWith":"cc/jac"
+ },
+ {
+ "scheme":"aaaaa",
+ "host":"bbbbb",
+ "port":"10",
+ "pathRegex":"ccc",
+ "path":"ddd",
+ "pathStartWith":"eee"
+ }
+ ]
+ }
+ ],
+ "metadata": [
+ {
+ "name": "ohos.extablility.form",
+ "resource": "$profile:form_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
+ "reason": "$string:reason",
+ "usedScene": {
+ "abilities": ["FormAbility"],
+ "when": "inuse"
+ }
+ },
+ {
+ "reason": "use ohos.permission.INSTALL_BUNDLE",
+ "name": "ohos.permission.INSTALL_BUNDLE"
+ }
+ ],
+ "definePermissions":[
+ {
+ "name":"ohos.abilitydemo.permission.PROVIDER",
+ "grantMode":"system_grant",
+ "availableLevel":"system_basic",
+ "provisionEnable":true,
+ "distributedSceneEnable":true,
+ "label":"$string:permlab_provider",
+ "labelId":12,
+ "description":"$string:permdesc_provider",
+ "descriptionId":13
+ },
+ {
+ "name":"ohos.abilitydemo.permission.PROVIDER002",
+ "grantMode":"system_grant",
+ "availableLevel":"system_basic",
+ "provisionEnable":true,
+ "distributedSceneEnable":true,
+ "label":"$string:permlab_provider",
+ "labelId":112,
+ "description":"$string:permdesc_provider002",
+ "descriptionId":113
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/element/color.json b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..8ab41dcca1ad079e8d94f49627b9cdcdc650b0d8
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "white",
+ "value": "#16777221"
+ }
+ ]
+}
diff --git a/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/element/string.json b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..d005a7c3d91893013274b2c0897bde887f4d88a3
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,40 @@
+{
+ "string": [
+ {
+ "name": "description_application",
+ "value": "description"
+ },
+ {
+ "name": "extension_name",
+ "value": "label"
+ },
+ {
+ "name": "description_main_ability",
+ "value": "description"
+ },
+ {
+ "name": "permlab_provider",
+ "value": "label"
+ },
+ {
+ "name": "form_description",
+ "value": "description"
+ },
+ {
+ "name": "reason",
+ "value": "reason"
+ },
+ {
+ "name": "permdesc_provider",
+ "value": "description"
+ },
+ {
+ "name": "permdesc_provider002",
+ "value": "description"
+ },
+ {
+ "name": "16777219",
+ "value": "description"
+ }
+ ]
+}
diff --git a/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/media/aa_icon.png b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/media/aa_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/media/aa_icon.png differ
diff --git a/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/media/app_icon.png b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/media/app_icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/media/app_icon.png differ
diff --git a/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/media/icon.png b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/media/icon.png differ
diff --git a/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/profile/form_config.json b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/profile/form_config.json
new file mode 100644
index 0000000000000000000000000000000000000000..3fd6a0513f497250c799ae10559bc550a00c0b6b
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/profile/form_config.json
@@ -0,0 +1,24 @@
+{
+ "forms": [
+ {
+ "colorMode": "auto",
+ "defaultDimension": "2*2",
+ "description": "$string:16777219",
+ "formConfigAbility": "ability://xxxxx",
+ "formVisibleNotify": false,
+ "isDefault": true,
+ "name": "Form_Js",
+ "scheduledUpdateTime": "10:30",
+ "src": "",
+ "supportDimensions": [
+ "2*2"
+ ],
+ "updateDuration": 1,
+ "updateEnabled": true,
+ "window": {
+ "autoDesignWidth": true,
+ "designWidth": 720
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/profile/main_pages.json b/services/dbms/test/sceneProject/unittest/system_module/entry/src/main/resources/base/profile/main_pages.json
new file mode 100644
index 0000000000000000000000000000000000000000..96b478210df9884592229ae2db6f6bb7f86c14f4
--- /dev/null
+++ b/services/dbms/test/sceneProject/unittest/system_module/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/services/dbms/test/unittest/dbms_services_kit_test/BUILD.gn b/services/dbms/test/unittest/dbms_services_kit_test/BUILD.gn
index 72d9ec3c313fac5e3fbb6d570b846a0661659844..fd9a7891c60f555313d581c3a036b5c2bf6a3129 100644
--- a/services/dbms/test/unittest/dbms_services_kit_test/BUILD.gn
+++ b/services/dbms/test/unittest/dbms_services_kit_test/BUILD.gn
@@ -1,4 +1,4 @@
-# Copyright (c) 2022 Huawei Device Co., Ltd.
+# Copyright (c) 2022-2023 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
@@ -21,6 +21,7 @@ ohos_unittest("DbmsServicesKitTest") {
include_dirs = [
"${dbms_inner_api_path}/include",
"${dbms_services_path}/include",
+ "${bundle_framework_path}/services/bundlemgr/include",
]
sources = [
@@ -34,7 +35,11 @@ ohos_unittest("DbmsServicesKitTest") {
sources += [ "dbms_services_kit_test.cpp" ]
- deps = [ "${dbms_inner_api_path}:dbms_fwk" ]
+ deps = [
+ "${dbms_inner_api_path}:dbms_fwk",
+ "${dbms_services_path}/test/sceneProject/unittest/ohos_test:copy_ohos_test",
+ "${dbms_services_path}/test/sceneProject/unittest/system_module:distributed_system_module",
+ ]
external_deps = [
"ability_base:want",
@@ -59,7 +64,6 @@ ohos_unittest("DbmsServicesKitTest") {
"samgr:samgr_proxy",
]
defines = []
-
if (hisysevent_enable_dbms) {
sources += [ "${dbms_services_path}/src/event_report.cpp" ]
external_deps += [ "hisysevent:libhisysevent" ]
diff --git a/services/dbms/test/unittest/dbms_services_kit_test/dbms_services_kit_test.cpp b/services/dbms/test/unittest/dbms_services_kit_test/dbms_services_kit_test.cpp
index 2c3e822922d0016e15c097fcd30cad5c31fa9d39..12318477634481184ba1ef8fd740cf292d4156e9 100644
--- a/services/dbms/test/unittest/dbms_services_kit_test/dbms_services_kit_test.cpp
+++ b/services/dbms/test/unittest/dbms_services_kit_test/dbms_services_kit_test.cpp
@@ -21,9 +21,12 @@
#include
#include
#include
+#include
#include "accesstoken_kit.h"
#include "appexecfwk_errors.h"
+#include "bundle_installer_proxy.h"
+#include "bundle_mgr_proxy.h"
#include "dbms_device_manager.h"
#include "distributed_ability_info.h"
#include "distributed_bms.h"
@@ -36,11 +39,15 @@
#ifdef DISTRIBUTED_BUNDLE_IMAGE_ENABLE
#include "image_compress.h"
#endif
+#include "iservice_registry.h"
#include "json_util.h"
#include "nativetoken_kit.h"
#include "token_setproc.h"
+#include "scope_guard.h"
#include "service_control.h"
#include "softbus_common.h"
+#include "status_receiver_host.h"
+#include "system_ability_definition.h"
using namespace testing::ext;
using namespace std::chrono_literals;
@@ -50,9 +57,10 @@ namespace OHOS {
namespace {
const std::string WRONG_BUNDLE_NAME = "wrong";
const std::string WRONG_ABILITY_NAME = "wrong";
-const std::string BUNDLE_NAME = "com.ohos.launcher";
-const std::string MODULE_NAME = "launcher_settings";
-const std::string ABILITY_NAME = "com.ohos.launcher.settings.MainAbility";
+const std::string BUNDLE_NAME = "com.query.test";
+const std::string MODULE_NAME = "module01";
+const std::string ABILITY_NAME = "MainAbility";
+const std::string SYSTEM_HAP_FILE_PATH = "/data/test/resource/bms/install_bundle/distributed_system_module.hap";
const std::string DEVICE_ID = "1111";
const std::string INVALID_NAME = "invalid";
const std::string HAP_FILE_PATH =
@@ -62,8 +70,61 @@ const std::string PATH_LOCATIONS = "/data/app/el1/bundle/new_create.txt";
const std::string DEVICE_ID_NORMAL = "deviceId";
const std::string LOCALE_INFO = "localeInfo";
const std::string EMPTY_STRING = "";
+const int32_t USERID = 100;
+const std::string MSG_SUCCESS = "[SUCCESS]";
+const std::string OPERATION_FAILED = "Failure";
+const std::string OPERATION_SUCCESS = "Success";
} // namespace
+class StatusReceiverImpl : public StatusReceiverHost {
+public:
+ StatusReceiverImpl();
+ virtual ~StatusReceiverImpl();
+ virtual void OnStatusNotify(const int progress) override;
+ virtual void OnFinished(const int32_t resultCode, const std::string &resultMsg) override;
+ std::string GetResultMsg() const;
+
+private:
+ mutable std::promise resultMsgSignal_;
+ int iProgress_ = 0;
+
+ DISALLOW_COPY_AND_MOVE(StatusReceiverImpl);
+};
+
+StatusReceiverImpl::StatusReceiverImpl()
+{
+ APP_LOGI("create status receiver instance");
+}
+
+StatusReceiverImpl::~StatusReceiverImpl()
+{
+ APP_LOGI("destroy status receiver instance");
+}
+
+void StatusReceiverImpl::OnFinished(const int32_t resultCode, const std::string &resultMsg)
+{
+ APP_LOGD("OnFinished result is %{public}d, %{public}s", resultCode, resultMsg.c_str());
+ resultMsgSignal_.set_value(resultMsg);
+}
+void StatusReceiverImpl::OnStatusNotify(const int progress)
+{
+ EXPECT_GT(progress, iProgress_);
+ iProgress_ = progress;
+ APP_LOGI("OnStatusNotify progress:%{public}d", progress);
+}
+
+std::string StatusReceiverImpl::GetResultMsg() const
+{
+ auto future = resultMsgSignal_.get_future();
+ future.wait();
+ std::string resultMsg = future.get();
+ if (resultMsg == MSG_SUCCESS) {
+ return OPERATION_SUCCESS;
+ } else {
+ return OPERATION_FAILED + resultMsg;
+ }
+}
+
class DbmsServicesKitTest : public testing::Test {
public:
DbmsServicesKitTest();
@@ -77,6 +138,10 @@ public:
std::shared_ptr GetDistributedDataStorage();
std::shared_ptr GetEventReport();
sptr GetSptrDistributedBms();
+ static sptr GetBundleMgrProxy();
+ static sptr GetInstallerProxy();
+ bool InstallBundle(const std::string &bundlePath) const;
+ bool UninstallBundle(const std::string &bundleName) const;
private:
std::shared_ptr distributedBms_ = nullptr;
std::shared_ptr distributedBmsProxy_ = nullptr;
@@ -131,6 +196,81 @@ void DbmsServicesKitTest::TearDown()
ServiceControlWithExtra("d-bms", STOP, &extraArgv, 1);
}
+sptr DbmsServicesKitTest::GetBundleMgrProxy()
+{
+ sptr systemAbilityManager =
+ SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
+ if (!systemAbilityManager) {
+ APP_LOGE("fail to get system ability mgr.");
+ return nullptr;
+ }
+
+ sptr remoteObject = systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
+ if (!remoteObject) {
+ APP_LOGE("fail to get bundle manager proxy.");
+ return nullptr;
+ }
+
+ APP_LOGI("get bundle manager proxy success.");
+ return iface_cast(remoteObject);
+}
+
+sptr DbmsServicesKitTest::GetInstallerProxy()
+{
+ sptr bundleMgrProxy = GetBundleMgrProxy();
+ if (!bundleMgrProxy) {
+ APP_LOGE("bundle mgr proxy is nullptr.");
+ return nullptr;
+ }
+
+ sptr installerProxy = bundleMgrProxy->GetBundleInstaller();
+ if (!installerProxy) {
+ APP_LOGE("fail to get bundle installer proxy.");
+ return nullptr;
+ }
+
+ APP_LOGI("get bundle installer proxy success.");
+ return installerProxy;
+}
+
+bool DbmsServicesKitTest::InstallBundle(const std::string &bundlePath) const
+{
+ setuid(Constants::FOUNDATION_UID);
+ ScopeGuard uidGuard([&] { setuid(Constants::ROOT_UID); });
+ sptr installerProxy = GetInstallerProxy();
+ if (!installerProxy) {
+ APP_LOGE("get bundle installer failed.");
+ return false;
+ }
+ InstallParam installParam;
+ installParam.installFlag = InstallFlag::REPLACE_EXISTING;
+ installParam.userId = USERID;
+ sptr statusReceiver = (new (std::nothrow) StatusReceiverImpl());
+ EXPECT_NE(statusReceiver, nullptr);
+ bool result = installerProxy->Install(bundlePath, installParam, statusReceiver);
+ EXPECT_EQ(statusReceiver->GetResultMsg(), OPERATION_SUCCESS);
+ return result;
+}
+
+bool DbmsServicesKitTest::UninstallBundle(const std::string &bundleName) const
+{
+ setuid(Constants::FOUNDATION_UID);
+ ScopeGuard uidGuard([&] { setuid(Constants::ROOT_UID); });
+ sptr installerProxy = GetInstallerProxy();
+ if (!installerProxy) {
+ APP_LOGE("get bundle installer failed.");
+ return false;
+ }
+ InstallParam installParam;
+ installParam.installFlag = InstallFlag::NORMAL;
+ installParam.userId = USERID;
+ sptr statusReceiver = (new (std::nothrow) StatusReceiverImpl());
+ EXPECT_NE(statusReceiver, nullptr);
+ bool result = installerProxy->Uninstall(bundleName, installParam, statusReceiver);
+ EXPECT_EQ(statusReceiver->GetResultMsg(), OPERATION_SUCCESS);
+ return result;
+}
+
std::shared_ptr DbmsServicesKitTest::GetDistributedBms()
{
if (distributedBms_ == nullptr) {
@@ -297,6 +437,9 @@ HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0006, Function | SmallTest | L
*/
HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0007, Function | SmallTest | Level0)
{
+ auto res = InstallBundle(SYSTEM_HAP_FILE_PATH);
+ EXPECT_TRUE(res);
+
auto distributedBms = GetDistributedBms();
EXPECT_NE(distributedBms, nullptr);
if (distributedBms != nullptr) {
@@ -307,6 +450,8 @@ HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0007, Function | SmallTest | L
auto ret = distributedBms->GetAbilityInfo(name, info);
EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_ABILITY_NOT_EXIST);
}
+ res = UninstallBundle(BUNDLE_NAME);
+ EXPECT_TRUE(res);
}
/**
@@ -318,6 +463,8 @@ HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0007, Function | SmallTest | L
*/
HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0008, Function | SmallTest | Level0)
{
+ auto res = InstallBundle(SYSTEM_HAP_FILE_PATH);
+ EXPECT_TRUE(res);
auto distributedBms = GetDistributedBms();
EXPECT_NE(distributedBms, nullptr);
if (distributedBms != nullptr) {
@@ -328,6 +475,8 @@ HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0008, Function | SmallTest | L
auto ret = distributedBms->GetAbilityInfo(name, info);
EXPECT_EQ(ret, ERR_OK);
}
+ res = UninstallBundle(BUNDLE_NAME);
+ EXPECT_TRUE(res);
}
/**
@@ -339,6 +488,9 @@ HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0008, Function | SmallTest | L
*/
HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0009, Function | SmallTest | Level0)
{
+ auto res = InstallBundle(SYSTEM_HAP_FILE_PATH);
+ EXPECT_TRUE(res);
+
auto distributedBms = GetDistributedBms();
EXPECT_NE(distributedBms, nullptr);
if (distributedBms != nullptr) {
@@ -350,6 +502,8 @@ HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0009, Function | SmallTest | L
auto ret = distributedBms->GetAbilityInfo(name, info);
EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_ABILITY_NOT_EXIST);
}
+ res = UninstallBundle(BUNDLE_NAME);
+ EXPECT_TRUE(res);
}
/**
@@ -380,6 +534,9 @@ HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0010, Function | SmallTest | L
*/
HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0011, Function | SmallTest | Level0)
{
+ auto res = InstallBundle(SYSTEM_HAP_FILE_PATH);
+ EXPECT_TRUE(res);
+
auto distributedBms = GetDistributedBms();
EXPECT_NE(distributedBms, nullptr);
if (distributedBms != nullptr) {
@@ -393,6 +550,8 @@ HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0011, Function | SmallTest | L
auto ret = distributedBms->GetAbilityInfos(names, infos);
EXPECT_EQ(ret, ERR_BUNDLE_MANAGER_ABILITY_NOT_EXIST);
}
+ res = UninstallBundle(BUNDLE_NAME);
+ EXPECT_TRUE(res);
}
/**
@@ -404,6 +563,9 @@ HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0011, Function | SmallTest | L
*/
HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0012, Function | SmallTest | Level0)
{
+ auto res = InstallBundle(SYSTEM_HAP_FILE_PATH);
+ EXPECT_TRUE(res);
+
auto distributedBms = GetDistributedBms();
EXPECT_NE(distributedBms, nullptr);
if (distributedBms != nullptr) {
@@ -416,6 +578,8 @@ HWTEST_F(DbmsServicesKitTest, DbmsServicesKitTest_0012, Function | SmallTest | L
auto ret = distributedBms->GetAbilityInfos(names, infos);
EXPECT_EQ(ret, ERR_OK);
}
+ res = UninstallBundle(BUNDLE_NAME);
+ EXPECT_TRUE(res);
}
/**