1# Copyright (c) 2025 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/UsbSubTest", 25 "${usb_driver_path}/utils/include", 26 ] 27} 28 29ohos_unittest("test_feature_transfer") { 30 sources = [ 31 "${usb_driver_path}/test/UsbSubTest/UsbSubTest.cpp", 32 "src/usbd_transfer_test.cpp", 33 ] 34 35 include_dirs = [ "${usb_driver_path}/test/UsbSubTest" ] 36 37 configs = [ ":module_private_config" ] 38 39 deps = [ 40 "${usb_driver_path}/ddk:libusb_core", 41 "${usb_driver_path}/hdi_service:libusb_device_interface_service_2.0", 42 "${usb_driver_path}/hdi_service:libusb_host_interface_service_2.0", 43 ] 44 45 if (is_standard_system) { 46 external_deps = [ 47 "drivers_interface_usb:libusb_proxy_2.0", 48 "eventhandler:libeventhandler", 49 "googletest:gtest_main", 50 "hdf_core:libhdf_utils", 51 "hilog:libhilog", 52 "ipc:ipc_single", 53 "safwk:system_ability_fwk", 54 ] 55 56 if (usb_samgr_enable) { 57 external_deps += [ "samgr:samgr_proxy" ] 58 59 if (defined(defines)) { 60 defines += [ "USB_ENABLE_SAMGR" ] 61 } else { 62 defines = [ "USB_ENABLE_SAMGR" ] 63 } 64 } 65 66 if (usb_c_utils_enable) { 67 external_deps += [ "c_utils:utils" ] 68 } 69 } else { 70 external_deps = [ "hilog:libhilog" ] 71 } 72 module_out_path = module_output_path 73} 74ohos_unittest("test_feature_device") { 75 sources = [ 76 "${usb_driver_path}/test/UsbSubTest/UsbSubTest.cpp", 77 "src/usbd_device_test.cpp", 78 ] 79 80 include_dirs = [ 81 "${usb_driver_path}/test/UsbSubTest", 82 "${usb_driver_path}/utils/include", 83 ] 84 85 configs = [ ":module_private_config" ] 86 87 deps = [ 88 "${usb_driver_path}/ddk:libusb_core", 89 "${usb_driver_path}/hdi_service:libusb_device_interface_service_2.0", 90 "${usb_driver_path}/hdi_service:libusb_host_interface_service_2.0", 91 ] 92 93 if (is_standard_system) { 94 external_deps = [ 95 "drivers_interface_usb:libusb_proxy_2.0", 96 "eventhandler:libeventhandler", 97 "googletest:gtest_main", 98 "hdf_core:libhdf_utils", 99 "hilog:libhilog", 100 "ipc:ipc_single", 101 "safwk:system_ability_fwk", 102 ] 103 104 if (usb_samgr_enable) { 105 external_deps += [ "samgr:samgr_proxy" ] 106 107 if (defined(defines)) { 108 defines += [ "USB_ENABLE_SAMGR" ] 109 } else { 110 defines = [ "USB_ENABLE_SAMGR" ] 111 } 112 } 113 114 if (usb_c_utils_enable) { 115 external_deps += [ "c_utils:utils" ] 116 } 117 } else { 118 external_deps = [ "hilog:libhilog" ] 119 } 120 module_out_path = module_output_path 121} 122 123ohos_unittest("test_feature_function") { 124 sources = [ "src/usbd_function_test.cpp" ] 125 126 configs = [ ":module_private_config" ] 127 128 deps = [ 129 "${usb_driver_path}/ddk:libusb_core", 130 "${usb_driver_path}/hdi_service:libusb_device_interface_service_2.0", 131 "${usb_driver_path}/hdi_service:libusb_port_interface_service_2.0", 132 ] 133 134 if (is_standard_system) { 135 external_deps = [ 136 "drivers_interface_usb:libusb_proxy_2.0", 137 "eventhandler:libeventhandler", 138 "googletest:gtest_main", 139 "hdf_core:libhdf_host", 140 "hdf_core:libhdf_utils", 141 "hilog:libhilog", 142 "ipc:ipc_single", 143 "safwk:system_ability_fwk", 144 ] 145 146 if (usb_samgr_enable) { 147 external_deps += [ "samgr:samgr_proxy" ] 148 149 if (defined(defines)) { 150 defines += [ "USB_ENABLE_SAMGR" ] 151 } else { 152 defines = [ "USB_ENABLE_SAMGR" ] 153 } 154 } 155 156 if (usb_c_utils_enable) { 157 external_deps += [ "c_utils:utils" ] 158 } 159 } else { 160 external_deps = [ "hilog:libhilog" ] 161 } 162 module_out_path = module_output_path 163} 164 165ohos_unittest("test_feature_request") { 166 sources = [ 167 "${usb_driver_path}/test/UsbSubTest/UsbSubTest.cpp", 168 "src/usbd_request_test.cpp", 169 ] 170 171 include_dirs = [ 172 "${usb_driver_path}/test/UsbSubTest", 173 "${usb_driver_path}/utils/include", 174 ] 175 176 configs = [ ":module_private_config" ] 177 178 deps = [ 179 "${usb_driver_path}/ddk:libusb_core", 180 "${usb_driver_path}/hdi_service:libusb_host_interface_service_2.0", 181 "${usb_driver_path}/hdi_service:libusb_port_interface_service_2.0", 182 ] 183 184 if (is_standard_system) { 185 external_deps = [ 186 "drivers_interface_usb:libusb_proxy_2.0", 187 "eventhandler:libeventhandler", 188 "googletest:gtest_main", 189 "hdf_core:libhdf_utils", 190 "hilog:libhilog", 191 "ipc:ipc_single", 192 "safwk:system_ability_fwk", 193 ] 194 195 if (usb_samgr_enable) { 196 external_deps += [ "samgr:samgr_proxy" ] 197 198 if (defined(defines)) { 199 defines += [ "USB_ENABLE_SAMGR" ] 200 } else { 201 defines = [ "USB_ENABLE_SAMGR" ] 202 } 203 } 204 205 if (usb_c_utils_enable) { 206 external_deps += [ "c_utils:utils" ] 207 } 208 } else { 209 external_deps = [ "hilog:libhilog" ] 210 } 211 module_out_path = module_output_path 212} 213 214ohos_unittest("test_feature_usbfnmtp") { 215 sources = [ "src/usbfn_mtp_test.cpp" ] 216 217 configs = [ ":module_private_config" ] 218 219 deps = [ 220 "${usb_driver_path}/ddk:libusb_core", 221 "${usb_driver_path}/gadget/function/mtp:libusbfn_mtp_interface_service_1.0", 222 "${usb_driver_path}/hdi_service:libusb_interface_service_1.2", 223 ] 224 225 if (is_standard_system) { 226 external_deps = [ 227 "drivers_interface_usb:libusb_proxy_1.1", 228 "drivers_interface_usb:libusbfn_mtp_proxy_1.0", 229 "eventhandler:libeventhandler", 230 "googletest:gtest_main", 231 "hdf_core:libhdf_host", 232 "hdf_core:libhdf_utils", 233 "hilog:libhilog", 234 "ipc:ipc_single", 235 ] 236 if (usb_c_utils_enable) { 237 external_deps += [ "c_utils:utils" ] 238 } 239 } else { 240 external_deps = [ "hilog:libhilog" ] 241 } 242 module_out_path = module_output_path 243} 244 245ohos_unittest("test_feature_manageinterface") { 246 sources = [ 247 "${usb_driver_path}/test/UsbSubTest/UsbSubTest.cpp", 248 "src/usbd_manage_interface_test.cpp", 249 ] 250 251 include_dirs = [ "${usb_driver_path}/test/UsbSubTest" ] 252 253 configs = [ ":module_private_config" ] 254 255 deps = [ 256 "${usb_driver_path}/ddk:libusb_core", 257 "${usb_driver_path}/hdi_service:libusb_host_interface_service_2.0", 258 "${usb_driver_path}/hdi_service:libusb_port_interface_service_2.0", 259 ] 260 261 if (is_standard_system) { 262 external_deps = [ 263 "drivers_interface_usb:libusb_proxy_2.0", 264 "eventhandler:libeventhandler", 265 "googletest:gtest_main", 266 "hdf_core:libhdf_utils", 267 "hilog:libhilog", 268 "ipc:ipc_single", 269 "safwk:system_ability_fwk", 270 ] 271 272 if (usb_samgr_enable) { 273 external_deps += [ "samgr:samgr_proxy" ] 274 275 if (defined(defines)) { 276 defines += [ "USB_ENABLE_SAMGR" ] 277 } else { 278 defines = [ "USB_ENABLE_SAMGR" ] 279 } 280 } 281 282 if (usb_c_utils_enable) { 283 external_deps += [ "c_utils:utils" ] 284 } 285 } else { 286 external_deps = [ "hilog:libhilog" ] 287 } 288 module_out_path = module_output_path 289} 290 291ohos_unittest("test_feature_devicestatus") { 292 sources = [ 293 "${usb_driver_path}/test/UsbSubTest/UsbSubTest.cpp", 294 "src/usbd_device_status_test.cpp", 295 ] 296 297 include_dirs = [ "${usb_driver_path}/test/UsbSubTest" ] 298 299 configs = [ ":module_private_config" ] 300 301 deps = [ 302 "${usb_driver_path}/ddk:libusb_core", 303 "${usb_driver_path}/hdi_service:libusb_device_interface_service_2.0", 304 "${usb_driver_path}/hdi_service:libusb_host_interface_service_2.0", 305 ] 306 307 if (is_standard_system) { 308 external_deps = [ 309 "drivers_interface_usb:libusb_proxy_2.0", 310 "eventhandler:libeventhandler", 311 "googletest:gtest_main", 312 "hdf_core:libhdf_utils", 313 "hilog:libhilog", 314 "ipc:ipc_single", 315 "safwk:system_ability_fwk", 316 ] 317 318 if (usb_samgr_enable) { 319 external_deps += [ "samgr:samgr_proxy" ] 320 321 if (defined(defines)) { 322 defines += [ "USB_ENABLE_SAMGR" ] 323 } else { 324 defines = [ "USB_ENABLE_SAMGR" ] 325 } 326 } 327 328 if (usb_c_utils_enable) { 329 external_deps += [ "c_utils:utils" ] 330 } 331 } else { 332 external_deps = [ "hilog:libhilog" ] 333 } 334 module_out_path = module_output_path 335} 336 337ohos_unittest("test_feature_accessory") { 338 sources = [ 339 "${usb_driver_path}/test/UsbSubTest/UsbSubTest.cpp", 340 "src/usbd_accessory_test.cpp", 341 ] 342 343 include_dirs = [ "${usb_driver_path}/test/UsbSubTest" ] 344 345 configs = [ ":module_private_config" ] 346 347 deps = [ 348 "${usb_driver_path}/ddk:libusb_core", 349 "${usb_driver_path}/hdi_service:libusb_device_interface_service_2.0", 350 ] 351 352 if (is_standard_system) { 353 external_deps = [ 354 "drivers_interface_usb:libusb_proxy_2.0", 355 "eventhandler:libeventhandler", 356 "googletest:gtest_main", 357 "hdf_core:libhdf_utils", 358 "hilog:libhilog", 359 "ipc:ipc_single", 360 "safwk:system_ability_fwk", 361 ] 362 363 if (usb_samgr_enable) { 364 external_deps += [ "samgr:samgr_proxy" ] 365 366 if (defined(defines)) { 367 defines += [ "USB_ENABLE_SAMGR" ] 368 } else { 369 defines = [ "USB_ENABLE_SAMGR" ] 370 } 371 } 372 373 if (usb_c_utils_enable) { 374 external_deps += [ "c_utils:utils" ] 375 } 376 } else { 377 external_deps = [ "hilog:libhilog" ] 378 } 379 module_out_path = module_output_path 380} 381 382ohos_unittest("test_feature_interrupt_transfer") { 383 sources = [ 384 "${usb_driver_path}/test/UsbSubTest/UsbSubTest.cpp", 385 "src/usbd_interrupt_transfer_test.cpp", 386 ] 387 388 include_dirs = [ "${usb_driver_path}/test/UsbSubTest" ] 389 390 configs = [ ":module_private_config" ] 391 392 deps = [ 393 "${usb_driver_path}/ddk:libusb_core", 394 "${usb_driver_path}/hdi_service:libusb_host_interface_service_2.0", 395 "${usb_driver_path}/hdi_service:libusb_port_interface_service_2.0", 396 ] 397 398 if (is_standard_system) { 399 external_deps = [ 400 "drivers_interface_usb:libusb_proxy_2.0", 401 "eventhandler:libeventhandler", 402 "googletest:gtest_main", 403 "hdf_core:libhdf_utils", 404 "hilog:libhilog", 405 "ipc:ipc_single", 406 "safwk:system_ability_fwk", 407 ] 408 409 if (usb_samgr_enable) { 410 external_deps += [ "samgr:samgr_proxy" ] 411 412 if (defined(defines)) { 413 defines += [ "USB_ENABLE_SAMGR" ] 414 } else { 415 defines = [ "USB_ENABLE_SAMGR" ] 416 } 417 } 418 419 if (usb_c_utils_enable) { 420 external_deps += [ "c_utils:utils" ] 421 } 422 } else { 423 external_deps = [ "hilog:libhilog" ] 424 } 425 module_out_path = module_output_path 426} 427 428ohos_unittest("test_feature_asynctransfer") { 429 sources = [ 430 "${usb_driver_path}/test/UsbSubTest/UsbSubTest.cpp", 431 "src/usbd_async_transfer_test.cpp", 432 ] 433 434 include_dirs = [ "${usb_driver_path}/test/UsbSubTest" ] 435 436 configs = [ ":module_private_config" ] 437 438 deps = [ 439 "${usb_driver_path}/ddk:libusb_core", 440 "${usb_driver_path}/hdi_service:libusb_host_interface_service_2.0", 441 "${usb_driver_path}/hdi_service:libusb_port_interface_service_2.0", 442 "${usb_driver_path}/libusb_adapter:libusb_adapter", 443 ] 444 445 if (is_standard_system) { 446 external_deps = [ 447 "drivers_interface_usb:libusb_proxy_2.0", 448 "eventhandler:libeventhandler", 449 "googletest:gtest_main", 450 "hdf_core:libhdf_utils", 451 "hilog:libhilog", 452 "ipc:ipc_single", 453 "libusb:libusb", 454 "safwk:system_ability_fwk", 455 ] 456 457 if (usb_samgr_enable) { 458 external_deps += [ "samgr:samgr_proxy" ] 459 460 if (defined(defines)) { 461 defines += [ "USB_ENABLE_SAMGR" ] 462 } else { 463 defines = [ "USB_ENABLE_SAMGR" ] 464 } 465 } 466 467 if (usb_c_utils_enable) { 468 external_deps += [ "c_utils:utils" ] 469 } 470 } else { 471 external_deps = [ "hilog:libhilog" ] 472 } 473 module_out_path = module_output_path 474} 475 476group("passthrough_test") { 477 testonly = true 478 deps = [ 479 ":test_feature_accessory", 480 ":test_feature_asynctransfer", 481 ":test_feature_device", 482 ":test_feature_devicestatus", 483 ":test_feature_function", 484 ":test_feature_interrupt_transfer", 485 ":test_feature_manageinterface", 486 ":test_feature_request", 487 ":test_feature_transfer", 488 ] 489} 490