• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2023-2024 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 = "dfs_service/dfs_service"
28  sources = [
29    "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/battery_status.cpp",
30    "${distributedfile_path}/services/cloudsyncservice/src/sync_rule/battery_status_listener.cpp",
31    "${distributedfile_path}/test/mock/battersrvclient_mock.cpp",
32    "battery_status_listener_test.cpp",
33  ]
34
35  include_dirs = [
36    "${services_path}/cloudsyncservice/include",
37    "${services_path}/cloudsyncservice/include/sync_rule",
38    "${innerkits_native_path}/cloudsync_kit_inner",
39    "${distributedfile_path}/adapter/cloud_adapter_example/include",
40    "${distributedfile_path}/test/mock",
41    "${services_path}/cloudsyncservice/include/sync_rule",
42    "${utils_path}/log/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  ]
50
51  external_deps = [
52    "ability_base:want",
53    "c_utils:utils",
54    "common_event_service:cesfwk_innerkits",
55    "googletest:gmock_main",
56    "googletest:gtest_main",
57    "hilog:libhilog",
58    "hisysevent:libhisysevent",
59    "image_framework:image_native",
60    "init:libbegetutil",
61    "ipc:ipc_core",
62    "netmanager_base:net_conn_manager_if",
63    "relational_store:native_rdb",
64    "safwk:system_ability_fwk",
65    "samgr:samgr_proxy",
66  ]
67
68  defines = [
69    "private=public",
70    "LOG_DOMAIN=0xD004310",
71    "LOG_TAG=\"CLOUD_SYNC_TEST\"",
72  ]
73
74  if (cloudsync_service_resource_schedule) {
75    external_deps += [ "resource_schedule_service:ressched_client" ]
76    defines += [ "CLOUDSYNC_SERVICE_RESOURCE_SCHEDULE" ]
77  }
78
79  if (cloudsync_service_power) {
80    external_deps += [ "battery_manager:batterysrv_client" ]
81    defines += [ "SUPPORT_POWER" ]
82  }
83  use_exceptions = true
84}
85
86ohos_unittest("net_conn_callback_observer_test") {
87  module_out_path = "dfs_service/dfs_service"
88  sources = [
89    "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/net_conn_callback_observer.cpp",
90    "net_conn_callback_observer_test.cpp",
91  ]
92
93  include_dirs = [
94    "${services_path}/cloudsyncservice/include",
95    "${services_path}/cloudsyncservice/include/sync_rule",
96    "${utils_path}/log/include",
97    "${innerkits_native_path}/cloud_file_kit_inner",
98    "${innerkits_native_path}/cloudsync_kit_inner",
99    "${distributedfile_path}/adapter/cloud_adapter_example/include",
100  ]
101
102  deps = [
103    "${services_path}/cloudsyncservice:cloudsync_sa_static",
104    "${utils_path}:libdistributedfiledentry",
105    "${utils_path}:libdistributedfileutils",
106  ]
107
108  external_deps = [
109    "ability_base:want",
110    "c_utils:utils",
111    "common_event_service:cesfwk_innerkits",
112    "googletest:gmock_main",
113    "googletest:gtest_main",
114    "hilog:libhilog",
115    "hisysevent:libhisysevent",
116    "image_framework:image_native",
117    "init:libbegetutil",
118    "ipc:ipc_core",
119    "netmanager_base:net_conn_manager_if",
120    "relational_store:native_rdb",
121    "safwk:system_ability_fwk",
122    "samgr:samgr_proxy",
123  ]
124
125  defines = [ "private=public" ]
126
127  use_exceptions = true
128}
129
130ohos_unittest("network_status_test") {
131  module_out_path = "dfs_service/dfs_service"
132  sources = [
133    "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/data_sync_manager.cpp",
134    "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/net_conn_callback_observer.cpp",
135    "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/network_status.cpp",
136    "${distributedfile_path}/test/mock/net_conn_client_mock.cpp",
137    "network_status_test.cpp",
138  ]
139
140  include_dirs = [
141    "${distributedfile_path}/interfaces/inner_api/native/cloud_file_kit_inner",
142    "${distributedfile_path}/test/mock/",
143    "${innerkits_native_path}/cloud_file_kit_inner",
144    "${services_path}/cloudsyncservice/include",
145    "${services_path}/cloudsyncservice/include/sync_rule",
146    "${utils_path}/log/include",
147    "${innerkits_native_path}/cloudsync_kit_inner",
148    "${distributedfile_path}/adapter/cloud_adapter_example/include",
149  ]
150
151  deps = [
152    "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
153    "${utils_path}:libdistributedfileutils",
154  ]
155
156  external_deps = [
157    "access_token:libaccesstoken_sdk",
158    "access_token:libtokenid_sdk",
159    "c_utils:utils",
160    "common_event_service:cesfwk_innerkits",
161    "data_share:datashare_consumer",
162    "dfs_service:cloudsync_kit_inner",
163    "googletest:gmock_main",
164    "googletest:gtest_main",
165    "hilog:libhilog",
166    "hisysevent:libhisysevent",
167    "image_framework:image_native",
168    "init:libbegetutil",
169    "ipc:ipc_core",
170    "netmanager_base:net_conn_manager_if",
171    "relational_store:native_rdb",
172    "samgr:samgr_proxy",
173  ]
174
175  defines = [ "private=public" ]
176  if (cloudsync_service_resource_schedule) {
177    external_deps += [ "resource_schedule_service:ressched_client" ]
178    defines += [ "CLOUDSYNC_SERVICE_RESOURCE_SCHEDULE" ]
179  }
180  use_exceptions = true
181}
182
183ohos_unittest("cloud_status_test") {
184  module_out_path = "dfs_service/dfs_service"
185  sources = [
186    "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/cloud_status.cpp",
187    "${distributedfile_path}/test/mock/cloud_file_kit_mock.cpp",
188    "${distributedfile_path}/test/unittests/cloudsync_sa/mock/datashare_helper.cpp",
189    "${distributedfile_path}/utils/log/src/dfs_error.cpp",
190    "cloud_status_test.cpp",
191  ]
192
193  include_dirs = [
194    "${distributedfile_path}/interfaces/inner_api/native/cloud_file_kit_inner",
195    "${services_path}/cloudsyncservice/include",
196    "${distributedfile_path}/adapter/cloud_adapter_example/include",
197    "${distributedfile_path}/test/mock",
198    "${distributedfile_path}/test/unittests/cloudsync_sa/mock",
199  ]
200
201  deps = [
202    "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
203    "${innerkits_native_path}/cloudsync_kit_inner:cloudsync_kit_inner",
204    "${services_path}/cloudsyncservice:cloudsync_sa_static",
205    "${utils_path}:libdistributedfileutils",
206  ]
207
208  external_deps = [
209    "ability_base:zuri",
210    "c_utils:utils",
211    "googletest:gmock_main",
212    "googletest:gtest_main",
213    "hilog:libhilog",
214    "hisysevent:libhisysevent",
215    "ipc:ipc_core",
216  ]
217
218  defines = [ "private=public" ]
219  if (dfs_service_feature_enable_cloud_adapter) {
220    defines += [ "CLOUD_ADAPTER_ENABLED" ]
221  }
222
223  use_exceptions = true
224}
225
226ohos_unittest("battery_status_test") {
227  branch_protector_ret = "pac_ret"
228  sanitize = {
229    ubsan = true
230    boundary_sanitize = true
231    cfi = true
232    cfi_cross_dso = true
233    debug = true
234    blocklist = "${distributedfile_path}/cfi_blocklist.txt"
235  }
236  module_out_path = "dfs_service/dfs_service"
237  sources = [
238    "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/battery_status.cpp",
239    "${distributedfile_path}/test/mock/battersrvclient_mock.cpp",
240    "battery_status_test.cpp",
241  ]
242
243  include_dirs = [
244    "${services_path}/cloudsyncservice/include",
245    "${services_path}/cloudsyncservice/include/sync_rule",
246    "${innerkits_native_path}/cloudsync_kit_inner",
247    "${distributedfile_path}/adapter/cloud_adapter_example/include",
248    "${distributedfile_path}/interfaces/inner_api/native/cloud_file_kit_inner",
249    "${utils_path}/log/include",
250    "${distributedfile_path}/test/mock",
251  ]
252
253  deps = [
254    "${services_path}/cloudsyncservice:cloudsync_sa_static",
255    "${utils_path}:libdistributedfileutils",
256  ]
257
258  external_deps = [
259    "ability_base:want",
260    "c_utils:utils",
261    "common_event_service:cesfwk_innerkits",
262    "googletest:gmock_main",
263    "googletest:gtest_main",
264    "hilog:libhilog",
265    "hisysevent:libhisysevent",
266    "image_framework:image_native",
267    "init:libbegetutil",
268    "ipc:ipc_core",
269    "netmanager_base:net_conn_manager_if",
270    "power_manager:powermgr_client",
271    "relational_store:native_rdb",
272    "safwk:system_ability_fwk",
273    "samgr:samgr_proxy",
274  ]
275
276  defines = [
277    "private=public",
278    "LOG_DOMAIN=0xD004310",
279    "LOG_TAG=\"CLOUD_SYNC_TEST\"",
280  ]
281
282  if (cloudsync_service_power) {
283    external_deps += [ "battery_manager:batterysrv_client" ]
284
285    defines += [ "SUPPORT_POWER" ]
286  }
287
288  use_exceptions = true
289}
290
291ohos_unittest("network_set_manager_test") {
292  branch_protector_ret = "pac_ret"
293  sanitize = {
294    ubsan = true
295    boundary_sanitize = true
296    cfi = true
297    cfi_cross_dso = true
298    debug = true
299    blocklist = "${distributedfile_path}/cfi_blocklist.txt"
300  }
301
302  module_out_path = "dfs_service/dfs_service"
303  sources = [ "network_set_manager_test.cpp" ]
304
305  include_dirs = [
306    "${distributedfile_path}/interfaces/inner_api/native/cloud_file_kit_inner",
307    "${distributedfile_path}/test/unittests/cloudsync_sa/mock",
308    "${innerkits_native_path}/cloud_file_kit_inner",
309    "${innerkits_native_path}/cloudsync_kit_inner",
310    "${services_path}/cloudsyncservice/include",
311    "${services_path}/cloudsyncservice/include/sync_rule",
312    "${utils_path}/log/include",
313    "${distributedfile_path}/adapter/cloud_adapter_example/include",
314  ]
315
316  deps = [
317    "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
318    "${utils_path}:libdistributedfileutils",
319  ]
320
321  external_deps = [
322    "ability_base:zuri",
323    "ability_runtime:dataobs_manager",
324    "access_token:libtokenid_sdk",
325    "c_utils:utils",
326    "googletest:gmock_main",
327    "googletest:gtest_main",
328    "hilog:libhilog",
329    "hisysevent:libhisysevent",
330    "image_framework:image_native",
331    "init:libbegetutil",
332    "ipc:ipc_core",
333    "ipc:ipc_single",
334    "safwk:system_ability_fwk",
335    "samgr:samgr_proxy",
336  ]
337
338  defines = [ "private=public" ]
339  use_exceptions = true
340}
341
342ohos_unittest("system_load_test") {
343  module_out_path = "dfs_service/dfs_service"
344  sources = [
345    "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/system_load.cpp",
346    "system_load_test.cpp",
347  ]
348
349  include_dirs = [
350    "${distributedfile_path}/interfaces/inner_api/native/cloud_file_kit_inner",
351    "${innerkits_native_path}/cloud_file_kit_inner",
352    "${services_path}/cloudsyncservice/include",
353    "${services_path}/cloudsyncservice/include/sync_rule",
354    "${utils_path}/log/include",
355    "${innerkits_native_path}/cloudsync_kit_inner",
356    "${distributedfile_path}/adapter/cloud_adapter_example/include",
357  ]
358
359  deps = [
360    "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
361    "${utils_path}:libdistributedfileutils",
362  ]
363
364  external_deps = [
365    "access_token:libaccesstoken_sdk",
366    "access_token:libtokenid_sdk",
367    "c_utils:utils",
368    "common_event_service:cesfwk_innerkits",
369    "data_share:datashare_consumer",
370    "dfs_service:cloudsync_kit_inner",
371    "ffrt:libffrt",
372    "googletest:gmock_main",
373    "googletest:gtest_main",
374    "hilog:libhilog",
375    "hisysevent:libhisysevent",
376    "image_framework:image_native",
377    "init:libbegetutil",
378    "ipc:ipc_core",
379    "netmanager_base:net_conn_manager_if",
380    "relational_store:native_rdb",
381    "resource_schedule_service:ressched_client",
382    "samgr:samgr_proxy",
383  ]
384
385  defines = [ "private=public" ]
386  use_exceptions = true
387}
388
389ohos_unittest("screen_status_listener_test") {
390  branch_protector_ret = "pac_ret"
391  sanitize = {
392    ubsan = true
393    boundary_sanitize = true
394    cfi = true
395    cfi_cross_dso = true
396    debug = true
397    blocklist = "${distributedfile_path}/cfi_blocklist.txt"
398  }
399  module_out_path = "dfs_service/dfs_service"
400  sources = [
401    "${distributedfile_path}/services/cloudsyncservice/src/sync_rule/screen_status_listener.cpp",
402    "screen_status_listener_test.cpp",
403  ]
404
405  include_dirs = [
406    "${services_path}/cloudsyncservice/include",
407    "${services_path}/cloudsyncservice/include/sync_rule",
408    "${innerkits_native_path}/cloudsync_kit_inner",
409    "${distributedfile_path}/adapter/cloud_adapter_example/include",
410    "${utils_path}/log/include",
411  ]
412
413  deps = [
414    "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
415    "${services_path}/cloudsyncservice:cloudsync_sa_static",
416    "${utils_path}:libdistributedfileutils",
417  ]
418
419  external_deps = [
420    "ability_base:want",
421    "c_utils:utils",
422    "common_event_service:cesfwk_innerkits",
423    "googletest:gmock",
424    "googletest:gtest",
425    "hilog:libhilog",
426    "hisysevent:libhisysevent",
427    "init:libbegetutil",
428    "ipc:ipc_core",
429    "netmanager_base:net_conn_manager_if",
430    "relational_store:native_rdb",
431    "safwk:system_ability_fwk",
432    "samgr:samgr_proxy",
433  ]
434
435  defines = [
436    "private=public",
437    "LOG_DOMAIN=0xD004310",
438    "LOG_TAG=\"CLOUD_SYNC_TEST\"",
439  ]
440  if (cloudsync_service_resource_schedule) {
441    external_deps += [ "resource_schedule_service:ressched_client" ]
442    defines += [ "CLOUDSYNC_SERVICE_RESOURCE_SCHEDULE" ]
443  }
444  use_exceptions = true
445}
446
447ohos_unittest("user_status_listener_test") {
448  branch_protector_ret = "pac_ret"
449  sanitize = {
450    ubsan = true
451    boundary_sanitize = true
452    cfi = true
453    cfi_cross_dso = true
454    debug = true
455    blocklist = "${distributedfile_path}/cfi_blocklist.txt"
456  }
457  module_out_path = "dfs_service/dfs_service"
458  sources = [
459    "${distributedfile_path}/services/cloudsyncservice/src/sync_rule/user_status_listener.cpp",
460    "user_status_listener_test.cpp",
461  ]
462
463  include_dirs = [
464    "${services_path}/cloudsyncservice/include",
465    "${services_path}/cloudsyncservice/include/sync_rule",
466    "${services_path}/cloudsyncservice/include/transport/softbus",
467    "${innerkits_native_path}/cloudsync_kit_inner",
468    "${distributedfile_path}/adapter/cloud_adapter_example/include",
469    "${utils_path}/log/include",
470  ]
471
472  deps = [
473    "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
474    "${services_path}/cloudsyncservice:cloudsync_sa_static",
475    "${utils_path}:libdistributedfileutils",
476  ]
477
478  external_deps = [
479    "ability_base:want",
480    "c_utils:utils",
481    "common_event_service:cesfwk_innerkits",
482    "dsoftbus:softbus_client",
483    "ffrt:libffrt",
484    "googletest:gmock",
485    "googletest:gtest",
486    "hilog:libhilog",
487    "hisysevent:libhisysevent",
488    "init:libbegetutil",
489    "ipc:ipc_core",
490    "netmanager_base:net_conn_manager_if",
491    "relational_store:native_rdb",
492    "safwk:system_ability_fwk",
493    "samgr:samgr_proxy",
494  ]
495
496  defines = [
497    "private=public",
498    "LOG_DOMAIN=0xD004310",
499    "LOG_TAG=\"CLOUD_SYNC_TEST\"",
500  ]
501  if (cloudsync_service_resource_schedule) {
502    external_deps += [ "resource_schedule_service:ressched_client" ]
503    defines += [ "CLOUDSYNC_SERVICE_RESOURCE_SCHEDULE" ]
504  }
505  use_exceptions = true
506}
507
508ohos_unittest("package_status_listener_test") {
509  branch_protector_ret = "pac_ret"
510  sanitize = {
511    ubsan = true
512    boundary_sanitize = true
513    cfi = true
514    cfi_cross_dso = true
515    debug = true
516    blocklist = "${distributedfile_path}/cfi_blocklist.txt"
517  }
518  module_out_path = "dfs_service/dfs_service"
519  sources = [
520    "${distributedfile_path}/services/cloudsyncservice/src/sync_rule/package_status_listener.cpp",
521    "package_status_listener_test.cpp",
522  ]
523
524  include_dirs = [
525    "${services_path}/cloudsyncservice/include",
526    "${services_path}/cloudsyncservice/include/sync_rule",
527    "${innerkits_native_path}/cloudsync_kit_inner",
528    "${distributedfile_path}/adapter/cloud_adapter_example/include",
529    "${services_path}/cloudsyncservice/include/sync_rule",
530    "${utils_path}/log/include",
531  ]
532
533  deps = [
534    "${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
535    "${services_path}/cloudsyncservice:cloudsync_sa_static",
536    "${utils_path}:libdistributedfileutils",
537  ]
538
539  external_deps = [
540    "ability_base:want",
541    "c_utils:utils",
542    "common_event_service:cesfwk_innerkits",
543    "googletest:gmock",
544    "googletest:gtest",
545    "hilog:libhilog",
546    "hisysevent:libhisysevent",
547    "init:libbegetutil",
548    "ipc:ipc_core",
549    "netmanager_base:net_conn_manager_if",
550    "relational_store:native_rdb",
551    "safwk:system_ability_fwk",
552    "samgr:samgr_proxy",
553  ]
554
555  defines = [
556    "private=public",
557    "LOG_DOMAIN=0xD004310",
558    "LOG_TAG=\"CLOUD_SYNC_TEST\"",
559  ]
560  if (cloudsync_service_resource_schedule) {
561    external_deps += [ "resource_schedule_service:ressched_client" ]
562    defines += [ "CLOUDSYNC_SERVICE_RESOURCE_SCHEDULE" ]
563  }
564  use_exceptions = true
565}
566
567ohos_unittest("settings_data_manager_test") {
568  branch_protector_ret = "pac_ret"
569  sanitize = {
570    ubsan = true
571    boundary_sanitize = true
572    cfi = true
573    cfi_cross_dso = true
574    debug = true
575    blocklist = "${distributedfile_path}/cfi_blocklist.txt"
576  }
577
578  module_out_path = "dfs_service/dfs_service"
579  sources = [
580    "settings_data_manager_test.cpp",
581    "${distributedfile_path}/frameworks/native/cloud_file_kit_inner/src/sync_rule/settings_data_manager.cpp",
582    "${distributedfile_path}/test/unittests/cloudsync_sa/mock/data_ability_observer_stub.cpp",
583    "${distributedfile_path}/test/unittests/cloudsync_sa/mock/datashare_helper.cpp",
584    "${distributedfile_path}/test/unittests/cloudsync_sa/mock/datashare_result_set.cpp",
585  ]
586
587  include_dirs = [
588    "${distributedfile_path}/interfaces/inner_api/native/cloud_file_kit_inner",
589    "${distributedfile_path}/test/unittests/cloudsync_sa/mock",
590    "${utils_path}/log/include",
591  ]
592
593  deps = [
594    "${utils_path}:libdistributedfileutils",
595  ]
596
597  external_deps = [
598    "ability_base:zuri",
599    "ability_runtime:dataobs_manager",
600    "c_utils:utils",
601    "googletest:gmock_main",
602    "googletest:gtest_main",
603    "hilog:libhilog",
604    "ipc:ipc_core",
605    "ipc:ipc_single",
606  ]
607
608  defines = [ "private=public" ]
609  use_exceptions = true
610}
611
612group("cloudsync_sa_sync_rule_test") {
613  testonly = true
614  deps = [
615    ":battery_status_listener_test",
616    ":battery_status_test",
617    ":cloud_status_test",
618    ":net_conn_callback_observer_test",
619    ":network_set_manager_test",
620    ":network_status_test",
621    ":package_status_listener_test",
622    ":screen_status_listener_test",
623    ":settings_data_manager_test",
624    ":system_load_test",
625    ":user_status_listener_test",
626  ]
627}
628