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.
13
14import("//build/test.gni")
15import("../../../nfc.gni")
16
17config("nfc_service_unit_test_config") {
18  visibility = [ ":*" ]
19
20  include_dirs = [
21    "$NFC_DIR/interfaces/inner_api/cardEmulation",
22    "$NFC_DIR/interfaces/inner_api/common",
23    "$NFC_DIR/interfaces/inner_api/controller",
24    "$NFC_DIR/interfaces/inner_api/tags",
25    "$NFC_DIR/services/include",
26    "$NFC_DIR/services/src/nci_adapter/nci_native_default/include",
27    "$NFC_DIR/services/src",
28    "$NFC_DIR/services/src/external_deps",
29    "$NFC_DIR/services/src/tag",
30  ]
31
32  defines = []
33  if (nfc_service_feature_vendor_applications_enabled) {
34    defines += [ "VENDOR_APPLICATIONS_ENABLED" ]
35  }
36  cflags_cc = []
37  ldflags = []
38  libs = []
39}
40
41unit_test_deps = [
42  "$NFC_DIR/interfaces/inner_api/cardEmulation:nfc_inner_kits_card_emulation",
43  "$NFC_DIR/interfaces/inner_api/common:nfc_inner_kits_common",
44  "$NFC_DIR/interfaces/inner_api/controller:nfc_inner_kits_controller",
45  "$NFC_DIR/interfaces/inner_api/tags:nfc_inner_kits_tags",
46  "$NFC_DIR/services:nfc_service_static",
47  "//third_party/googletest:gtest_main",
48]
49
50unit_test_external_deps = [
51  "ability_base:want",
52  "ability_base:zuri",
53  "ability_runtime:ability_manager",
54  "ability_runtime:app_manager",
55  "ability_runtime:dataobs_manager",
56  "access_token:libaccesstoken_sdk",
57  "bluetooth:btframework",
58  "bundle_framework:appexecfwk_core",
59  "c_utils:utils",
60  "common_event_service:cesfwk_innerkits",
61  "data_share:datashare_consumer",
62  "hilog:libhilog",
63  "ipc:ipc_core",
64  "safwk:system_ability_fwk",
65  "samgr:samgr_proxy",
66  "wifi:wifi_sdk",
67]
68
69ohos_unittest("controller_test") {
70  module_out_path = "nfc/services"
71
72  sources = [
73    "controller_test/app_data_parser_test.cpp",
74    "controller_test/external_deps_proxy_test.cpp",
75    "controller_test/ndef_msg_callback_stub_test.cpp",
76    "controller_test/nfc_ability_connection_callback_test.cpp",
77    "controller_test/nfc_controller_callback_stub_test.cpp",
78    "controller_test/nfc_controller_death_recipient_test.cpp",
79    "controller_test/nfc_controller_impl_test.cpp",
80    "controller_test/nfc_controller_test.cpp",
81    "controller_test/nfc_preferences_test.cpp",
82    "controller_test/query_app_info_callback_stub_test.cpp",
83    "controller_test/reader_mode_callback_stub_test.cpp",
84    "controller_test/tag_ability_dispatcher_test.cpp",
85  ]
86
87  configs = [ ":nfc_service_unit_test_config" ]
88
89  deps = unit_test_deps
90
91  external_deps = unit_test_external_deps
92
93  part_name = "nfc"
94  subsystem_name = "communication"
95}
96
97ohos_unittest("cardemulation_test") {
98  module_out_path = "nfc/services"
99
100  sources = [ "cardemulation_test/cardemulation_test.cpp" ]
101
102  configs = [ ":nfc_service_unit_test_config" ]
103
104  deps = unit_test_deps
105
106  external_deps = unit_test_external_deps
107
108  part_name = "nfc"
109  subsystem_name = "communication"
110}
111
112ohos_unittest("ce_service_test") {
113  module_out_path = "nfc/services"
114
115  sources = [ "ce_service_test/ce_service_test.cpp" ]
116
117  configs = [ ":nfc_service_unit_test_config" ]
118
119  deps = unit_test_deps
120
121  external_deps = unit_test_external_deps
122
123  part_name = "nfc"
124  subsystem_name = "communication"
125}
126
127ohos_unittest("hce_cmd_callback_stub_test") {
128  module_out_path = "nfc/services"
129
130  sources = [ "hce_cmd_callback_stub_test/hce_cmd_callback_stub_test.cpp" ]
131
132  configs = [ ":nfc_service_unit_test_config" ]
133
134  deps = unit_test_deps
135
136  external_deps = unit_test_external_deps
137
138  part_name = "nfc"
139  subsystem_name = "communication"
140}
141
142ohos_unittest("hce_service_test") {
143  module_out_path = "nfc/services"
144
145  sources = [ "hce_service_test/hce_service_test.cpp" ]
146
147  configs = [ ":nfc_service_unit_test_config" ]
148
149  deps = unit_test_deps
150
151  external_deps = unit_test_external_deps
152
153  part_name = "nfc"
154  subsystem_name = "communication"
155}
156
157ohos_unittest("hce_session_test") {
158  module_out_path = "nfc/services"
159
160  sources = [ "hce_session_test/hce_session_test.cpp" ]
161
162  configs = [ ":nfc_service_unit_test_config" ]
163
164  deps = unit_test_deps
165
166  external_deps = unit_test_external_deps
167
168  part_name = "nfc"
169  subsystem_name = "communication"
170}
171
172ohos_unittest("host_card_emulation_manager_test") {
173  module_out_path = "nfc/services"
174
175  sources = [
176    "host_card_emulation_manager_test/host_card_emulation_manager_test.cpp",
177  ]
178
179  configs = [ ":nfc_service_unit_test_config" ]
180
181  deps = unit_test_deps
182
183  external_deps = unit_test_external_deps
184
185  part_name = "nfc"
186  subsystem_name = "communication"
187}
188
189ohos_unittest("isodep_card_handler_test") {
190  module_out_path = "nfc/services"
191
192  sources = [ "isodep_card_handler_test/isodep_card_handler_test.cpp" ]
193
194  configs = [ ":nfc_service_unit_test_config" ]
195
196  deps = unit_test_deps
197
198  external_deps = unit_test_external_deps
199
200  part_name = "nfc"
201  subsystem_name = "communication"
202}
203
204ohos_unittest("nci_ce_proxy_test") {
205  module_out_path = "nfc/services"
206
207  sources = [ "nci_ce_proxy_test/nci_ce_proxy_test.cpp" ]
208
209  configs = [ ":nfc_service_unit_test_config" ]
210
211  deps = unit_test_deps
212
213  external_deps = unit_test_external_deps
214
215  part_name = "nfc"
216  subsystem_name = "communication"
217}
218
219ohos_unittest("nci_nfcc_proxy_test") {
220  module_out_path = "nfc/services"
221
222  sources = [ "nci_nfcc_proxy_test/nci_nfcc_proxy_test.cpp" ]
223
224  configs = [ ":nfc_service_unit_test_config" ]
225
226  deps = unit_test_deps
227
228  external_deps = unit_test_external_deps
229
230  part_name = "nfc"
231  subsystem_name = "communication"
232}
233
234ohos_unittest("nci_tag_proxy_test") {
235  module_out_path = "nfc/services"
236
237  sources = [ "nci_tag_proxy_test/nci_tag_proxy_test.cpp" ]
238
239  configs = [ ":nfc_service_unit_test_config" ]
240
241  deps = unit_test_deps
242
243  external_deps = unit_test_external_deps
244
245  part_name = "nfc"
246  subsystem_name = "communication"
247}
248
249ohos_unittest("tags_test") {
250  module_out_path = "nfc/services"
251
252  sources = [
253    "tags_test/foreground_callback_stub_test.cpp",
254    "tags_test/iso15693_tag_test.cpp",
255    "tags_test/isodep_tag_test.cpp",
256    "tags_test/mifare_classic_tag_test.cpp",
257    "tags_test/mifare_ultralight_tag_test.cpp",
258    "tags_test/ndef_formatable_tag_test.cpp",
259    "tags_test/ndef_har_data_parser_test.cpp",
260    "tags_test/ndef_har_dispatch_test.cpp",
261    "tags_test/ndef_message_test.cpp",
262    "tags_test/ndef_tag_test.cpp",
263    "tags_test/nfca_tag_test.cpp",
264    "tags_test/nfcb_tag_test.cpp",
265    "tags_test/nfcf_tag_test.cpp",
266    "tags_test/tag_foreground_test.cpp",
267    "tags_test/tag_info_test.cpp",
268    "tags_test/taginfo_parcelable_test.cpp",
269  ]
270
271  configs = [ ":nfc_service_unit_test_config" ]
272
273  deps = unit_test_deps
274
275  external_deps = unit_test_external_deps
276
277  part_name = "nfc"
278  subsystem_name = "communication"
279}
280
281ohos_unittest("public_test") {
282  module_out_path = "nfc/services"
283
284  sources = [ "public_test/nfc_public_test.cpp" ]
285
286  configs = [ ":nfc_service_unit_test_config" ]
287
288  deps = unit_test_deps
289
290  external_deps = unit_test_external_deps
291
292  part_name = "nfc"
293  subsystem_name = "communication"
294}
295
296ohos_unittest("services_test") {
297  module_out_path = "nfc/services"
298
299  sources = [
300    "services_test/app_data_parser_test.cpp",
301    "services_test/ndef_bt_data_parser_test.cpp",
302    "services_test/ndef_wifi_data_parser_test.cpp",
303    "services_test/nfc_event_handler_test.cpp",
304    "services_test/nfc_polling_manager_test.cpp",
305    "services_test/nfc_polling_params_test.cpp",
306  ]
307
308  configs = [ ":nfc_service_unit_test_config" ]
309
310  deps = unit_test_deps
311
312  external_deps = unit_test_external_deps
313
314  part_name = "nfc"
315  subsystem_name = "communication"
316}
317
318ohos_unittest("services_tags_test") {
319  module_out_path = "nfc/services"
320
321  sources = [
322    "services_tags_test/bt_connection_manager_test.cpp",
323    "services_tags_test/nfc_service_tdd.cpp",
324    "services_tags_test/tag_dispatcher_test.cpp",
325    "services_tags_test/tag_session_stub_test.cpp",
326    "services_tags_test/tag_session_test.cpp",
327    "services_tags_test/wifi_connection_manager_test.cpp",
328  ]
329
330  configs = [ ":nfc_service_unit_test_config" ]
331
332  deps = unit_test_deps
333
334  external_deps = unit_test_external_deps
335
336  part_name = "nfc"
337  subsystem_name = "communication"
338}
339
340ohos_unittest("nci_adapter_test") {
341  module_out_path = "nfc/services"
342  configs = [ ":nfc_service_unit_test_config" ]
343  cflags_cc = [ "-DNXP_EXTNS=TRUE" ]
344
345  sources = [
346    "nci_adapter_test/nfcc_nci_adapter_test.cpp",
347    "nci_adapter_test/tag_host_test.cpp",
348    "nci_adapter_test/tag_nci_adapter_test.cpp",
349  ]
350
351  deps = unit_test_deps
352  if (!nfc_use_vendor_nci_native) {
353    deps += [
354      "$NFC_DIR/services/src/nci_adapter/nci_native_default:nci_native_default",
355    ]
356  }
357  external_deps = unit_test_external_deps
358
359  part_name = "nfc"
360  subsystem_name = "communication"
361}
362
363ohos_unittest("service_ipc_test") {
364  module_out_path = "nfc/services"
365  configs = [ ":nfc_service_unit_test_config" ]
366  cflags_cc = [ "-DNXP_EXTNS=TRUE" ]
367
368  sources = [ "ipc_test/tag_session_test.cpp" ]
369
370  deps = unit_test_deps
371
372  external_deps = unit_test_external_deps
373
374  part_name = "nfc"
375  subsystem_name = "communication"
376}
377
378group("nfc_service_unittest") {
379  testonly = true
380  deps = [
381    ":cardemulation_test",
382    ":ce_service_test",
383    ":controller_test",
384    ":hce_cmd_callback_stub_test",
385    ":hce_service_test",
386    ":hce_session_test",
387    ":host_card_emulation_manager_test",
388    ":isodep_card_handler_test",
389    ":nci_ce_proxy_test",
390    ":nci_nfcc_proxy_test",
391    ":nci_tag_proxy_test",
392    ":public_test",
393    ":service_ipc_test",
394    ":services_tags_test",
395    ":services_test",
396    ":tags_test",
397  ]
398  if (!nfc_use_vendor_nci_native) {
399    deps += [ ":nci_adapter_test" ]
400  }
401}
402