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