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_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 "${appexecfwk_path}/services/bundlemgr/include", 25 "${appexecfwk_path}/services/bundlemgr/include/quick_fix", 26 "${appexecfwk_path}/services/bundlemgr/include/sandbox_app", 27 "${bundletool_test_path}/mock", 28 "//base/notification/eventhandler/interfaces/inner_api", 29 "//base/security/permission/interfaces/innerkits/permission_standard/permissionsdk/main/cpp/include", 30 "//base/security/appverify/interfaces/innerkits/appverify/include", 31 "//third_party/googletest/googlemock/include", 32 "//third_party/json/single_include", 33 ] 34} 35 36tools_bm_mock_sources = [ 37 "${bundletool_test_path}/mock/mock_bundle_installer_host.cpp", 38 "${bundletool_test_path}/mock/mock_bundle_mgr_host.cpp", 39] 40 41ohos_unittest("bm_command_dump_test") { 42 module_out_path = module_output_path 43 44 include_dirs = [] 45 46 sources = [ 47 "${bundletool_path}/src/bundle_command.cpp", 48 "${bundletool_path}/src/bundle_command_common.cpp", 49 "${bundletool_path}/src/quick_fix_command.cpp", 50 "${bundletool_path}/src/shell_command.cpp", 51 "${bundletool_path}/src/status_receiver_impl.cpp", 52 "${kits_path}/js/bundlemgr/bundle_death_recipient.cpp", 53 "bm_command_dump_test.cpp", 54 ] 55 sources += tools_bm_mock_sources 56 57 configs = [ 58 "${bundletool_path}:tools_bm_config", 59 ":tools_bm_config_mock", 60 ] 61 62 cflags = [] 63 if (target_cpu == "arm") { 64 cflags += [ "-DBINDER_IPC_32BIT" ] 65 } 66 67 deps = [ 68 "${ability_runtime_path}/services/abilitymgr:abilityms", 69 "${appexecfwk_path}/common:libappexecfwk_common", 70 "${appexecfwk_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:quickfix_manager", 78 "appverify:libhapverify", 79 "bundle_framework:appexecfwk_base", 80 "bundle_framework:appexecfwk_core", 81 "c_utils:utils", 82 "common_event_service:cesfwk_innerkits", 83 "eventhandler:libeventhandler", 84 "hiviewdfx_hilog_native:libhilog", 85 "init:libbegetutil", 86 "ipc:ipc_core", 87 "kv_store:distributeddata_inner", 88 "os_account:os_account_innerkits", 89 "resource_management:global_resmgr", 90 "samgr:samgr_proxy", 91 ] 92} 93 94ohos_unittest("bm_command_dump_dependencies_test") { 95 module_out_path = module_output_path 96 97 include_dirs = [] 98 99 sources = [ 100 "${bundletool_path}/src/bundle_command.cpp", 101 "${bundletool_path}/src/bundle_command_common.cpp", 102 "${bundletool_path}/src/quick_fix_command.cpp", 103 "${bundletool_path}/src/shell_command.cpp", 104 "${bundletool_path}/src/status_receiver_impl.cpp", 105 "${kits_path}/js/bundlemgr/bundle_death_recipient.cpp", 106 "bm_command_dump_dependencies_test.cpp", 107 ] 108 sources += tools_bm_mock_sources 109 110 configs = [ 111 "${bundletool_path}:tools_bm_config", 112 ":tools_bm_config_mock", 113 ] 114 115 cflags = [] 116 if (target_cpu == "arm") { 117 cflags += [ "-DBINDER_IPC_32BIT" ] 118 } 119 120 deps = [ 121 "${ability_runtime_path}/services/abilitymgr:abilityms", 122 "${appexecfwk_path}/common:libappexecfwk_common", 123 "${appexecfwk_path}/services/bundlemgr:libbms", 124 "//third_party/googletest:gmock_main", 125 "//third_party/googletest:gtest_main", 126 ] 127 128 external_deps = [ 129 "ability_base:want", 130 "ability_runtime:quickfix_manager", 131 "appverify:libhapverify", 132 "bundle_framework:appexecfwk_base", 133 "bundle_framework:appexecfwk_core", 134 "c_utils:utils", 135 "common_event_service:cesfwk_innerkits", 136 "eventhandler:libeventhandler", 137 "hiviewdfx_hilog_native:libhilog", 138 "init:libbegetutil", 139 "ipc:ipc_core", 140 "kv_store:distributeddata_inner", 141 "os_account:os_account_innerkits", 142 "resource_management:global_resmgr", 143 "samgr:samgr_proxy", 144 ] 145} 146 147ohos_unittest("bm_command_install_test") { 148 module_out_path = module_output_path 149 150 include_dirs = [] 151 152 sources = [ 153 "${bundletool_path}/src/bundle_command.cpp", 154 "${bundletool_path}/src/bundle_command_common.cpp", 155 "${bundletool_path}/src/quick_fix_command.cpp", 156 "${bundletool_path}/src/shell_command.cpp", 157 "${bundletool_path}/src/status_receiver_impl.cpp", 158 "${kits_path}/js/bundlemgr/bundle_death_recipient.cpp", 159 "bm_command_install_test.cpp", 160 ] 161 sources += tools_bm_mock_sources 162 163 configs = [ 164 "${bundletool_path}:tools_bm_config", 165 ":tools_bm_config_mock", 166 ] 167 168 cflags = [] 169 if (target_cpu == "arm") { 170 cflags += [ "-DBINDER_IPC_32BIT" ] 171 } 172 173 deps = [ 174 "${ability_runtime_path}/services/abilitymgr:abilityms", 175 "${appexecfwk_path}/common:libappexecfwk_common", 176 "${appexecfwk_path}/services/bundlemgr:libbms", 177 "//third_party/googletest:gmock_main", 178 "//third_party/googletest:gtest_main", 179 ] 180 181 external_deps = [ 182 "ability_base:want", 183 "ability_runtime:quickfix_manager", 184 "appverify:libhapverify", 185 "bundle_framework:appexecfwk_base", 186 "bundle_framework:appexecfwk_core", 187 "c_utils:utils", 188 "common_event_service:cesfwk_innerkits", 189 "eventhandler:libeventhandler", 190 "hiviewdfx_hilog_native:libhilog", 191 "init:libbegetutil", 192 "ipc:ipc_core", 193 "kv_store:distributeddata_inner", 194 "os_account:os_account_innerkits", 195 "resource_management:global_resmgr", 196 "samgr:samgr_proxy", 197 ] 198} 199 200ohos_unittest("bm_command_test") { 201 module_out_path = module_output_path 202 203 include_dirs = [] 204 205 sources = [ 206 "${bundletool_path}/src/bundle_command.cpp", 207 "${bundletool_path}/src/bundle_command_common.cpp", 208 "${bundletool_path}/src/quick_fix_command.cpp", 209 "${bundletool_path}/src/shell_command.cpp", 210 "${bundletool_path}/src/status_receiver_impl.cpp", 211 "${kits_path}/js/bundlemgr/bundle_death_recipient.cpp", 212 "bm_command_test.cpp", 213 ] 214 sources += tools_bm_mock_sources 215 216 configs = [ 217 "${bundletool_path}:tools_bm_config", 218 ":tools_bm_config_mock", 219 ] 220 221 cflags = [] 222 if (target_cpu == "arm") { 223 cflags += [ "-DBINDER_IPC_32BIT" ] 224 } 225 226 deps = [ 227 "${ability_runtime_path}/services/abilitymgr:abilityms", 228 "${appexecfwk_path}/common:libappexecfwk_common", 229 "${appexecfwk_path}/services/bundlemgr:libbms", 230 "//third_party/googletest:gmock_main", 231 "//third_party/googletest:gtest_main", 232 ] 233 234 external_deps = [ 235 "ability_base:want", 236 "ability_runtime:quickfix_manager", 237 "appverify:libhapverify", 238 "bundle_framework:appexecfwk_base", 239 "bundle_framework:appexecfwk_core", 240 "c_utils:utils", 241 "common_event_service:cesfwk_innerkits", 242 "eventhandler:libeventhandler", 243 "hiviewdfx_hilog_native:libhilog", 244 "init:libbegetutil", 245 "ipc:ipc_core", 246 "kv_store:distributeddata_inner", 247 "os_account:os_account_innerkits", 248 "resource_management:global_resmgr", 249 "samgr:samgr_proxy", 250 ] 251} 252 253ohos_unittest("bm_command_uninstall_test") { 254 module_out_path = module_output_path 255 256 include_dirs = [] 257 258 sources = [ 259 "${bundletool_path}/src/bundle_command.cpp", 260 "${bundletool_path}/src/bundle_command_common.cpp", 261 "${bundletool_path}/src/quick_fix_command.cpp", 262 "${bundletool_path}/src/shell_command.cpp", 263 "${bundletool_path}/src/status_receiver_impl.cpp", 264 "${kits_path}/js/bundlemgr/bundle_death_recipient.cpp", 265 "bm_command_uninstall_test.cpp", 266 ] 267 sources += tools_bm_mock_sources 268 269 configs = [ 270 "${bundletool_path}:tools_bm_config", 271 ":tools_bm_config_mock", 272 ] 273 274 cflags = [] 275 if (target_cpu == "arm") { 276 cflags += [ "-DBINDER_IPC_32BIT" ] 277 } 278 279 deps = [ 280 "${ability_runtime_path}/services/abilitymgr:abilityms", 281 "${appexecfwk_path}/common:libappexecfwk_common", 282 "${appexecfwk_path}/services/bundlemgr:libbms", 283 "//third_party/googletest:gmock_main", 284 "//third_party/googletest:gtest_main", 285 ] 286 287 external_deps = [ 288 "ability_base:want", 289 "ability_runtime:quickfix_manager", 290 "appverify:libhapverify", 291 "bundle_framework:appexecfwk_base", 292 "bundle_framework:appexecfwk_core", 293 "c_utils:utils", 294 "common_event_service:cesfwk_innerkits", 295 "eventhandler:libeventhandler", 296 "hiviewdfx_hilog_native:libhilog", 297 "init:libbegetutil", 298 "ipc:ipc_core", 299 "kv_store:distributeddata_inner", 300 "os_account:os_account_innerkits", 301 "resource_management:global_resmgr", 302 "samgr:samgr_proxy", 303 ] 304} 305 306ohos_unittest("bm_command_quickfix_test") { 307 module_out_path = module_output_path 308 309 include_dirs = [] 310 311 sources = [ 312 "${bundletool_path}/src/bundle_command.cpp", 313 "${bundletool_path}/src/bundle_command_common.cpp", 314 "${bundletool_path}/src/quick_fix_command.cpp", 315 "${bundletool_path}/src/shell_command.cpp", 316 "${bundletool_path}/src/status_receiver_impl.cpp", 317 "${kits_path}/js/bundlemgr/bundle_death_recipient.cpp", 318 "bm_command_quickfix_test.cpp", 319 ] 320 sources += tools_bm_mock_sources 321 322 configs = [ 323 "${bundletool_path}:tools_bm_config", 324 ":tools_bm_config_mock", 325 ] 326 327 cflags = [] 328 if (target_cpu == "arm") { 329 cflags += [ "-DBINDER_IPC_32BIT" ] 330 } 331 332 deps = [ 333 "${ability_runtime_path}/services/abilitymgr:abilityms", 334 "${appexecfwk_path}/common:libappexecfwk_common", 335 "${appexecfwk_path}/services/bundlemgr:libbms", 336 "//third_party/googletest:gmock_main", 337 "//third_party/googletest:gtest_main", 338 ] 339 340 external_deps = [ 341 "ability_base:want", 342 "ability_runtime:quickfix_manager", 343 "appverify:libhapverify", 344 "bundle_framework:appexecfwk_base", 345 "bundle_framework:appexecfwk_core", 346 "c_utils:utils", 347 "common_event_service:cesfwk_innerkits", 348 "eventhandler:libeventhandler", 349 "hiviewdfx_hilog_native:libhilog", 350 "init:libbegetutil", 351 "ipc:ipc_core", 352 "kv_store:distributeddata_inner", 353 "os_account:os_account_innerkits", 354 "resource_management:global_resmgr", 355 "samgr:samgr_proxy", 356 ] 357} 358 359group("unittest") { 360 testonly = true 361 362 deps = [ 363 ":bm_command_dump_dependencies_test", 364 ":bm_command_dump_test", 365 ":bm_command_install_test", 366 ":bm_command_quickfix_test", 367 ":bm_command_test", 368 ":bm_command_uninstall_test", 369 ] 370} 371