1# Copyright (c) 2022 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/ohos_var.gni")
14import("//build/test.gni")
15import("//foundation/distributeddatamgr/datamgr_service/datamgr_service.gni")
16
17module_output_path = "datamgr_service/distributeddatafwk"
18
19###############################################################################
20config("module_private_config") {
21  visibility = [ ":*" ]
22
23  include_dirs = [
24    "${device_manager_path}/interfaces/inner_kits/native_cpp/include",
25    "../include/",
26    "../../service/bootstrap/include/",
27    "../../service/common/",
28    "../../service/rdb/",
29    "../../../../../relational_store/interfaces/inner_api/rdb/include",
30    "../../../../../relational_store/interfaces/inner_api/common_type/include",
31    "${kv_store_distributeddb_path}/interfaces/include",
32    "${kv_store_distributeddb_path}/include",
33    "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include",
34    "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include",
35    "${kv_store_common_path}",
36    "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/src",
37    "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include",
38    "${kv_store_path}/interfaces/innerkits/distributeddata/include",
39    "${data_service_path}/adapter/include",
40    "${data_service_path}/framework/include",
41    "${data_service_path}/service/config/include",
42    "${data_service_path}/app/src",
43    "${data_service_path}/adapter/include/account",
44    "${data_service_path}/app/src/security",
45    "${data_service_path}/service/crypto/include",
46    "${data_service_path}/service/matrix/include",
47    "${data_service_path}/service/waterversion",
48    "//third_party/json/single_include",
49  ]
50  ldflags = [ "-Wl,--whole-archive" ]
51  defines = [ "OPENSSL_SUPPRESS_DEPRECATED" ]
52}
53
54ohos_unittest("CheckerManagerTest") {
55  module_out_path = module_output_path
56  sources = [ "checker_manager_test.cpp" ]
57
58  configs = [ ":module_private_config" ]
59
60  external_deps = [
61    "access_token:libaccesstoken_sdk",
62    "access_token:libnativetoken",
63    "c_utils:utils",
64    "hilog:libhilog",
65    "ipc:ipc_core",
66  ]
67
68  deps = [
69    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter",
70    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/src/checker:distributeddata_checker_static",
71    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework:distributeddatasvcfwk",
72    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/service:distributeddatasvc",
73    "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata:distributeddata_inner",
74    "//third_party/googletest:gtest_main",
75    "//third_party/openssl:libcrypto_shared",
76  ]
77}
78
79ohos_unittest("EventCenterTest") {
80  module_out_path = module_output_path
81  sources = [ "event_center_test.cpp" ]
82
83  configs = [ ":module_private_config" ]
84
85  external_deps = [
86    "c_utils:utils",
87    "hilog:libhilog",
88    "ipc:ipc_core",
89  ]
90
91  deps = [
92    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter",
93    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework:distributeddatasvcfwk",
94    "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata:distributeddata_inner",
95    "//third_party/googletest:gtest_main",
96  ]
97}
98
99ohos_unittest("SerializableTest") {
100  module_out_path = module_output_path
101
102  sources = [ "serializable_test.cpp" ]
103
104  configs = [ ":module_private_config" ]
105
106  external_deps = [
107    "ability_base:base",
108    "ability_base:want",
109    "c_utils:utils",
110    "hilog:libhilog",
111    "ipc:ipc_core",
112  ]
113
114  deps = [
115    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter",
116    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/framework:distributeddatasvcfwk",
117    "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata:distributeddata_inner",
118    "//third_party/googletest:gtest_main",
119    "//third_party/openssl:libcrypto_shared",
120  ]
121}
122
123ohos_unittest("ServiceUtilsTest") {
124  module_out_path = module_output_path
125
126  sources = [ "utils_test.cpp" ]
127
128  configs = [ ":module_private_config" ]
129
130  cflags = [
131    "-Dprivate=public",
132    "-Dprotected=public",
133  ]
134
135  external_deps = [
136    "access_token:libaccesstoken_sdk",
137    "access_token:libnativetoken",
138    "c_utils:utils",
139    "hilog:libhilog",
140    "ipc:ipc_core",
141  ]
142
143  deps = [
144    "${data_service_path}/framework:distributeddatasvcfwk",
145    "//third_party/googletest:gtest_main",
146  ]
147}
148
149ohos_unittest("StoreTest") {
150  module_out_path = module_output_path
151
152  include_dirs = [ "${data_service_path}/service/test/mock" ]
153
154  sources = [
155    "${data_service_path}/framework/metadata/store_meta_data.cpp",
156    "${data_service_path}/framework/store/auto_cache.cpp",
157    "${data_service_path}/service/rdb/rdb_query.cpp",
158    "${data_service_path}/service/test/mock/general_store_mock.cpp",
159    "store_test.cpp",
160  ]
161
162  configs = [ ":module_private_config" ]
163
164  cflags = [
165    "-Dprivate=public",
166    "-Dprotected=public",
167  ]
168
169  external_deps = [
170    "access_token:libaccesstoken_sdk",
171    "access_token:libnativetoken",
172    "c_utils:utils",
173    "hilog:libhilog",
174    "ipc:ipc_core",
175    "kv_store:distributeddata_inner",
176    "kv_store:distributeddb",
177    "relational_store:native_rdb",
178  ]
179
180  deps = [
181    "${data_service_path}/framework:distributeddatasvcfwk",
182    "${data_service_path}/service:distributeddatasvc",
183    "//third_party/googletest:gtest_main",
184  ]
185}
186
187ohos_unittest("AssetLoaderTest") {
188  module_out_path = module_output_path
189  sources = [ "asset_loader_test.cpp" ]
190  configs = [ ":module_private_config" ]
191  deps = [ "${data_service_path}/framework:distributeddatasvcfwk" ]
192}
193
194ohos_unittest("BackupRuleManagerTest") {
195  module_out_path = module_output_path
196  sources = [ "backup_rule_manager_test.cpp" ]
197  configs = [ ":module_private_config" ]
198  deps = [ "${data_service_path}/framework:distributeddatasvcfwk" ]
199}
200
201ohos_unittest("BindEventTest") {
202  module_out_path = module_output_path
203  sources = [ "bind_event_test.cpp" ]
204  configs = [ ":module_private_config" ]
205  deps = [ "${data_service_path}/framework:distributeddatasvcfwk" ]
206}
207
208ohos_unittest("CloudInfoTest") {
209  module_out_path = module_output_path
210  sources = [ "cloud_test.cpp" ]
211  configs = [ ":module_private_config" ]
212  deps = [ "${data_service_path}/framework:distributeddatasvcfwk" ]
213}
214
215ohos_unittest("ConstantTest") {
216  module_out_path = module_output_path
217  sources = [ "constant_test.cpp" ]
218  configs = [ ":module_private_config" ]
219  deps = [ "${data_service_path}/framework:distributeddatasvcfwk" ]
220}
221
222ohos_unittest("CryptoTest") {
223  module_out_path = module_output_path
224  sources = [ "crypto_test.cpp" ]
225  configs = [ ":module_private_config" ]
226  deps = [ "${data_service_path}/framework:distributeddatasvcfwk" ]
227}
228
229ohos_unittest("EventTest") {
230  module_out_path = module_output_path
231  sources = [ "event_test.cpp" ]
232  configs = [ ":module_private_config" ]
233  deps = [ "${data_service_path}/framework:distributeddatasvcfwk" ]
234}
235
236ohos_unittest("FeatureTest") {
237  module_out_path = module_output_path
238  sources = [ "feature_test.cpp" ]
239  configs = [ ":module_private_config" ]
240  deps = [
241    "${data_service_path}/framework:distributeddatasvcfwk",
242    "${kv_store_path}/interfaces/innerkits/distributeddata:distributeddata_inner",
243  ]
244}
245
246ohos_unittest("MetaDataManagerTest") {
247  module_out_path = module_output_path
248
249  sources = [ "meta_data_manager_test.cpp" ]
250
251  configs = [ ":module_private_config" ]
252
253  external_deps = [
254    "c_utils:utils",
255    "hilog:libhilog",
256    "ipc:ipc_core",
257  ]
258
259  deps = [
260    "${data_service_path}/framework:distributeddatasvcfwk",
261    "${data_service_path}/service:distributeddatasvc",
262    "//third_party/googletest:gtest_main",
263  ]
264}
265
266ohos_unittest("GeneralStoreTest") {
267  module_out_path = module_output_path
268  sources = [ "general_store_test.cpp" ]
269  configs = [ ":module_private_config" ]
270  deps = [ "${data_service_path}/framework:distributeddatasvcfwk" ]
271}
272
273ohos_unittest("SubscriptionTest") {
274  module_out_path = module_output_path
275  sources = [ "subscription_test.cpp" ]
276  configs = [ ":module_private_config" ]
277  deps = [ "${data_service_path}/framework:distributeddatasvcfwk" ]
278}
279
280ohos_unittest("StoreMetaDataLocalTest") {
281  module_out_path = module_output_path
282  sources = [ "store_meta_data_local_test.cpp" ]
283  configs = [ ":module_private_config" ]
284  deps = [ "${data_service_path}/framework:distributeddatasvcfwk" ]
285}
286
287ohos_unittest("ServiceMetaDataTest") {
288  module_out_path = module_output_path
289
290  sources = [
291    "${data_service_path}/app/src/kvstore_meta_manager.cpp",
292    "meta_data_test.cpp",
293  ]
294
295  sanitize = {
296    cfi = true
297    cfi_cross_dso = true
298    debug = false
299  }
300
301  configs = [ ":module_private_config" ]
302
303  include_dirs = [
304    "${device_manager_path}/interfaces/inner_kits/native_cpp/include",
305    "../include/",
306    "../../service/bootstrap/include/",
307    "../../service/common/",
308    "../../service/rdb/",
309    "../../../../../relational_store/interfaces/inner_api/rdb/include",
310    "../../../../../relational_store/interfaces/inner_api/common_type/include",
311    "${kv_store_distributeddb_path}/interfaces/include",
312    "${kv_store_distributeddb_path}/include",
313    "${kv_store_path}/frameworks/innerkitsimpl/distributeddatasvc/include",
314    "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/include",
315    "${kv_store_common_path}",
316    "${kv_store_path}/frameworks/innerkitsimpl/distributeddatafwk/src",
317    "${kv_store_path}/frameworks/innerkitsimpl/kvdb/include",
318    "${kv_store_path}/interfaces/innerkits/distributeddata/include",
319    "${data_service_path}/adapter/include",
320    "${data_service_path}/framework/include",
321    "${data_service_path}/service/config/include",
322    "${data_service_path}/app/src",
323    "${data_service_path}/adapter/include/account",
324    "${data_service_path}/app/src/security",
325    "${data_service_path}/service/crypto/include",
326    "${data_service_path}/service/matrix/include",
327    "${data_service_path}/service/waterversion",
328    "${data_service_path}/service/kvdb",
329    "//third_party/json/single_include",
330  ]
331
332  external_deps = [
333    "c_utils:utils",
334    "dataclassification:data_transit_mgr",
335    "device_auth:deviceauth_sdk",
336    "hilog:libhilog",
337    "hisysevent:libhisysevent",
338    "hitrace:hitrace_meter",
339    "hitrace:libhitracechain",
340    "ipc:ipc_core",
341    "kv_store:distributeddata_inner",
342    "kv_store:distributeddata_mgr",
343    "kv_store:distributeddb",
344    "safwk:system_ability_fwk",
345    "samgr:samgr_proxy",
346  ]
347
348  deps = [
349    "${data_service_path}/adapter:distributeddata_adapter",
350    "${data_service_path}/adapter/broadcaster:distributeddata_broadcaster_static",
351    "${data_service_path}/adapter/utils:distributeddata_utils_static",
352    "${data_service_path}/app/src/checker:distributeddata_checker_static",
353    "${data_service_path}/framework:distributeddatasvcfwk",
354    "${data_service_path}/service:distributeddatasvc",
355    "${kv_store_distributeddb_path}:distributeddb",
356    "${kv_store_path}/interfaces/innerkits/distributeddata:distributeddata_inner",
357    "${kv_store_path}/interfaces/innerkits/distributeddatamgr:distributeddata_mgr",
358    "//third_party/googletest:gtest_main",
359    "//third_party/openssl:libcrypto_shared",
360  ]
361}
362
363###############################################################################
364group("unittest") {
365  testonly = true
366
367  deps = []
368
369  deps += [
370    ":AssetLoaderTest",
371    ":BackupRuleManagerTest",
372    ":BindEventTest",
373    ":CheckerManagerTest",
374    ":CloudInfoTest",
375    ":ConstantTest",
376    ":CryptoTest",
377    ":EventCenterTest",
378    ":EventTest",
379    ":FeatureTest",
380    ":GeneralStoreTest",
381    ":MetaDataManagerTest",
382    ":SerializableTest",
383    ":ServiceMetaDataTest",
384    ":ServiceUtilsTest",
385    ":StoreMetaDataLocalTest",
386    ":StoreTest",
387    ":SubscriptionTest",
388  ]
389}
390###############################################################################
391