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