1# Copyright (c) 2021-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("./../../../usb.gni") 16 17module_output_path = "drivers_peripheral_usb/usb" 18 19config("module_private_config") { 20 visibility = [ ":*" ] 21 22 include_dirs = [ 23 "include", 24 "${usb_driver_path}/test/UsbSubscriberTest", 25 "${usb_driver_path}/utils/include", 26 ] 27} 28 29ohos_unittest("test_transfer") { 30 sources = [ 31 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 32 "src/usbd_transfer_test.cpp", 33 ] 34 35 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 36 37 configs = [ ":module_private_config" ] 38 39 deps = [ 40 "${usb_driver_path}/ddk:libusb_core", 41 "${usb_driver_path}/hdi_service:libusb_interface_service_1.1", 42 ] 43 44 if (is_standard_system) { 45 external_deps = [ 46 "drivers_interface_usb:libusb_proxy_1.1", 47 "eventhandler:libeventhandler", 48 "googletest:gtest_main", 49 "hdf_core:libhdf_utils", 50 "hilog:libhilog", 51 "ipc:ipc_single", 52 "safwk:system_ability_fwk", 53 ] 54 55 if (usb_samgr_enable) { 56 external_deps += [ "samgr:samgr_proxy" ] 57 58 if (defined(defines)) { 59 defines += [ "USB_ENABLE_SAMGR" ] 60 } else { 61 defines = [ "USB_ENABLE_SAMGR" ] 62 } 63 } 64 65 if (usb_c_utils_enable) { 66 external_deps += [ "c_utils:utils" ] 67 } 68 } else { 69 external_deps = [ "hilog:libhilog" ] 70 } 71 module_out_path = module_output_path 72} 73ohos_unittest("test_device") { 74 sources = [ 75 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 76 "src/usbd_device_test.cpp", 77 ] 78 79 include_dirs = [ 80 "${usb_driver_path}/test/UsbSubscriberTest", 81 "${usb_driver_path}/utils/include", 82 ] 83 84 configs = [ ":module_private_config" ] 85 86 deps = [ 87 "${usb_driver_path}/ddk:libusb_core", 88 "${usb_driver_path}/hdi_service:libusb_interface_service_1.1", 89 ] 90 91 if (is_standard_system) { 92 external_deps = [ 93 "drivers_interface_usb:libusb_proxy_1.1", 94 "eventhandler:libeventhandler", 95 "googletest:gtest_main", 96 "hdf_core:libhdf_utils", 97 "hilog:libhilog", 98 "ipc:ipc_single", 99 "safwk:system_ability_fwk", 100 ] 101 102 if (usb_samgr_enable) { 103 external_deps += [ "samgr:samgr_proxy" ] 104 105 if (defined(defines)) { 106 defines += [ "USB_ENABLE_SAMGR" ] 107 } else { 108 defines = [ "USB_ENABLE_SAMGR" ] 109 } 110 } 111 112 if (usb_c_utils_enable) { 113 external_deps += [ "c_utils:utils" ] 114 } 115 } else { 116 external_deps = [ "hilog:libhilog" ] 117 } 118 module_out_path = module_output_path 119} 120 121ohos_unittest("test_function") { 122 sources = [ "src/usbd_function_test.cpp" ] 123 124 configs = [ ":module_private_config" ] 125 126 deps = [ 127 "${usb_driver_path}/ddk:libusb_core", 128 "${usb_driver_path}/hdi_service:libusb_interface_service_1.1", 129 ] 130 131 if (is_standard_system) { 132 external_deps = [ 133 "drivers_interface_usb:libusb_proxy_1.1", 134 "eventhandler:libeventhandler", 135 "googletest:gtest_main", 136 "hdf_core:libhdf_host", 137 "hdf_core:libhdf_utils", 138 "hilog:libhilog", 139 "ipc:ipc_single", 140 "safwk:system_ability_fwk", 141 ] 142 143 if (usb_samgr_enable) { 144 external_deps += [ "samgr:samgr_proxy" ] 145 146 if (defined(defines)) { 147 defines += [ "USB_ENABLE_SAMGR" ] 148 } else { 149 defines = [ "USB_ENABLE_SAMGR" ] 150 } 151 } 152 153 if (usb_c_utils_enable) { 154 external_deps += [ "c_utils:utils" ] 155 } 156 } else { 157 external_deps = [ "hilog:libhilog" ] 158 } 159 module_out_path = module_output_path 160} 161 162ohos_unittest("test_request") { 163 sources = [ 164 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 165 "src/usbd_interface_test.cpp", 166 "src/usbd_request_test.cpp", 167 ] 168 169 include_dirs = [ 170 "${usb_driver_path}/test/UsbSubscriberTest", 171 "${usb_driver_path}/utils/include", 172 ] 173 174 configs = [ ":module_private_config" ] 175 176 deps = [ 177 "${usb_driver_path}/ddk:libusb_core", 178 "${usb_driver_path}/hdi_service:libusb_interface_service_1.1", 179 ] 180 181 if (is_standard_system) { 182 external_deps = [ 183 "drivers_interface_usb:libusb_proxy_1.1", 184 "eventhandler:libeventhandler", 185 "googletest:gtest_main", 186 "hdf_core:libhdf_utils", 187 "hilog:libhilog", 188 "ipc:ipc_single", 189 "safwk:system_ability_fwk", 190 ] 191 192 if (usb_samgr_enable) { 193 external_deps += [ "samgr:samgr_proxy" ] 194 195 if (defined(defines)) { 196 defines += [ "USB_ENABLE_SAMGR" ] 197 } else { 198 defines = [ "USB_ENABLE_SAMGR" ] 199 } 200 } 201 202 if (usb_c_utils_enable) { 203 external_deps += [ "c_utils:utils" ] 204 } 205 } else { 206 external_deps = [ "hilog:libhilog" ] 207 } 208 module_out_path = module_output_path 209} 210 211ohos_unittest("test_usbfnmtp") { 212 sources = [ "src/usbfn_mtp_test.cpp" ] 213 214 configs = [ ":module_private_config" ] 215 216 deps = [ 217 "${usb_driver_path}/ddk:libusb_core", 218 "${usb_driver_path}/gadget/function/mtp:libusbfn_mtp_interface_service_1.0", 219 "${usb_driver_path}/hdi_service:libusb_interface_service_1.1", 220 ] 221 222 if (is_standard_system) { 223 external_deps = [ 224 "drivers_interface_usb:libusb_proxy_1.1", 225 "drivers_interface_usb:libusbfn_mtp_proxy_1.0", 226 "eventhandler:libeventhandler", 227 "googletest:gtest_main", 228 "hdf_core:libhdf_host", 229 "hdf_core:libhdf_utils", 230 "hilog:libhilog", 231 "ipc:ipc_single", 232 ] 233 if (usb_c_utils_enable) { 234 external_deps += [ "c_utils:utils" ] 235 } 236 } else { 237 external_deps = [ "hilog:libhilog" ] 238 } 239 module_out_path = module_output_path 240} 241 242ohos_unittest("test_manageinterface") { 243 sources = [ 244 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 245 "src/usbd_manage_interface_test.cpp", 246 ] 247 248 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 249 250 configs = [ ":module_private_config" ] 251 252 deps = [ 253 "${usb_driver_path}/ddk:libusb_core", 254 "${usb_driver_path}/hdi_service:libusb_interface_service_1.1", 255 ] 256 257 if (is_standard_system) { 258 external_deps = [ 259 "drivers_interface_usb:libusb_proxy_1.1", 260 "eventhandler:libeventhandler", 261 "googletest:gtest_main", 262 "hdf_core:libhdf_utils", 263 "hilog:libhilog", 264 "ipc:ipc_single", 265 "safwk:system_ability_fwk", 266 ] 267 268 if (usb_samgr_enable) { 269 external_deps += [ "samgr:samgr_proxy" ] 270 271 if (defined(defines)) { 272 defines += [ "USB_ENABLE_SAMGR" ] 273 } else { 274 defines = [ "USB_ENABLE_SAMGR" ] 275 } 276 } 277 278 if (usb_c_utils_enable) { 279 external_deps += [ "c_utils:utils" ] 280 } 281 } else { 282 external_deps = [ "hilog:libhilog" ] 283 } 284 module_out_path = module_output_path 285} 286 287ohos_unittest("test_devicestatus") { 288 sources = [ 289 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 290 "src/usbd_device_status_test.cpp", 291 ] 292 293 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 294 295 configs = [ ":module_private_config" ] 296 297 deps = [ 298 "${usb_driver_path}/ddk:libusb_core", 299 "${usb_driver_path}/hdi_service:libusb_interface_service_1.1", 300 ] 301 302 if (is_standard_system) { 303 external_deps = [ 304 "drivers_interface_usb:libusb_proxy_1.1", 305 "eventhandler:libeventhandler", 306 "googletest:gtest_main", 307 "hdf_core:libhdf_utils", 308 "hilog:libhilog", 309 "ipc:ipc_single", 310 "safwk:system_ability_fwk", 311 ] 312 313 if (usb_samgr_enable) { 314 external_deps += [ "samgr:samgr_proxy" ] 315 316 if (defined(defines)) { 317 defines += [ "USB_ENABLE_SAMGR" ] 318 } else { 319 defines = [ "USB_ENABLE_SAMGR" ] 320 } 321 } 322 323 if (usb_c_utils_enable) { 324 external_deps += [ "c_utils:utils" ] 325 } 326 } else { 327 external_deps = [ "hilog:libhilog" ] 328 } 329 module_out_path = module_output_path 330} 331 332ohos_unittest("test_accessory") { 333 sources = [ 334 "${usb_driver_path}/test/UsbSubscriberTest/UsbSubscriberTest.cpp", 335 "src/usbd_accessory_test.cpp", 336 ] 337 338 include_dirs = [ "${usb_driver_path}/test/UsbSubscriberTest" ] 339 340 configs = [ ":module_private_config" ] 341 342 deps = [ 343 "${usb_driver_path}/ddk:libusb_core", 344 "${usb_driver_path}/hdi_service:libusb_interface_service_1.1", 345 ] 346 347 if (is_standard_system) { 348 external_deps = [ 349 "drivers_interface_usb:libusb_proxy_1.1", 350 "eventhandler:libeventhandler", 351 "googletest:gtest_main", 352 "hdf_core:libhdf_utils", 353 "hilog:libhilog", 354 "ipc:ipc_single", 355 "safwk:system_ability_fwk", 356 ] 357 358 if (usb_samgr_enable) { 359 external_deps += [ "samgr:samgr_proxy" ] 360 361 if (defined(defines)) { 362 defines += [ "USB_ENABLE_SAMGR" ] 363 } else { 364 defines = [ "USB_ENABLE_SAMGR" ] 365 } 366 } 367 368 if (usb_c_utils_enable) { 369 external_deps += [ "c_utils:utils" ] 370 } 371 } else { 372 external_deps = [ "hilog:libhilog" ] 373 } 374 module_out_path = module_output_path 375} 376 377group("hal_test") { 378 testonly = true 379 deps = [] 380} 381