diff --git a/test/sceneProject/unittest/test_bundle/previewTest/AppScope/app.json b/test/sceneProject/unittest/test_bundle/previewTest/AppScope/app.json deleted file mode 100755 index 9aabb9f3933ee2b0f7243021bcfd146d6bfc667d..0000000000000000000000000000000000000000 --- a/test/sceneProject/unittest/test_bundle/previewTest/AppScope/app.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "app": { - "apiReleaseType": "Release", - "bundleName": "com.example.previewtest", - "debug": true, - "icon": "$media:app_icon", - "iconId": 16777217, - "label": "$string:app_name", - "labelId": 16777216, - "minAPIVersion": 9, - "targetAPIVersion": 9, - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0" - } -} diff --git a/test/sceneProject/unittest/test_bundle/previewTest/AppScope/app.json5 b/test/sceneProject/unittest/test_bundle/previewTest/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b192070a56eb9ca07be2386a24b268f24fca7648 --- /dev/null +++ b/test/sceneProject/unittest/test_bundle/previewTest/AppScope/app.json5 @@ -0,0 +1,14 @@ +{ + "app": { + "apiReleaseType": "Release1", + "bundleName": "com.example.previewtest", + "debug": true, + "icon": "$media:app_icon", + "label": "$string:app_name", + "minAPIVersion": 9, + "targetAPIVersion": 9, + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0" + } +} diff --git a/test/sceneProject/unittest/test_bundle/previewTest/AppScope/resources/base/media/app_icon.png b/test/sceneProject/unittest/test_bundle/previewTest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/test/sceneProject/unittest/test_bundle/previewTest/AppScope/resources/base/media/app_icon.png differ diff --git a/test/sceneProject/unittest/test_bundle/previewTest/BUILD.gn b/test/sceneProject/unittest/test_bundle/previewTest/BUILD.gn index a696ebad64b6d9523736e9d22f3c575ed933e0e5..f5795e6e3a482d8e5c3e207d5e4c23b29358978e 100755 --- a/test/sceneProject/unittest/test_bundle/previewTest/BUILD.gn +++ b/test/sceneProject/unittest/test_bundle/previewTest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2022-2025 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 @@ -12,32 +12,22 @@ # limitations under the License. import("//build/ohos.gni") +import("//vendor/huawei/build/framework/templates/hmos_app.gni") import("../../../../../appexecfwk.gni") -ohos_hap("previewTest") { - hap_profile = "entry/src/main/module.json" +hmos_app("previewTest") { + hvigor_home = "//vendor/huawei/binary/artifacts/build/intepgral_hvigor_tools/5.19.0/HvigorAndPlugin-Integration.5.19.0/bin" + sdk_home = "//prebuilts/hmos-sdk/5.1.1.202/harmonyos-sdk-linux" + node_version = "v18.20.1" hap_name = "preview" - subsystem_name = "bundlemanager" - final_hap_path = "$root_out_dir/tests/unittest/bundle_framework/bundle_framework/resource/test_bundle/${hap_name}.hap" - testonly = true - deps = [ - ":hjs_demo_js_assets", - ":hjs_demo_resources", - ] + hap_out_dir = "$root_out_dir/tests/unittest/bundle_framework/bundle_framework/resource/test_bundle" + build_level = "module" + build_modules = [ "entry" ] + assemble_type = "assembleHap" + js_build_mode = "release" + build_profile = "build-profile.json5" certificate_profile = "${bundle_framework_path}/test/sceneProject/signature/com.example.previewtest.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" + module_install_dir = "app/com.example.previewtest" + part_name = "bundle_framework" + subsystem_name = "bundlemanager" } diff --git a/test/sceneProject/unittest/test_bundle/previewTest/build-profile.json5 b/test/sceneProject/unittest/test_bundle/previewTest/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..fda4295abbbbf09775a7fb4d6b9d96120bf7dd6d --- /dev/null +++ b/test/sceneProject/unittest/test_bundle/previewTest/build-profile.json5 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.1.1(19)", + "compileSdkVersion": "5.1.1(19)", + "targetSdkVersion": "5.1.1(19)", + "runtimeOS": "HarmonyOS" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/test/sceneProject/unittest/test_bundle/previewTest/entry/build-profile.json5 b/test/sceneProject/unittest/test_bundle/previewTest/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b4d65d490ef6cbe22d933b9231555210f1555786 --- /dev/null +++ b/test/sceneProject/unittest/test_bundle/previewTest/entry/build-profile.json5 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/test/sceneProject/unittest/test_bundle/previewTest/entry/hvigorfile.ts b/test/sceneProject/unittest/test_bundle/previewTest/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54 --- /dev/null +++ b/test/sceneProject/unittest/test_bundle/previewTest/entry/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/test/sceneProject/unittest/test_bundle/previewTest/entry/obfuscation-rules.txt b/test/sceneProject/unittest/test_bundle/previewTest/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/test/sceneProject/unittest/test_bundle/previewTest/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/test/sceneProject/unittest/test_bundle/previewTest/entry/oh-package.json5 b/test/sceneProject/unittest/test_bundle/previewTest/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4bf3e2a9b1ae7381cf9363dff1cbcc1861a41e7b --- /dev/null +++ b/test/sceneProject/unittest/test_bundle/previewTest/entry/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/ets/pages/index/index.ets b/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/ets/pages/index/index.ets index 26c5c0ffd1a38336960d32d88382bbb2d767ad7b..4f0678d2b639f7b2b586b5532454181393872a7c 100755 --- a/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/ets/pages/index/index.ets +++ b/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/ets/pages/index/index.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Copyright (c) 2022-2025 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 @@ -14,29 +14,11 @@ */ import file from '@system.file'; -import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" -import GlobalContext from "../MainAbility/GlobalContext.ts" - - @Entry @Component struct Index { aboutToAppear(){ console.info("start run testcase!!!!") - const core:Core = Core.getInstance() - const expectExtend:ExpectExtend = new ExpectExtend({ - id: 'extend' - }) - core.addService('expect', expectExtend) - const reportExtend:ReportExtend = new ReportExtend(file) - - core.addService('report', reportExtend) - core.init() - core.subscribeEvent('task', reportExtend) - - const globalContext:GlobalContext = new GlobalContext() - globalContext.globalContext(core) - core.execute() } build() { diff --git a/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/module.json b/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/module.json deleted file mode 100755 index 694ac71ab0cd82c19402c81a1eb5bf04924fd0be..0000000000000000000000000000000000000000 --- a/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/module.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "module": { - "abilities": [ - { - "description": "$string:MainAbility_desc", - "descriptionId": 16777218, - "icon": "$media:icon", - "iconId": 16777222, - "label": "$string:MainAbility_label", - "labelId": 16777219, - "name": "MainAbility", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ], - "srcEntry": "./ets/MainAbility/MainAbility.ts", - "startWindowBackground": "$color:white", - "startWindowBackgroundId": 16777221, - "startWindowIcon": "$media:icon", - "startWindowIconId": 16777222, - "exported": true - } - ], - "deliveryWithInstall": true, - "description": "$string:entry_desc", - "descriptionId": 16777220, - "deviceTypes": [ - "2in1", - "default", - "tablet" - ], - "extensionAbilities": [ - { - "name": "extensionAbility_A", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ], - "srcEntry": "", - "type": "preview" - } - ], - "fileContextMenu": "$profile:menu", - "installationFree": false, - "mainElement": "MainAbility", - "name": "entry", - "pages": "$profile:main_pages", - "srcEntry": "./ets/Application/AbilityStage.ts", - "type": "entry", - "virtualMachine": "ark" - } -} \ No newline at end of file diff --git a/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/module.json5 b/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..61cbd0f009f1f066dd3c232fbb795c8238021f44 --- /dev/null +++ b/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/module.json5 @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "module": { + "abilities": [ + { + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "name": "MainAbility", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ], + "srcEntry": "./ets/MainAbility/MainAbility.ts", + "startWindowBackground": "$color:white", + "startWindowIcon": "$media:icon", + "exported": true + } + ], + "deliveryWithInstall": true, + "description": "$string:entry_desc", + "deviceTypes": [ + "2in1", + "default", + "tablet", + "tv", + "wearable" + ], + "extensionAbilities": [ + { + "name": "extensionAbility_A", + "skills": [ + { + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + } + ], + "srcEntry": "", + "type": "preview" + } + ], + "fileContextMenu": "$profile:menu", + "installationFree": false, + "mainElement": "MainAbility", + "name": "entry", + "pages": "$profile:main_pages", + "srcEntry": "./ets/Application/AbilityStage.ts", + "type": "entry", + "virtualMachine": "ark" + } +} \ No newline at end of file diff --git a/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/resources/base/profile/insight_intent.json b/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/resources/base/profile/insight_intent.json index 2a97a79a386026611e729de0942f00cbe3cd2baa..f1b1810e6126afbfec8df2bfaffc968797793116 100644 --- a/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/resources/base/profile/insight_intent.json +++ b/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/resources/base/profile/insight_intent.json @@ -1 +1,10 @@ -{"test": "json"} \ No newline at end of file +{ + "insightIntents": [ + { + "intentName": "ViewTravelGuides", + "domain": "TravelDomain", + "intentVersion": "1.0.1", + "srcEntry": "./ets/pages/index/index.ets" + } + ] +} \ No newline at end of file diff --git a/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/resources/base/profile/menu.json b/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/resources/base/profile/menu.json index 9082d25efc941ca2e88df309c7546e7e8623b248..69930b518a64fa3c11b32f4f692638cf23025838 100644 --- a/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/resources/base/profile/menu.json +++ b/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/resources/base/profile/menu.json @@ -1 +1,14 @@ -{"key": "value"} \ No newline at end of file +{ + "fileContextMenu": [ + { + "abilityName": "MainAbility", + "menuItem": "$string:MainAbility_desc", + "menuHandler": "openCompress", + "menuContext": [ + { + "menuKind": 0 + } + ] + } + ] +} diff --git a/test/sceneProject/unittest/test_bundle/previewTest/hvigor/hvigor-config.json5 b/test/sceneProject/unittest/test_bundle/previewTest/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c61d3eed60978a00d9a67b754ec36c0c9dcde929 --- /dev/null +++ b/test/sceneProject/unittest/test_bundle/previewTest/hvigor/hvigor-config.json5 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/test/sceneProject/unittest/test_bundle/previewTest/hvigorfile.ts b/test/sceneProject/unittest/test_bundle/previewTest/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156 --- /dev/null +++ b/test/sceneProject/unittest/test_bundle/previewTest/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/ets/MainAbility/GlobalContext.ts b/test/sceneProject/unittest/test_bundle/previewTest/oh-package.json5 similarity index 50% rename from test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/ets/MainAbility/GlobalContext.ts rename to test/sceneProject/unittest/test_bundle/previewTest/oh-package.json5 index 0a0a885f3e2610c79645c247880b0675dc905ad8..15ec86a73e760904339e9269d493e3015429d8a2 100644 --- a/test/sceneProject/unittest/test_bundle/previewTest/entry/src/main/ets/MainAbility/GlobalContext.ts +++ b/test/sceneProject/unittest/test_bundle/previewTest/oh-package.json5 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 @@ -12,17 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {Core} from "deccjsunit/index.ets" -import testsuite from "../../test/List.test.ets" -export default class GlobalContext { - constructor(){ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21" } - globalContext(core:Core) { - 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) - } -} \ No newline at end of file +}