From ff36a9a0142ac26e53449f52e3295e788d3b9351 Mon Sep 17 00:00:00 2001 From: lanhaoyu Date: Fri, 25 Apr 2025 10:18:12 +0800 Subject: [PATCH] general_tdd_two Signed-off-by: lanhaoyu --- .../frameworks/test/unittest/BUILD.gn | 2 + .../unittest/general_normalize_test/BUILD.gn | 76 + .../default/js/MainAbility/app.js | 37 + .../default/js/MainAbility/app.js.map | 1 + .../default/js/MainAbility/manifest.json | 1 + .../default/js/MainAbility/pages/index.js | 88 + .../default/js/MainAbility/pages/index.js.map | 1 + .../general_normalize_file/fa/config.json | 96 + .../general_normalize_file/fa/pack.json | 1 + .../stage/ets/sourceMaps.map | 20 + .../general_normalize_file/stage/module.json | 50 + .../general_normalize_file/stage/pack.json | 1 + .../resources/base/profile/main_pages.json | 5 + .../general_normalize_test.cpp | 2996 +++++++++++++++++ 14 files changed, 3375 insertions(+) create mode 100644 packing_tool/frameworks/test/unittest/general_normalize_test/BUILD.gn create mode 100644 packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/app.js create mode 100644 packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/app.js.map create mode 100644 packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/manifest.json create mode 100644 packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/pages/index.js create mode 100644 packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/pages/index.js.map create mode 100644 packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/config.json create mode 100644 packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/pack.json create mode 100644 packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/ets/sourceMaps.map create mode 100644 packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/module.json create mode 100644 packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/pack.json create mode 100644 packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/resources/base/profile/main_pages.json create mode 100644 packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_test.cpp diff --git a/packing_tool/frameworks/test/unittest/BUILD.gn b/packing_tool/frameworks/test/unittest/BUILD.gn index de5faf0a..f2321d47 100644 --- a/packing_tool/frameworks/test/unittest/BUILD.gn +++ b/packing_tool/frameworks/test/unittest/BUILD.gn @@ -20,6 +20,7 @@ group("unittest") { "app_packager_test:unittest", "appqf_packager_test:unittest", "fast_app_packager_test:unittest", + "general_normalize_test:unittest", "hap_packager_test:unittest", "hqf_packager_test:unittest", "hqf_verify_test:unittest", @@ -28,6 +29,7 @@ group("unittest") { "json/hap_verify_info_test:unittest", "json/hap_verify_utils_test:unittest", "json/json_utils_test:unittest", + "json/module_json_fa_test:unittest", "json/module_json_stage_test:unittest", "json/module_json_test:unittest", "json/module_json_utils_test:unittest", diff --git a/packing_tool/frameworks/test/unittest/general_normalize_test/BUILD.gn b/packing_tool/frameworks/test/unittest/general_normalize_test/BUILD.gn new file mode 100644 index 00000000..a73c9b25 --- /dev/null +++ b/packing_tool/frameworks/test/unittest/general_normalize_test/BUILD.gn @@ -0,0 +1,76 @@ +# 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("//build/ohos.gni") +import("//build/test.gni") + +config("general_normalize_test_config") { + include_dirs = [ + "../../../include", + "../../../include/json", + ] + + cflags_cc = [ "-fexceptions" ] + cflags_objcc = cflags_cc +} + +module_output_path = "developtools/packing_tool" + +ohos_unittest("general_normalize_test") { + module_out_path = module_output_path + public_configs = [ ":general_normalize_test_config" ] + sources = [ + "../../../src/general_normalize.cpp", + "../../../src/hap_packager.cpp", + "../../../src/hsp_packager.cpp", + "../../../src/json/json_utils.cpp", + "../../../src/json/module_json.cpp", + "../../../src/json/module_json_fa.cpp", + "../../../src/json/module_json_stage.cpp", + "../../../src/json/normalize_version_utils.cpp", + "../../../src/json/pack_info.cpp", + "../../../src/json/pt_json.cpp", + "../../../src/log.cpp", + "../../../src/packager.cpp", + "../../../src/unzip_wrapper.cpp", + "../../../src/utils.cpp", + "../../../src/zip_utils.cpp", + "../../../src/zip_wrapper.cpp", + "general_normalize_test.cpp", + ] + + external_deps = [ + "bounds_checking_function:libsec_static", + "cJSON:cjson_static", + "hilog:libhilog", + "openssl:libcrypto_shared", + "zlib:libz", + ] + + deps = [ + ":copy_test_file", + "../ohos_test:copy_ohos_test", + ] +} + +group("unittest") { + testonly = true + deps = [ ":general_normalize_test" ] +} + +ohos_copy("copy_test_file") { + subsystem_name = "developtools" + part_name = "packing_tool" + sources = [ "./general_normalize_file" ] + outputs = [ "$root_out_dir/tests/unittest/developtools/packing_tool/test_file/general_normalize_file/" ] +} diff --git a/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/app.js b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/app.js new file mode 100644 index 00000000..e70b250f --- /dev/null +++ b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/app.js @@ -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. + */ + +(function () { +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var hilog = globalThis.requireNapi('hilog'); +var app = { + onCreate() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Application onCreate'); + }, + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'Application onDestroy'); + }, +}; + +exports.default = app; +globalThis['app.js_8e74c152fb289caceeb880912823241e9d4b2806ecc0022940f4429f6d749b02'] + = globalThis['app.js_8e74c152fb289caceeb880912823241e9d4b2806ecc0022940f4429f6d749b02'] || { + default: app +} +})() +//# sourceMappingURL=app.js.map diff --git a/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/app.js.map b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/app.js.map new file mode 100644 index 00000000..93239c38 --- /dev/null +++ b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/app.js.map @@ -0,0 +1 @@ +{"version":3,"file":"app.js","sources":["D:/ArkTsProject/packingToolFaDemo/entry/src/main/ets/MainAbility/app.ets"],"sourcesContent":["import hilog from '@ohos.hilog';\n\nexport default {\n onCreate() {\n hilog.info(0x0000, 'testTag', '%{public}s', 'Application onCreate');\n },\n onDestroy() {\n hilog.info(0x0000, 'testTag', '%{public}s', 'Application onDestroy');\n },\n}"],"names":[],"mappings":"CAAA"} \ No newline at end of file diff --git a/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/manifest.json b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/manifest.json new file mode 100644 index 00000000..a4bfd1e2 --- /dev/null +++ b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/manifest.json @@ -0,0 +1 @@ +{"appID":"com.example.packingtoolfademo","versionName":"1.0.0","versionCode":1000000,"minPlatformVersion":9,"appName":".MainAbility","deviceType":["default","tablet"],"window":{"designWidth":720,"autoDesignWidth":false},"pages":["pages/index"],"mode":{"syntax":"ets","type":"pageAbility"}} diff --git a/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/pages/index.js b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/pages/index.js new file mode 100644 index 00000000..1d5415ae --- /dev/null +++ b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/pages/index.js @@ -0,0 +1,88 @@ +/* + * 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. + */ + +(function () { +'use strict'; + +"use strict"; +class Index extends ViewPU { + constructor(parent, params, __localStorage, elmtId = -1) { + super(parent, __localStorage, elmtId); + this.__message = new ObservedPropertySimplePU('Hello World', this, "message"); + this.setInitiallyProvidedValue(params); + } + setInitiallyProvidedValue(params) { + if (params.message !== undefined) { + this.message = params.message; + } + } + updateStateVars(params) { + } + purgeVariableDependenciesOnElmtId(rmElmtId) { + this.__message.purgeDependencyOnElmtId(rmElmtId); + } + aboutToBeDeleted() { + this.__message.aboutToBeDeleted(); + SubscriberManager.Get().delete(this.id__()); + this.aboutToBeDeletedInternal(); + } + get message() { + return this.__message.get(); + } + set message(newValue) { + this.__message.set(newValue); + } + initialRender() { + this.observeComponentCreation((elmtId, isInitialRender) => { + ViewStackProcessor.StartGetAccessRecordingFor(elmtId); + Row.create(); + Row.height('100%'); + if (!isInitialRender) { + Row.pop(); + } + ViewStackProcessor.StopGetAccessRecording(); + }); + this.observeComponentCreation((elmtId, isInitialRender) => { + ViewStackProcessor.StartGetAccessRecordingFor(elmtId); + Column.create(); + Column.width('100%'); + if (!isInitialRender) { + Column.pop(); + } + ViewStackProcessor.StopGetAccessRecording(); + }); + this.observeComponentCreation((elmtId, isInitialRender) => { + ViewStackProcessor.StartGetAccessRecordingFor(elmtId); + Text.create(this.message); + Text.fontSize(50); + Text.fontWeight(FontWeight.Bold); + if (!isInitialRender) { + Text.pop(); + } + ViewStackProcessor.StopGetAccessRecording(); + }); + Text.pop(); + Column.pop(); + Row.pop(); + } + rerender() { + this.updateDirtyElements(); + } +} +ViewStackProcessor.StartGetAccessRecordingFor(ViewStackProcessor.AllocateNewElmetIdForNextComponent()); +loadDocument(new Index(undefined, {})); +ViewStackProcessor.StopGetAccessRecording(); +})() +//# sourceMappingURL=index.js.map diff --git a/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/pages/index.js.map b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/pages/index.js.map new file mode 100644 index 00000000..275b007d --- /dev/null +++ b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/assets_jsbundle/default/js/MainAbility/pages/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sources":["D:/ArkTsProject/packingToolFaDemo/entry/src/main/ets/MainAbility/pages/index.ets"],"sourcesContent":["@Entry\n@Component\nstruct Index {\n @State message: string = 'Hello World'\n\n build() {\n Row() {\n Column() {\n Text(this.message)\n .fontSize(50)\n .fontWeight(FontWeight.Bold)\n }\n .width('100%')\n }\n .height('100%')\n }\n}"],"names":[],"mappings":"CAAA"} \ No newline at end of file diff --git a/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/config.json b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/config.json new file mode 100644 index 00000000..58e4106a --- /dev/null +++ b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/config.json @@ -0,0 +1,96 @@ +{ + "app" : + { + "apiVersion" : + { + "compatible" : 9, + "releaseType" : "Release", + "target" : 9 + }, + "bundleName" : "com.example.packingtoolfademo", + "vendor" : "example", + "version" : + { + "code" : 1000000, + "name" : "1.0.0" + } + }, + "deviceConfig" : + { + "default" : + { + "debug" : true + } + }, + "module" : + { + "abilities" : + [ + { + "description" : "$string:MainAbility_desc", + "descriptionId" : 16777216, + "formsEnabled" : false, + "icon" : "$media:icon", + "iconId" : 16777220, + "label" : "$string:MainAbility_label", + "labelId" : 16777217, + "launchType" : "standard", + "name" : ".MainAbility", + "orientation" : "unspecified", + "skills" : + [ + { + "actions" : + [ + "action.system.home" + ], + "entities" : + [ + "entity.system.home" + ] + } + ], + "srcLanguage" : "ets", + "srcPath" : "MainAbility", + "type" : "page", + "visible" : true + } + ], + "deviceType" : + [ + "default", + "tablet" + ], + "distro" : + { + "deliveryWithInstall" : true, + "installationFree" : false, + "moduleName" : "entry", + "moduleType" : "entry", + "virtualMachine" : "ark9.0.0.0" + }, + "js" : + [ + { + "mode" : + { + "syntax" : "ets", + "type" : "pageAbility" + }, + "name" : ".MainAbility", + "pages" : + [ + "pages/index" + ], + "window" : + { + "autoDesignWidth" : false, + "designWidth" : 720 + } + } + ], + "mainAbility" : ".MainAbility", + "name" : ".entry", + "package" : "com.example.packingtoolfademo" + } +} \ No newline at end of file diff --git a/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/pack.json b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/pack.json new file mode 100644 index 00000000..04870b2b --- /dev/null +++ b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/fa/pack.json @@ -0,0 +1 @@ +{"summary":{"app":{"bundleName":"com.example.packingtoolfademo","version":{"code":1000000,"name":"1.0.0"}},"modules":[{"mainAbility":".MainAbility","deviceType":["default","tablet"],"abilities":[{"name":".MainAbility","label":"$string:MainAbility_label","visible":true}],"distro":{"deliveryWithInstall":true,"moduleName":"entry","moduleType":"entry","installationFree":false},"apiVersion":{"target":9,"compatible":9,"releaseType":"Release"}}]},"packages":[{"deviceType":["default","tablet"],"moduleType":"entry","deliveryWithInstall":true,"name":"entry-default"}]} diff --git a/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/ets/sourceMaps.map b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/ets/sourceMaps.map new file mode 100644 index 00000000..6e057157 --- /dev/null +++ b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/ets/sourceMaps.map @@ -0,0 +1,20 @@ +{ + "entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/entryability/EntryAbility.js": { + "version": 3, + "file": "EntryAbility.ts", + "sources": [ + "entry/src/main/ets/entryability/EntryAbility.ts" + ], + "names": [], + "mappings": "AAAA" + }, + "entry/build/default/cache/default/default@CompileArkTS/esmodule/debug/entry/src/main/ets/pages/Index.js": { + "version": 3, + "file": "Index.ets", + "sources": [ + "entry/src/main/ets/pages/Index.ets" + ], + "names": [], + "mappings": "AAAA" + } +} \ No newline at end of file diff --git a/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/module.json b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/module.json new file mode 100644 index 00000000..5427967a --- /dev/null +++ b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/module.json @@ -0,0 +1,50 @@ +{ + "app": { + "bundleName": "com.example.packingtooldemo", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "targetAPIVersion": 12, + "minAPIVersion": 12, + "apiReleaseType": "Canary2", + "debug": true, + "iconId": 16777217, + "labelId": 16777216 + }, + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": ["default", "tablet"], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [{ + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ts", + "description": "$string:EntryAbility_desc", + "icon": "$media:icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:icon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [{ + "entities": ["entity.system.home"], + "actions": ["action.system.home"] + }], + "descriptionId": 16777218, + "iconId": 16777222, + "labelId": 16777219, + "startWindowIconId": 16777222, + "startWindowBackgroundId": 16777221 + }], + "generateBuildHash": true, + "virtualMachine": "ark12.0.1.0", + "compileMode": "esmodule", + "dependencies": [], + "descriptionId": 16777220 + } +} \ No newline at end of file diff --git a/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/pack.json b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/pack.json new file mode 100644 index 00000000..b221fd94 --- /dev/null +++ b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/pack.json @@ -0,0 +1 @@ +{"summary":{"app":{"bundleName":"com.example.packingtooldemo","version":{"code":1000000,"name":"1.0.0"}},"modules":[{"mainAbility":"EntryAbility","deviceType":["default","tablet"],"abilities":[{"name":"EntryAbility","label":"$string:EntryAbility_label"}],"distro":{"moduleType":"entry","installationFree":false,"deliveryWithInstall":true,"moduleName":"entry"},"apiVersion":{"compatible":12,"releaseType":"Canary2","target":12}}]},"packages":[{"deviceType":["default","tablet"],"moduleType":"entry","deliveryWithInstall":true,"name":"entry-default"}]} diff --git a/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/resources/base/profile/main_pages.json b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/resources/base/profile/main_pages.json new file mode 100644 index 00000000..1898d94f --- /dev/null +++ b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_file/stage/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_test.cpp b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_test.cpp new file mode 100644 index 00000000..cf8d6db6 --- /dev/null +++ b/packing_tool/frameworks/test/unittest/general_normalize_test/general_normalize_test.cpp @@ -0,0 +1,2996 @@ +/* + * 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. + */ + +#include +#include +#include +#include +#include + +#define private public +#define protected public +#include "module_json.h" +#include "pt_json.h" +#include "log.h" +#include "general_normalize.h" +#include "hap_packager.h" +#undef private +#undef protected + +#include "hqf_packager.h" +#include "hsp_packager.h" +#include "json/json_utils.h" +#include "json/normalize_version_utils.h" +#include "json/pack_info.h" +#include "log.h" +#include "utils.h" +#include "zip_utils.h" + +using namespace testing; +using namespace testing::ext; +using namespace OHOS::AppPackingTool; + +namespace OHOS { +namespace { +const std::string OUT_PATH = "/data/test/testouthap"; +const std::string HAP_OUT_PATH = "/data/test/entry-default-unsigned.hap"; +const std::string HAP_INPUT_LIST = "/data/test/entry-default-unsigned.hap"; +const std::string INPUT_LIST = "/data/test/testinputhap"; +const std::string VERSION_CODE = "9999999"; +const std::string VERSION_NAME = "30.11.22"; +const std::string STAGE_INDEX_PATH = "/data/test/resource/packingtool/test_file/stage/resources.index"; +const std::string STAGE_PACK_INFO_PATH = "/data/test/resource/packingtool/test_file/stage/pack.info"; +const std::string STAGE_ETS_PATH = "/data/test/resource/packingtool/test_file/stage/ets"; +const std::string STAGE_RESOURCES_PATH = "/data/test/resource/packingtool/test_file/stage/resources"; +const std::string STAGE_JSON_PATH = "/data/test/resource/packingtool/test_file/stage/module.json"; +const std::string STAGE_RPCID_PATH = "/data/test/resource/packingtool/test_file/stage/rpcid.sc"; +const std::string PATH = "/data/test/resource/packingtool/test_file/stage"; +const std::string BUNDLE_NAME = "com.example.packingtoolfademo"; +const std::string MIN_COMPATIBLE_VERSION_CODE = "99"; +const std::string MIN_API_VERSION = "11"; +const std::string TARGET_API_VERSION = "12"; +const std::string API_RELEASE_TYPE = "Canary1"; +const std::string INVAILD_INT_NUM = "2147483648"; +const std::string INVAILD_PATTERN = "-123"; +const std::string TOO_LONG_VERSION_NAME(OHOS::AppPackingTool::Constants::MAX_VERSION_NAME_LENGTH + 1, '1'); +const std::string TOO_SHORT_BUNDLE_NAME(OHOS::AppPackingTool::Constants::BUNDLE_NAME_LEN_MIN - 1, '1'); +const std::string TOO_LONG_BUNDLE_NAME(OHOS::AppPackingTool::Constants::BUNDLE_NAME_LEN_MAX + 1, '1'); +const std::string INVALID_DEVICE_TYPES = +"\"default\", \"tablet\", \"tv\", \"wearable\", \"car\", \"2in1\", \"abc\""; +const std::string CONFIG_JSON_STRING = "{" + "\"app\": {" + "\"apiVersion\": {" + "\"compatible\": 9," + "\"releaseType\": \"Release\"," + "\"target\": 9" + "}," + "\"bundleName\": \"com.example.packingtoolfademo\"," + "\"vendor\": \"example\"," + "\"version\": {" + "\"code\" : 1000000," + "\"name\" : \"1.0.0\"" + "}" + "}," + "\"deviceConfig\": {" + "\"default\": {" + "\"debug\": true" + "}" + "}," + "\"module\": {" + "\"abilities\": [" + "{" + "\"description\": \"$string:MainAbility_desc\"," + "\"descriptionId\": 16777216," + "\"formsEnabled\": false," + "\"icon\": \"$media:icon\"," + "\"iconId\": 16777220," + "\"label\": \"$string:MainAbility_label\"," + "\"labelId\": 16777217," + "\"launchType\": \"standard\"," + "\"name\": \".MainAbility\"," + "\"orientation\": \"unspecified\"," + "\"skills\": [" + "{" + "\"actions\": [" + "\"action.system.home\"" + "]," + "\"entities\": [" + "\"entity.system.home\"" + "]" + "}" + "]," + "\"srcLanguage\" : \"ets\"," + "\"srcPath\" : \"MainAbility\"," + "\"type\" : \"page\"," + "\"visible\" : true" + "}" + "]," + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"distro\": {" + "\"deliveryWithInstall\": true," + "\"installationFree\": false," + "\"moduleName\": \"entry\"," + "\"moduleType\": \"entry\"," + "\"virtualMachine\": \"ark9.0.0.0\"" + "}," + "\"js\": [" + "{" + "\"mode\": {" + "\"syntax\": \"ets\"," + "\"type\": \"pageAbility\"" + "}," + "\"name\": \".MainAbility\"," + "\"pages\": [" + "\"pages/index\"" + "]," + "\"window\": {" + "\"autoDesignWidth\": false," + "\"designWidth\": 720" + "}" + "}" + "]," + "\"mainAbility\" : \".MainAbility\"," + "\"name\" : \".entry\"," + "\"package\" : \"com.example.packingtoolfademo\"" + "}" +"}"; +const std::string CONFIG_JSON_STRING_NO_MODULE_NAME = "{" + "\"app\": {" + "\"apiVersion\": {" + "\"compatible\": 9," + "\"releaseType\": \"Release\"," + "\"target\": 9" + "}," + "\"bundleName\": \"com.example.packingtoolfademo\"," + "\"vendor\": \"example\"," + "\"version\": {" + "\"code\" : 1000000," + "\"name\" : \"1.0.0\"" + "}" + "}," + "\"deviceConfig\": {" + "\"default\": {" + "\"debug\": true" + "}" + "}," + "\"module\": {" + "\"abilities\": [" + "{" + "\"description\": \"$string:MainAbility_desc\"," + "\"descriptionId\": 16777216," + "\"formsEnabled\": false," + "\"icon\": \"$media:icon\"," + "\"iconId\": 16777220," + "\"label\": \"$string:MainAbility_label\"," + "\"labelId\": 16777217," + "\"launchType\": \"standard\"," + "\"name\": \".MainAbility\"," + "\"orientation\": \"unspecified\"," + "\"skills\": [" + "{" + "\"actions\": [" + "\"action.system.home\"" + "]," + "\"entities\": [" + "\"entity.system.home\"" + "]" + "}" + "]," + "\"srcLanguage\" : \"ets\"," + "\"srcPath\" : \"MainAbility\"," + "\"type\" : \"page\"," + "\"visible\" : true" + "}" + "]," + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"distro\": {" + "\"deliveryWithInstall\": true," + "\"installationFree\": false," + "\"moduleName\": \"entry\"," + "\"moduleType\": \"entry\"," + "\"virtualMachine\": \"ark9.0.0.0\"" + "}," + "\"js\": [" + "{" + "\"mode\": {" + "\"syntax\": \"ets\"," + "\"type\": \"pageAbility\"" + "}," + "\"name\": \".MainAbility\"," + "\"pages\": [" + "\"pages/index\"" + "]," + "\"window\": {" + "\"autoDesignWidth\": false," + "\"designWidth\": 720" + "}" + "}" + "]," + "\"mainAbility\" : \".MainAbility\"," + "\"package\" : \"com.example.packingtoolfademo\"" + "}" +"}"; +const std::string CONFIG_JSON_STRING_NO_APP_VERSION = "{" + "\"app\": {" + "\"apiVersion\": {" + "\"compatible\": 9," + "\"releaseType\": \"Release\"," + "\"target\": 9" + "}," + "\"bundleName\": \"com.example.packingtoolfademo\"," + "\"vendor\": \"example\"" + "}," + "\"deviceConfig\": {" + "\"default\": {" + "\"debug\": true" + "}" + "}," + "\"module\": {" + "\"abilities\": [" + "{" + "\"description\": \"$string:MainAbility_desc\"," + "\"descriptionId\": 16777216," + "\"formsEnabled\": false," + "\"icon\": \"$media:icon\"," + "\"iconId\": 16777220," + "\"label\": \"$string:MainAbility_label\"," + "\"labelId\": 16777217," + "\"launchType\": \"standard\"," + "\"name\": \".MainAbility\"," + "\"orientation\": \"unspecified\"," + "\"skills\": [" + "{" + "\"actions\": [" + "\"action.system.home\"" + "]," + "\"entities\": [" + "\"entity.system.home\"" + "]" + "}" + "]," + "\"srcLanguage\" : \"ets\"," + "\"srcPath\" : \"MainAbility\"," + "\"type\" : \"page\"," + "\"visible\" : true" + "}" + "]," + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"distro\": {" + "\"deliveryWithInstall\": true," + "\"installationFree\": false," + "\"moduleName\": \"entry\"," + "\"moduleType\": \"entry\"," + "\"virtualMachine\": \"ark9.0.0.0\"" + "}," + "\"js\": [" + "{" + "\"mode\": {" + "\"syntax\": \"ets\"," + "\"type\": \"pageAbility\"" + "}," + "\"name\": \".MainAbility\"," + "\"pages\": [" + "\"pages/index\"" + "]," + "\"window\": {" + "\"autoDesignWidth\": false," + "\"designWidth\": 720" + "}" + "}" + "]," + "\"mainAbility\" : \".MainAbility\"," + "\"name\" : \".entry\"," + "\"package\" : \"com.example.packingtoolfademo\"" + "}" +"}"; +const std::string CONFIG_JSON_STRING_NO_BUNDLE_NAME = "{" + "\"app\": {" + "\"apiVersion\": {" + "\"compatible\": 9," + "\"releaseType\": \"Release\"," + "\"target\": 9" + "}," + "\"vendor\": \"example\"," + "\"version\": {" + "\"code\" : 1000000," + "\"name\" : \"1.0.0\"" + "}" + "}," + "\"deviceConfig\": {" + "\"default\": {" + "\"debug\": true" + "}" + "}," + "\"module\": {" + "\"abilities\": [" + "{" + "\"description\": \"$string:MainAbility_desc\"," + "\"descriptionId\": 16777216," + "\"formsEnabled\": false," + "\"icon\": \"$media:icon\"," + "\"iconId\": 16777220," + "\"label\": \"$string:MainAbility_label\"," + "\"labelId\": 16777217," + "\"launchType\": \"standard\"," + "\"name\": \".MainAbility\"," + "\"orientation\": \"unspecified\"," + "\"skills\": [" + "{" + "\"actions\": [" + "\"action.system.home\"" + "]," + "\"entities\": [" + "\"entity.system.home\"" + "]" + "}" + "]," + "\"srcLanguage\" : \"ets\"," + "\"srcPath\" : \"MainAbility\"," + "\"type\" : \"page\"," + "\"visible\" : true" + "}" + "]," + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"distro\": {" + "\"deliveryWithInstall\": true," + "\"installationFree\": false," + "\"moduleName\": \"entry\"," + "\"moduleType\": \"entry\"," + "\"virtualMachine\": \"ark9.0.0.0\"" + "}," + "\"js\": [" + "{" + "\"mode\": {" + "\"syntax\": \"ets\"," + "\"type\": \"pageAbility\"" + "}," + "\"name\": \".MainAbility\"," + "\"pages\": [" + "\"pages/index\"" + "]," + "\"window\": {" + "\"autoDesignWidth\": false," + "\"designWidth\": 720" + "}" + "}" + "]," + "\"mainAbility\" : \".MainAbility\"," + "\"name\" : \".entry\"," + "\"package\" : \"com.example.packingtoolfademo\"" + "}" +"}"; +const std::string JSON_STRING = "{" + "\"summary\": {" + "\"app\": {" + "\"bundleName\": \"com.example.myapplication\"," + "\"bundleType\": \"bundleApp\"," + "\"version\": {" + "\"code\": 1000000," + "\"name\": \"1.0.0\"" + "}" + "}," + "\"modules\": [" + "{" + "\"mainAbility\": \"EntryAbility\"," + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"abilities\": [" + "{" + "\"name\": \"EntryAbility\"," + "\"label\": \"$string:EntryAbility_label\"" + "}" + "]," + "\"distro\": {" + "\"moduleType\": \"entry\"," + "\"installationFree\": false," + "\"deliveryWithInstall\": true," + "\"moduleName\": \"entry\"" + "}," + "\"extensionAbilities\": [" + "]," + "\"apiVersion\": {" + "\"compatible\": 12," + "\"releaseType\": \"Canary2\"," + "\"target\": 12" + "}" + "}" + "]" + "}," + "\"packages\":[" + "{" + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"moduleType\": \"entry\"," + "\"deliveryWithInstall\": true," + "\"name\": \"entry-default\"" + "}" + "]" +"}"; + +const std::string JSON_STRING_NO_APP_VERSION = "{" + "\"summary\": {" + "\"app\": {" + "\"bundleName\": \"com.example.myapplication\"," + "\"bundleType\": \"bundleApp\"" + "}," + "\"modules\": [" + "{" + "\"mainAbility\": \"EntryAbility\"," + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"abilities\": [" + "{" + "\"name\": \"EntryAbility\"," + "\"label\": \"$string:EntryAbility_label\"" + "}" + "]," + "\"distro\": {" + "\"moduleType\": \"entry\"," + "\"installationFree\": false," + "\"deliveryWithInstall\": true," + "\"moduleName\": \"entry\"" + "}," + "\"extensionAbilities\": [" + "]," + "\"apiVersion\": {" + "\"compatible\": 12," + "\"releaseType\": \"Canary2\"," + "\"target\": 12" + "}" + "}" + "]" + "}," + "\"packages\":[" + "{" + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"moduleType\": \"entry\"," + "\"deliveryWithInstall\": true," + "\"name\": \"entry-default\"" + "}" + "]" +"}"; + +const std::string JSON_STRING_NO_BUNDLE_NAME = "{" + "\"summary\": {" + "\"app\": {" + "\"bundleType\": \"bundleApp\"," + "\"version\": {" + "\"code\": 1000000," + "\"name\": \"1.0.0\"" + "}" + "}," + "\"modules\": [" + "{" + "\"mainAbility\": \"EntryAbility\"," + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"abilities\": [" + "{" + "\"name\": \"EntryAbility\"," + "\"label\": \"$string:EntryAbility_label\"" + "}" + "]," + "\"distro\": {" + "\"moduleType\": \"entry\"," + "\"installationFree\": false," + "\"deliveryWithInstall\": true," + "\"moduleName\": \"entry\"" + "}," + "\"extensionAbilities\": [" + "]," + "\"apiVersion\": {" + "\"compatible\": 12," + "\"releaseType\": \"Canary2\"," + "\"target\": 12" + "}" + "}" + "]" + "}," + "\"packages\":[" + "{" + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"moduleType\": \"entry\"," + "\"deliveryWithInstall\": true," + "\"name\": \"entry-default\"" + "}" + "]" +"}"; + +const std::string JSON_STRING_NO_BUNDLE_TYPE = "{" + "\"summary\": {" + "\"app\": {" + "\"bundleName\": \"com.example.myapplication\"," + "\"version\": {" + "\"code\": 1000000," + "\"name\": \"1.0.0\"" + "}" + "}," + "\"modules\": [" + "{" + "\"mainAbility\": \"EntryAbility\"," + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"abilities\": [" + "{" + "\"name\": \"EntryAbility\"," + "\"label\": \"$string:EntryAbility_label\"" + "}" + "]," + "\"distro\": {" + "\"moduleType\": \"entry\"," + "\"installationFree\": false," + "\"deliveryWithInstall\": true," + "\"moduleName\": \"entry\"" + "}," + "\"extensionAbilities\": [" + "]," + "\"apiVersion\": {" + "\"compatible\": 12," + "\"releaseType\": \"Canary2\"," + "\"target\": 12" + "}" + "}" + "]" + "}," + "\"packages\":[" + "{" + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"moduleType\": \"entry\"," + "\"deliveryWithInstall\": true," + "\"name\": \"entry-default\"" + "}" + "]" +"}"; +const std::string MODULE_JSON_STRING_ONLY_VERSION = "{" + "\"app\": {" + "\"version\": {" + "\"code\": 666," + "\"name\": \"test_version\"," + "\"minCompatibleVersionCode\": 555" + "}" + "}," + "\"module\": {" + "\"name\": \"entry\"," + "\"type\": \"entry\"" + "}," + "\"deviceConfig\": {" + "\"default\": {\"debug\": true}" + "}" +"}"; +const std::string MODULE_JSON_STRING = "{" + "\"app\": {" + "\"bundleName\": \"test_bundle_name\"," + "\"bundleType\": \"atomicService\"," + "\"vendor\": \"\"," + "\"versionCode\": 1000000," + "\"versionName\": \"test_version_name\"," + "\"icon\": \"media:app_icon\"," + "\"label\": \"string:app_name\"," + "\"apiReleaseType\": \"Canary\"," + "\"compileSdkVersion\": \"test_compileSdkVersion\"," + "\"targetAPIVersion\": 10," + "\"minAPIVersion\": 10," + "\"compileSdkType\": \"OpenHarmony\"," + "\"debug\": true," + "\"iconId\": 16777217," + "\"labelId\": 16777216," + "\"version\": {" + "\"code\": 666," + "\"name\": \"test_version\"," + "\"minCompatibleVersionCode\": 555" + "}," + "\"apiVersion\": {" + "\"compileSdkType\": \"OpenHarmony\"," + "\"compileSdkVersion\": \"test_apiVersion_compileSdkVersion\"," + "\"releaseType\": \"test_apiVersion_release\"," + "\"compatible\": 7," + "\"target\": 10" + "}," + "\"targetBundleName\": \"test_app_targetBundleName\"," + "\"multiAppMode\": {" + "\"multiAppModeType\": \"test_multiAppMode\"," + "\"maxCount\": 9" + "}," + "\"generateBuildHash\": true," + "\"minCompatibleVersionCode\": 99," + "\"asanEnabled\": true," + "\"tsanEnabled\": false," + "\"compressNativeLibs\": true," + "\"targetPriority\": 5" + "}," + "\"module\": {" + "\"name\": \"entry\"," + "\"type\": \"entry\"," + "\"description\": \"string:module_desc\"," + "\"mainElement\": \"EntryAbility\"," + "\"deviceTypes\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"deliveryWithInstall\": true," + "\"installationFree\": true," + "\"pages\": \"profile:main_pages\"," + "\"abilities\": [" + "{" + "\"name\": \"EntryAbility\"," + "\"moduleName\": \"test_module_name\"," + "\"srcEntry\": \"./ets/entryability/EntryAbility.ts\"," + "\"description\": \"string:EntryAbility_desc\"," + "\"icon\": \"media:icon\"," + "\"label\": \"string:EntryAbility_label\"," + "\"startWindowIcon\": \"media:icon\"," + "\"startWindowBackground\": \"color:start_window_background\"," + "\"exported\": true," + "\"skills\": [" + "{" + "\"entities\": [\"entity.system.home\"]," + "\"actions\": [\"action.system.home\"]" + "}" + "]," + "\"descriptionId\": 16777218," + "\"iconId\": 16777222," + "\"labelId\": 16777219," + "\"startWindowIconId\": 16777222," + "\"startWindowBackgroundId\": 16777221," + "\"continueType\":[]" + "}" + "]," + "\"virtualMachine\": \"test_virtualMachine\"," + "\"compileMode\": \"esmodule\"," + "\"dependencies\": [" + "{" + "\"bundleName\": \"test_modules_dependency_1\"," + "\"moduleName\": \"entry_1\"" + "}," + "{" + "\"bundleName\": \"test_modules_dependency_2\"," + "\"moduleName\": \"entry_1\"" + "}" + "]," + "\"descriptionId\": 16777220," + "\"distro\": {" + "\"installationFree\": false," + "\"moduleType\": \"entry\"," + "\"moduleName\": \"test_module_name\"" + "}," + "\"preloads\": [" + "{" + "\"name\": \"test_name_1\"," + "\"moduleName\": \"test_module_name_1\"" + "}" + "]," + "\"package\": \"test_package\"," + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"targetModuleName\": \"test_module_targetBundleName\"," + "\"targetPriority\": 6," + "\"proxyDatas\": [" + "{" + "\"uri\": \"test_uri1\"" + "}," + "{" + "\"uri\": \"test_uri2\"" + "}" + "]," + "\"atomicService\": {" + "\"preloads\": [" + "{" + "\"atomicServiceObj\": \"test_atomicService\"" + "}" + "]" + "}," + "\"metadata\": [" + "{" + "\"name\": \"test_metadata\"," + "\"value\": \"test_value\"," + "\"resource\": \"test_resource\"" + "}" + "]," + "\"extensionAbilities\": [" + "{" + "\"name\": \"test_extension_abilities\"" + "}" + "]" + "}," + "\"deviceConfig\": {" + "\"default\": {\"debug\": true}" + "}" +"}"; +const std::string MODULE_JSON_STRING_NO_APP_VERSION = "{" + "\"app\": {" + "\"bundleName\": \"test_bundle_name\"," + "\"bundleType\": \"atomicService\"," + "\"vendor\": \"\"," + "\"versionCode\": 1000000," + "\"versionName\": \"test_version_name\"," + "\"icon\": \"media:app_icon\"," + "\"label\": \"string:app_name\"," + "\"apiReleaseType\": \"Canary\"," + "\"compileSdkVersion\": \"test_compileSdkVersion\"," + "\"targetAPIVersion\": 10," + "\"minAPIVersion\": 10," + "\"compileSdkType\": \"OpenHarmony\"," + "\"debug\": true," + "\"iconId\": 16777217," + "\"labelId\": 16777216," + "\"apiVersion\": {" + "\"compileSdkType\": \"OpenHarmony\"," + "\"compileSdkVersion\": \"test_apiVersion_compileSdkVersion\"," + "\"releaseType\": \"test_apiVersion_release\"," + "\"compatible\": 7," + "\"target\": 10" + "}," + "\"targetBundleName\": \"test_app_targetBundleName\"," + "\"multiAppMode\": {" + "\"multiAppModeType\": \"test_multiAppMode\"," + "\"maxCount\": 9" + "}," + "\"generateBuildHash\": true," + "\"minCompatibleVersionCode\": 99," + "\"asanEnabled\": true," + "\"tsanEnabled\": false," + "\"compressNativeLibs\": true," + "\"targetPriority\": 5" + "}," + "\"module\": {" + "\"name\": \"entry\"," + "\"type\": \"entry\"," + "\"description\": \"string:module_desc\"," + "\"mainElement\": \"EntryAbility\"," + "\"deviceTypes\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"deliveryWithInstall\": true," + "\"installationFree\": true," + "\"pages\": \"profile:main_pages\"," + "\"abilities\": [" + "{" + "\"name\": \"EntryAbility\"," + "\"moduleName\": \"test_module_name\"," + "\"srcEntry\": \"./ets/entryability/EntryAbility.ts\"," + "\"description\": \"string:EntryAbility_desc\"," + "\"icon\": \"media:icon\"," + "\"label\": \"string:EntryAbility_label\"," + "\"startWindowIcon\": \"media:icon\"," + "\"startWindowBackground\": \"color:start_window_background\"," + "\"exported\": true," + "\"skills\": [" + "{" + "\"entities\": [\"entity.system.home\"]," + "\"actions\": [\"action.system.home\"]" + "}" + "]," + "\"descriptionId\": 16777218," + "\"iconId\": 16777222," + "\"labelId\": 16777219," + "\"startWindowIconId\": 16777222," + "\"startWindowBackgroundId\": 16777221," + "\"continueType\":[]" + "}" + "]," + "\"virtualMachine\": \"test_virtualMachine\"," + "\"compileMode\": \"esmodule\"," + "\"dependencies\": [" + "{" + "\"bundleName\": \"test_modules_dependency_1\"," + "\"moduleName\": \"entry_1\"" + "}," + "{" + "\"bundleName\": \"test_modules_dependency_2\"," + "\"moduleName\": \"entry_1\"" + "}" + "]," + "\"descriptionId\": 16777220," + "\"distro\": {" + "\"installationFree\": false," + "\"moduleType\": \"entry\"," + "\"moduleName\": \"test_module_name\"" + "}," + "\"preloads\": [" + "{" + "\"name\": \"test_name_1\"," + "\"moduleName\": \"test_module_name_1\"" + "}" + "]," + "\"package\": \"test_package\"," + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"targetModuleName\": \"test_module_targetBundleName\"," + "\"targetPriority\": 6," + "\"proxyDatas\": [" + "{" + "\"uri\": \"test_uri1\"" + "}," + "{" + "\"uri\": \"test_uri2\"" + "}" + "]," + "\"atomicService\": {" + "\"preloads\": [" + "{" + "\"atomicServiceObj\": \"test_atomicService\"" + "}" + "]" + "}," + "\"metadata\": [" + "{" + "\"name\": \"test_metadata\"," + "\"value\": \"test_value\"," + "\"resource\": \"test_resource\"" + "}" + "]," + "\"extensionAbilities\": [" + "{" + "\"name\": \"test_extension_abilities\"" + "}" + "]" + "}," + "\"deviceConfig\": {" + "\"default\": {\"debug\": true}" + "}" +"}"; +const std::string MODULE_JSON_STRING_NO_BUNDLE_NAME = "{" + "\"app\": {" + "\"bundleType\": \"atomicService\"," + "\"vendor\": \"\"," + "\"versionCode\": 1000000," + "\"versionName\": \"test_version_name\"," + "\"icon\": \"media:app_icon\"," + "\"label\": \"string:app_name\"," + "\"apiReleaseType\": \"Canary\"," + "\"compileSdkVersion\": \"test_compileSdkVersion\"," + "\"targetAPIVersion\": 10," + "\"minAPIVersion\": 10," + "\"compileSdkType\": \"OpenHarmony\"," + "\"debug\": true," + "\"iconId\": 16777217," + "\"labelId\": 16777216," + "\"version\": {" + "\"code\": 666," + "\"name\": \"test_version\"," + "\"minCompatibleVersionCode\": 555" + "}," + "\"apiVersion\": {" + "\"compileSdkType\": \"OpenHarmony\"," + "\"compileSdkVersion\": \"test_apiVersion_compileSdkVersion\"," + "\"releaseType\": \"test_apiVersion_release\"," + "\"compatible\": 7," + "\"target\": 10" + "}," + "\"targetBundleName\": \"test_app_targetBundleName\"," + "\"multiAppMode\": {" + "\"multiAppModeType\": \"test_multiAppMode\"," + "\"maxCount\": 9" + "}," + "\"generateBuildHash\": true," + "\"minCompatibleVersionCode\": 99," + "\"asanEnabled\": true," + "\"tsanEnabled\": false," + "\"compressNativeLibs\": true," + "\"targetPriority\": 5" + "}," + "\"module\": {" + "\"name\": \"entry\"," + "\"type\": \"entry\"," + "\"description\": \"string:module_desc\"," + "\"mainElement\": \"EntryAbility\"," + "\"deviceTypes\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"deliveryWithInstall\": true," + "\"installationFree\": true," + "\"pages\": \"profile:main_pages\"," + "\"abilities\": [" + "{" + "\"name\": \"EntryAbility\"," + "\"moduleName\": \"test_module_name\"," + "\"srcEntry\": \"./ets/entryability/EntryAbility.ts\"," + "\"description\": \"string:EntryAbility_desc\"," + "\"icon\": \"media:icon\"," + "\"label\": \"string:EntryAbility_label\"," + "\"startWindowIcon\": \"media:icon\"," + "\"startWindowBackground\": \"color:start_window_background\"," + "\"exported\": true," + "\"skills\": [" + "{" + "\"entities\": [\"entity.system.home\"]," + "\"actions\": [\"action.system.home\"]" + "}" + "]," + "\"descriptionId\": 16777218," + "\"iconId\": 16777222," + "\"labelId\": 16777219," + "\"startWindowIconId\": 16777222," + "\"startWindowBackgroundId\": 16777221," + "\"continueType\":[]" + "}" + "]," + "\"virtualMachine\": \"test_virtualMachine\"," + "\"compileMode\": \"esmodule\"," + "\"dependencies\": [" + "{" + "\"bundleName\": \"test_modules_dependency_1\"," + "\"moduleName\": \"entry_1\"" + "}," + "{" + "\"bundleName\": \"test_modules_dependency_2\"," + "\"moduleName\": \"entry_1\"" + "}" + "]," + "\"descriptionId\": 16777220," + "\"distro\": {" + "\"installationFree\": false," + "\"moduleType\": \"entry\"," + "\"moduleName\": \"test_module_name\"" + "}," + "\"preloads\": [" + "{" + "\"name\": \"test_name_1\"," + "\"moduleName\": \"test_module_name_1\"" + "}" + "]," + "\"package\": \"test_package\"," + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"targetModuleName\": \"test_module_targetBundleName\"," + "\"targetPriority\": 6," + "\"proxyDatas\": [" + "{" + "\"uri\": \"test_uri1\"" + "}," + "{" + "\"uri\": \"test_uri2\"" + "}" + "]," + "\"atomicService\": {" + "\"preloads\": [" + "{" + "\"atomicServiceObj\": \"test_atomicService\"" + "}" + "]" + "}," + "\"metadata\": [" + "{" + "\"name\": \"test_metadata\"," + "\"value\": \"test_value\"," + "\"resource\": \"test_resource\"" + "}" + "]," + "\"extensionAbilities\": [" + "{" + "\"name\": \"test_extension_abilities\"" + "}" + "]" + "}," + "\"deviceConfig\": {" + "\"default\": {\"debug\": true}" + "}" +"}"; +const std::string MODULE_JSON_STRING_NO_BUNDLE_TYPE = "{" + "\"app\": {" + "\"bundleName\": \"test_bundle_name\"," + "\"vendor\": \"\"," + "\"versionCode\": 1000000," + "\"versionName\": \"test_version_name\"," + "\"icon\": \"media:app_icon\"," + "\"label\": \"string:app_name\"," + "\"apiReleaseType\": \"Canary\"," + "\"compileSdkVersion\": \"test_compileSdkVersion\"," + "\"targetAPIVersion\": 10," + "\"minAPIVersion\": 10," + "\"compileSdkType\": \"OpenHarmony\"," + "\"debug\": true," + "\"iconId\": 16777217," + "\"labelId\": 16777216," + "\"version\": {" + "\"code\": 666," + "\"name\": \"test_version\"," + "\"minCompatibleVersionCode\": 555" + "}," + "\"apiVersion\": {" + "\"compileSdkType\": \"OpenHarmony\"," + "\"compileSdkVersion\": \"test_apiVersion_compileSdkVersion\"," + "\"releaseType\": \"test_apiVersion_release\"," + "\"compatible\": 7," + "\"target\": 10" + "}," + "\"targetBundleName\": \"test_app_targetBundleName\"," + "\"multiAppMode\": {" + "\"multiAppModeType\": \"test_multiAppMode\"," + "\"maxCount\": 9" + "}," + "\"generateBuildHash\": true," + "\"minCompatibleVersionCode\": 99," + "\"asanEnabled\": true," + "\"tsanEnabled\": false," + "\"compressNativeLibs\": true," + "\"targetPriority\": 5" + "}," + "\"module\": {" + "\"name\": \"entry\"," + "\"type\": \"entry\"," + "\"description\": \"string:module_desc\"," + "\"mainElement\": \"EntryAbility\"," + "\"deviceTypes\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"deliveryWithInstall\": true," + "\"installationFree\": true," + "\"pages\": \"profile:main_pages\"," + "\"abilities\": [" + "{" + "\"name\": \"EntryAbility\"," + "\"moduleName\": \"test_module_name\"," + "\"srcEntry\": \"./ets/entryability/EntryAbility.ts\"," + "\"description\": \"string:EntryAbility_desc\"," + "\"icon\": \"media:icon\"," + "\"label\": \"string:EntryAbility_label\"," + "\"startWindowIcon\": \"media:icon\"," + "\"startWindowBackground\": \"color:start_window_background\"," + "\"exported\": true," + "\"skills\": [" + "{" + "\"entities\": [\"entity.system.home\"]," + "\"actions\": [\"action.system.home\"]" + "}" + "]," + "\"descriptionId\": 16777218," + "\"iconId\": 16777222," + "\"labelId\": 16777219," + "\"startWindowIconId\": 16777222," + "\"startWindowBackgroundId\": 16777221," + "\"continueType\":[]" + "}" + "]," + "\"virtualMachine\": \"test_virtualMachine\"," + "\"compileMode\": \"esmodule\"," + "\"dependencies\": [" + "{" + "\"bundleName\": \"test_modules_dependency_1\"," + "\"moduleName\": \"entry_1\"" + "}," + "{" + "\"bundleName\": \"test_modules_dependency_2\"," + "\"moduleName\": \"entry_1\"" + "}" + "]," + "\"descriptionId\": 16777220," + "\"distro\": {" + "\"installationFree\": false," + "\"moduleType\": \"entry\"," + "\"moduleName\": \"test_module_name\"" + "}," + "\"preloads\": [" + "{" + "\"name\": \"test_name_1\"," + "\"moduleName\": \"test_module_name_1\"" + "}" + "]," + "\"package\": \"test_package\"," + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"targetModuleName\": \"test_module_targetBundleName\"," + "\"targetPriority\": 6," + "\"proxyDatas\": [" + "{" + "\"uri\": \"test_uri1\"" + "}," + "{" + "\"uri\": \"test_uri2\"" + "}" + "]," + "\"atomicService\": {" + "\"preloads\": [" + "{" + "\"atomicServiceObj\": \"test_atomicService\"" + "}" + "]" + "}," + "\"metadata\": [" + "{" + "\"name\": \"test_metadata\"," + "\"value\": \"test_value\"," + "\"resource\": \"test_resource\"" + "}" + "]," + "\"extensionAbilities\": [" + "{" + "\"name\": \"test_extension_abilities\"" + "}" + "]" + "}," + "\"deviceConfig\": {" + "\"default\": {\"debug\": true}" + "}" +"}"; +const std::string MODULE_JSON_STRING_NO_MODULE_NAME = "{" + "\"app\": {" + "\"bundleName\": \"test_bundle_name\"," + "\"bundleType\": \"atomicService\"," + "\"vendor\": \"\"," + "\"versionCode\": 1000000," + "\"versionName\": \"test_version_name\"," + "\"icon\": \"media:app_icon\"," + "\"label\": \"string:app_name\"," + "\"apiReleaseType\": \"Canary\"," + "\"compileSdkVersion\": \"test_compileSdkVersion\"," + "\"targetAPIVersion\": 10," + "\"minAPIVersion\": 10," + "\"compileSdkType\": \"OpenHarmony\"," + "\"debug\": true," + "\"iconId\": 16777217," + "\"labelId\": 16777216," + "\"version\": {" + "\"code\": 666," + "\"name\": \"test_version\"," + "\"minCompatibleVersionCode\": 555" + "}," + "\"apiVersion\": {" + "\"compileSdkType\": \"OpenHarmony\"," + "\"compileSdkVersion\": \"test_apiVersion_compileSdkVersion\"," + "\"releaseType\": \"test_apiVersion_release\"," + "\"compatible\": 7," + "\"target\": 10" + "}," + "\"targetBundleName\": \"test_app_targetBundleName\"," + "\"multiAppMode\": {" + "\"multiAppModeType\": \"test_multiAppMode\"," + "\"maxCount\": 9" + "}," + "\"generateBuildHash\": true," + "\"minCompatibleVersionCode\": 99," + "\"asanEnabled\": true," + "\"tsanEnabled\": false," + "\"compressNativeLibs\": true," + "\"targetPriority\": 5" + "}," + "\"module\": {" + "\"type\": \"entry\"," + "\"description\": \"string:module_desc\"," + "\"mainElement\": \"EntryAbility\"," + "\"deviceTypes\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"deliveryWithInstall\": true," + "\"installationFree\": true," + "\"pages\": \"profile:main_pages\"," + "\"abilities\": [" + "{" + "\"name\": \"EntryAbility\"," + "\"moduleName\": \"test_module_name\"," + "\"srcEntry\": \"./ets/entryability/EntryAbility.ts\"," + "\"description\": \"string:EntryAbility_desc\"," + "\"icon\": \"media:icon\"," + "\"label\": \"string:EntryAbility_label\"," + "\"startWindowIcon\": \"media:icon\"," + "\"startWindowBackground\": \"color:start_window_background\"," + "\"exported\": true," + "\"skills\": [" + "{" + "\"entities\": [\"entity.system.home\"]," + "\"actions\": [\"action.system.home\"]" + "}" + "]," + "\"descriptionId\": 16777218," + "\"iconId\": 16777222," + "\"labelId\": 16777219," + "\"startWindowIconId\": 16777222," + "\"startWindowBackgroundId\": 16777221," + "\"continueType\":[]" + "}" + "]," + "\"virtualMachine\": \"test_virtualMachine\"," + "\"compileMode\": \"esmodule\"," + "\"dependencies\": [" + "{" + "\"bundleName\": \"test_modules_dependency_1\"," + "\"moduleName\": \"entry_1\"" + "}," + "{" + "\"bundleName\": \"test_modules_dependency_2\"," + "\"moduleName\": \"entry_1\"" + "}" + "]," + "\"descriptionId\": 16777220," + "\"distro\": {" + "\"installationFree\": false," + "\"moduleType\": \"entry\"," + "\"moduleName\": \"test_module_name\"" + "}," + "\"preloads\": [" + "{" + "\"name\": \"test_name_1\"," + "\"moduleName\": \"test_module_name_1\"" + "}" + "]," + "\"package\": \"test_package\"," + "\"deviceType\": [" + "\"default\"," + "\"tablet\"" + "]," + "\"targetModuleName\": \"test_module_targetBundleName\"," + "\"targetPriority\": 6," + "\"proxyDatas\": [" + "{" + "\"uri\": \"test_uri1\"" + "}," + "{" + "\"uri\": \"test_uri2\"" + "}" + "]," + "\"atomicService\": {" + "\"preloads\": [" + "{" + "\"atomicServiceObj\": \"test_atomicService\"" + "}" + "]" + "}," + "\"metadata\": [" + "{" + "\"name\": \"test_metadata\"," + "\"value\": \"test_value\"," + "\"resource\": \"test_resource\"" + "}" + "]," + "\"extensionAbilities\": [" + "{" + "\"name\": \"test_extension_abilities\"" + "}" + "]" + "}," + "\"deviceConfig\": {" + "\"default\": {\"debug\": true}" + "}" +"}"; +const std::string MAPLIST_CONVERT_STRING = "{" + "[" + "{" + "\"key\": \"value\"" + "}" + "]" +"}"; +const std::string TEST_STRING_NOTHING = "{" +"}"; +} + +class GeneralNormalizeTest : public testing::Test { +public: + GeneralNormalizeTest() {} + virtual ~GeneralNormalizeTest() {} + + static void SetUpTestCase(); + + static void TearDownTestCase(); + + void SetUp(); + + void TearDown(); +}; + +void GeneralNormalizeTest::SetUpTestCase() +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, HAP_OUT_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_FORCE, "true"}, + {OHOS::AppPackingTool::Constants::PARAM_JSON_PATH, STAGE_JSON_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_ETS_PATH, STAGE_ETS_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_RESOURCES_PATH, STAGE_RESOURCES_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_INDEX_PATH, STAGE_INDEX_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_PACK_INFO_PATH, STAGE_PACK_INFO_PATH}, + }; + + OHOS::AppPackingTool::HapPackager hapPackager(parameterMap, resultReceiver); + system("mv /data/test/resource/packingtool/test_file/stage/pack.json " + "/data/test/resource/packingtool/test_file/stage/pack.info"); + system("mkdir /data/test/resource/packingtool/test_file/stage/ets"); + system("touch /data/test/resource/packingtool/test_file/stage/resources.index"); + EXPECT_EQ(hapPackager.InitAllowedParam(), 0); + EXPECT_EQ(hapPackager.PreProcess(), 0); + EXPECT_EQ(hapPackager.Process(), 0); + EXPECT_EQ(hapPackager.PostProcess(), 0); + system("rm -rf /data/test/resource/packingtool/test_file/stage"); + system("rm -rf /data/test/resource/packingtool/test_file/fa"); +} + +void GeneralNormalizeTest::TearDownTestCase() +{ + system("rm -rf /data/test/testouthap"); + system("rm -rf /data/test/entry-default-unsigned.hap"); +} + +void GeneralNormalizeTest::SetUp() {} + +void GeneralNormalizeTest::TearDown() {} + +/* + * @tc.name: InitAllowedParam_0100 + * @tc.desc: InitAllowedParam. + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, InitAllowedParam_0100, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = {}; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.InitAllowedParam(), 0); +} + +/* + * @tc.name: Process_0100 + * @tc.desc: Process + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, Process_0100, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, HAP_INPUT_LIST}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, VERSION_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + }; + + system("mkdir /data/test/testouthap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 0); + EXPECT_EQ(generalNormalize.Process(), 0); + system("rm -rf /data/test/testouthap"); +} + +/* + * @tc.name: Process_0200 + * @tc.desc: Process + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, Process_0200, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, HAP_INPUT_LIST}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, VERSION_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + }; + + system("mkdir /data/test/testouthap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 0); + system("rm -rf /data/test/entry-default-unsigned.hap"); + system("touch /data/test/entry-default-unsigned.hap"); + EXPECT_EQ(generalNormalize.Process(), 1); + system("rm -rf /data/test/testouthap"); +} + +/* + * @tc.name: PreProcess_0100 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_0100, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); +} + +/* + * @tc.name: PreProcess_0200 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_0200, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + }; + system("mkdir /data/test/testouthap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + system("rm -rf /data/test/testouthap"); +} + +/* + * @tc.name: PreProcess_0300 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_0300, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, "module.json"}, + }; + system("mkdir /data/test/testouthap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + system("rm -rf /data/test/testouthap"); +} + +/* + * @tc.name: PreProcess_0400 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_0400, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, INPUT_LIST}, + }; + system("mkdir /data/test/testouthap"); + system("mkdir /data/test/testinputhap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + system("rm -rf /data/test/testouthap"); + system("rm -rf /data/test/testinputhap"); +} + +/* + * @tc.name: PreProcess_0500 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_0500, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, INPUT_LIST}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, INVAILD_PATTERN}, + }; + system("mkdir /data/test/testouthap"); + system("mkdir /data/test/testinputhap"); + system("touch /data/test/testinputhap/test.hap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + parameterMap[OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME] = TOO_LONG_VERSION_NAME; + OHOS::AppPackingTool::GeneralNormalize generalNormalize2(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + system("rm -rf /data/test/testouthap"); + system("rm -rf /data/test/testinputhap"); +} + +/* + * @tc.name: PreProcess_0600 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_0600, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, INPUT_LIST}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, VERSION_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, INVAILD_PATTERN}, + }; + system("mkdir /data/test/testouthap"); + system("mkdir /data/test/testinputhap"); + system("touch /data/test/testinputhap/test.hap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + parameterMap[OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE] = INVAILD_INT_NUM; + OHOS::AppPackingTool::GeneralNormalize generalNormalize2(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + system("rm -rf /data/test/testouthap"); + system("rm -rf /data/test/testinputhap"); +} + +/* + * @tc.name: PreProcess_0700 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_0700, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, INPUT_LIST}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, VERSION_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_NAME, INVAILD_PATTERN}, + }; + system("mkdir /data/test/testouthap"); + system("mkdir /data/test/testinputhap"); + system("touch /data/test/testinputhap/test.hap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + parameterMap[OHOS::AppPackingTool::Constants::PARAM_BUNDLE_NAME] = TOO_SHORT_BUNDLE_NAME; + OHOS::AppPackingTool::GeneralNormalize generalNormalize2(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + parameterMap[OHOS::AppPackingTool::Constants::PARAM_BUNDLE_NAME] = TOO_LONG_BUNDLE_NAME; + OHOS::AppPackingTool::GeneralNormalize generalNormalize3(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + system("rm -rf /data/test/testouthap"); + system("rm -rf /data/test/testinputhap"); +} + +/* + * @tc.name: PreProcess_0800 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_0800, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, INPUT_LIST}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, VERSION_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_NAME, BUNDLE_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_MIN_COMPATIBLE_VERSION_CODE, INVAILD_PATTERN}, + }; + system("mkdir /data/test/testouthap"); + system("mkdir /data/test/testinputhap"); + system("touch /data/test/testinputhap/test.hap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + parameterMap[OHOS::AppPackingTool::Constants::PARAM_MIN_COMPATIBLE_VERSION_CODE] = INVAILD_INT_NUM; + OHOS::AppPackingTool::GeneralNormalize generalNormalize2(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + system("rm -rf /data/test/testouthap"); + system("rm -rf /data/test/testinputhap"); +} + +/* + * @tc.name: PreProcess_0900 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_0900, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, INPUT_LIST}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, VERSION_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_NAME, BUNDLE_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_MIN_COMPATIBLE_VERSION_CODE, MIN_COMPATIBLE_VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_MIN_API_VERSION, INVAILD_PATTERN}, + }; + system("mkdir /data/test/testouthap"); + system("mkdir /data/test/testinputhap"); + system("touch /data/test/testinputhap/test.hap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + parameterMap[OHOS::AppPackingTool::Constants::PARAM_MIN_API_VERSION] = INVAILD_INT_NUM; + OHOS::AppPackingTool::GeneralNormalize generalNormalize2(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + system("rm -rf /data/test/testouthap"); + system("rm -rf /data/test/testinputhap"); +} + +/* + * @tc.name: PreProcess_1000 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_1000, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, INPUT_LIST}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, VERSION_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_NAME, BUNDLE_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_MIN_COMPATIBLE_VERSION_CODE, MIN_COMPATIBLE_VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_MIN_API_VERSION, MIN_API_VERSION}, + {OHOS::AppPackingTool::Constants::PARAM_TARGET_API_VERSION, INVAILD_PATTERN}, + }; + system("mkdir /data/test/testouthap"); + system("mkdir /data/test/testinputhap"); + system("touch /data/test/testinputhap/test.hap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + parameterMap[OHOS::AppPackingTool::Constants::PARAM_TARGET_API_VERSION] = INVAILD_INT_NUM; + OHOS::AppPackingTool::GeneralNormalize generalNormalize2(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + system("rm -rf /data/test/testouthap"); + system("rm -rf /data/test/testinputhap"); +} + +/* + * @tc.name: PreProcess_1100 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_1100, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, INPUT_LIST}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, VERSION_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_NAME, BUNDLE_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_MIN_COMPATIBLE_VERSION_CODE, MIN_COMPATIBLE_VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_MIN_API_VERSION, MIN_API_VERSION}, + {OHOS::AppPackingTool::Constants::PARAM_TARGET_API_VERSION, TARGET_API_VERSION}, + {OHOS::AppPackingTool::Constants::PARAM_API_RELEASE_TYPE, INVAILD_PATTERN}, + }; + system("mkdir /data/test/testouthap"); + system("mkdir /data/test/testinputhap"); + system("touch /data/test/testinputhap/test.hap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + system("rm -rf /data/test/testouthap"); + system("rm -rf /data/test/testinputhap"); +} + +/* + * @tc.name: PreProcess_1200 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_1200, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, INPUT_LIST}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, VERSION_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_NAME, BUNDLE_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_MIN_COMPATIBLE_VERSION_CODE, MIN_COMPATIBLE_VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_MIN_API_VERSION, MIN_API_VERSION}, + {OHOS::AppPackingTool::Constants::PARAM_TARGET_API_VERSION, TARGET_API_VERSION}, + {OHOS::AppPackingTool::Constants::PARAM_API_RELEASE_TYPE, API_RELEASE_TYPE}, + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_TYPE, INVAILD_PATTERN}, + }; + system("mkdir /data/test/testouthap"); + system("mkdir /data/test/testinputhap"); + system("touch /data/test/testinputhap/test.hap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + system("rm -rf /data/test/testouthap"); + system("rm -rf /data/test/testinputhap"); +} + +/* + * @tc.name: PreProcess_1300 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_1300, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, INPUT_LIST}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, VERSION_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_NAME, BUNDLE_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_MIN_COMPATIBLE_VERSION_CODE, MIN_COMPATIBLE_VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_MIN_API_VERSION, MIN_API_VERSION}, + {OHOS::AppPackingTool::Constants::PARAM_TARGET_API_VERSION, TARGET_API_VERSION}, + }; + system("mkdir /data/test/testouthap"); + system("mkdir /data/test/testinputhap"); + system("touch /data/test/testinputhap/test.hap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 0); + system("rm -rf /data/test/testouthap"); + system("rm -rf /data/test/testinputhap"); +} + +/* + * @tc.name: PreProcess_1400 + * @tc.desc: PreProcess + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, PreProcess_1400, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_OUT_PATH, OUT_PATH}, + {OHOS::AppPackingTool::Constants::PARAM_INPUT_LIST, INPUT_LIST}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, VERSION_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_NAME, BUNDLE_NAME}, + {OHOS::AppPackingTool::Constants::PARAM_MIN_COMPATIBLE_VERSION_CODE, MIN_COMPATIBLE_VERSION_CODE}, + {OHOS::AppPackingTool::Constants::PARAM_MIN_API_VERSION, MIN_API_VERSION}, + {OHOS::AppPackingTool::Constants::PARAM_TARGET_API_VERSION, TARGET_API_VERSION}, + {OHOS::AppPackingTool::Constants::PARAM_DEVICE_TYPES, INVALID_DEVICE_TYPES}, + }; + system("mkdir /data/test/testouthap"); + system("mkdir /data/test/testinputhap"); + system("touch /data/test/testinputhap/test.hap"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_EQ(generalNormalize.PreProcess(), 1); + system("rm -rf /data/test/testouthap"); + system("rm -rf /data/test/testinputhap"); +} + +/* + * @tc.name: ModifyModuleJson_0100 + * @tc.desc: ModifyModuleJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyModuleJson_0100, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string moduleJsonPath = ""; + std::map modifyMap; + EXPECT_FALSE(generalNormalize.ModifyModuleJson(moduleJsonPath, modifyMap, bundleName, moduleName)); +} + +/* + * @tc.name: ModifyModuleJson_0200 + * @tc.desc: ModifyModuleJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyModuleJson_0200, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string moduleJsonPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << MODULE_JSON_STRING; + file.close(); + } + std::map modifyMap; + EXPECT_TRUE(generalNormalize.ModifyModuleJson(moduleJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyModuleJson_0300 + * @tc.desc: ModifyModuleJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyModuleJson_0300, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string moduleJsonPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + std::map modifyMap; + EXPECT_FALSE(generalNormalize.ModifyModuleJson(moduleJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyModuleJson_0400 + * @tc.desc: ModifyModuleJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyModuleJson_0400, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string moduleJsonPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + std::map modifyMap; + EXPECT_FALSE(generalNormalize.ModifyModuleJson(moduleJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyModuleJson_0500 + * @tc.desc: ModifyModuleJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyModuleJson_0500, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_NAME, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string moduleJsonPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + std::map modifyMap; + EXPECT_FALSE(generalNormalize.ModifyModuleJson(moduleJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyModuleJson_0600 + * @tc.desc: ModifyModuleJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyModuleJson_0600, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_MIN_COMPATIBLE_VERSION_CODE, MIN_COMPATIBLE_VERSION_CODE}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string moduleJsonPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + std::map modifyMap; + EXPECT_FALSE(generalNormalize.ModifyModuleJson(moduleJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyModuleJson_0700 + * @tc.desc: ModifyModuleJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyModuleJson_0700, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_MIN_API_VERSION, MIN_API_VERSION}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string moduleJsonPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + std::map modifyMap; + EXPECT_FALSE(generalNormalize.ModifyModuleJson(moduleJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyModuleJson_0800 + * @tc.desc: ModifyModuleJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyModuleJson_0800, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_TARGET_API_VERSION, TARGET_API_VERSION}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string moduleJsonPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + std::map modifyMap; + EXPECT_FALSE(generalNormalize.ModifyModuleJson(moduleJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyModuleJson_0900 + * @tc.desc: ModifyModuleJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyModuleJson_0900, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_API_RELEASE_TYPE, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string moduleJsonPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + std::map modifyMap; + EXPECT_FALSE(generalNormalize.ModifyModuleJson(moduleJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyModuleJson_1000 + * @tc.desc: ModifyModuleJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyModuleJson_1000, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_TYPE, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string moduleJsonPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + std::map modifyMap; + EXPECT_FALSE(generalNormalize.ModifyModuleJson(moduleJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyModuleJson_1100 + * @tc.desc: ModifyModuleJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyModuleJson_1100, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_INSTALLATION_FREE, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string moduleJsonPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + std::map modifyMap; + EXPECT_FALSE(generalNormalize.ModifyModuleJson(moduleJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyModuleJson_1200 + * @tc.desc: ModifyModuleJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyModuleJson_1200, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_DELIVERY_WITH_INSTALL, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string moduleJsonPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + std::map modifyMap; + EXPECT_FALSE(generalNormalize.ModifyModuleJson(moduleJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyModuleJson_1300 + * @tc.desc: ModifyModuleJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyModuleJson_1300, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_DEVICE_TYPES, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string moduleJsonPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + std::map modifyMap; + EXPECT_FALSE(generalNormalize.ModifyModuleJson(moduleJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyConfigJson_0100 + * @tc.desc: ModifyConfigJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyConfigJson_0100, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string configJsonPath = ""; + std::map modifyMap; + EXPECT_FALSE(generalNormalize.ModifyConfigJson(configJsonPath, modifyMap, bundleName, moduleName)); +} + +/* + * @tc.name: ModifyConfigJson_0200 + * @tc.desc: ModifyConfigJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyConfigJson_0200, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string configJsonPath = "/data/test/config.json"; + std::map modifyMap; + system("touch /data/test/config.json"); + system("chmod 777 /data/test/config.json"); + std::ofstream file("/data/test/config.json"); + if (file.is_open()) { + file << CONFIG_JSON_STRING; + file.close(); + } + EXPECT_TRUE(generalNormalize.ModifyConfigJson(configJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyConfigJson_0300 + * @tc.desc: ModifyConfigJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyConfigJson_0300, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string configJsonPath = "/data/test/config.json"; + std::map modifyMap; + system("touch /data/test/config.json"); + system("chmod 777 /data/test/config.json"); + std::ofstream file("/data/test/config.json"); + if (file.is_open()) { + file << CONFIG_JSON_STRING_NO_APP_VERSION; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyConfigJson(configJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyConfigJson_0400 + * @tc.desc: ModifyConfigJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyConfigJson_0400, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string configJsonPath = "/data/test/config.json"; + std::map modifyMap; + system("touch /data/test/config.json"); + system("chmod 777 /data/test/config.json"); + std::ofstream file("/data/test/config.json"); + if (file.is_open()) { + file << CONFIG_JSON_STRING_NO_APP_VERSION; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyConfigJson(configJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyConfigJson_0500 + * @tc.desc: ModifyConfigJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyConfigJson_0500, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_NAME, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string configJsonPath = "/data/test/config.json"; + std::map modifyMap; + system("touch /data/test/config.json"); + system("chmod 777 /data/test/config.json"); + std::ofstream file("/data/test/config.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyConfigJson(configJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyConfigJson_0600 + * @tc.desc: ModifyConfigJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyConfigJson_0600, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_MIN_COMPATIBLE_VERSION_CODE, MIN_COMPATIBLE_VERSION_CODE}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string configJsonPath = "/data/test/config.json"; + std::map modifyMap; + system("touch /data/test/config.json"); + system("chmod 777 /data/test/config.json"); + std::ofstream file("/data/test/config.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyConfigJson(configJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyConfigJson_0700 + * @tc.desc: ModifyConfigJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyConfigJson_0700, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_MIN_API_VERSION, MIN_API_VERSION}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string configJsonPath = "/data/test/config.json"; + std::map modifyMap; + system("touch /data/test/config.json"); + system("chmod 777 /data/test/config.json"); + std::ofstream file("/data/test/config.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyConfigJson(configJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyConfigJson_0800 + * @tc.desc: ModifyConfigJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyConfigJson_0800, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_TARGET_API_VERSION, TARGET_API_VERSION}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string configJsonPath = "/data/test/config.json"; + std::map modifyMap; + system("touch /data/test/config.json"); + system("chmod 777 /data/test/config.json"); + std::ofstream file("/data/test/config.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyConfigJson(configJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyConfigJson_0900 + * @tc.desc: ModifyConfigJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyConfigJson_0900, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_API_RELEASE_TYPE, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string configJsonPath = "/data/test/config.json"; + std::map modifyMap; + system("touch /data/test/config.json"); + system("chmod 777 /data/test/config.json"); + std::ofstream file("/data/test/config.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyConfigJson(configJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyConfigJson_1000 + * @tc.desc: ModifyConfigJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyConfigJson_1000, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_TYPE, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string configJsonPath = "/data/test/config.json"; + std::map modifyMap; + system("touch /data/test/config.json"); + system("chmod 777 /data/test/config.json"); + std::ofstream file("/data/test/config.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyConfigJson(configJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + + +/* + * @tc.name: ModifyConfigJson_1100 + * @tc.desc: ModifyConfigJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyConfigJson_1100, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_INSTALLATION_FREE, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string configJsonPath = "/data/test/config.json"; + std::map modifyMap; + system("touch /data/test/config.json"); + system("chmod 777 /data/test/config.json"); + std::ofstream file("/data/test/config.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyConfigJson(configJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyConfigJson_1200 + * @tc.desc: ModifyConfigJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyConfigJson_1200, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_DELIVERY_WITH_INSTALL, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string configJsonPath = "/data/test/config.json"; + std::map modifyMap; + system("touch /data/test/config.json"); + system("chmod 777 /data/test/config.json"); + std::ofstream file("/data/test/config.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyConfigJson(configJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} +/* + * @tc.name: ModifyConfigJson_1300 + * @tc.desc: ModifyConfigJson + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyConfigJson_1300, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_DEVICE_TYPES, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string configJsonPath = "/data/test/config.json"; + std::map modifyMap; + system("touch /data/test/config.json"); + system("chmod 777 /data/test/config.json"); + std::ofstream file("/data/test/config.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyConfigJson(configJsonPath, modifyMap, bundleName, moduleName)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyPackInfo_0100 + * @tc.desc: ModifyPackInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyPackInfo_0100, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string packInfoPath = ""; + EXPECT_FALSE(generalNormalize.ModifyPackInfo(packInfoPath)); +} + +/* + * @tc.name: ModifyPackInfo_0200 + * @tc.desc: ModifyPackInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyPackInfo_0200, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string packInfoPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << JSON_STRING; + file.close(); + } + EXPECT_TRUE(generalNormalize.ModifyPackInfo(packInfoPath)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyPackInfo_0300 + * @tc.desc: ModifyPackInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyPackInfo_0300, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_VERSION_CODE, VERSION_CODE}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string packInfoPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << JSON_STRING_NO_APP_VERSION; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyPackInfo(packInfoPath)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyPackInfo_0400 + * @tc.desc: ModifyPackInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyPackInfo_0400, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_VERSION_NAME, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string packInfoPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << JSON_STRING_NO_APP_VERSION; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyPackInfo(packInfoPath)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyPackInfo_0500 + * @tc.desc: ModifyPackInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyPackInfo_0500, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_NAME, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string packInfoPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << JSON_STRING_NO_BUNDLE_NAME; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyPackInfo(packInfoPath)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyPackInfo_0600 + * @tc.desc: ModifyPackInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyPackInfo_0600, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_MIN_COMPATIBLE_VERSION_CODE, MIN_COMPATIBLE_VERSION_CODE}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string packInfoPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyPackInfo(packInfoPath)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyPackInfo_0700 + * @tc.desc: ModifyPackInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyPackInfo_0700, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_MIN_API_VERSION, MIN_API_VERSION}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string packInfoPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyPackInfo(packInfoPath)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyPackInfo_0800 + * @tc.desc: ModifyPackInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyPackInfo_0800, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_TARGET_API_VERSION, TARGET_API_VERSION}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string packInfoPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyPackInfo(packInfoPath)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyPackInfo_0900 + * @tc.desc: ModifyPackInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyPackInfo_0900, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_API_RELEASE_TYPE, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string packInfoPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyPackInfo(packInfoPath)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyPackInfo_1000 + * @tc.desc: ModifyPackInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyPackInfo_1000, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_BUNDLE_TYPE, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string packInfoPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyPackInfo(packInfoPath)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyPackInfo_1100 + * @tc.desc: ModifyPackInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyPackInfo_1100, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_INSTALLATION_FREE, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string packInfoPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyPackInfo(packInfoPath)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyPackInfo_1200 + * @tc.desc: ModifyPackInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyPackInfo_1200, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_DELIVERY_WITH_INSTALL, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string packInfoPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyPackInfo(packInfoPath)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ModifyPackInfo_1300 + * @tc.desc: ModifyPackInfo + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ModifyPackInfo_1300, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap = { + {OHOS::AppPackingTool::Constants::PARAM_DEVICE_TYPES, ""}, + }; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::string packInfoPath = "/data/test/module.json"; + system("touch /data/test/module.json"); + system("chmod 777 /data/test/module.json"); + std::ofstream file("/data/test/module.json"); + if (file.is_open()) { + file << TEST_STRING_NOTHING; + file.close(); + } + EXPECT_FALSE(generalNormalize.ModifyPackInfo(packInfoPath)); + system("rm -f /data/test/module.json"); +} + +/* + * @tc.name: ProcessJsonFiles_0100 + * @tc.desc: ProcessJsonFiles + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ProcessJsonFiles_0100, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap; + std::string packingPath = "/data/test/generalnormalize_packing"; + system("mkdir /data/test/generalnormalize_packing"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::list> modifyMapList; + EXPECT_FALSE(generalNormalize.ProcessJsonFiles(packingPath, modifyMapList, bundleName, moduleName)); + system("rm -rf /data/test/generalnormalize_packing"); +} + +/* + * @tc.name: ProcessJsonFiles_0200 + * @tc.desc: ProcessJsonFiles + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ProcessJsonFiles_0200, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap; + std::string packingPath = "/data/test/generalnormalize_packing"; + system("mkdir /data/test/generalnormalize_packing"); + system("touch /data/test/generalnormalize_packing/module.json"); + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::list> modifyMapList; + EXPECT_FALSE(generalNormalize.ProcessJsonFiles(packingPath, modifyMapList, bundleName, moduleName)); + system("rm -rf /data/test/generalnormalize_packing"); +} + +/* + * @tc.name: ProcessJsonFiles_0300 + * @tc.desc: ProcessJsonFiles + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ProcessJsonFiles_0300, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap; + std::string packingPath = "/data/test/generalnormalize_packing"; + system("mkdir /data/test/generalnormalize_packing"); + system("touch /data/test/generalnormalize_packing/module.json"); + system("chmod 777 /data/test/generalnormalize_packing/module.json"); + std::ofstream file("/data/test/generalnormalize_packing/module.json"); + if (file.is_open()) { + file << MODULE_JSON_STRING; + file.close(); + } + std::list> modifyMapList; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_TRUE(generalNormalize.ProcessJsonFiles(packingPath, modifyMapList, bundleName, moduleName)); + system("rm -rf /data/test/generalnormalize_packing"); +} + +/* + * @tc.name: ProcessJsonFiles_0400 + * @tc.desc: ProcessJsonFiles + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ProcessJsonFiles_0400, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap; + std::string packingPath = "/data/test/generalnormalize_packing"; + system("mkdir /data/test/generalnormalize_packing"); + system("touch /data/test/generalnormalize_packing/module.json"); + system("chmod 777 /data/test/generalnormalize_packing/module.json"); + std::ofstream file("/data/test/generalnormalize_packing/module.json"); + if (file.is_open()) { + file << MODULE_JSON_STRING; + file.close(); + } + system("touch /data/test/generalnormalize_packing/pack.info"); + std::list> modifyMapList; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_FALSE(generalNormalize.ProcessJsonFiles(packingPath, modifyMapList, bundleName, moduleName)); + system("rm -rf /data/test/generalnormalize_packing"); +} + +/* + * @tc.name: ProcessJsonFiles_0500 + * @tc.desc: ProcessJsonFiles + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ProcessJsonFiles_0500, Function | MediumTest | Level1) +{ + std::string bundleName = ""; + std::string moduleName = ""; + std::string resultReceiver; + std::map parameterMap; + std::string packingPath = "/data/test/generalnormalize_packing"; + system("mkdir /data/test/generalnormalize_packing"); + system("touch /data/test/generalnormalize_packing/config.json"); + system("chmod 777 /data/test/generalnormalize_packing/config.json"); + std::ofstream file("/data/test/generalnormalize_packing/config.json"); + if (file.is_open()) { + file << CONFIG_JSON_STRING; + file.close(); + } + std::list> modifyMapList; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_TRUE(generalNormalize.ProcessJsonFiles(packingPath, modifyMapList, bundleName, moduleName)); + system("rm -rf /data/test/generalnormalize_packing"); +} + +/* + * @tc.name: ConvertMapListToString_0100 + * @tc.desc: ConvertMapListToString + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ConvertMapListToString_0100, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::list> modifyMapList; + EXPECT_EQ(generalNormalize.ConvertMapListToString(modifyMapList), "[]"); +} + +/* + * @tc.name: ConvertMapListToString_0200 + * @tc.desc: ConvertMapListToString + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, ConvertMapListToString_0200, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + std::list> modifyMapList; + std::map modifyMap; + modifyMap["key"] = "value"; + modifyMapList.push_back(modifyMap); + EXPECT_EQ(generalNormalize.ConvertMapListToString(modifyMapList), "[{\"key\":\"value\"}]"); +} + +/* + * @tc.name: CompressDirToHap_0100 + * @tc.desc: CompressDirToHap + * @tc.type: FUNC + * @tc.require: + */ +HWTEST_F(GeneralNormalizeTest, CompressDirToHap_0100, Function | MediumTest | Level1) +{ + std::string resultReceiver; + std::map parameterMap; + std::string sourceDir = "/data/test/sourcedir"; + system("mkdir /data/test/sourcedir"); + system("mkdir /data/test/sourcedir/ets"); + system("mkdir /data/test/sourcedir/hnp"); + system("mkdir /data/test/sourcedir/libs"); + system("mkdir /data/test/sourcedir/an"); + system("mkdir /data/test/sourcedir/ap"); + system("mkdir /data/test/sourcedir/resources"); + system("mkdir /data/test/sourcedir/js"); + system("mkdir /data/test/sourcedir/assets"); + system("mkdir /data/test/sourcedir/maple"); + system("mkdir /data/test/sourcedir/shared_libs"); + system("touch /data/test/sourcedir/config.json"); + system("chmod 777 /data/test/sourcedir/config.json"); + system("touch /data/test/sourcedir/resources.index"); + system("chmod 777 /data/test/sourcedir/resources.index"); + system("touch /data/test/sourcedir/pack.info"); + system("chmod 777 /data/test/sourcedir/pack.info"); + system("touch /data/test/sourcedir/rpcid.sc"); + system("chmod 777 /data/test/sourcedir/rpcid.sc"); + + std::string zipFilePath = "/data/test/sourcedir/test.hsp"; + OHOS::AppPackingTool::GeneralNormalize generalNormalize(parameterMap, resultReceiver); + EXPECT_FALSE(generalNormalize.CompressDirToHap(sourceDir, zipFilePath)); + system("rm -rf /data/test/sourcedir"); +} +} \ No newline at end of file -- Gitee