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. 13 14import("//build/test.gni") 15import("//foundation/filemanagement/dfs_service/distributedfile.gni") 16 17ohos_unittest("battery_status_listener_test") { 18 branch_protector_ret = "pac_ret" 19 sanitize = { 20 ubsan = true 21 boundary_sanitize = true 22 cfi = true 23 cfi_cross_dso = true 24 debug = true 25 blocklist = "${distributedfile_path}/cfi_blocklist.txt" 26 } 27 module_out_path = "filemanagement/dfs_service" 28 sources = [ 29 "${distributedfile_path}/services/cloudsyncservice/src/sync_rule/battery_status_listener.cpp", 30 "battery_status_listener_test.cpp", 31 ] 32 33 include_dirs = [ 34 "${services_path}/cloudsyncservice/include", 35 "${services_path}/cloudsyncservice/include/sync_rule", 36 "${innerkits_native_path}/cloudsync_kit_inner", 37 "${distributedfile_path}/adapter/cloud_adapter_example/include", 38 "${services_path}/cloudsyncservice/include/sync_rule", 39 "${utils_path}/log/include", 40 "${image_framework_path}/mock/native/include/log", 41 "${media_library_path}/interfaces/inner_api/media_library_helper/include", 42 "${media_library_path}/frameworks/utils/include", 43 ] 44 45 deps = [ 46 "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit", 47 "${services_path}/cloudsyncservice:cloudsync_sa_static", 48 "${utils_path}:libdistributedfileutils", 49 "//third_party/googletest:gmock_main", 50 "//third_party/googletest:gtest_main", 51 ] 52 53 external_deps = [ 54 "ability_base:want", 55 "c_utils:utils", 56 "common_event_service:cesfwk_innerkits", 57 "hilog:libhilog", 58 "hisysevent:libhisysevent", 59 "init:libbegetutil", 60 "ipc:ipc_core", 61 "netmanager_base:net_conn_manager_if", 62 "relational_store:native_rdb", 63 "safwk:system_ability_fwk", 64 "samgr:samgr_proxy", 65 ] 66 67 defines = [ 68 "private=public", 69 "LOG_DOMAIN=0xD004310", 70 "LOG_TAG=\"CLOUD_SYNC_TEST\"", 71 ] 72 if (cloudsync_service_resource_schedule) { 73 external_deps += [ "resource_schedule_service:ressched_client" ] 74 defines += [ "CLOUDSYNC_SERVICE_RESOURCE_SCHEDULE" ] 75 } 76 use_exceptions = true 77} 78 79ohos_unittest("net_conn_callback_observer_test") { 80 module_out_path = "filemanagement/dfs_service" 81 sources = [ 82 "${distributedfile_path}/services/cloudsyncservice/src/sync_rule/net_conn_callback_observer.cpp", 83 "net_conn_callback_observer_test.cpp", 84 ] 85 86 include_dirs = [ 87 "${services_path}/cloudsyncservice/include", 88 "${services_path}/cloudsyncservice/include/sync_rule", 89 "${utils_path}/log/include", 90 "${image_framework_path}/mock/native/include/log", 91 "${innerkits_native_path}/cloudsync_kit_inner", 92 "${distributedfile_path}/adapter/cloud_adapter_example/include", 93 ] 94 95 deps = [ 96 "${services_path}/cloudsyncservice:cloudsync_sa_static", 97 "${utils_path}:libdistributedfiledentry", 98 "${utils_path}:libdistributedfileutils", 99 "//third_party/googletest:gmock_main", 100 "//third_party/googletest:gtest_main", 101 ] 102 103 external_deps = [ 104 "ability_base:want", 105 "c_utils:utils", 106 "common_event_service:cesfwk_innerkits", 107 "hilog:libhilog", 108 "hisysevent:libhisysevent", 109 "init:libbegetutil", 110 "ipc:ipc_core", 111 "netmanager_base:net_conn_manager_if", 112 "relational_store:native_rdb", 113 "safwk:system_ability_fwk", 114 "samgr:samgr_proxy", 115 ] 116 117 defines = [ "private=public" ] 118 119 use_exceptions = true 120} 121 122ohos_unittest("network_status_test") { 123 module_out_path = "filemanagement/dfs_service" 124 sources = [ 125 "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/data_sync_manager.cpp", 126 "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/net_conn_callback_observer.cpp", 127 "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/network_status.cpp", 128 "${distributedfile_path}/test/mock/net_conn_client_mock.cpp", 129 "${distributedfile_path}/test/unittests/cloudsync_sa/mock/network_set_manager_mock.cpp", 130 "network_status_test.cpp", 131 ] 132 133 include_dirs = [ 134 "${distributedfile_path}/interfaces/inner_api/native/cloud_file_kit_inner", 135 "${distributedfile_path}/test/mock/", 136 "${innerkits_native_path}/cloud_file_kit_inner", 137 "${services_path}/cloudsyncservice/include", 138 "${services_path}/cloudsyncservice/include/sync_rule", 139 "${utils_path}/log/include", 140 "${image_framework_path}/mock/native/include/log", 141 "${innerkits_native_path}/cloudsync_kit_inner", 142 "${distributedfile_path}/adapter/cloud_adapter_example/include", 143 "${media_library_path}/interfaces/inner_api/media_library_helper/include", 144 "${media_library_path}/frameworks/utils/include", 145 ] 146 147 deps = [ 148 "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit", 149 "${utils_path}:libdistributedfileutils", 150 "//third_party/googletest:gmock_main", 151 "//third_party/googletest:gtest_main", 152 ] 153 154 external_deps = [ 155 "access_token:libaccesstoken_sdk", 156 "access_token:libtokenid_sdk", 157 "c_utils:utils", 158 "common_event_service:cesfwk_innerkits", 159 "data_share:datashare_consumer", 160 "dfs_service:cloudsync_kit_inner", 161 "hilog:libhilog", 162 "hisysevent:libhisysevent", 163 "init:libbegetutil", 164 "ipc:ipc_core", 165 "netmanager_base:net_conn_manager_if", 166 "relational_store:native_rdb", 167 "samgr:samgr_proxy", 168 ] 169 170 defines = [ "private=public" ] 171 if (cloudsync_service_resource_schedule) { 172 external_deps += [ "resource_schedule_service:ressched_client" ] 173 defines += [ "CLOUDSYNC_SERVICE_RESOURCE_SCHEDULE" ] 174 } 175 use_exceptions = true 176} 177 178ohos_unittest("cloud_status_test") { 179 module_out_path = "filemanagement/dfs_service" 180 sources = [ 181 "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/cloud_status.cpp", 182 "${distributedfile_path}/test/mock/cloud_file_kit_mock.cpp", 183 "${distributedfile_path}/utils/log/src/dfs_error.cpp", 184 "cloud_status_test.cpp", 185 ] 186 187 include_dirs = [ 188 "${distributedfile_path}/interfaces/inner_api/native/cloud_file_kit_inner", 189 "${services_path}/cloudsyncservice/include", 190 "${media_library_path}/frameworks/utils/include", 191 "${distributedfile_path}/adapter/cloud_adapter_example/include", 192 "${distributedfile_path}/test/mock", 193 ] 194 195 deps = [ 196 "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit", 197 "${innerkits_native_path}/cloudsync_kit_inner:cloudsync_kit_inner", 198 "${services_path}/cloudsyncservice:cloudsync_sa_static", 199 "${utils_path}:libdistributedfileutils", 200 "//third_party/googletest:gmock_main", 201 "//third_party/googletest:gtest_main", 202 ] 203 204 external_deps = [ 205 "c_utils:utils", 206 "hilog:libhilog", 207 "hisysevent:libhisysevent", 208 ] 209 210 defines = [ "private=public" ] 211 212 use_exceptions = true 213} 214 215ohos_unittest("battery_status_test") { 216 branch_protector_ret = "pac_ret" 217 sanitize = { 218 ubsan = true 219 boundary_sanitize = true 220 cfi = true 221 cfi_cross_dso = true 222 debug = true 223 blocklist = "${distributedfile_path}/cfi_blocklist.txt" 224 } 225 module_out_path = "filemanagement/dfs_service" 226 sources = [ 227 "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/battery_status.cpp", 228 "${distributedfile_path}/test/mock/battersrvclient_mock.cpp", 229 "battery_status_test.cpp", 230 ] 231 232 include_dirs = [ 233 "${services_path}/cloudsyncservice/include", 234 "${services_path}/cloudsyncservice/include/sync_rule", 235 "${innerkits_native_path}/cloudsync_kit_inner", 236 "${distributedfile_path}/adapter/cloud_adapter_example/include", 237 "${distributedfile_path}/interfaces/inner_api/native/cloud_file_kit_inner", 238 "${utils_path}/log/include", 239 "${image_framework_path}/mock/native/include/log", 240 "${media_library_path}/interfaces/inner_api/media_library_helper/include", 241 "${media_library_path}/frameworks/utils/include", 242 "${distributedfile_path}/test/mock", 243 ] 244 245 deps = [ 246 "${services_path}/cloudsyncservice:cloudsync_sa_static", 247 "${utils_path}:libdistributedfileutils", 248 "//third_party/googletest:gmock_main", 249 "//third_party/googletest:gtest_main", 250 ] 251 252 external_deps = [ 253 "ability_base:want", 254 "c_utils:utils", 255 "common_event_service:cesfwk_innerkits", 256 "hilog:libhilog", 257 "hisysevent:libhisysevent", 258 "init:libbegetutil", 259 "ipc:ipc_core", 260 "netmanager_base:net_conn_manager_if", 261 "power_manager:powermgr_client", 262 "relational_store:native_rdb", 263 "safwk:system_ability_fwk", 264 "samgr:samgr_proxy", 265 ] 266 267 defines = [ 268 "private=public", 269 "LOG_DOMAIN=0xD004310", 270 "LOG_TAG=\"CLOUD_SYNC_TEST\"", 271 ] 272 273 if (cloudsync_service_power) { 274 external_deps += [ "battery_manager:batterysrv_client" ] 275 276 defines += [ "SUPPORT_POWER" ] 277 } 278 279 use_exceptions = true 280} 281 282ohos_unittest("network_set_manager_test") { 283 branch_protector_ret = "pac_ret" 284 sanitize = { 285 ubsan = true 286 boundary_sanitize = true 287 cfi = true 288 cfi_cross_dso = true 289 debug = true 290 blocklist = "${distributedfile_path}/cfi_blocklist.txt" 291 } 292 293 module_out_path = "filemanagement/dfs_service" 294 sources = [ 295 "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/network_set_manager.cpp", 296 "${distributedfile_path}/test/unittests/cloudsync_sa/mock/datashare_helper.cpp", 297 "network_set_manager_test.cpp", 298 ] 299 300 include_dirs = [ 301 "${distributedfile_path}/interfaces/inner_api/native/cloud_file_kit_inner", 302 "${distributedfile_path}/test/unittests/cloudsync_sa/mock", 303 "${innerkits_native_path}/cloud_file_kit_inner", 304 "${innerkits_native_path}/cloudsync_kit_inner", 305 "${services_path}/cloudsyncservice/include", 306 "${services_path}/cloudsyncservice/include/sync_rule", 307 "${utils_path}/log/include", 308 "${image_framework_path}/mock/native/include/log", 309 "${distributedfile_path}/adapter/cloud_adapter_example/include", 310 "${media_library_path}/interfaces/inner_api/media_library_helper/include", 311 "${media_library_path}/frameworks/utils/include", 312 ] 313 314 deps = [ 315 "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit", 316 "${utils_path}:libdistributedfileutils", 317 "//third_party/googletest:gmock_main", 318 "//third_party/googletest:gtest_main", 319 ] 320 321 external_deps = [ 322 "ability_base:zuri", 323 "ability_runtime:dataobs_manager", 324 "access_token:libtokenid_sdk", 325 "c_utils:utils", 326 "hilog:libhilog", 327 "hisysevent:libhisysevent", 328 "init:libbegetutil", 329 "ipc:ipc_core", 330 "ipc:ipc_single", 331 "safwk:system_ability_fwk", 332 ] 333 334 defines = [ "private=public" ] 335 336 use_exceptions = true 337} 338 339ohos_unittest("system_load_test") { 340 module_out_path = "filemanagement/dfs_service" 341 sources = [ 342 "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/system_load.cpp", 343 "system_load_test.cpp", 344 ] 345 346 include_dirs = [ 347 "${distributedfile_path}/interfaces/inner_api/native/cloud_file_kit_inner", 348 "${innerkits_native_path}/cloud_file_kit_inner", 349 "${services_path}/cloudsyncservice/include", 350 "${services_path}/cloudsyncservice/include/sync_rule", 351 "${utils_path}/log/include", 352 "${image_framework_path}/mock/native/include/log", 353 "${innerkits_native_path}/cloudsync_kit_inner", 354 "${distributedfile_path}/adapter/cloud_adapter_example/include", 355 "${media_library_path}/interfaces/inner_api/media_library_helper/include", 356 "${media_library_path}/frameworks/utils/include", 357 ] 358 359 deps = [ 360 "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit", 361 "${utils_path}:libdistributedfileutils", 362 "//third_party/googletest:gmock_main", 363 "//third_party/googletest:gtest_main", 364 ] 365 366 external_deps = [ 367 "access_token:libaccesstoken_sdk", 368 "access_token:libtokenid_sdk", 369 "c_utils:utils", 370 "common_event_service:cesfwk_innerkits", 371 "data_share:datashare_consumer", 372 "dfs_service:cloudsync_kit_inner", 373 "ffrt:libffrt", 374 "hilog:libhilog", 375 "hisysevent:libhisysevent", 376 "init:libbegetutil", 377 "ipc:ipc_core", 378 "netmanager_base:net_conn_manager_if", 379 "relational_store:native_rdb", 380 "resource_schedule_service:ressched_client", 381 "samgr:samgr_proxy", 382 ] 383 384 defines = [ "private=public" ] 385 386 use_exceptions = true 387} 388 389group("cloudsync_sa_sync_rule_test") { 390 testonly = true 391 deps = [ 392 ":battery_status_listener_test", 393 ":battery_status_test", 394 ":cloud_status_test", 395 ":network_set_manager_test", 396 ":network_status_test", 397 ":system_load_test", 398 ] 399} 400