1# Copyright (c) 2022-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("//foundation/distributeddatamgr/pasteboard/pasteboard.gni") 16 17config("module_private_config") { 18 visibility = [ ":*" ] 19 20 include_dirs = [ 21 "${pasteboard_framework_path}/include", 22 "${pasteboard_innerkits_path}/include", 23 "${pasteboard_root_path}/adapter/include", 24 "${pasteboard_service_path}/load/include", 25 "${pasteboard_tlv_path}", 26 "include", 27 "test/include", 28 ] 29} 30 31module_output_path = "pasteboard/pasteboard" 32 33ohos_unittest("PasteboardFrameworkTest") { 34 branch_protector_ret = "pac_ret" 35 sanitize = { 36 cfi = true 37 cfi_cross_dso = true 38 debug = false 39 blocklist = "./cfi_blocklist.txt" 40 } 41 use_exceptions = true 42 resource_config_file = "//foundation/distributeddatamgr/pasteboard/framework/test/resource/ohos_test.xml" 43 module_out_path = module_output_path 44 45 sources = [ 46 "${pasteboard_framework_path}/clip/clip_plugin.cpp", 47 "${pasteboard_framework_path}/clip/default_clip.cpp", 48 "${pasteboard_framework_path}/device/dev_profile.cpp", 49 "${pasteboard_framework_path}/device/device_profile_proxy.cpp", 50 "${pasteboard_framework_path}/device/distributed_module_config.cpp", 51 "${pasteboard_framework_path}/device/dm_adapter.cpp", 52 "${pasteboard_framework_path}/eventcenter/event.cpp", 53 "${pasteboard_framework_path}/eventcenter/event_center.cpp", 54 "${pasteboard_framework_path}/eventcenter/pasteboard_event.cpp", 55 "${pasteboard_framework_path}/serializable/serializable.cpp", 56 "${pasteboard_innerkits_path}/src/pasteboard_copy.cpp", 57 "${pasteboard_service_path}/load/src/config.cpp", 58 "mock/ffrt_utils_mock.cpp", 59 "src/clip_plugin_test.cpp", 60 "src/convert_utils_test.cpp", 61 "src/dev_profile_test.cpp", 62 "src/distributed_module_config_test.cpp", 63 "src/dm_adapter_test.cpp", 64 "src/event_center_test.cpp", 65 "src/event_test.cpp", 66 "src/paste_data_entry_test.cpp", 67 "src/paste_data_record_test.cpp", 68 "src/paste_data_test.cpp", 69 "src/pasteboard_client_test.cpp", 70 "src/pasteboard_client_udmf_delay_test.cpp", 71 "src/pasteboard_copy_test.cpp", 72 "src/pasteboard_event_test.cpp", 73 "src/pasteboard_multi_type_unified_data_delay_test.cpp", 74 "src/pasteboard_unified_data_test.cpp", 75 "src/pasteboard_unified_data_uri_test.cpp", 76 "src/pasteboard_utils_test.cpp", 77 "src/serializable_test.cpp", 78 "src/tlv_object_test.cpp", 79 "src/web_controller_test.cpp", 80 ] 81 configs = [ ":module_private_config" ] 82 cflags = [ "-fno-access-control" ] 83 external_deps = [ 84 "ability_base:base", 85 "ability_base:want", 86 "ability_base:zuri", 87 "access_token:libaccesstoken_sdk", 88 "access_token:libtoken_setproc", 89 "app_file_service:fileuri_native", 90 "cJSON:cjson", 91 "c_utils:utils", 92 "device_manager:devicemanagersdk", 93 "dfs_service:distributed_file_daemon_kit_inner", 94 "ffrt:libffrt", 95 "googletest:gmock", 96 "googletest:gtest_main", 97 "hilog:libhilog", 98 "hisysevent:libhisysevent", 99 "image_framework:image_native", 100 "init:libbeget_proxy", 101 "init:libbegetutil", 102 "ipc:ipc_core", 103 "libuv:uv", 104 "samgr:samgr_proxy", 105 "udmf:udmf_client", 106 ] 107 108 deps = [ 109 "${pasteboard_innerkits_path}:pasteboard_client", 110 "${pasteboard_innerkits_path}:pasteboard_data", 111 ] 112 113 defines = [] 114 115 if (pasteboard_device_info_manager_part_enabled) { 116 external_deps += [ 117 "device_info_manager:distributed_device_profile_common", 118 "device_info_manager:distributed_device_profile_sdk", 119 ] 120 defines += [ "PB_DEVICE_INFO_MANAGER_ENABLE" ] 121 } 122 123 if (pasteboard_device_manager_part_enabled) { 124 external_deps += [ "device_manager:devicemanagersdk" ] 125 defines += [ "PB_DEVICE_MANAGER_ENABLE" ] 126 } 127} 128 129ohos_unittest("PasteboardFrameworkMockTest") { 130 branch_protector_ret = "pac_ret" 131 sanitize = { 132 cfi = true 133 cfi_cross_dso = true 134 debug = false 135 blocklist = "./cfi_blocklist.txt" 136 } 137 resource_config_file = 138 "${pasteboard_root_path}/framework/test/resource/ohos_test.xml" 139 module_out_path = module_output_path 140 141 sources = [ 142 "${pasteboard_framework_path}/device/dev_profile.cpp", 143 "${pasteboard_framework_path}/device/distributed_module_config.cpp", 144 "${pasteboard_framework_path}/device/dm_adapter.cpp", 145 "${pasteboard_framework_path}/eventcenter/event.cpp", 146 "${pasteboard_framework_path}/eventcenter/event_center.cpp", 147 "${pasteboard_framework_path}/eventcenter/pasteboard_event.cpp", 148 "${pasteboard_framework_path}/serializable/serializable.cpp", 149 "${pasteboard_root_path}/adapter/src/device_profile_adapter.cpp", 150 "${pasteboard_service_path}/load/src/config.cpp", 151 "mock/device_manager_mock.cpp", 152 "mock/device_profile_proxy_virtual.cpp", 153 "mock/distributed_device_profile_client_mock.cpp", 154 "mock/ffrt_utils_mock.cpp", 155 "src/dev_profile_mock_test.cpp", 156 "src/distributed_module_config_mock_test.cpp", 157 "src/dm_adapter_mock_test.cpp", 158 ] 159 configs = [ ":module_private_config" ] 160 cflags = [ "-fno-access-control" ] 161 external_deps = [ 162 "ability_base:base", 163 "ability_base:want", 164 "ability_base:zuri", 165 "cJSON:cjson", 166 "c_utils:utils", 167 "ffrt:libffrt", 168 "googletest:gmock", 169 "googletest:gtest_main", 170 "hilog:libhilog", 171 "hisysevent:libhisysevent", 172 "image_framework:image_native", 173 "init:libbeget_proxy", 174 "init:libbegetutil", 175 "ipc:ipc_core", 176 "samgr:samgr_proxy", 177 "udmf:udmf_client", 178 ] 179 180 deps = [ "${pasteboard_innerkits_path}:pasteboard_client" ] 181 182 defines = [] 183 184 if (pasteboard_device_info_manager_part_enabled) { 185 external_deps += [ 186 "device_info_manager:distributed_device_profile_common", 187 "device_info_manager:distributed_device_profile_sdk", 188 ] 189 defines += [ "PB_DEVICE_INFO_MANAGER_ENABLE" ] 190 } 191 192 if (pasteboard_device_manager_part_enabled) { 193 external_deps += [ "device_manager:devicemanagersdk" ] 194 defines += [ "PB_DEVICE_MANAGER_ENABLE" ] 195 } 196} 197 198ohos_unittest("FfrtUtilsTest") { 199 branch_protector_ret = "pac_ret" 200 sanitize = { 201 cfi = true 202 cfi_cross_dso = true 203 debug = false 204 blocklist = "./cfi_blocklist.txt" 205 } 206 module_out_path = module_output_path 207 208 sources = [ "src/ffrt_utils_test.cpp" ] 209 210 configs = [ ":module_private_config" ] 211 212 deps = [ "${pasteboard_framework_path}:pasteboard_framework" ] 213 214 external_deps = [ 215 "c_utils:utils", 216 "ffrt:libffrt", 217 "googletest:gtest_main", 218 "hilog:libhilog", 219 "ipc:ipc_core", 220 ] 221} 222 223ohos_unittest("PasteboardClientProxyMockTest") { 224 branch_protector_ret = "pac_ret" 225 sanitize = { 226 cfi = true 227 cfi_cross_dso = true 228 debug = false 229 blocklist = "./cfi_blocklist.txt" 230 } 231 use_exceptions = true 232 resource_config_file = 233 "${pasteboard_root_path}/framework/test/resource/ohos_test.xml" 234 module_out_path = module_output_path 235 sources = [ 236 "${pasteboard_root_path}/adapter/pasteboard_progress/pasteboard_progress.cpp", 237 "${pasteboard_root_path}/framework/framework/device/dm_adapter.cpp", 238 "${pasteboard_root_path}/framework/framework/serializable/serializable.cpp", 239 "${pasteboard_root_path}/framework/innerkits/src/pasteboard_client.cpp", 240 "${pasteboard_root_path}/framework/innerkits/src/pasteboard_copy.cpp", 241 "${pasteboard_root_path}/framework/innerkits/src/pasteboard_load_callback.cpp", 242 "${pasteboard_root_path}/framework/innerkits/src/pasteboard_progress_signal.cpp", 243 "${pasteboard_root_path}/framework/innerkits/src/pasteboard_samgr_listener.cpp", 244 "${pasteboard_root_path}/framework/innerkits/src/pasteboard_service_loader.cpp", 245 "${pasteboard_root_path}/framework/innerkits/src/pasteboard_signal_callback.cpp", 246 "${pasteboard_service_path}/core/src/pasteboard_pattern.cpp", 247 "${pasteboard_service_path}/load/src/config.cpp", 248 "${pasteboard_service_path}/zidl/src/pasteboard_delay_getter_client.cpp", 249 "${pasteboard_service_path}/zidl/src/pasteboard_delay_getter_stub.cpp", 250 "${pasteboard_service_path}/zidl/src/pasteboard_entry_getter_client.cpp", 251 "${pasteboard_service_path}/zidl/src/pasteboard_entry_getter_stub.cpp", 252 "${pasteboard_utils_path}/native/src/pasteboard_time.cpp", 253 "mock/system_ability_manager_client_mock.cpp", 254 "src/pasteboard_client_proxy_mock_test.cpp", 255 ] 256 configs = [ ":module_private_config" ] 257 cflags = [ "-fno-access-control" ] 258 external_deps = [ 259 "ability_base:base", 260 "ability_base:want", 261 "ability_base:zuri", 262 "ability_runtime:ability_manager", 263 "ability_runtime:uri_permission_mgr", 264 "ability_runtime:wantagent_innerkits", 265 "access_token:libtokenid_sdk", 266 "app_file_service:fileuri_native", 267 "bundle_framework:appexecfwk_base", 268 "bundle_framework:appexecfwk_core", 269 "cJSON:cjson", 270 "c_utils:utils", 271 "device_manager:devicemanagersdk", 272 "dfs_service:distributed_file_daemon_kit_inner", 273 "ffrt:libffrt", 274 "googletest:gmock", 275 "googletest:gtest_main", 276 "hilog:libhilog", 277 "hisysevent:libhisysevent", 278 "hitrace:hitrace_meter", 279 "image_framework:image_native", 280 "init:libbeget_proxy", 281 "init:libbegetutil", 282 "ipc:ipc_core", 283 "ipc:ipc_single", 284 "kv_store:distributeddata_mgr", 285 "libuv:uv", 286 "libxml2:libxml2", 287 "samgr:samgr_proxy", 288 "time_service:time_client", 289 "udmf:udmf_client", 290 ] 291 292 deps = [ 293 "${pasteboard_framework_path}:pasteboard_framework", 294 "${pasteboard_innerkits_path}:pasteboard_client", 295 "${pasteboard_innerkits_path}:pasteboard_data", 296 "${pasteboard_root_path}/services:pasteboard_stub_proxy", 297 ] 298 299 defines = [] 300 301 if (pasteboard_device_info_manager_part_enabled) { 302 external_deps += [ 303 "device_info_manager:distributed_device_profile_common", 304 "device_info_manager:distributed_device_profile_sdk", 305 ] 306 defines += [ "PB_DEVICE_INFO_MANAGER_ENABLE" ] 307 } 308 309 if (pasteboard_device_manager_part_enabled) { 310 external_deps += [ "device_manager:devicemanagersdk" ] 311 defines += [ "PB_DEVICE_MANAGER_ENABLE" ] 312 } 313} 314 315ohos_unittest("MessageParcelWarpTest") { 316 branch_protector_ret = "pac_ret" 317 sanitize = { 318 cfi = true 319 cfi_cross_dso = true 320 debug = false 321 blocklist = "./cfi_blocklist.txt" 322 } 323 resource_config_file = 324 "${pasteboard_root_path}/framework/test/resource/ohos_test.xml" 325 module_out_path = module_output_path 326 327 sources = [ 328 "${pasteboard_root_path}/framework/framework/device/dm_adapter.cpp", 329 "${pasteboard_root_path}/framework/framework/serializable/serializable.cpp", 330 "${pasteboard_service_path}/load/src/config.cpp", 331 "src/message_parcel_warp_test.cpp", 332 ] 333 configs = [ ":module_private_config" ] 334 cflags = [ "-fno-access-control" ] 335 external_deps = [ 336 "ability_base:base", 337 "ability_base:want", 338 "ability_base:zuri", 339 "cJSON:cjson", 340 "c_utils:utils", 341 "ffrt:libffrt", 342 "googletest:gmock", 343 "googletest:gtest_main", 344 "hilog:libhilog", 345 "image_framework:image_native", 346 "init:libbeget_proxy", 347 "init:libbegetutil", 348 "ipc:ipc_core", 349 "samgr:samgr_proxy", 350 "udmf:udmf_client", 351 ] 352 353 deps = [ 354 "${pasteboard_framework_path}:pasteboard_framework", 355 "${pasteboard_innerkits_path}:pasteboard_client", 356 "${pasteboard_innerkits_path}:pasteboard_data", 357 ] 358 359 defines = [] 360 361 if (pasteboard_device_info_manager_part_enabled) { 362 external_deps += [ 363 "device_info_manager:distributed_device_profile_common", 364 "device_info_manager:distributed_device_profile_sdk", 365 ] 366 defines += [ "PB_DEVICE_INFO_MANAGER_ENABLE" ] 367 } 368 369 if (pasteboard_device_manager_part_enabled) { 370 external_deps += [ "device_manager:devicemanagersdk" ] 371 defines += [ "PB_DEVICE_MANAGER_ENABLE" ] 372 } 373} 374 375ohos_unittest("PasteboardClientMockTest") { 376 branch_protector_ret = "pac_ret" 377 sanitize = { 378 cfi = true 379 cfi_cross_dso = true 380 debug = false 381 blocklist = "./cfi_blocklist.txt" 382 } 383 use_exceptions = true 384 resource_config_file = "//foundation/distributeddatamgr/pasteboard/framework/test/resource/ohos_test.xml" 385 module_out_path = module_output_path 386 387 sources = [ 388 "${pasteboard_root_path}/adapter/data_share/datashare_delegate.cpp", 389 "${pasteboard_root_path}/adapter/pasteboard_progress/pasteboard_progress.cpp", 390 "${pasteboard_root_path}/adapter/security_level/security_level.cpp", 391 "${pasteboard_root_path}/framework/framework/device/dm_adapter.cpp", 392 "${pasteboard_root_path}/framework/framework/serializable/serializable.cpp", 393 "${pasteboard_root_path}/framework/innerkits/src/pasteboard_client.cpp", 394 "${pasteboard_root_path}/framework/innerkits/src/pasteboard_copy.cpp", 395 "${pasteboard_root_path}/framework/innerkits/src/pasteboard_samgr_listener.cpp", 396 "${pasteboard_root_path}/framework/innerkits/src/pasteboard_signal_callback.cpp", 397 "${pasteboard_service_path}/account/src/account_manager.cpp", 398 "${pasteboard_service_path}/core/src/pasteboard_dialog.cpp", 399 "${pasteboard_service_path}/core/src/pasteboard_lib_guard.cpp", 400 "${pasteboard_service_path}/core/src/pasteboard_pattern.cpp", 401 "${pasteboard_service_path}/dfx/src/behaviour/pasteboard_behaviour_reporter_impl.cpp", 402 "${pasteboard_service_path}/dfx/src/calculate_time_consuming.cpp", 403 "${pasteboard_service_path}/dfx/src/command.cpp", 404 "${pasteboard_service_path}/dfx/src/fault/pasteboard_fault_impl.cpp", 405 "${pasteboard_service_path}/dfx/src/hiview_adapter.cpp", 406 "${pasteboard_service_path}/dfx/src/pasteboard_dump_helper.cpp", 407 "${pasteboard_service_path}/dfx/src/pasteboard_event_dfx.cpp", 408 "${pasteboard_service_path}/dfx/src/pasteboard_trace.cpp", 409 "${pasteboard_service_path}/dfx/src/reporter.cpp", 410 "${pasteboard_service_path}/dfx/src/statistic/time_consuming_statistic_impl.cpp", 411 "${pasteboard_service_path}/load/src/config.cpp", 412 "${pasteboard_service_path}/load/src/loader.cpp", 413 "${pasteboard_service_path}/switch/pasteboard_switch.cpp", 414 "${pasteboard_service_path}/zidl/src/entity_recognition_observer_stub.cpp", 415 "${pasteboard_service_path}/zidl/src/pasteboard_delay_getter_client.cpp", 416 "${pasteboard_service_path}/zidl/src/pasteboard_delay_getter_proxy.cpp", 417 "${pasteboard_service_path}/zidl/src/pasteboard_delay_getter_stub.cpp", 418 "${pasteboard_service_path}/zidl/src/pasteboard_entry_getter_client.cpp", 419 "${pasteboard_service_path}/zidl/src/pasteboard_entry_getter_proxy.cpp", 420 "${pasteboard_service_path}/zidl/src/pasteboard_entry_getter_stub.cpp", 421 "${pasteboard_service_path}/zidl/src/pasteboard_observer_stub.cpp", 422 "${pasteboard_utils_path}/native/src/pasteboard_common.cpp", 423 "${pasteboard_utils_path}/native/src/pasteboard_time.cpp", 424 "src/pasteboard_client_mock_test.cpp", 425 ] 426 configs = [ ":module_private_config" ] 427 cflags = [ "-fno-access-control" ] 428 external_deps = [ 429 "ability_base:base", 430 "ability_base:want", 431 "ability_base:zuri", 432 "ability_runtime:ability_manager", 433 "ability_runtime:uri_permission_mgr", 434 "ability_runtime:wantagent_innerkits", 435 "access_token:libaccesstoken_sdk", 436 "access_token:libprivacy_sdk", 437 "access_token:libtokenid_sdk", 438 "app_file_service:fileshare_native", 439 "app_file_service:fileuri_native", 440 "app_file_service:remote_file_share_native", 441 "bundle_framework:appexecfwk_base", 442 "bundle_framework:appexecfwk_core", 443 "cJSON:cjson", 444 "c_utils:utils", 445 "common_event_service:cesfwk_innerkits", 446 "data_share:datashare_consumer", 447 "dataclassification:data_transit_mgr", 448 "device_manager:devicemanagersdk", 449 "dfs_service:distributed_file_daemon_kit_inner", 450 "eventhandler:libeventhandler", 451 "ffrt:libffrt", 452 "googletest:gmock", 453 "googletest:gtest_main", 454 "hilog:libhilog", 455 "hisysevent:libhisysevent", 456 "hitrace:hitrace_meter", 457 "hitrace:libhitracechain", 458 "image_framework:image_native", 459 "imf:inputmethod_client", 460 "init:libbeget_proxy", 461 "init:libbegetutil", 462 "input:libmmi-client", 463 "ipc:ipc_core", 464 "ipc:ipc_single", 465 "libuv:uv", 466 "libxml2:libxml2", 467 "memmgr:memmgrclient", 468 "os_account:os_account_innerkits", 469 "resource_schedule_service:ressched_client", 470 "safwk:system_ability_fwk", 471 "samgr:samgr_proxy", 472 "udmf:udmf_client", 473 "window_manager:libwm", 474 ] 475 476 deps = [ 477 "${pasteboard_framework_path}:pasteboard_framework", 478 "${pasteboard_innerkits_path}:pasteboard_client", 479 "${pasteboard_innerkits_path}:pasteboard_data", 480 "${pasteboard_root_path}/services:pasteboard_stub_proxy", 481 "${pasteboard_service_path}:pasteboard_service", 482 ] 483 484 defines = [] 485 486 if (pasteboard_device_info_manager_part_enabled) { 487 external_deps += [ 488 "device_info_manager:distributed_device_profile_common", 489 "device_info_manager:distributed_device_profile_sdk", 490 ] 491 defines += [ "PB_DEVICE_INFO_MANAGER_ENABLE" ] 492 } 493 494 if (pasteboard_device_manager_part_enabled) { 495 external_deps += [ "device_manager:devicemanagersdk" ] 496 defines += [ "PB_DEVICE_MANAGER_ENABLE" ] 497 } 498} 499 500ohos_unittest("PasteboardServiceLoaderTest") { 501 module_out_path = module_output_path 502 defines = [ 503 "private = public", 504 "protected = public", 505 ] 506 sources = [ 507 "${pasteboard_root_path}/framework/innerkits/src/pasteboard_load_callback.cpp", 508 "${pasteboard_root_path}/framework/innerkits/src/pasteboard_service_loader.cpp", 509 "src/pasteboard_service_loader_test.cpp", 510 ] 511 configs = [ ":module_private_config" ] 512 cflags = [ "-fno-access-control" ] 513 external_deps = [ 514 "c_utils:utils", 515 "ffrt:libffrt", 516 "googletest:gmock_main", 517 "googletest:gtest_main", 518 "hilog:libhilog", 519 "ipc:ipc_core", 520 "samgr:samgr_proxy", 521 "udmf:udmf_client", 522 ] 523 524 deps = [ 525 "${pasteboard_framework_path}:pasteboard_framework", 526 "${pasteboard_innerkits_path}:pasteboard_client", 527 "${pasteboard_innerkits_path}:pasteboard_data", 528 "${pasteboard_root_path}/services:pasteboard_stub_proxy", 529 ] 530} 531 532ohos_unittest("PasteboardDisposableClientTest") { 533 branch_protector_ret = "pac_ret" 534 sanitize = { 535 ubsan = true 536 boundary_sanitize = true 537 cfi = true 538 cfi_cross_dso = true 539 debug = false 540 } 541 542 module_out_path = module_output_path 543 544 sources = [ "src/pasteboard_disposable_client_test.cpp" ] 545 546 deps = [ 547 "${pasteboard_framework_path}:pasteboard_framework", 548 "${pasteboard_innerkits_path}:pasteboard_client", 549 "${pasteboard_innerkits_path}:pasteboard_data", 550 ] 551 552 external_deps = [ 553 "access_token:libaccesstoken_sdk", 554 "access_token:libtoken_setproc", 555 "c_utils:utils", 556 "googletest:gtest_main", 557 "hilog:libhilog", 558 "ipc:ipc_single", 559 ] 560} 561 562group("unittest") { 563 testonly = true 564 deps = [ 565 ":FfrtUtilsTest", 566 ":MessageParcelWarpTest", 567 ":PasteboardClientMockTest", 568 ":PasteboardClientProxyMockTest", 569 ":PasteboardDisposableClientTest", 570 ":PasteboardFrameworkMockTest", 571 ":PasteboardFrameworkTest", 572 ":PasteboardServiceLoaderTest", 573 ] 574} 575