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("./../../../usbmgr.gni")
16
17module_output_path = "${usb_manager_part_name}/usb_unittest_test"
18
19config("module_private_config") {
20  visibility = [ ":*" ]
21  include_dirs = [
22    "include",
23    "//third_party/googletest/googlemock/include",
24    "${usb_manager_path}/interfaces/kits/js/napi/include",
25    "${usb_manager_path}/utils/native/include",
26    "${usb_manager_path}/test/common/include",
27    "${usb_manager_path}/test/native/mock/include",
28    "${usb_manager_path}/test/native/service_unittest/include",
29  ]
30}
31
32ohos_unittest("test_mock_bulkcallback") {
33  module_out_path = module_output_path
34  sources = [
35    "${usb_manager_path}/services/native/src/usb_service_subscriber.cpp",
36    "${usb_manager_path}/test/common/src/usb_callback_test.cpp",
37    "${usb_manager_path}/test/native/service_unittest/src/usb_common_test.cpp",
38    "src/usb_bulkcallback_mock_test.cpp",
39    "src/usb_impl_mock.cpp",
40  ]
41
42  configs = [
43    "${utils_path}:utils_config",
44    ":module_private_config",
45  ]
46
47  deps = [
48    "${usb_manager_path}/interfaces/innerkits:usbsrv_client",
49    "${usb_manager_path}/services:usbservice",
50    "//third_party/cJSON:cjson",
51    "//third_party/googletest:gmock_main",
52    "//third_party/googletest:gtest_main",
53  ]
54
55  external_deps = [
56    "ability_base:want",
57    "ability_runtime:ability_manager",
58    "access_token:libaccesstoken_sdk",
59    "access_token:libnativetoken",
60    "access_token:libtoken_setproc",
61    "bundle_framework:appexecfwk_base",
62    "bundle_framework:appexecfwk_core",
63    "c_utils:utils",
64    "common_event_service:cesfwk_innerkits",
65    "drivers_interface_usb:libusb_proxy_1.0",
66    "eventhandler:libeventhandler",
67    "hilog:libhilog",
68    "ipc:ipc_core",
69    "samgr:samgr_proxy",
70  ]
71}
72
73ohos_unittest("test_mock_usbcore") {
74  module_out_path = module_output_path
75  sources = [
76    "${usb_manager_path}/services/native/src/usb_service_subscriber.cpp",
77    "${usb_manager_path}/test/native/service_unittest/src/usb_common_test.cpp",
78    "src/usb_core_mock_test.cpp",
79    "src/usb_impl_mock.cpp",
80  ]
81
82  configs = [
83    "${utils_path}:utils_config",
84    ":module_private_config",
85  ]
86
87  deps = [
88    "${usb_manager_path}/interfaces/innerkits:usbsrv_client",
89    "${usb_manager_path}/services:usbservice",
90    "//third_party/cJSON:cjson",
91    "//third_party/googletest:gmock_main",
92    "//third_party/googletest:gtest_main",
93  ]
94
95  external_deps = [
96    "ability_base:want",
97    "ability_runtime:ability_manager",
98    "access_token:libaccesstoken_sdk",
99    "access_token:libnativetoken",
100    "access_token:libtoken_setproc",
101    "bundle_framework:appexecfwk_base",
102    "bundle_framework:appexecfwk_core",
103    "c_utils:utils",
104    "common_event_service:cesfwk_innerkits",
105    "drivers_interface_usb:libusb_proxy_1.0",
106    "eventhandler:libeventhandler",
107    "hilog:libhilog",
108    "ipc:ipc_core",
109    "samgr:samgr_proxy",
110  ]
111}
112
113ohos_unittest("test_mock_usbdevicepipe") {
114  module_out_path = module_output_path
115  sources = [
116    "${usb_manager_path}/services/native/src/usb_service_subscriber.cpp",
117    "${usb_manager_path}/test/native/service_unittest/src/usb_common_test.cpp",
118    "src/usb_device_pipe_mock_test.cpp",
119    "src/usb_impl_mock.cpp",
120  ]
121
122  configs = [
123    "${utils_path}:utils_config",
124    ":module_private_config",
125  ]
126
127  deps = [
128    "${usb_manager_path}/interfaces/innerkits:usbsrv_client",
129    "${usb_manager_path}/services:usbservice",
130    "//third_party/cJSON:cjson",
131    "//third_party/googletest:gmock_main",
132    "//third_party/googletest:gtest_main",
133  ]
134
135  external_deps = [
136    "ability_base:want",
137    "ability_runtime:ability_manager",
138    "access_token:libaccesstoken_sdk",
139    "access_token:libnativetoken",
140    "access_token:libtoken_setproc",
141    "bundle_framework:appexecfwk_base",
142    "bundle_framework:appexecfwk_core",
143    "c_utils:utils",
144    "common_event_service:cesfwk_innerkits",
145    "drivers_interface_usb:libusb_proxy_1.0",
146    "eventhandler:libeventhandler",
147    "hilog:libhilog",
148    "ipc:ipc_core",
149    "samgr:samgr_proxy",
150  ]
151}
152
153ohos_unittest("test_mock_usbevent") {
154  module_out_path = module_output_path
155  sources = [
156    "${usb_manager_path}/services/native/src/usb_service_subscriber.cpp",
157    "${usb_manager_path}/test/native/service_unittest/src/usb_common_test.cpp",
158    "src/usb_event_mock_test.cpp",
159    "src/usb_impl_mock.cpp",
160  ]
161
162  configs = [
163    "${utils_path}:utils_config",
164    ":module_private_config",
165  ]
166
167  deps = [
168    "${usb_manager_path}/interfaces/innerkits:usbsrv_client",
169    "${usb_manager_path}/services:usbservice",
170    "//third_party/cJSON:cjson",
171    "//third_party/googletest:gmock_main",
172    "//third_party/googletest:gtest_main",
173  ]
174
175  external_deps = [
176    "ability_base:want",
177    "ability_runtime:ability_manager",
178    "access_token:libaccesstoken_sdk",
179    "access_token:libnativetoken",
180    "access_token:libtoken_setproc",
181    "bundle_framework:appexecfwk_base",
182    "bundle_framework:appexecfwk_core",
183    "c_utils:utils",
184    "common_event_service:cesfwk_innerkits",
185    "drivers_interface_usb:libusb_proxy_1.0",
186    "eventhandler:libeventhandler",
187    "hilog:libhilog",
188    "ipc:ipc_core",
189    "samgr:samgr_proxy",
190  ]
191}
192
193ohos_unittest("test_mock_usbrequest") {
194  module_out_path = module_output_path
195  sources = [
196    "${usb_manager_path}/services/native/src/usb_service_subscriber.cpp",
197    "${usb_manager_path}/test/native/service_unittest/src/usb_common_test.cpp",
198    "src/usb_impl_mock.cpp",
199    "src/usb_request_mock_test.cpp",
200  ]
201
202  configs = [
203    "${utils_path}:utils_config",
204    ":module_private_config",
205  ]
206
207  deps = [
208    "${usb_manager_path}/interfaces/innerkits:usbsrv_client",
209    "${usb_manager_path}/services:usbservice",
210    "//third_party/cJSON:cjson",
211    "//third_party/googletest:gmock_main",
212    "//third_party/googletest:gtest_main",
213  ]
214
215  external_deps = [
216    "ability_base:want",
217    "ability_runtime:ability_manager",
218    "access_token:libaccesstoken_sdk",
219    "access_token:libnativetoken",
220    "access_token:libtoken_setproc",
221    "bundle_framework:appexecfwk_base",
222    "bundle_framework:appexecfwk_core",
223    "c_utils:utils",
224    "common_event_service:cesfwk_innerkits",
225    "drivers_interface_usb:libusb_proxy_1.0",
226    "eventhandler:libeventhandler",
227    "hilog:libhilog",
228    "ipc:ipc_core",
229    "samgr:samgr_proxy",
230  ]
231}
232
233group("usb_auto_test") {
234  testonly = true
235  deps = [
236    ":test_mock_bulkcallback",
237    ":test_mock_usbcore",
238    ":test_mock_usbdevicepipe",
239    ":test_mock_usbevent",
240    ":test_mock_usbrequest",
241  ]
242}
243