1# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/test.gni")
15import("../../../bundletool.gni")
16
17module_output_path = "bundle_tool/tools"
18
19config("tools_bm_config_moduletest") {
20  include_dirs = [
21    "${bundle_framework_path}/services/bundlemgr/include/installd",
22    "${bundle_framework_path}/services/bundlemgr/include",
23    "${bundle_framework_path}/services/bundlemgr/include/sandbox_app",
24    "${bundle_framework_path}/services/bundlemgr/include/shared",
25    "//third_party/json/include",
26    "//third_party/zlib",
27    "//third_party/zlib/contrib/minizip",
28  ]
29}
30
31tools_bm_mock_sources = [
32  "${bundletool_test_path}/mock/mock_bundle_installer_host.cpp",
33  "${bundletool_test_path}/mock/mock_bundle_mgr_host.cpp",
34]
35
36ohos_moduletest("bm_command_dump_module_test") {
37  module_out_path = module_output_path
38
39  sources = [
40    "${bundletool_path}/src/bundle_command.cpp",
41    "${bundletool_path}/src/bundle_command_common.cpp",
42    "${bundletool_path}/src/quick_fix_command.cpp",
43    "${bundletool_path}/src/quick_fix_status_callback_host_impl.cpp",
44    "${bundletool_path}/src/shell_command.cpp",
45    "${bundletool_path}/src/status_receiver_impl.cpp",
46    "${kits_path}/js/bundlemgr/bundle_death_recipient.cpp",
47    "bm_command_dump_module_test.cpp",
48  ]
49  sources += tools_bm_mock_sources
50
51  configs = [
52    "${bundletool_path}:tools_bm_config",
53    "${bundletool_test_path}/unittest/bm:tools_bm_config_mock",
54  ]
55
56  cflags = []
57  if (target_cpu == "arm") {
58    cflags += [ "-DBINDER_IPC_32BIT" ]
59  }
60
61  deps = [
62    "${bundle_framework_path}/services/bundlemgr:libbms",
63    "//third_party/googletest:gmock_main",
64    "//third_party/googletest:gtest_main",
65  ]
66
67  external_deps = [
68    "ability_base:base",
69    "ability_base:want",
70    "ability_runtime:app_manager",
71    "ability_runtime:quickfix_manager",
72    "access_token:libaccesstoken_sdk",
73    "appverify:libhapverify",
74    "bundle_framework:appexecfwk_base",
75    "bundle_framework:appexecfwk_core",
76    "bundle_framework:bundle_napi_common",
77    "bundle_framework:libappexecfwk_common",
78    "c_utils:utils",
79    "common_event_service:cesfwk_innerkits",
80    "hilog:libhilog",
81    "init:libbegetutil",
82    "ipc:ipc_core",
83    "kv_store:distributeddata_inner",
84    "os_account:os_account_innerkits",
85    "samgr:samgr_proxy",
86  ]
87
88  external_deps += bm_install_external_deps
89}
90
91ohos_moduletest("bm_command_install_module_test") {
92  module_out_path = module_output_path
93
94  sources = [
95    "${bundletool_path}/src/bundle_command.cpp",
96    "${bundletool_path}/src/bundle_command_common.cpp",
97    "${bundletool_path}/src/quick_fix_command.cpp",
98    "${bundletool_path}/src/quick_fix_status_callback_host_impl.cpp",
99    "${bundletool_path}/src/shell_command.cpp",
100    "${bundletool_path}/src/status_receiver_impl.cpp",
101    "${kits_path}/js/bundlemgr/bundle_death_recipient.cpp",
102    "bm_command_install_module_test.cpp",
103  ]
104  sources += tools_bm_mock_sources
105
106  configs = [
107    "${bundletool_path}:tools_bm_config",
108    "${bundletool_test_path}/unittest/bm:tools_bm_config_mock",
109  ]
110
111  cflags = []
112  if (target_cpu == "arm") {
113    cflags += [ "-DBINDER_IPC_32BIT" ]
114  }
115
116  deps = [
117    "${bundle_framework_path}/services/bundlemgr:libbms",
118    "//third_party/googletest:gmock_main",
119    "//third_party/googletest:gtest_main",
120  ]
121
122  external_deps = [
123    "ability_base:base",
124    "ability_base:want",
125    "ability_runtime:app_manager",
126    "ability_runtime:quickfix_manager",
127    "access_token:libaccesstoken_sdk",
128    "appverify:libhapverify",
129    "bundle_framework:appexecfwk_base",
130    "bundle_framework:appexecfwk_core",
131    "bundle_framework:bundle_napi_common",
132    "bundle_framework:libappexecfwk_common",
133    "c_utils:utils",
134    "common_event_service:cesfwk_innerkits",
135    "hilog:libhilog",
136    "init:libbegetutil",
137    "ipc:ipc_core",
138    "kv_store:distributeddata_inner",
139    "os_account:os_account_innerkits",
140    "samgr:samgr_proxy",
141  ]
142
143  external_deps += bm_install_external_deps
144}
145
146ohos_moduletest("bm_command_uninstall_module_test") {
147  module_out_path = module_output_path
148
149  sources = [
150    "${bundletool_path}/src/bundle_command.cpp",
151    "${bundletool_path}/src/bundle_command_common.cpp",
152    "${bundletool_path}/src/quick_fix_command.cpp",
153    "${bundletool_path}/src/quick_fix_status_callback_host_impl.cpp",
154    "${bundletool_path}/src/shell_command.cpp",
155    "${bundletool_path}/src/status_receiver_impl.cpp",
156    "${kits_path}/js/bundlemgr/bundle_death_recipient.cpp",
157    "bm_command_uninstall_module_test.cpp",
158  ]
159  sources += tools_bm_mock_sources
160
161  configs = [
162    "${bundletool_path}:tools_bm_config",
163    "${bundletool_test_path}/unittest/bm:tools_bm_config_mock",
164  ]
165
166  cflags = []
167  if (target_cpu == "arm") {
168    cflags += [ "-DBINDER_IPC_32BIT" ]
169  }
170
171  deps = [
172    "${bundle_framework_path}/services/bundlemgr:libbms",
173    "//third_party/googletest:gmock_main",
174    "//third_party/googletest:gtest_main",
175  ]
176
177  external_deps = [
178    "ability_base:base",
179    "ability_base:want",
180    "ability_runtime:app_manager",
181    "ability_runtime:quickfix_manager",
182    "access_token:libaccesstoken_sdk",
183    "appverify:libhapverify",
184    "bundle_framework:appexecfwk_base",
185    "bundle_framework:appexecfwk_core",
186    "bundle_framework:bundle_napi_common",
187    "bundle_framework:libappexecfwk_common",
188    "c_utils:utils",
189    "common_event_service:cesfwk_innerkits",
190    "hilog:libhilog",
191    "init:libbegetutil",
192    "ipc:ipc_core",
193    "kv_store:distributeddata_inner",
194    "os_account:os_account_innerkits",
195    "samgr:samgr_proxy",
196  ]
197
198  external_deps += bm_install_external_deps
199}
200
201group("moduletest") {
202  testonly = true
203
204  deps = [
205    ":bm_command_dump_module_test",
206    ":bm_command_install_module_test",
207    ":bm_command_uninstall_module_test",
208  ]
209}
210