1# Copyright (C) 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. 13import("//build/test.gni") 14import("//foundation/filemanagement/dfs_service/distributedfile.gni") 15 16ohos_unittest("cloud_sync_callback_client_test") { 17 module_out_path = "dfs_service/dfs_service" 18 19 sources = [ "cloud_sync_callback_client_test.cpp" ] 20 21 include_dirs = [ 22 "${services_path}/cloudsyncservice/include/ipc", 23 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include", 24 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 25 "${distributedfile_path}/utils/log/include", 26 ] 27 28 external_deps = [ 29 "c_utils:utils", 30 "dfs_service:cloudsync_kit_inner", 31 "googletest:gmock_main", 32 "googletest:gtest_main", 33 "hilog:libhilog", 34 "ipc:ipc_single", 35 ] 36 37 defines = [ "private=public" ] 38 39 use_exceptions = true 40} 41 42ohos_unittest("cloud_sync_callback_stub_test") { 43 module_out_path = "dfs_service/dfs_service" 44 45 sources = [ "cloud_sync_callback_stub_test.cpp" ] 46 47 include_dirs = [ 48 "${services_path}/cloudsyncservice/include/ipc", 49 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include", 50 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 51 "${distributedfile_path}/utils/log/include", 52 ] 53 54 55 external_deps = [ 56 "c_utils:utils", 57 "dfs_service:cloudsync_kit_inner", 58 "googletest:gmock_main", 59 "googletest:gtest_main", 60 "hilog:libhilog", 61 "ipc:ipc_single", 62 ] 63 64 defines = [ "private=public" ] 65 66 use_exceptions = true 67} 68 69ohos_unittest("cloud_sync_manager_impl_test") { 70 branch_protector_ret = "pac_ret" 71 sanitize = { 72 integer_overflow = true 73 cfi = true 74 cfi_cross_dso = true 75 debug = false 76 blocklist = "${distributedfile_path}/cfi_blocklist.txt" 77 } 78 79 module_out_path = "dfs_service/dfs_service" 80 81 sources = [ 82 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/cloud_sync_manager_impl.cpp", 83 "${distributedfile_path}/test/mock/system_ability_manager_client_mock.cpp", 84 "cloud_sync_manager_impl_test.cpp", 85 ] 86 87 include_dirs = [ 88 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 89 "${distributedfile_path}/interfaces/inner_api/native/cloudsync_kit_inner", 90 "${distributedfile_path}/test/mock", 91 "${distributedfile_path}/test/mock/ipc", 92 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include", 93 "${distributedfile_path}/test/unittests/cloudsync_sa/mock", 94 "${distributedfile_path}/utils/log/include", 95 "${distributedfile_path}/utils/system/include", 96 "${services_path}/cloudsyncservice/include/ipc", 97 "${utils_path}/dentry/include/", 98 ] 99 100 deps = [ 101 "${utils_path}:libdistributedfileutils", 102 "${utils_path}:libdistributedfiledentry", 103 ] 104 105 external_deps = [ 106 "c_utils:utils", 107 "dfs_service:cloudsync_kit_inner", 108 "googletest:gmock_main", 109 "googletest:gtest_main", 110 "hilog:libhilog", 111 "ipc:ipc_single", 112 "json:nlohmann_json_static", 113 "samgr:samgr_proxy", 114 ] 115 116 defines = [ 117 "private=public", 118 "LOG_DOMAIN=0xD004310", 119 "LOG_TAG=\"CLOUD_SYNC_TEST\"", 120 ] 121 122 use_exceptions = true 123} 124 125ohos_unittest("cloud_sync_manager_impl_unnomal_test") { 126 module_out_path = "dfs_service/dfs_service" 127 128 sources = [ "cloud_sync_manager_impl_unnomal_test.cpp" ] 129 130 include_dirs = [ 131 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 132 "${services_path}/cloudsyncservice/include/ipc", 133 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include", 134 "${distributedfile_path}/test/mock/ipc", 135 "${distributedfile_path}/interfaces/inner_api/native/cloudsync_kit_inner", 136 "${distributedfile_path}/utils/log/include", 137 ] 138 139 deps = [ "${services_path}/cloudsyncservice:cloudsync_sa_static" ] 140 141 external_deps = [ 142 "c_utils:utils", 143 "dfs_service:cloudsync_kit_inner", 144 "googletest:gmock_main", 145 "googletest:gtest_main", 146 "hilog:libhilog", 147 "ipc:ipc_single", 148 "samgr:samgr_proxy", 149 ] 150 151 defines = [ "private=public" ] 152 153 use_exceptions = true 154} 155 156ohos_unittest("cloud_sync_manager_test") { 157 module_out_path = "dfs_service/dfs_service" 158 159 sources = [ "cloud_sync_manager_test.cpp" ] 160 161 include_dirs = [ 162 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 163 "${distributedfile_path}/interfaces/inner_api/native/cloudsync_kit_inner", 164 ] 165 166 deps = [ "${utils_path}:libdistributedfileutils" ] 167 168 external_deps = [ 169 "c_utils:utils", 170 "dfs_service:cloudsync_kit_inner", 171 "googletest:gmock_main", 172 "googletest:gtest_main", 173 "hilog:libhilog", 174 "ipc:ipc_single", 175 "samgr:samgr_proxy", 176 ] 177 178 defines = [ "private=public" ] 179 180 use_exceptions = true 181} 182 183ohos_unittest("cloud_download_callback_client_test") { 184 module_out_path = "dfs_service/dfs_service" 185 186 sources = [ "cloud_download_callback_client_test.cpp" ] 187 188 include_dirs = [ 189 "${services_path}/cloudsyncservice/include/ipc", 190 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include", 191 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 192 "${distributedfile_path}/interfaces/inner_api/native/cloudsync_kit_inner", 193 "${distributedfile_path}/utils/log/include", 194 ] 195 196 external_deps = [ 197 "c_utils:utils", 198 "dfs_service:cloudsync_kit_inner", 199 "googletest:gmock_main", 200 "googletest:gtest_main", 201 "hilog:libhilog", 202 "ipc:ipc_single", 203 ] 204 205 defines = [ 206 "private=public", 207 "LOG_DOMAIN=0xD004307", 208 "LOG_TAG=\"CLOUDSYNC_TEST\"", 209 ] 210 211 use_exceptions = true 212} 213 214ohos_unittest("cloud_download_callback_stub_test") { 215 module_out_path = "dfs_service/dfs_service" 216 217 sources = [ 218 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/cloud_download_callback_stub.cpp", 219 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/cloud_optimize_callback_stub.cpp", 220 "../../../mock/cloud_download_uri_manager_hook.cpp", 221 "cloud_download_callback_stub_test.cpp", 222 ] 223 224 include_dirs = [ 225 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include", 226 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 227 "${distributedfile_path}/interfaces/inner_api/native/cloudsync_kit_inner", 228 "${distributedfile_path}/utils/log/include", 229 ] 230 231 external_deps = [ 232 "c_utils:utils", 233 "dfs_service:cloudsync_kit_inner", 234 "googletest:gmock_main", 235 "googletest:gtest_main", 236 "hilog:libhilog", 237 "ipc:ipc_single", 238 ] 239 240 defines = [ 241 "private=public", 242 "protected=public", 243 "LOG_DOMAIN=0xD004307", 244 "LOG_TAG=\"CLOUDSYNC_TEST\"", 245 ] 246 247 use_exceptions = true 248} 249 250ohos_unittest("cloud_download_uri_manager_test") { 251 module_out_path = "dfs_service/dfs_service" 252 253 sources = [ 254 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/cloud_download_uri_manager.cpp", 255 "cloud_download_uri_manager_test.cpp", 256 ] 257 258 include_dirs = [ 259 "${services_path}/cloudsyncservice/include/ipc", 260 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include", 261 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 262 ] 263 264 deps = [ "${utils_path}:libdistributedfileutils" ] 265 266 external_deps = [ 267 "c_utils:utils", 268 "dfs_service:cloudsync_kit_inner", 269 "googletest:gmock_main", 270 "googletest:gtest_main", 271 "hilog:libhilog", 272 "ipc:ipc_single", 273 ] 274 275 defines = [ "private=public" ] 276 277 use_exceptions = true 278} 279 280ohos_unittest("cloud_sync_common_test") { 281 module_out_path = "dfs_service/dfs_service" 282 283 sources = [ 284 "cloud_sync_common_test.cpp", 285 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/cloud_sync_common.cpp", 286 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/file_hook/parcel_mock.cpp" 287 ] 288 289 include_dirs = [ 290 "${distributedfile_path}/interfaces/inner_api/native/cloudsync_kit_inner", 291 "${distributedfile_path}/test/mock", 292 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/file_hook", 293 ] 294 295 deps = [ "${utils_path}:libdistributedfileutils" ] 296 297 external_deps = [ 298 "googletest:gmock_main", 299 "googletest:gtest_main", 300 "hilog:libhilog", 301 ] 302 303 defines = [ "private=public" ] 304 305 use_exceptions = true 306} 307 308ohos_unittest("cloud_sync_asset_manager_impl_test") { 309 module_out_path = "dfs_service/dfs_service" 310 311 sources = [ 312 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/cloud_sync_asset_manager_impl.cpp", 313 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/download_asset_callback_client.cpp", 314 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/download_asset_callback_stub.cpp", 315 "cloud_sync_asset_manager_impl_test.cpp", 316 ] 317 318 include_dirs = [ 319 "${services_path}/cloudsyncservice/include/ipc", 320 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include", 321 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 322 "${distributedfile_path}/utils/log/include", 323 ] 324 325 external_deps = [ 326 "c_utils:utils", 327 "dfs_service:cloudsync_kit_inner", 328 "googletest:gmock_main", 329 "googletest:gtest_main", 330 "hilog:libhilog", 331 "ipc:ipc_single", 332 "samgr:samgr_proxy", 333 ] 334 335 defines = [ "private=public" ] 336 337 use_exceptions = true 338} 339 340ohos_unittest("cloud_sync_asset_manager_impl_unnomal_test") { 341 module_out_path = "dfs_service/dfs_service" 342 343 sources = [ 344 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/cloud_sync_asset_manager_impl.cpp", 345 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/download_asset_callback_client.cpp", 346 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/download_asset_callback_stub.cpp", 347 "cloud_sync_asset_manager_impl_unnomal_test.cpp", 348 ] 349 350 include_dirs = [ 351 "${services_path}/cloudsyncservice/include/ipc", 352 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include", 353 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 354 ] 355 356 deps = [ "${utils_path}:libdistributedfileutils" ] 357 358 external_deps = [ 359 "c_utils:utils", 360 "dfs_service:cloudsync_asset_kit_inner", 361 "googletest:gmock_main", 362 "googletest:gtest_main", 363 "hilog:libhilog", 364 "ipc:ipc_single", 365 "samgr:samgr_proxy", 366 ] 367 368 defines = [ "private=public" ] 369 370 use_exceptions = true 371} 372 373ohos_unittest("cloud_sync_asset_manager_test") { 374 module_out_path = "dfs_service/dfs_service" 375 376 sources = [ "cloud_sync_asset_manager_test.cpp" ] 377 378 include_dirs = [ 379 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 380 "${distributedfile_path}/interfaces/inner_api/native/cloudsync_kit_inner", 381 ] 382 383 deps = [ "${utils_path}:libdistributedfileutils" ] 384 385 external_deps = [ 386 "c_utils:utils", 387 "dfs_service:cloudsync_asset_kit_inner", 388 "googletest:gmock_main", 389 "googletest:gtest_main", 390 "hilog:libhilog", 391 "ipc:ipc_single", 392 ] 393 394 defines = [ "private=public" ] 395 396 use_exceptions = true 397} 398 399ohos_unittest("download_asset_callback_client_test") { 400 module_out_path = "dfs_service/dfs_service" 401 402 sources = [ 403 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/download_asset_callback_client.cpp", 404 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/download_asset_callback_stub.cpp", 405 "download_asset_callback_client_test.cpp", 406 ] 407 408 include_dirs = [ 409 "${services_path}/cloudsyncservice/include/ipc", 410 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include", 411 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 412 "${distributedfile_path}/interfaces/inner_api/native/cloudsync_kit_inner", 413 ] 414 415 deps = [ "${utils_path}:libdistributedfileutils" ] 416 417 external_deps = [ 418 "c_utils:utils", 419 "dfs_service:cloudsync_kit_inner", 420 "googletest:gmock_main", 421 "googletest:gtest_main", 422 "hilog:libhilog", 423 "ipc:ipc_single", 424 ] 425 426 defines = [ 427 "private=public", 428 "LOG_DOMAIN=0xD004307", 429 "LOG_TAG=\"CLOUDSYNC_TEST\"", 430 ] 431 432 use_exceptions = true 433} 434 435ohos_unittest("download_asset_callback_stub_test") { 436 module_out_path = "dfs_service/dfs_service" 437 438 sources = [ 439 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/download_asset_callback_stub.cpp", 440 "../../../mock/cloud_download_uri_manager_hook.cpp", 441 "download_asset_callback_stub_test.cpp", 442 ] 443 444 include_dirs = [ 445 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include", 446 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 447 "${distributedfile_path}/interfaces/inner_api/native/cloudsync_kit_inner", 448 ] 449 450 deps = [ "${utils_path}:libdistributedfileutils" ] 451 452 external_deps = [ 453 "c_utils:utils", 454 "dfs_service:cloudsync_kit_inner", 455 "googletest:gmock_main", 456 "googletest:gtest_main", 457 "hilog:libhilog", 458 "ipc:ipc_single", 459 ] 460 461 defines = [ 462 "private=public", 463 "protected=public", 464 "LOG_DOMAIN=0xD004307", 465 "LOG_TAG=\"CLOUDSYNC_TEST\"", 466 ] 467 468 use_exceptions = true 469} 470 471ohos_unittest("downgrade_dl_callback_stub_test") { 472 module_out_path = "dfs_service/dfs_service" 473 474 sources = [ 475 "downgrade_dl_callback_stub_test.cpp", 476 ] 477 478 include_dirs = [ 479 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include", 480 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 481 "${distributedfile_path}/interfaces/inner_api/native/cloudsync_kit_inner", 482 "${distributedfile_path}/utils/log/include", 483 ] 484 485 deps = [] 486 487 external_deps = [ 488 "c_utils:utils", 489 "dfs_service:cloudsync_kit_inner", 490 "googletest:gmock_main", 491 "googletest:gtest_main", 492 "hilog:libhilog", 493 "ipc:ipc_single", 494 ] 495 496 defines = [ 497 "private=public", 498 "protected=public", 499 "LOG_DOMAIN=0xD004307", 500 "LOG_TAG=\"CLOUDSYNC_TEST\"", 501 ] 502 503 use_exceptions = true 504} 505 506ohos_unittest("downgrade_dl_callback_client_test") { 507 module_out_path = "dfs_service/dfs_service" 508 509 sources = [ "downgrade_dl_callback_client_test.cpp" ] 510 511 include_dirs = [ 512 "${services_path}/cloudsyncservice/include/ipc", 513 "${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include", 514 "${distributedfile_path}/frameworks/native/cloudsync_kit_inner/include", 515 "${distributedfile_path}/utils/log/include", 516 ] 517 518 519 external_deps = [ 520 "c_utils:utils", 521 "dfs_service:cloudsync_kit_inner", 522 "googletest:gmock_main", 523 "googletest:gtest_main", 524 "hilog:libhilog", 525 "ipc:ipc_single", 526 ] 527 528 defines = [ "private=public" ] 529 530 use_exceptions = true 531} 532 533group("cloudsync_impl_test") { 534 testonly = true 535 536 deps = [ 537 ":cloud_download_callback_client_test", 538 ":cloud_download_callback_stub_test", 539 ":cloud_download_uri_manager_test", 540 ":cloud_sync_asset_manager_impl_test", 541 ":cloud_sync_asset_manager_impl_unnomal_test", 542 ":cloud_sync_asset_manager_test", 543 ":cloud_sync_callback_client_test", 544 ":cloud_sync_callback_stub_test", 545 ":cloud_sync_common_test", 546 ":cloud_sync_manager_impl_test", 547 ":cloud_sync_manager_impl_unnomal_test", 548 ":cloud_sync_manager_test", 549 ":download_asset_callback_client_test", 550 ":download_asset_callback_stub_test", 551 ":downgrade_dl_callback_client_test", 552 ":downgrade_dl_callback_stub_test", 553 ] 554} 555