1# Copyright (c) 2021-2023 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_unittest") { 20 include_dirs = [ "${bundletool_test_path}/mock/" ] 21} 22 23tools_bm_mock_sources = [ 24 "${bundletool_test_path}/mock/mock_bundle_installer_host.cpp", 25 "${bundletool_test_path}/mock/mock_bundle_mgr_host.cpp", 26] 27 28ohos_unittest("bm_command_dump_test") { 29 module_out_path = module_output_path 30 31 include_dirs = [] 32 33 sources = [ 34 "${bundletool_path}/src/bundle_command.cpp", 35 "${bundletool_path}/src/bundle_command_common.cpp", 36 "${bundletool_path}/src/quick_fix_command.cpp", 37 "${bundletool_path}/src/quick_fix_status_callback_host_impl.cpp", 38 "${bundletool_path}/src/shell_command.cpp", 39 "${bundletool_path}/src/status_receiver_impl.cpp", 40 "bm_command_dump_test.cpp", 41 ] 42 sources += tools_bm_mock_sources 43 44 configs = [ 45 "${bundletool_path}:tools_bm_config", 46 ":tools_bm_config_unittest", 47 ] 48 49 cflags = [] 50 if (target_cpu == "arm") { 51 cflags += [ "-DBINDER_IPC_32BIT" ] 52 } 53 54 deps = [] 55 56 external_deps = [ 57 "ability_base:want", 58 "ability_runtime:app_manager", 59 "ability_runtime:quickfix_manager", 60 "access_token:libaccesstoken_sdk", 61 "appverify:libhapverify", 62 "bundle_framework:appexecfwk_base", 63 "bundle_framework:appexecfwk_core", 64 "bundle_framework:bundle_napi_common", 65 "bundle_framework:bundle_tool_libs", 66 "bundle_framework:libappexecfwk_common", 67 "c_utils:utils", 68 "common_event_service:cesfwk_innerkits", 69 "eventhandler:libeventhandler", 70 "googletest:gmock_main", 71 "googletest:gtest_main", 72 "hilog:libhilog", 73 "init:libbegetutil", 74 "ipc:ipc_core", 75 "json:nlohmann_json_static", 76 "kv_store:distributeddata_inner", 77 "os_account:os_account_innerkits", 78 "relational_store:native_rdb", 79 "samgr:samgr_proxy", 80 ] 81 82 external_deps += bm_install_external_deps 83} 84 85ohos_unittest("bm_command_dump_dependencies_test") { 86 module_out_path = module_output_path 87 88 include_dirs = [ "${bundletool_test_path}/mock" ] 89 90 sources = [ 91 "${bundletool_path}/src/bundle_command.cpp", 92 "${bundletool_path}/src/bundle_command_common.cpp", 93 "${bundletool_path}/src/quick_fix_command.cpp", 94 "${bundletool_path}/src/quick_fix_status_callback_host_impl.cpp", 95 "${bundletool_path}/src/shell_command.cpp", 96 "${bundletool_path}/src/status_receiver_impl.cpp", 97 "bm_command_dump_dependencies_test.cpp", 98 ] 99 sources += tools_bm_mock_sources 100 101 configs = [ "${bundletool_path}:tools_bm_config" ] 102 103 cflags = [] 104 if (target_cpu == "arm") { 105 cflags += [ "-DBINDER_IPC_32BIT" ] 106 } 107 108 external_deps = [ 109 "ability_base:want", 110 "ability_runtime:app_manager", 111 "ability_runtime:quickfix_manager", 112 "access_token:libaccesstoken_sdk", 113 "appverify:libhapverify", 114 "bundle_framework:appexecfwk_base", 115 "bundle_framework:appexecfwk_core", 116 "bundle_framework:bundle_napi_common", 117 "bundle_framework:bundle_tool_libs", 118 "bundle_framework:libappexecfwk_common", 119 "c_utils:utils", 120 "common_event_service:cesfwk_innerkits", 121 "eventhandler:libeventhandler", 122 "googletest:gmock_main", 123 "googletest:gtest_main", 124 "hilog:libhilog", 125 "init:libbegetutil", 126 "ipc:ipc_core", 127 "json:nlohmann_json_static", 128 "kv_store:distributeddata_inner", 129 "os_account:os_account_innerkits", 130 "relational_store:native_rdb", 131 "samgr:samgr_proxy", 132 ] 133 134 external_deps += bm_install_external_deps 135} 136 137ohos_unittest("bm_command_install_test") { 138 module_out_path = module_output_path 139 140 include_dirs = [ "${bundletool_test_path}/mock" ] 141 142 sources = [ 143 "${bundletool_path}/src/bundle_command.cpp", 144 "${bundletool_path}/src/bundle_command_common.cpp", 145 "${bundletool_path}/src/quick_fix_command.cpp", 146 "${bundletool_path}/src/quick_fix_status_callback_host_impl.cpp", 147 "${bundletool_path}/src/shell_command.cpp", 148 "${bundletool_path}/src/status_receiver_impl.cpp", 149 "bm_command_install_test.cpp", 150 ] 151 sources += tools_bm_mock_sources 152 153 configs = [ "${bundletool_path}:tools_bm_config" ] 154 155 cflags = [] 156 if (target_cpu == "arm") { 157 cflags += [ "-DBINDER_IPC_32BIT" ] 158 } 159 160 deps = [] 161 162 external_deps = [ 163 "ability_base:want", 164 "ability_runtime:app_manager", 165 "ability_runtime:quickfix_manager", 166 "access_token:libaccesstoken_sdk", 167 "appverify:libhapverify", 168 "bundle_framework:appexecfwk_base", 169 "bundle_framework:appexecfwk_core", 170 "bundle_framework:bundle_napi_common", 171 "bundle_framework:bundle_tool_libs", 172 "bundle_framework:libappexecfwk_common", 173 "c_utils:utils", 174 "common_event_service:cesfwk_innerkits", 175 "eventhandler:libeventhandler", 176 "googletest:gmock_main", 177 "googletest:gtest_main", 178 "hilog:libhilog", 179 "init:libbegetutil", 180 "ipc:ipc_core", 181 "json:nlohmann_json_static", 182 "kv_store:distributeddata_inner", 183 "os_account:os_account_innerkits", 184 "relational_store:native_rdb", 185 "samgr:samgr_proxy", 186 ] 187 188 external_deps += bm_install_external_deps 189} 190 191ohos_unittest("bm_command_test") { 192 module_out_path = module_output_path 193 194 include_dirs = [ "${bundletool_test_path}/mock" ] 195 196 sources = [ 197 "${bundletool_path}/src/bundle_command.cpp", 198 "${bundletool_path}/src/bundle_command_common.cpp", 199 "${bundletool_path}/src/quick_fix_command.cpp", 200 "${bundletool_path}/src/quick_fix_status_callback_host_impl.cpp", 201 "${bundletool_path}/src/shell_command.cpp", 202 "${bundletool_path}/src/status_receiver_impl.cpp", 203 "bm_command_test.cpp", 204 ] 205 sources += tools_bm_mock_sources 206 207 configs = [ "${bundletool_path}:tools_bm_config" ] 208 209 cflags = [] 210 if (target_cpu == "arm") { 211 cflags += [ "-DBINDER_IPC_32BIT" ] 212 } 213 214 deps = [] 215 216 external_deps = [ 217 "ability_base:want", 218 "ability_runtime:app_manager", 219 "ability_runtime:quickfix_manager", 220 "access_token:libaccesstoken_sdk", 221 "appverify:libhapverify", 222 "bundle_framework:appexecfwk_base", 223 "bundle_framework:appexecfwk_core", 224 "bundle_framework:bundle_napi_common", 225 "bundle_framework:bundle_tool_libs", 226 "bundle_framework:libappexecfwk_common", 227 "c_utils:utils", 228 "common_event_service:cesfwk_innerkits", 229 "eventhandler:libeventhandler", 230 "googletest:gmock_main", 231 "googletest:gtest_main", 232 "hilog:libhilog", 233 "init:libbegetutil", 234 "ipc:ipc_core", 235 "json:nlohmann_json_static", 236 "kv_store:distributeddata_inner", 237 "os_account:os_account_innerkits", 238 "relational_store:native_rdb", 239 "samgr:samgr_proxy", 240 ] 241 242 external_deps += bm_install_external_deps 243 defines = [] 244 if (account_enable_bm) { 245 external_deps += [ "os_account:os_account_innerkits" ] 246 defines += [ "ACCOUNT_ENABLE" ] 247 } 248} 249 250ohos_unittest("bm_command_uninstall_test") { 251 module_out_path = module_output_path 252 253 include_dirs = [ "${bundletool_test_path}/mock" ] 254 255 sources = [ 256 "${bundletool_path}/src/bundle_command.cpp", 257 "${bundletool_path}/src/bundle_command_common.cpp", 258 "${bundletool_path}/src/quick_fix_command.cpp", 259 "${bundletool_path}/src/quick_fix_status_callback_host_impl.cpp", 260 "${bundletool_path}/src/shell_command.cpp", 261 "${bundletool_path}/src/status_receiver_impl.cpp", 262 "bm_command_uninstall_test.cpp", 263 ] 264 sources += tools_bm_mock_sources 265 266 configs = [ "${bundletool_path}:tools_bm_config" ] 267 268 cflags = [] 269 if (target_cpu == "arm") { 270 cflags += [ "-DBINDER_IPC_32BIT" ] 271 } 272 273 deps = [] 274 275 external_deps = [ 276 "ability_base:want", 277 "ability_runtime:app_manager", 278 "ability_runtime:quickfix_manager", 279 "access_token:libaccesstoken_sdk", 280 "appverify:libhapverify", 281 "bundle_framework:appexecfwk_base", 282 "bundle_framework:appexecfwk_core", 283 "bundle_framework:bundle_napi_common", 284 "bundle_framework:bundle_tool_libs", 285 "bundle_framework:libappexecfwk_common", 286 "c_utils:utils", 287 "common_event_service:cesfwk_innerkits", 288 "eventhandler:libeventhandler", 289 "googletest:gmock_main", 290 "googletest:gtest_main", 291 "hilog:libhilog", 292 "init:libbegetutil", 293 "ipc:ipc_core", 294 "json:nlohmann_json_static", 295 "kv_store:distributeddata_inner", 296 "os_account:os_account_innerkits", 297 "relational_store:native_rdb", 298 "samgr:samgr_proxy", 299 ] 300 301 external_deps += bm_install_external_deps 302} 303 304ohos_unittest("bm_command_quickfix_test") { 305 module_out_path = module_output_path 306 307 include_dirs = [ "${bundletool_test_path}/mock" ] 308 309 sources = [ 310 "${bundletool_path}/src/bundle_command.cpp", 311 "${bundletool_path}/src/bundle_command_common.cpp", 312 "${bundletool_path}/src/quick_fix_command.cpp", 313 "${bundletool_path}/src/quick_fix_status_callback_host_impl.cpp", 314 "${bundletool_path}/src/shell_command.cpp", 315 "${bundletool_path}/src/status_receiver_impl.cpp", 316 "bm_command_quickfix_test.cpp", 317 ] 318 sources += tools_bm_mock_sources 319 320 configs = [ "${bundletool_path}:tools_bm_config" ] 321 322 cflags = [] 323 if (target_cpu == "arm") { 324 cflags += [ "-DBINDER_IPC_32BIT" ] 325 } 326 327 external_deps = [ 328 "ability_base:want", 329 "ability_runtime:app_manager", 330 "ability_runtime:quickfix_manager", 331 "access_token:libaccesstoken_sdk", 332 "appverify:libhapverify", 333 "bundle_framework:appexecfwk_base", 334 "bundle_framework:appexecfwk_core", 335 "bundle_framework:bundle_napi_common", 336 "bundle_framework:bundle_tool_libs", 337 "bundle_framework:libappexecfwk_common", 338 "c_utils:utils", 339 "common_event_service:cesfwk_innerkits", 340 "eventhandler:libeventhandler", 341 "googletest:gmock_main", 342 "googletest:gtest_main", 343 "hilog:libhilog", 344 "init:libbegetutil", 345 "ipc:ipc_core", 346 "json:nlohmann_json_static", 347 "kv_store:distributeddata_inner", 348 "os_account:os_account_innerkits", 349 "relational_store:native_rdb", 350 "samgr:samgr_proxy", 351 ] 352 353 external_deps += bm_install_external_deps 354} 355 356ohos_unittest("bm_command_overlay_test") { 357 module_out_path = module_output_path 358 359 include_dirs = [ "${bundletool_test_path}/mock" ] 360 361 sources = [ 362 "${bundletool_path}/src/bundle_command.cpp", 363 "${bundletool_path}/src/bundle_command_common.cpp", 364 "${bundletool_path}/src/quick_fix_command.cpp", 365 "${bundletool_path}/src/quick_fix_status_callback_host_impl.cpp", 366 "${bundletool_path}/src/shell_command.cpp", 367 "${bundletool_path}/src/status_receiver_impl.cpp", 368 "bm_command_overlay_test.cpp", 369 ] 370 sources += tools_bm_mock_sources 371 372 configs = [ "${bundletool_path}:tools_bm_config" ] 373 374 cflags = [] 375 if (target_cpu == "arm") { 376 cflags += [ "-DBINDER_IPC_32BIT" ] 377 } 378 379 deps = [] 380 381 external_deps = [ 382 "ability_base:want", 383 "ability_runtime:app_manager", 384 "ability_runtime:quickfix_manager", 385 "access_token:libaccesstoken_sdk", 386 "appverify:libhapverify", 387 "bundle_framework:appexecfwk_base", 388 "bundle_framework:appexecfwk_core", 389 "bundle_framework:bundle_napi_common", 390 "bundle_framework:bundle_tool_libs", 391 "bundle_framework:libappexecfwk_common", 392 "c_utils:utils", 393 "common_event_service:cesfwk_innerkits", 394 "eventhandler:libeventhandler", 395 "googletest:gmock_main", 396 "googletest:gtest_main", 397 "hilog:libhilog", 398 "init:libbegetutil", 399 "ipc:ipc_core", 400 "json:nlohmann_json_static", 401 "kv_store:distributeddata_inner", 402 "os_account:os_account_innerkits", 403 "relational_store:native_rdb", 404 "samgr:samgr_proxy", 405 ] 406 407 external_deps += bm_install_external_deps 408 409 defines = [] 410 if (overlay_install_bm) { 411 defines += [ "BUNDLE_FRAMEWORK_OVERLAY_INSTALLATION" ] 412 } 413} 414 415group("unittest") { 416 testonly = true 417 418 deps = [ 419 ":bm_command_dump_dependencies_test", 420 ":bm_command_dump_test", 421 ":bm_command_install_test", 422 ":bm_command_overlay_test", 423 ":bm_command_quickfix_test", 424 ":bm_command_test", 425 ":bm_command_uninstall_test", 426 ] 427} 428