1# Copyright (c) 2021-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("./../../../usbmgr.gni")
16
17declare_args() {
18  usb_manage_feature_support_port_change = false
19}
20
21module_output_path = "${usb_manager_part_name}/usb_unittest_test"
22
23config("module_private_config") {
24  visibility = [ ":*" ]
25
26  include_dirs = [
27    "include",
28    "${usb_manager_path}/test/common/include/",
29  ]
30}
31
32ohos_unittest("test_usbdevicepipe") {
33  module_out_path = module_output_path
34  sources = [
35    "src/usb_common_test.cpp",
36    "src/usb_device_pipe_test.cpp",
37  ]
38
39  configs = [
40    "${utils_path}:utils_config",
41    ":module_private_config",
42  ]
43
44  deps = [
45    "${usb_manager_path}/interfaces/innerkits:usbsrv_client",
46    "${usb_manager_path}/services:usbservice",
47    "//third_party/googletest:gtest_main",
48  ]
49
50  external_deps = [
51    "ability_base:want",
52    "access_token:libaccesstoken_sdk",
53    "access_token:libnativetoken",
54    "access_token:libtoken_setproc",
55    "bundle_framework:appexecfwk_base",
56    "c_utils:utils",
57    "common_event_service:cesfwk_innerkits",
58    "drivers_interface_usb:libusb_proxy_1.0",
59    "eventhandler:libeventhandler",
60    "hilog:libhilog",
61    "ipc:ipc_core",
62    "safwk:system_ability_fwk",
63    "samgr:samgr_proxy",
64  ]
65}
66
67ohos_unittest("test_bulkcallback") {
68  module_out_path = module_output_path
69  sources = [
70    "${usb_manager_path}/test/common/src/usb_callback_test.cpp",
71    "src/usb_bulkcallback_test.cpp",
72    "src/usb_common_test.cpp",
73  ]
74
75  configs = [
76    "${utils_path}:utils_config",
77    ":module_private_config",
78  ]
79
80  deps = [
81    "${usb_manager_path}/interfaces/innerkits:usbsrv_client",
82    "${usb_manager_path}/services:usbservice",
83    "//third_party/googletest:gtest_main",
84  ]
85
86  external_deps = [
87    "ability_base:want",
88    "access_token:libaccesstoken_sdk",
89    "access_token:libnativetoken",
90    "access_token:libtoken_setproc",
91    "bundle_framework:appexecfwk_base",
92    "c_utils:utils",
93    "common_event_service:cesfwk_innerkits",
94    "drivers_interface_usb:libusb_proxy_1.0",
95    "eventhandler:libeventhandler",
96    "hilog:libhilog",
97    "ipc:ipc_core",
98    "safwk:system_ability_fwk",
99    "samgr:samgr_proxy",
100  ]
101}
102
103ohos_unittest("test_usbrequest") {
104  module_out_path = module_output_path
105  sources = [
106    "src/usb_common_test.cpp",
107    "src/usb_request_test.cpp",
108  ]
109
110  configs = [
111    "${utils_path}:utils_config",
112    ":module_private_config",
113  ]
114
115  deps = [
116    "${usb_manager_path}/interfaces/innerkits:usbsrv_client",
117    "${usb_manager_path}/services:usbservice",
118    "//third_party/googletest:gtest_main",
119  ]
120
121  external_deps = [
122    "ability_base:want",
123    "access_token:libaccesstoken_sdk",
124    "access_token:libnativetoken",
125    "access_token:libtoken_setproc",
126    "bundle_framework:appexecfwk_base",
127    "c_utils:utils",
128    "common_event_service:cesfwk_innerkits",
129    "drivers_interface_usb:libusb_proxy_1.0",
130    "eventhandler:libeventhandler",
131    "hilog:libhilog",
132    "ipc:ipc_core",
133    "safwk:system_ability_fwk",
134    "samgr:samgr_proxy",
135  ]
136}
137
138ohos_unittest("test_usbcore") {
139  module_out_path = module_output_path
140  sources = [
141    "src/usb_common_test.cpp",
142    "src/usb_core_test.cpp",
143  ]
144
145  configs = [
146    "${utils_path}:utils_config",
147    ":module_private_config",
148  ]
149
150  deps = [
151    "${usb_manager_path}/interfaces/innerkits:usbsrv_client",
152    "${usb_manager_path}/services:usbservice",
153    "//third_party/googletest:gtest_main",
154  ]
155
156  external_deps = [
157    "ability_base:want",
158    "access_token:libaccesstoken_sdk",
159    "access_token:libnativetoken",
160    "access_token:libtoken_setproc",
161    "bundle_framework:appexecfwk_base",
162    "c_utils:utils",
163    "common_event_service:cesfwk_innerkits",
164    "drivers_interface_usb:libusb_proxy_1.0",
165    "eventhandler:libeventhandler",
166    "hilog:libhilog",
167    "ipc:ipc_core",
168    "safwk:system_ability_fwk",
169    "samgr:samgr_proxy",
170  ]
171}
172
173ohos_unittest("test_usbevent") {
174  module_out_path = module_output_path
175  sources = [ "src/usb_event_test.cpp" ]
176
177  configs = [
178    "${utils_path}:utils_config",
179    ":module_private_config",
180  ]
181
182  deps = [
183    "${usb_manager_path}/interfaces/innerkits:usbsrv_client",
184    "${usb_manager_path}/services:usbservice",
185    "//third_party/cJSON:cjson",
186    "//third_party/googletest:gtest_main",
187  ]
188
189  external_deps = [
190    "ability_base:want",
191    "bundle_framework:appexecfwk_base",
192    "c_utils:utils",
193    "common_event_service:cesfwk_innerkits",
194    "drivers_interface_usb:libusb_proxy_1.0",
195    "eventhandler:libeventhandler",
196    "hilog:libhilog",
197    "ipc:ipc_core",
198    "safwk:system_ability_fwk",
199    "samgr:samgr_proxy",
200  ]
201
202  if (usb_manage_feature_support_port_change) {
203    if (defined(defines)) {
204      defines += [ "SUPPORT_PORT_CHNAGE_TEST" ]
205    } else {
206      defines = [ "SUPPORT_PORT_CHNAGE_TEST" ]
207    }
208  }
209}
210
211ohos_unittest("test_usbmanageinterface") {
212  module_out_path = module_output_path
213  sources = [
214    "src/usb_common_test.cpp",
215    "src/usb_manage_interface_test.cpp",
216  ]
217
218  configs = [
219    "${utils_path}:utils_config",
220    ":module_private_config",
221  ]
222
223  deps = [
224    "${usb_manager_path}/interfaces/innerkits:usbsrv_client",
225    "${usb_manager_path}/services:usbservice",
226    "//third_party/googletest:gtest_main",
227  ]
228
229  external_deps = [
230    "ability_base:want",
231    "access_token:libaccesstoken_sdk",
232    "access_token:libnativetoken",
233    "access_token:libtoken_setproc",
234    "bundle_framework:appexecfwk_base",
235    "c_utils:utils",
236    "common_event_service:cesfwk_innerkits",
237    "drivers_interface_usb:libusb_proxy_1.0",
238    "eventhandler:libeventhandler",
239    "hilog:libhilog",
240    "ipc:ipc_core",
241    "safwk:system_ability_fwk",
242    "samgr:samgr_proxy",
243  ]
244}
245
246ohos_unittest("test_usbdevicestatus") {
247  module_out_path = module_output_path
248  sources = [
249    "src/usb_common_test.cpp",
250    "src/usb_device_status_test.cpp",
251  ]
252
253  configs = [
254    "${utils_path}:utils_config",
255    ":module_private_config",
256  ]
257
258  deps = [
259    "${usb_manager_path}/interfaces/innerkits:usbsrv_client",
260    "${usb_manager_path}/services:usbservice",
261    "//third_party/googletest:gtest_main",
262  ]
263
264  external_deps = [
265    "ability_base:want",
266    "access_token:libaccesstoken_sdk",
267    "access_token:libnativetoken",
268    "access_token:libtoken_setproc",
269    "bundle_framework:appexecfwk_base",
270    "c_utils:utils",
271    "common_event_service:cesfwk_innerkits",
272    "drivers_interface_usb:libusb_proxy_1.1",
273    "eventhandler:libeventhandler",
274    "hilog:libhilog",
275    "ipc:ipc_core",
276    "safwk:system_ability_fwk",
277    "samgr:samgr_proxy",
278  ]
279}
280
281ohos_unittest("test_usbdfx") {
282  module_out_path = module_output_path
283  sources = [
284    "src/usb_common_test.cpp",
285    "src/usb_dfx_test.cpp",
286  ]
287
288  configs = [
289    "${utils_path}:utils_config",
290    ":module_private_config",
291  ]
292
293  deps = [
294    "${usb_manager_path}/interfaces/innerkits:usbsrv_client",
295    "${usb_manager_path}/services:usbservice",
296    "//third_party/cJSON:cjson",
297    "//third_party/googletest:gtest_main",
298  ]
299
300  external_deps = [
301    "ability_base:want",
302    "access_token:libaccesstoken_sdk",
303    "access_token:libnativetoken",
304    "access_token:libtoken_setproc",
305    "bundle_framework:appexecfwk_base",
306    "c_utils:utils",
307    "common_event_service:cesfwk_innerkits",
308    "drivers_interface_usb:libusb_proxy_1.0",
309    "eventhandler:libeventhandler",
310    "hilog:libhilog",
311    "ipc:ipc_core",
312    "safwk:system_ability_fwk",
313    "samgr:samgr_proxy",
314  ]
315}
316
317group("unittest") {
318  testonly = true
319  deps = [
320    ":test_bulkcallback",
321    ":test_usbcore",
322    ":test_usbdevicepipe",
323    ":test_usbdevicestatus",
324    ":test_usbdfx",
325    ":test_usbevent",
326    ":test_usbmanageinterface",
327    ":test_usbrequest",
328  ]
329}
330