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/test.gni")
14import("//foundation/distributeddatamgr/kv_store/kv_store.gni")
15
16module_output_path = "kv_store/distributeddatafwk"
17
18###############################################################################
19config("module_private_config") {
20  visibility = [ ":*" ]
21
22  include_dirs = [
23    "${kv_store_base_path}/frameworks/innerkitsimpl/distributeddatasvc/include",
24    "../../../../interfaces/innerkits/distributeddatamgr/include/",
25    "//commonlibrary/c_utils/base/include",
26    "//foundation/distributeddatamgr/kv_store/frameworks/common",
27    "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/kvdb/include",
28    "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/kvdb/src",
29    "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/distributeddatafwk/include",
30    "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/distributeddatafwk/src",
31    "//foundation/distributeddatamgr/kv_store/frameworks/innerkitsimpl/distributeddatafwk/test/distributedtest/single_kvstore_client",
32    "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/app_distributeddata/include",
33    "//foundation/distributeddatamgr/kv_store/interfaces/innerkits/distributeddata/include",
34    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/app/include",
35    "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp/include",
36    "//base/hiviewdfx/hitrace/interfaces/native/innerkits/include",
37    "//test/testfwk/developer_test/aw/distributed",
38  ]
39  lib_dirs = [ "//foundation/appexecfwk/libs" ]
40}
41
42###############################################################################
43ohos_source_set("kvdb_src_file") {
44  testonly = true
45
46  old_sources = [
47    "../../distributeddatafwk/src/blob.cpp",
48    "../../distributeddatafwk/src/change_notification.cpp",
49    "../../distributeddatafwk/src/data_query.cpp",
50    "../../distributeddatafwk/src/distributed_kv_data_manager.cpp",
51    "../../distributeddatafwk/src/ikvstore_client_death_observer.cpp",
52    "../../distributeddatafwk/src/ikvstore_observer.cpp",
53    "../../distributeddatafwk/src/kv_utils.cpp",
54    "../../distributeddatafwk/src/kvdb_notifier_client.cpp",
55    "../../distributeddatafwk/src/kvdb_notifier_stub.cpp",
56    "../../distributeddatafwk/src/kvstore_client_death_observer.cpp",
57    "../../distributeddatafwk/src/kvstore_datashare_bridge.cpp",
58    "../../distributeddatafwk/src/kvstore_observer_client.cpp",
59    "../../distributeddatafwk/src/kvstore_service_death_notifier.cpp",
60    "../../distributeddatafwk/src/sync_observer.cpp",
61  ]
62
63  kvdb_sources = [
64    "../src/backup_manager.cpp",
65    "../src/convertor.cpp",
66    "../src/dev_manager.cpp",
67    "../src/device_convertor.cpp",
68    "../src/kv_types_util.cpp",
69    "../src/kvdb_service_client.cpp",
70    "../src/observer_bridge.cpp",
71    "../src/security_manager.cpp",
72    "../src/single_store_impl.cpp",
73    "../src/store_factory.cpp",
74    "../src/store_manager.cpp",
75    "../src/store_result_set.cpp",
76    "../src/store_util.cpp",
77    "../src/system_api.cpp",
78    "../src/task_executor.cpp",
79    "../src/task_executor_adapter.cpp",
80  ]
81
82  sources = old_sources + kvdb_sources
83  if (qemu_disable) {
84    sources += [ "../src/auto_sync_timer.cpp" ]
85  } else {
86    sources += [ "../src/auto_sync_timer_mock.cpp" ]
87  }
88  configs = [ ":module_private_config" ]
89
90  deps = [
91    "../../../../databaseutils:database_utils",
92    "../../../../interfaces/innerkits/distributeddatamgr:distributeddata_mgr",
93    "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb:distributeddb",
94    "//foundation/distributedhardware/device_manager/interfaces/inner_kits/native_cpp:devicemanagersdk",
95  ]
96  external_deps = [
97    "access_token:libaccesstoken_sdk",
98    "access_token:libtokenid_sdk",
99    "c_utils:utils",
100    "file_api:securitylabel",
101    "hilog:libhilog",
102    "hisysevent:libhisysevent",
103    "hitrace:hitrace_meter",
104    "hitrace:libhitracechain",
105    "huks:libhukssdk",
106    "ipc:ipc_single",
107    "samgr:samgr_proxy",
108  ]
109  if (dms_service_enable && qemu_disable) {
110    external_deps += [ "dmsfwk:distributed_sdk" ]
111  }
112
113  public_external_deps = [
114    "data_share:datashare_common",
115    "data_share:datashare_provider",
116  ]
117
118  part_name = "kv_store"
119}
120
121ohos_unittest("SingleStoreImplTest") {
122  module_out_path = module_output_path
123
124  sources = [
125    "../../kvdb/src/kv_hiview_reporter_mock.cpp",
126    "single_store_impl_test.cpp",
127  ]
128
129  configs = [ ":module_private_config" ]
130
131  external_deps = [
132    "c_utils:utils",
133    "hilog:libhilog",
134    "ipc:ipc_single",
135    "safwk:system_ability_fwk",
136    "samgr:samgr_proxy",
137  ]
138
139  deps = [
140    ":kvdb_src_file",
141    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter",
142    "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/:distributeddb",
143    "//third_party/googletest:gtest",
144  ]
145}
146
147ohos_unittest("StoreUtilTest") {
148  module_out_path = module_output_path
149
150  sources = [
151    "../../kvdb/src/kv_hiview_reporter_mock.cpp",
152    "store_util_test.cpp",
153  ]
154
155  configs = [ ":module_private_config" ]
156
157  external_deps = [
158    "c_utils:utils",
159    "hilog:libhilog",
160    "ipc:ipc_single",
161    "safwk:system_ability_fwk",
162    "samgr:samgr_proxy",
163  ]
164
165  deps = [
166    ":kvdb_src_file",
167    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter",
168    "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/:distributeddb",
169    "//third_party/googletest:gtest",
170  ]
171}
172
173ohos_unittest("BackupManagerTest") {
174  module_out_path = module_output_path
175
176  sources = [
177    "../../kvdb/src/kv_hiview_reporter_mock.cpp",
178    "backup_manager_test.cpp",
179  ]
180
181  configs = [ ":module_private_config" ]
182
183  external_deps = [
184    "c_utils:utils",
185    "hilog:libhilog",
186    "ipc:ipc_single",
187    "safwk:system_ability_fwk",
188    "samgr:samgr_proxy",
189  ]
190
191  deps = [
192    ":kvdb_src_file",
193    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter",
194    "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/:distributeddb",
195    "//third_party/googletest:gtest",
196  ]
197}
198
199ohos_unittest("DevManagerTest") {
200  module_out_path = module_output_path
201
202  sources = [
203    "../../kvdb/src/kv_hiview_reporter_mock.cpp",
204    "dev_manager_test.cpp",
205  ]
206
207  configs = [ ":module_private_config" ]
208
209  external_deps = [
210    "c_utils:utils",
211    "hilog:libhilog",
212    "ipc:ipc_single",
213    "safwk:system_ability_fwk",
214    "samgr:samgr_proxy",
215  ]
216
217  deps = [
218    ":kvdb_src_file",
219    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter",
220    "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/:distributeddb",
221    "//third_party/googletest:gtest",
222  ]
223}
224
225ohos_unittest("SingleStoreImplGetTopTest") {
226  module_out_path = module_output_path
227
228  sources = [
229    "../../kvdb/src/kv_hiview_reporter_mock.cpp",
230    "single_store_impl_get_top_test.cpp",
231  ]
232
233  configs = [ ":module_private_config" ]
234
235  external_deps = [
236    "c_utils:utils",
237    "hilog:libhilog",
238    "ipc:ipc_single",
239    "safwk:system_ability_fwk",
240    "samgr:samgr_proxy",
241  ]
242
243  deps = [
244    ":kvdb_src_file",
245    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter",
246    "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/:distributeddb",
247    "//third_party/googletest:gtest",
248  ]
249}
250
251ohos_unittest("StoreFactoryTest") {
252  module_out_path = module_output_path
253
254  sources = [
255    "../../kvdb/src/kv_hiview_reporter_mock.cpp",
256    "store_factory_test.cpp",
257  ]
258
259  configs = [ ":module_private_config" ]
260
261  external_deps = [
262    "c_utils:utils",
263    "hilog:libhilog",
264    "ipc:ipc_single",
265    "safwk:system_ability_fwk",
266    "samgr:samgr_proxy",
267  ]
268
269  deps = [
270    ":kvdb_src_file",
271    "//foundation/distributeddatamgr/datamgr_service/services/distributeddataservice/adapter:distributeddata_adapter",
272    "//foundation/distributeddatamgr/kv_store/frameworks/libs/distributeddb/:distributeddb",
273    "//third_party/googletest:gtest",
274  ]
275}
276
277###############################################################################
278group("unittest") {
279  testonly = true
280
281  deps = []
282  deps += [
283    ":BackupManagerTest",
284    ":DevManagerTest",
285    ":SingleStoreImplGetTopTest",
286    ":SingleStoreImplTest",
287    ":StoreFactoryTest",
288    ":StoreUtilTest",
289  ]
290}
291###############################################################################
292