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