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_bulk_transfer") { 33 module_out_path = module_output_path 34 sources = [ 35 "src/usb_common_test.cpp", 36 "src/usb_submit_transfer_bulk_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 ] 48 49 external_deps = [ 50 "ability_base:want", 51 "access_token:libaccesstoken_sdk", 52 "access_token:libnativetoken", 53 "access_token:libtoken_setproc", 54 "bundle_framework:appexecfwk_base", 55 "c_utils:utils", 56 "common_event_service:cesfwk_innerkits", 57 "drivers_interface_usb:libusb_proxy_1.0", 58 "eventhandler:libeventhandler", 59 "googletest:gtest_main", 60 "hilog:libhilog", 61 "ipc:ipc_core", 62 "safwk:system_ability_fwk", 63 "samgr:samgr_proxy", 64 ] 65} 66 67ohos_unittest("test_isochronous_transfer") { 68 module_out_path = module_output_path 69 sources = [ 70 "src/usb_common_test.cpp", 71 "src/usb_submit_transfer_isochronous_test.cpp", 72 ] 73 74 configs = [ 75 "${utils_path}:utils_config", 76 ":module_private_config", 77 ] 78 79 deps = [ 80 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 81 "${usb_manager_path}/services:usbservice", 82 ] 83 84 external_deps = [ 85 "ability_base:want", 86 "access_token:libaccesstoken_sdk", 87 "access_token:libnativetoken", 88 "access_token:libtoken_setproc", 89 "bundle_framework:appexecfwk_base", 90 "c_utils:utils", 91 "common_event_service:cesfwk_innerkits", 92 "drivers_interface_usb:libusb_proxy_1.0", 93 "eventhandler:libeventhandler", 94 "googletest:gtest_main", 95 "hilog:libhilog", 96 "ipc:ipc_core", 97 "safwk:system_ability_fwk", 98 "samgr:samgr_proxy", 99 ] 100} 101 102ohos_unittest("test_interrupt_transfer") { 103 module_out_path = module_output_path 104 sources = [ 105 "src/usb_common_test.cpp", 106 "src/usb_submit_transfer_interrupt_test.cpp", 107 ] 108 109 configs = [ 110 "${utils_path}:utils_config", 111 ":module_private_config", 112 ] 113 114 deps = [ 115 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 116 "${usb_manager_path}/services:usbservice", 117 ] 118 119 external_deps = [ 120 "ability_base:want", 121 "access_token:libaccesstoken_sdk", 122 "access_token:libnativetoken", 123 "access_token:libtoken_setproc", 124 "bundle_framework:appexecfwk_base", 125 "c_utils:utils", 126 "common_event_service:cesfwk_innerkits", 127 "drivers_interface_usb:libusb_proxy_1.0", 128 "eventhandler:libeventhandler", 129 "googletest:gtest_main", 130 "hilog:libhilog", 131 "ipc:ipc_core", 132 "safwk:system_ability_fwk", 133 "samgr:samgr_proxy", 134 ] 135} 136 137ohos_unittest("test_usbdevicepipe") { 138 module_out_path = module_output_path 139 sources = [ 140 "src/usb_common_test.cpp", 141 "src/usb_device_pipe_test.cpp", 142 ] 143 144 configs = [ 145 "${utils_path}:utils_config", 146 ":module_private_config", 147 ] 148 149 deps = [ 150 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 151 "${usb_manager_path}/services:usbservice", 152 ] 153 154 external_deps = [ 155 "ability_base:want", 156 "access_token:libaccesstoken_sdk", 157 "access_token:libnativetoken", 158 "access_token:libtoken_setproc", 159 "bundle_framework:appexecfwk_base", 160 "c_utils:utils", 161 "common_event_service:cesfwk_innerkits", 162 "drivers_interface_usb:libusb_proxy_1.0", 163 "eventhandler:libeventhandler", 164 "googletest:gtest_main", 165 "hilog:libhilog", 166 "ipc:ipc_core", 167 "safwk:system_ability_fwk", 168 "samgr:samgr_proxy", 169 ] 170} 171 172ohos_unittest("test_bulkcallback") { 173 module_out_path = module_output_path 174 sources = [ 175 "${usb_manager_path}/test/common/src/usb_callback_test.cpp", 176 "src/usb_bulkcallback_test.cpp", 177 "src/usb_common_test.cpp", 178 ] 179 180 configs = [ 181 "${utils_path}:utils_config", 182 ":module_private_config", 183 ] 184 185 deps = [ 186 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 187 "${usb_manager_path}/services:usbservice", 188 ] 189 190 external_deps = [ 191 "ability_base:want", 192 "access_token:libaccesstoken_sdk", 193 "access_token:libnativetoken", 194 "access_token:libtoken_setproc", 195 "bundle_framework:appexecfwk_base", 196 "c_utils:utils", 197 "common_event_service:cesfwk_innerkits", 198 "drivers_interface_usb:libusb_proxy_1.0", 199 "eventhandler:libeventhandler", 200 "googletest:gtest_main", 201 "hilog:libhilog", 202 "ipc:ipc_core", 203 "safwk:system_ability_fwk", 204 "samgr:samgr_proxy", 205 ] 206} 207 208ohos_unittest("test_usbrequest") { 209 module_out_path = module_output_path 210 sources = [ 211 "src/usb_common_test.cpp", 212 "src/usb_request_test.cpp", 213 ] 214 215 configs = [ 216 "${utils_path}:utils_config", 217 ":module_private_config", 218 ] 219 220 deps = [ 221 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 222 "${usb_manager_path}/services:usbservice", 223 ] 224 225 external_deps = [ 226 "ability_base:want", 227 "access_token:libaccesstoken_sdk", 228 "access_token:libnativetoken", 229 "access_token:libtoken_setproc", 230 "bundle_framework:appexecfwk_base", 231 "c_utils:utils", 232 "common_event_service:cesfwk_innerkits", 233 "drivers_interface_usb:libusb_proxy_1.0", 234 "eventhandler:libeventhandler", 235 "googletest:gtest_main", 236 "hilog:libhilog", 237 "ipc:ipc_core", 238 "safwk:system_ability_fwk", 239 "samgr:samgr_proxy", 240 ] 241} 242 243ohos_unittest("test_usbcore") { 244 module_out_path = module_output_path 245 sources = [ 246 "src/usb_common_test.cpp", 247 "src/usb_core_test.cpp", 248 ] 249 250 configs = [ 251 "${utils_path}:utils_config", 252 ":module_private_config", 253 ] 254 255 deps = [ 256 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 257 "${usb_manager_path}/services:usbservice", 258 ] 259 260 external_deps = [ 261 "ability_base:want", 262 "access_token:libaccesstoken_sdk", 263 "access_token:libnativetoken", 264 "access_token:libtoken_setproc", 265 "bundle_framework:appexecfwk_base", 266 "c_utils:utils", 267 "common_event_service:cesfwk_innerkits", 268 "drivers_interface_usb:libusb_proxy_1.0", 269 "eventhandler:libeventhandler", 270 "googletest:gtest_main", 271 "hilog:libhilog", 272 "ipc:ipc_core", 273 "safwk:system_ability_fwk", 274 "samgr:samgr_proxy", 275 ] 276} 277 278ohos_unittest("test_usbevent") { 279 module_out_path = module_output_path 280 sources = [ "src/usb_event_test.cpp" ] 281 282 configs = [ 283 "${utils_path}:utils_config", 284 ":module_private_config", 285 ] 286 287 deps = [ 288 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 289 "${usb_manager_path}/services:usbservice", 290 ] 291 292 external_deps = [ 293 "ability_base:want", 294 "bundle_framework:appexecfwk_base", 295 "cJSON:cjson", 296 "c_utils:utils", 297 "common_event_service:cesfwk_innerkits", 298 "drivers_interface_usb:libusb_proxy_1.0", 299 "eventhandler:libeventhandler", 300 "googletest:gtest_main", 301 "hilog:libhilog", 302 "ipc:ipc_core", 303 "safwk:system_ability_fwk", 304 "samgr:samgr_proxy", 305 ] 306 307 if (usb_manage_feature_support_port_change) { 308 if (defined(defines)) { 309 defines += [ "SUPPORT_PORT_CHNAGE_TEST" ] 310 } else { 311 defines = [ "SUPPORT_PORT_CHNAGE_TEST" ] 312 } 313 } 314} 315 316ohos_unittest("test_usbmanageinterface") { 317 module_out_path = module_output_path 318 sources = [ 319 "src/usb_common_test.cpp", 320 "src/usb_manage_interface_test.cpp", 321 ] 322 323 configs = [ 324 "${utils_path}:utils_config", 325 ":module_private_config", 326 ] 327 328 deps = [ 329 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 330 "${usb_manager_path}/services:usbservice", 331 ] 332 333 external_deps = [ 334 "ability_base:want", 335 "access_token:libaccesstoken_sdk", 336 "access_token:libnativetoken", 337 "access_token:libtoken_setproc", 338 "bundle_framework:appexecfwk_base", 339 "c_utils:utils", 340 "common_event_service:cesfwk_innerkits", 341 "drivers_interface_usb:libusb_proxy_1.0", 342 "eventhandler:libeventhandler", 343 "googletest:gtest_main", 344 "hilog:libhilog", 345 "ipc:ipc_core", 346 "safwk:system_ability_fwk", 347 "samgr:samgr_proxy", 348 ] 349} 350 351ohos_unittest("test_usbdevicestatus") { 352 module_out_path = module_output_path 353 sources = [ 354 "src/usb_common_test.cpp", 355 "src/usb_device_status_test.cpp", 356 ] 357 358 configs = [ 359 "${utils_path}:utils_config", 360 ":module_private_config", 361 ] 362 363 deps = [ 364 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 365 "${usb_manager_path}/services:usbservice", 366 ] 367 368 external_deps = [ 369 "ability_base:want", 370 "access_token:libaccesstoken_sdk", 371 "access_token:libnativetoken", 372 "access_token:libtoken_setproc", 373 "bundle_framework:appexecfwk_base", 374 "c_utils:utils", 375 "common_event_service:cesfwk_innerkits", 376 "drivers_interface_usb:libusb_proxy_1.2", 377 "eventhandler:libeventhandler", 378 "googletest:gtest_main", 379 "hilog:libhilog", 380 "ipc:ipc_core", 381 "safwk:system_ability_fwk", 382 "samgr:samgr_proxy", 383 ] 384} 385 386ohos_unittest("test_usbdfx") { 387 module_out_path = module_output_path 388 sources = [ 389 "src/usb_common_test.cpp", 390 "src/usb_dfx_test.cpp", 391 ] 392 393 configs = [ 394 "${utils_path}:utils_config", 395 ":module_private_config", 396 ] 397 398 deps = [ 399 "${usb_manager_path}/interfaces/innerkits:usbsrv_client", 400 "${usb_manager_path}/services:usbservice", 401 ] 402 403 external_deps = [ 404 "ability_base:want", 405 "access_token:libaccesstoken_sdk", 406 "access_token:libnativetoken", 407 "access_token:libtoken_setproc", 408 "bundle_framework:appexecfwk_base", 409 "cJSON:cjson", 410 "c_utils:utils", 411 "common_event_service:cesfwk_innerkits", 412 "drivers_interface_usb:libusb_proxy_1.0", 413 "eventhandler:libeventhandler", 414 "googletest:gtest_main", 415 "hilog:libhilog", 416 "ipc:ipc_core", 417 "safwk:system_ability_fwk", 418 "samgr:samgr_proxy", 419 ] 420} 421 422group("unittest") { 423 testonly = true 424 deps = [ 425 ":test_bulk_transfer", 426 ":test_bulkcallback", 427 ":test_interrupt_transfer", 428 ":test_isochronous_transfer", 429 ":test_usbcore", 430 ":test_usbdevicepipe", 431 ":test_usbdevicestatus", 432 ":test_usbdfx", 433 ":test_usbevent", 434 ":test_usbmanageinterface", 435 ":test_usbrequest", 436 ] 437} 438