1 /*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include <iostream>
16 #include <vector>
17
18 #include "UsbSubscriberTest.h"
19 #include "hdf_log.h"
20 #include "securec.h"
21 #include "usbd_transfer_test.h"
22 #include "v1_0/iusb_interface.h"
23 #include "v1_0/usb_types.h"
24
25 const int SLEEP_TIME = 3;
26 const uint8_t BUS_NUM_99 = 99;
27 const uint8_t BUS_NUM_222 = 222;
28 const uint8_t BUS_NUM_255 = 255;
29 const uint8_t DEV_ADDR_99 = 99;
30 const uint8_t DEV_ADDR_244 = 244;
31 const uint8_t DEV_ADDR_255 = 255;
32 const uint32_t LENGTH_NUM_255 = 255;
33 const uint8_t INTERFACEID_1 = 1;
34 const uint8_t PIPE_ENDPOINTID_244 = 244;
35 const uint8_t PIPE_ENDPOINTID_255 = 255;
36 const uint8_t PIPE_INTERFACEID_244 = 244;
37 const uint8_t PIPE_INTERFACEID_255 = 255;
38 const uint8_t POINTID_1 = 1;
39 const uint8_t POINTID_99 = 99;
40 const uint8_t POINTID_129 = 130;
41 const uint8_t POINTID_BULK_IN = 0x82;
42 const uint8_t POINTID_BULK_OUT = 0x01;
43 const int32_t ASHMEM_MAX_SIZE = 1024;
44 const uint8_t SAMPLE_DATA_1 = 1;
45 const uint8_t SAMPLE_DATA_2 = 2;
46 const uint8_t SAMPLE_DATA_3 = 3;
47 UsbDev UsbdTransferTest::dev_ = {0, 0};
48
49 using namespace testing::ext;
50 using namespace OHOS;
51 using namespace OHOS::USB;
52 using namespace std;
53 using namespace OHOS::HDI::Usb::V1_0;
54
55 namespace {
56 sptr<IUsbInterface> g_usbInterface = nullptr;
57
InitAshmemOne(sptr<Ashmem> & asmptr,int32_t asmSize,uint8_t rflg)58 int32_t InitAshmemOne(sptr<Ashmem> &asmptr, int32_t asmSize, uint8_t rflg)
59 {
60 asmptr = Ashmem::CreateAshmem("ttashmem000", asmSize);
61 if (asmptr == nullptr) {
62 HDF_LOGE("InitAshmemOne CreateAshmem failed\n");
63 return HDF_FAILURE;
64 }
65
66 asmptr->MapReadAndWriteAshmem();
67
68 if (rflg == 0) {
69 uint8_t tdata[ASHMEM_MAX_SIZE];
70 int32_t offset = 0;
71 int32_t tlen = 0;
72
73 int32_t retSafe = memset_s(tdata, sizeof(tdata), 'Y', ASHMEM_MAX_SIZE);
74 if (retSafe != EOK) {
75 HDF_LOGE("InitAshmemOne memset_s failed\n");
76 return HDF_FAILURE;
77 }
78 while (offset < asmSize) {
79 tlen = (asmSize - offset) < ASHMEM_MAX_SIZE ? (asmSize - offset) : ASHMEM_MAX_SIZE;
80 asmptr->WriteToAshmem(tdata, tlen, offset);
81 offset += tlen;
82 }
83 }
84 return HDF_SUCCESS;
85 }
86
SetUpTestCase(void)87 void UsbdTransferTest::SetUpTestCase(void)
88 {
89 g_usbInterface = IUsbInterface::Get();
90 if (g_usbInterface == nullptr) {
91 HDF_LOGE("%{public}s:IUsbInterface::Get() failed.", __func__);
92 exit(0);
93 }
94 const int32_t DEFAULT_PORT_ID = 1;
95 const int32_t DEFAULT_ROLE_HOST = 1;
96 auto ret = g_usbInterface->SetPortRole(DEFAULT_PORT_ID, DEFAULT_ROLE_HOST, DEFAULT_ROLE_HOST);
97 sleep(SLEEP_TIME);
98 HDF_LOGI("UsbdTransferTest::[Device] %{public}d SetPortRole=%{public}d", __LINE__, ret);
99 ASSERT_EQ(0, ret);
100 if (ret != 0) {
101 exit(0);
102 }
103
104 sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest();
105 if (subscriber == nullptr) {
106 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
107 exit(0);
108 }
109 if (g_usbInterface->BindUsbdSubscriber(subscriber) != HDF_SUCCESS) {
110 HDF_LOGE("%{public}s: bind usbd subscriber failed", __func__);
111 exit(0);
112 }
113
114 std::cout << "please connect device, press enter to continue" << std::endl;
115 int c;
116 while ((c = getchar()) != '\n' && c != EOF) {
117 }
118
119 dev_ = { subscriber->busNum_, subscriber->devAddr_ };
120 HDF_LOGI("%{public}s: busNum:%{public}d, devAddr:%{public}d", __func__, subscriber->busNum_, subscriber->devAddr_);
121 ret = g_usbInterface->OpenDevice(dev_);
122 HDF_LOGI("UsbdTransferTest:: %{public}d OpenDevice=%{public}d", __LINE__, ret);
123 ASSERT_EQ(0, ret);
124 }
125
TearDownTestCase(void)126 void UsbdTransferTest::TearDownTestCase(void)
127 {
128 sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest();
129 if (subscriber == nullptr) {
130 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
131 exit(0);
132 }
133 if (g_usbInterface->BindUsbdSubscriber(subscriber) != HDF_SUCCESS) {
134 HDF_LOGE("%{public}s: bind usbd subscriber failed", __func__);
135 exit(0);
136 }
137 dev_ = { subscriber->busNum_, subscriber->devAddr_ };
138 auto ret = g_usbInterface->CloseDevice(dev_);
139 HDF_LOGI("UsbdTransferTest:: %{public}d Close=%{public}d", __LINE__, ret);
140 ASSERT_EQ(0, ret);
141 }
142
SetUp(void)143 void UsbdTransferTest::SetUp(void) {}
144
TearDown(void)145 void UsbdTransferTest::TearDown(void) {}
146
147 /**
148 * @tc.name: SUB_USB_HDI_0450
149 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
150 * std::vector<uint8_t> &data);
151 * @tc.desc: Positive test: parameters correctly, standard request: get configuration
152 * @tc.type: FUNC
153 */
154 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0450, Function | MediumTest | Level1)
155 {
156 struct UsbDev dev = dev_;
157 uint8_t buffer[LENGTH_NUM_255] = { 0 };
158 uint32_t length = LENGTH_NUM_255;
159 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
160 struct UsbCtrlTransfer ctrlparmas = { 0b10000000, 8, 0, 0, 1000 };
161 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
162 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0450 %{public}d ret=%{public}d", __LINE__, ret);
163 ASSERT_EQ(0, ret);
164 }
165
166 /**
167 * @tc.name: SUB_USB_HDI_0460
168 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
169 * std::vector<uint8_t> &data);
170 * @tc.desc: Negative test: parameters exception, busNum error, standard request: get configuration
171 * @tc.type: FUNC
172 */
173 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0460, Function | MediumTest | Level1)
174 {
175 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
176 uint8_t buffer[LENGTH_NUM_255] = { 0 };
177 uint32_t length = LENGTH_NUM_255;
178 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
179 struct UsbCtrlTransfer ctrlparmas = { 0b10000000, 8, 0, 0, 1000 };
180 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
181 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0460 %{public}d ret=%{public}d", __LINE__, ret);
182 ASSERT_NE(ret, 0);
183 }
184
185 /**
186 * @tc.name: SUB_USB_HDI_0470
187 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
188 * std::vector<uint8_t> &data);
189 * @tc.desc: Negative test: parameters exception, devAddr error, standard request: get configuration
190 * @tc.type: FUNC
191 */
192 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0470, Function | MediumTest | Level1)
193 {
194 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
195 uint8_t buffer[LENGTH_NUM_255] = { 0 };
196 uint32_t length = LENGTH_NUM_255;
197 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
198 struct UsbCtrlTransfer ctrlparmas = { 0b10000000, 8, 0, 0, 1000 };
199 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
200 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0470 %{public}d ret=%{public}d", __LINE__, ret);
201 ASSERT_NE(ret, 0);
202 }
203
204 /**
205 * @tc.name: SUB_USB_HDI_0480
206 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
207 * std::vector<uint8_t> &data);
208 * @tc.desc: Positive test: parameters correctly, standard request: get descriptor(device)
209 * @tc.type: FUNC
210 */
211 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0480, Function | MediumTest | Level1)
212 {
213 struct UsbDev dev = dev_;
214 uint32_t length = LENGTH_NUM_255;
215 uint8_t buffer[LENGTH_NUM_255] = { 0 };
216 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
217 struct UsbCtrlTransfer ctrlparmas = { 0b10000000, 6, 0x100, 0, 1000 };
218 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
219 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0480 %{public}d ret=%{public}d", __LINE__, ret);
220 ASSERT_EQ(0, ret);
221 }
222
223 /**
224 * @tc.name: SUB_USB_HDI_0490
225 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
226 * std::vector<uint8_t> &data);
227 * @tc.desc: Negative test: parameters exception, devAddr error, standard request: get descriptor(device)
228 * @tc.type: FUNC
229 */
230 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0490, Function | MediumTest | Level1)
231 {
232 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
233 uint32_t length = LENGTH_NUM_255;
234 uint8_t buffer[LENGTH_NUM_255] = { 0 };
235 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
236 struct UsbCtrlTransfer ctrlparmas = { 0b10000000, 6, 0x100, 0, 1000 };
237 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
238 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0490 %{public}d ret=%{public}d", __LINE__, ret);
239 ASSERT_NE(ret, 0);
240 }
241
242 /**
243 * @tc.name: SUB_USB_HDI_0500
244 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
245 * std::vector<uint8_t> &data);
246 * @tc.desc: Negative test: parameters exception, devAddr error, standard request: get descriptor(device)
247 * @tc.type: FUNC
248 */
249 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0500, Function | MediumTest | Level1)
250 {
251 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
252 uint32_t length = LENGTH_NUM_255;
253 uint8_t buffer[LENGTH_NUM_255] = { 0 };
254 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
255 struct UsbCtrlTransfer ctrlparmas = { 0b10000000, 6, 0x100, 0, 1000 };
256 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
257 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0500 %{public}d ret=%{public}d", __LINE__, ret);
258 ASSERT_NE(ret, 0);
259 }
260
261 /**
262 * @tc.name: SUB_USB_HDI_0510
263 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
264 * std::vector<uint8_t> &data);
265 * @tc.desc: Positive test: parameters correctly, standard request: get interface
266 * @tc.type: FUNC
267 */
268 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0510, Function | MediumTest | Level1)
269 {
270 struct UsbDev dev = dev_;
271 int32_t intercafeidex = 0;
272 uint32_t length = LENGTH_NUM_255;
273 uint8_t buffer[LENGTH_NUM_255] = { 0 };
274 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
275 struct UsbCtrlTransfer ctrlparmas = { 0b10000001, 0X0A, 0, intercafeidex, 1000 };
276 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
277 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0510 %{public}d ret=%{public}d", __LINE__, ret);
278 ASSERT_EQ(0, ret);
279 }
280
281 /**
282 * @tc.name: SUB_USB_HDI_0520
283 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
284 * std::vector<uint8_t> &data);
285 * @tc.desc: Negative test: parameters exception, busNum error, standard request: get interface
286 * @tc.type: FUNC
287 */
288 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0520, Function | MediumTest | Level1)
289 {
290 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
291 int32_t intercafeidex = 0;
292 uint32_t length = LENGTH_NUM_255;
293 uint8_t buffer[LENGTH_NUM_255] = { 0 };
294 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
295 struct UsbCtrlTransfer ctrlparmas = { 0b10000001, 0X0A, 0, intercafeidex, 1000 };
296 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
297 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0520 %{public}d ret=%{public}d", __LINE__, ret);
298 ASSERT_NE(ret, 0);
299 }
300
301 /**
302 * @tc.name: SUB_USB_HDI_0530
303 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
304 * std::vector<uint8_t> &data);
305 * @tc.desc: Negative test: parameters exception, devAddr error, standard request: get interface
306 * @tc.type: FUNC
307 */
308 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0530, Function | MediumTest | Level1)
309 {
310 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
311 int32_t intercafeidex = 0;
312 uint32_t length = LENGTH_NUM_255;
313 uint8_t buffer[LENGTH_NUM_255] = { 0 };
314 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
315 struct UsbCtrlTransfer ctrlparmas = { 0b10000001, 0X0A, 0, intercafeidex, 1000 };
316 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
317 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0530 %{public}d ret=%{public}d", __LINE__, ret);
318 ASSERT_NE(ret, 0);
319 }
320
321 /**
322 * @tc.name: SUB_USB_HDI_0540
323 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
324 * std::vector<uint8_t> &data);
325 * @tc.desc: Positive test: parameters correctly, standard request: get status(recipient device)
326 * @tc.type: FUNC
327 */
328 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0540, Function | MediumTest | Level1)
329 {
330 struct UsbDev dev = dev_;
331 uint32_t length = LENGTH_NUM_255;
332 uint8_t buffer[LENGTH_NUM_255] = { 0 };
333 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
334 struct UsbCtrlTransfer ctrlparmas = { 0b10000000, 0, 0, 0, 1000 };
335 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
336 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0540 %{public}d ret=%{public}d", __LINE__, ret);
337 ASSERT_EQ(0, ret);
338 }
339
340 /**
341 * @tc.name: SUB_USB_HDI_0550
342 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
343 * std::vector<uint8_t> &data);
344 * @tc.desc: Negative test: parameters exception, busNum error, standard request: get status(device)
345 * @tc.type: FUNC
346 */
347 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0550, Function | MediumTest | Level1)
348 {
349 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
350 uint32_t length = LENGTH_NUM_255;
351 uint8_t buffer[LENGTH_NUM_255] = { 0 };
352 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
353 struct UsbCtrlTransfer ctrlparmas = { 0b10000000, 0, 0, 0, 1000 };
354 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
355 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0550 %{public}d ret=%{public}d", __LINE__, ret);
356 ASSERT_NE(ret, 0);
357 }
358
359 /**
360 * @tc.name: SUB_USB_HDI_0560
361 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
362 * std::vector<uint8_t> &data);
363 * @tc.desc: Negative test: parameters exception, devAddr error, standard request: get status(device)
364 * @tc.type: FUNC
365 */
366 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0560, Function | MediumTest | Level1)
367 {
368 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
369 uint32_t length = LENGTH_NUM_255;
370 uint8_t buffer[LENGTH_NUM_255] = { 0 };
371 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
372 struct UsbCtrlTransfer ctrlparmas = { 0b10000000, 0, 0, 0, 1000 };
373 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
374 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0560 %{public}d ret=%{public}d", __LINE__, ret);
375 ASSERT_NE(ret, 0);
376 }
377
378 /**
379 * @tc.name: SUB_USB_HDI_0570
380 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
381 * std::vector<uint8_t> &data);
382 * @tc.desc: Positive test: parameters correctly, standard request: get status(interface)
383 * @tc.type: FUNC
384 */
385 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0570, Function | MediumTest | Level1)
386 {
387 struct UsbDev dev = dev_;
388 uint32_t length = LENGTH_NUM_255;
389 uint8_t buffer[LENGTH_NUM_255] = { 0 };
390 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
391 struct UsbCtrlTransfer ctrlparmas = { 0b10000001, 0, 0, 0, 1000 };
392 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
393 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0570 %{public}d ret=%{public}d", __LINE__, ret);
394 ASSERT_EQ(0, ret);
395 }
396
397 /**
398 * @tc.name: SUB_USB_HDI_0580
399 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
400 * std::vector<uint8_t> &data);
401 * @tc.desc: Negative test: parameters exception, busNum error, standard request: get status(interface)
402 * @tc.type: FUNC
403 */
404 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0580, Function | MediumTest | Level1)
405 {
406 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
407 uint32_t length = LENGTH_NUM_255;
408 uint8_t buffer[LENGTH_NUM_255] = { 0 };
409 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
410 struct UsbCtrlTransfer ctrlparmas = { 0b10000001, 0, 0, 0, 1000 };
411 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
412 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0580 %{public}d ret=%{public}d", __LINE__, ret);
413 ASSERT_NE(ret, 0);
414 }
415
416 /**
417 * @tc.name: SUB_USB_HDI_0590
418 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
419 * std::vector<uint8_t> &data);
420 * @tc.desc: Negative test: parameters exception, devAddr error, standard request: get status(interface)
421 * @tc.type: FUNC
422 */
423 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0590, Function | MediumTest | Level1)
424 {
425 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
426 uint32_t length = LENGTH_NUM_255;
427 uint8_t buffer[LENGTH_NUM_255] = { 0 };
428 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
429 struct UsbCtrlTransfer ctrlparmas = { 0b10000001, 0, 0, 0, 1000 };
430 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
431 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0590 %{public}d ret=%{public}d", __LINE__, ret);
432 ASSERT_NE(ret, 0);
433 }
434
435 /**
436 * @tc.name: SUB_USB_HDI_0600
437 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
438 * std::vector<uint8_t> &data);
439 * @tc.desc: Positive test: parameters correctly, standard request: get status(endpoint)
440 * @tc.type: FUNC
441 */
442 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0600, Function | MediumTest | Level1)
443 {
444 struct UsbDev dev = dev_;
445 uint32_t length = LENGTH_NUM_255;
446 uint8_t buffer[LENGTH_NUM_255] = { 0 };
447 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
448 struct UsbCtrlTransfer ctrlparmas = { 0b10000010, 0, 0, 0, 1000 };
449 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
450 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0600 %{public}d ret=%{public}d", __LINE__, ret);
451 ASSERT_EQ(0, ret);
452 }
453
454 /**
455 * @tc.name: SUB_USB_HDI_0610
456 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
457 * std::vector<uint8_t> &data);
458 * @tc.desc: Negative test: parameters exception, busNum error, standard request: get status(endpoint)
459 * @tc.type: FUNC
460 */
461 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0610, Function | MediumTest | Level1)
462 {
463 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
464 uint32_t length = LENGTH_NUM_255;
465 uint8_t buffer[LENGTH_NUM_255] = { 0 };
466 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
467 struct UsbCtrlTransfer ctrlparmas = { 0b10000010, 0, 0, 0, 1000 };
468 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
469 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0610 %{public}d ret=%{public}d", __LINE__, ret);
470 ASSERT_NE(ret, 0);
471 }
472
473 /**
474 * @tc.name: SUB_USB_HDI_0620
475 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
476 * std::vector<uint8_t> &data);
477 * @tc.desc: Negative test: parameters exception, devAddr error, standard request: get status(endpoint)
478 * @tc.type: FUNC
479 */
480 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0620, Function | MediumTest | Level1)
481 {
482 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
483 uint32_t length = LENGTH_NUM_255;
484 uint8_t buffer[LENGTH_NUM_255] = { 0 };
485 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
486 struct UsbCtrlTransfer ctrlparmas = { 0b10000010, 0, 0, 0, 1000 };
487 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
488 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0620 %{public}d ret=%{public}d", __LINE__, ret);
489 ASSERT_NE(ret, 0);
490 }
491
492 /**
493 * @tc.name: SUB_USB_HDI_0630
494 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
495 * std::vector<uint8_t> &data);
496 * @tc.desc: Positive test: parameters correctly, standard request: sync frame
497 * @tc.type: FUNC
498 */
499 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0630, Function | MediumTest | Level1)
500 {
501 struct UsbDev dev = dev_;
502 uint32_t length = LENGTH_NUM_255;
503 uint8_t buffer[LENGTH_NUM_255] = {};
504 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
505 struct UsbCtrlTransfer ctrlparmas = { 0b10000010, 0X0C, 0, 0, 1000 };
506 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
507 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0630 %{public}d ret=%{public}d", __LINE__, ret);
508 ASSERT_EQ(0, ret);
509 }
510
511 /**
512 * @tc.name: SUB_USB_HDI_0640
513 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
514 * std::vector<uint8_t> &data);
515 * @tc.desc: Negative test: parameters exception, busNum error, standard request: sync frame
516 * @tc.type: FUNC
517 */
518 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0640, Function | MediumTest | Level1)
519 {
520 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
521 uint32_t length = LENGTH_NUM_255;
522 uint8_t buffer[LENGTH_NUM_255] = {};
523 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
524 struct UsbCtrlTransfer ctrlparmas = { 0b10000010, 0X0C, 0, 0, 1000 };
525 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
526 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0640 %{public}d ret=%{public}d", __LINE__, ret);
527 ASSERT_NE(ret, 0);
528 }
529
530 /**
531 * @tc.name: SUB_USB_HDI_0650
532 * @tc.desc: Test functions to ControlTransferRead(const UsbDev &dev, UsbCtrlTransfer &ctrl,
533 * std::vector<uint8_t> &data);
534 * @tc.desc: Negative test: parameters exception, devAddr error, standard request: sync frame
535 * @tc.type: FUNC
536 */
537 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0650, Function | MediumTest | Level1)
538 {
539 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
540 uint32_t length = LENGTH_NUM_255;
541 uint8_t buffer[LENGTH_NUM_255] = {};
542 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
543 struct UsbCtrlTransfer ctrlparmas = { 0b10000010, 0X0C, 0, 0, 1000 };
544 auto ret = g_usbInterface->ControlTransferRead(dev, ctrlparmas, bufferdata);
545 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0650 %{public}d ret=%{public}d", __LINE__, ret);
546 ASSERT_NE(ret, 0);
547 }
548
549 /**
550 * @tc.name: SUB_USB_HDI_1780
551 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
552 * const std::vector<uint8_t> &data);
553 * @tc.desc: Positive test: parameters correctly
554 * @tc.type: FUNC
555 */
556 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1780, Function | MediumTest | Level1)
557 {
558 struct UsbDev dev = dev_;
559 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
560 bufferdata.push_back(SAMPLE_DATA_1);
561 bufferdata.push_back(SAMPLE_DATA_2);
562 bufferdata.push_back(SAMPLE_DATA_3);
563 struct UsbCtrlTransfer ctrlparmas = { 0b0001, 8, 0, 0, 1000 };
564 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
565 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1780 %{public}d ret=%{public}d", __LINE__, ret);
566 ASSERT_EQ(0, ret);
567 }
568
569 /**
570 * @tc.name: SUB_USB_HDI_1790
571 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
572 * const std::vector<uint8_t> &data);
573 * @tc.desc: Negative test: parameters exception, busNum error
574 * @tc.type: FUNC
575 */
576 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1790, Function | MediumTest | Level1)
577 {
578 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
579 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
580 bufferdata.push_back(SAMPLE_DATA_1);
581 bufferdata.push_back(SAMPLE_DATA_2);
582 bufferdata.push_back(SAMPLE_DATA_3);
583 struct UsbCtrlTransfer ctrlparmas = { 0b0001, 8, 0, 0, 1000 };
584 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
585 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1790 %{public}d ret=%{public}d", __LINE__, ret);
586 ASSERT_NE(ret, 0);
587 }
588
589 /**
590 * @tc.name: SUB_USB_HDI_1800
591 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
592 * const std::vector<uint8_t> &data);
593 * @tc.desc: Negative test: parameters exception, devAddr error
594 * @tc.type: FUNC
595 */
596 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1800, Function | MediumTest | Level1)
597 {
598 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
599 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
600 bufferdata.push_back(SAMPLE_DATA_1);
601 bufferdata.push_back(SAMPLE_DATA_2);
602 bufferdata.push_back(SAMPLE_DATA_3);
603 struct UsbCtrlTransfer ctrlparmas = { 0b0001, 8, 0, 0, 1000 };
604 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
605 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1800 %{public}d ret=%{public}d", __LINE__, ret);
606 ASSERT_NE(ret, 0);
607 }
608
609 /**
610 * @tc.name: SUB_USB_HDI_1810
611 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
612 * const std::vector<uint8_t> &data);
613 * @tc.desc: Positive test: parameters correctly
614 * @tc.type: FUNC
615 */
616 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1810, Function | MediumTest | Level1)
617 {
618 struct UsbDev dev = dev_;
619 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
620 bufferdata.push_back(SAMPLE_DATA_1);
621 bufferdata.push_back(SAMPLE_DATA_2);
622 bufferdata.push_back(SAMPLE_DATA_3);
623 struct UsbCtrlTransfer ctrlparmas = { 0b0001, 6, 0x100, 0, 1000 };
624 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
625 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1810 %{public}d ret=%{public}d", __LINE__, ret);
626 ASSERT_EQ(0, ret);
627 }
628
629 /**
630 * @tc.name: SUB_USB_HDI_1820
631 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
632 * const std::vector<uint8_t> &data);
633 * @tc.desc: Negative test: parameters exception, busNum error
634 * @tc.type: FUNC
635 */
636 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1820, Function | MediumTest | Level1)
637 {
638 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
639 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
640 bufferdata.push_back(SAMPLE_DATA_1);
641 bufferdata.push_back(SAMPLE_DATA_2);
642 bufferdata.push_back(SAMPLE_DATA_3);
643 struct UsbCtrlTransfer ctrlparmas = { 0b0001, 6, 0x100, 0, 1000 };
644 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
645 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1820 %{public}d ret=%{public}d", __LINE__, ret);
646 ASSERT_NE(ret, 0);
647 }
648
649 /**
650 * @tc.name: SUB_USB_HDI_1830
651 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
652 * const std::vector<uint8_t> &data);
653 * @tc.desc: Negative test: parameters exception, devAddr error
654 * @tc.type: FUNC
655 */
656 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1830, Function | MediumTest | Level1)
657 {
658 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
659 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
660 bufferdata.push_back(SAMPLE_DATA_1);
661 bufferdata.push_back(SAMPLE_DATA_2);
662 bufferdata.push_back(SAMPLE_DATA_3);
663 struct UsbCtrlTransfer ctrlparmas = { 0b0001, 6, 0x100, 0, 1000 };
664 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
665 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1830 %{public}d ret=%{public}d", __LINE__, ret);
666 ASSERT_NE(ret, 0);
667 }
668
669 /**
670 * @tc.name: SUB_USB_HDI_1840
671 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
672 * const std::vector<uint8_t> &data);
673 * @tc.desc: Positive test: parameters correctly
674 * @tc.type: FUNC
675 */
676 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1840, Function | MediumTest | Level1)
677 {
678 struct UsbDev dev = dev_;
679 int32_t intercafeidex = 0;
680 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
681 bufferdata.push_back(SAMPLE_DATA_1);
682 bufferdata.push_back(SAMPLE_DATA_2);
683 bufferdata.push_back(SAMPLE_DATA_3);
684 struct UsbCtrlTransfer ctrlparmas = { 0, 0X0A, 0, intercafeidex, 1000 };
685 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
686 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1840 %{public}d ret=%{public}d", __LINE__, ret);
687 ASSERT_EQ(0, ret);
688 }
689
690 /**
691 * @tc.name: SUB_USB_HDI_1850
692 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
693 * const std::vector<uint8_t> &data);
694 * @tc.desc: Negative test: parameters exception, busNum error
695 * @tc.type: FUNC
696 */
697 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1850, Function | MediumTest | Level1)
698 {
699 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
700 int32_t intercafeidex = 0;
701 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
702 bufferdata.push_back(SAMPLE_DATA_1);
703 bufferdata.push_back(SAMPLE_DATA_2);
704 bufferdata.push_back(SAMPLE_DATA_3);
705 struct UsbCtrlTransfer ctrlparmas = { 0, 0X0A, 0, intercafeidex, 1000 };
706 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
707 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1850 %{public}d ret=%{public}d", __LINE__, ret);
708 ASSERT_NE(ret, 0);
709 }
710
711 /**
712 * @tc.name: SUB_USB_HDI_1860
713 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
714 * const std::vector<uint8_t> &data);
715 * @tc.desc: Negative test: parameters exception, devAddr error
716 * @tc.type: FUNC
717 */
718 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1860, Function | MediumTest | Level1)
719 {
720 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
721 int32_t intercafeidex = 0;
722 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
723 bufferdata.push_back(SAMPLE_DATA_1);
724 bufferdata.push_back(SAMPLE_DATA_2);
725 bufferdata.push_back(SAMPLE_DATA_3);
726 struct UsbCtrlTransfer ctrlparmas = { 0, 0X0A, 0, intercafeidex, 1000 };
727 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
728 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1860 %{public}d ret=%{public}d", __LINE__, ret);
729 ASSERT_NE(ret, 0);
730 }
731
732 /**
733 * @tc.name: SUB_USB_HDI_1870
734 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
735 * const std::vector<uint8_t> &data);
736 * @tc.desc: Positive test: parameters correctly
737 * @tc.type: FUNC
738 */
739 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1870, Function | MediumTest | Level1)
740 {
741 struct UsbDev dev = dev_;
742 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
743 bufferdata.push_back(SAMPLE_DATA_1);
744 bufferdata.push_back(SAMPLE_DATA_2);
745 bufferdata.push_back(SAMPLE_DATA_3);
746 struct UsbCtrlTransfer ctrlparmas = { 0b0001, 0, 0, 0, 1000 };
747 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
748 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1870 %{public}d ret=%{public}d", __LINE__, ret);
749 ASSERT_EQ(0, ret);
750 }
751
752 /**
753 * @tc.name: SUB_USB_HDI_1880
754 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
755 * const std::vector<uint8_t> &data);
756 * @tc.desc: Negative test: parameters exception, busNum error
757 * @tc.type: FUNC
758 */
759 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1880, Function | MediumTest | Level1)
760 {
761 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
762 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
763 bufferdata.push_back(SAMPLE_DATA_1);
764 bufferdata.push_back(SAMPLE_DATA_2);
765 bufferdata.push_back(SAMPLE_DATA_3);
766 struct UsbCtrlTransfer ctrlparmas = { 0b0001, 0, 0, 0, 1000 };
767 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
768 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1880 %{public}d ret=%{public}d", __LINE__, ret);
769 ASSERT_NE(ret, 0);
770 }
771
772 /**
773 * @tc.name: SUB_USB_HDI_1890
774 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
775 * const std::vector<uint8_t> &data);
776 * @tc.desc: Negative test: parameters exception, devAddr error
777 * @tc.type: FUNC
778 */
779 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1890, Function | MediumTest | Level1)
780 {
781 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
782 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
783 bufferdata.push_back(SAMPLE_DATA_1);
784 bufferdata.push_back(SAMPLE_DATA_2);
785 bufferdata.push_back(SAMPLE_DATA_3);
786 struct UsbCtrlTransfer ctrlparmas = { 0b0001, 0, 0, 0, 1000 };
787 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
788 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1890 %{public}d ret=%{public}d", __LINE__, ret);
789 ASSERT_NE(ret, 0);
790 }
791
792 /**
793 * @tc.name: SUB_USB_HDI_1900
794 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
795 * const std::vector<uint8_t> &data);
796 * @tc.desc: Positive test: parameters correctly
797 * @tc.type: FUNC
798 */
799 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1900, Function | MediumTest | Level1)
800 {
801 struct UsbDev dev = dev_;
802 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
803 bufferdata.push_back(SAMPLE_DATA_1);
804 bufferdata.push_back(SAMPLE_DATA_2);
805 bufferdata.push_back(SAMPLE_DATA_3);
806 struct UsbCtrlTransfer ctrlparmas = { 0b0, 0, 0, 0, 1000 };
807 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
808 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1900 %{public}d ret=%{public}d", __LINE__, ret);
809 ASSERT_EQ(0, ret);
810 }
811
812 /**
813 * @tc.name: SUB_USB_HDI_1910
814 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
815 * const std::vector<uint8_t> &data);
816 * @tc.desc: Negative test: parameters exception, busNum error
817 * @tc.type: FUNC
818 */
819 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1910, Function | MediumTest | Level1)
820 {
821 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
822 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
823 bufferdata.push_back(SAMPLE_DATA_1);
824 bufferdata.push_back(SAMPLE_DATA_2);
825 bufferdata.push_back(SAMPLE_DATA_3);
826 struct UsbCtrlTransfer ctrlparmas = { 0b0, 0, 0, 0, 1000 };
827 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
828 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1910 %{public}d ret=%{public}d", __LINE__, ret);
829 ASSERT_NE(ret, 0);
830 }
831
832 /**
833 * @tc.name: SUB_USB_HDI_1920
834 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
835 * const std::vector<uint8_t> &data);
836 * @tc.desc: Negative test: parameters exception, devAddr error
837 * @tc.type: FUNC
838 */
839 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1920, Function | MediumTest | Level1)
840 {
841 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
842 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
843 bufferdata.push_back(SAMPLE_DATA_1);
844 bufferdata.push_back(SAMPLE_DATA_2);
845 bufferdata.push_back(SAMPLE_DATA_3);
846 struct UsbCtrlTransfer ctrlparmas = { 0b0, 0, 0, 0, 1000 };
847 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
848 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1920 %{public}d ret=%{public}d", __LINE__, ret);
849 ASSERT_NE(ret, 0);
850 }
851
852 /**
853 * @tc.name: SUB_USB_HDI_1930
854 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
855 * const std::vector<uint8_t> &data);
856 * @tc.desc: Positive test: parameters correctly
857 * @tc.type: FUNC
858 */
859 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1930, Function | MediumTest | Level1)
860 {
861 struct UsbDev dev = dev_;
862 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
863 bufferdata.push_back(SAMPLE_DATA_1);
864 bufferdata.push_back(SAMPLE_DATA_2);
865 bufferdata.push_back(SAMPLE_DATA_3);
866 struct UsbCtrlTransfer ctrlparmas = { 0b0010, 0, 0, 0, 1000 };
867 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
868 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1930 %{public}d ret=%{public}d", __LINE__, ret);
869 ASSERT_EQ(0, ret);
870 }
871
872 /**
873 * @tc.name: SUB_USB_HDI_1940
874 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
875 * const std::vector<uint8_t> &data);
876 * @tc.desc: Negative test: parameters exception, busNum error
877 * @tc.type: FUNC
878 */
879 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1940, Function | MediumTest | Level1)
880 {
881 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
882 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
883 bufferdata.push_back(SAMPLE_DATA_1);
884 bufferdata.push_back(SAMPLE_DATA_2);
885 bufferdata.push_back(SAMPLE_DATA_3);
886 struct UsbCtrlTransfer ctrlparmas = { 0b0010, 0, 0, 0, 1000 };
887 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
888 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1940 %{public}d ret=%{public}d", __LINE__, ret);
889 ASSERT_NE(ret, 0);
890 }
891
892 /**
893 * @tc.name: SUB_USB_HDI_1950
894 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
895 * const std::vector<uint8_t> &data);
896 * @tc.desc: Negative test: parameters exception, devAddr error
897 * @tc.type: FUNC
898 */
899 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1950, Function | MediumTest | Level1)
900 {
901 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
902 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
903 bufferdata.push_back(SAMPLE_DATA_1);
904 bufferdata.push_back(SAMPLE_DATA_2);
905 bufferdata.push_back(SAMPLE_DATA_3);
906 struct UsbCtrlTransfer ctrlparmas = { 0b0010, 0, 0, 0, 1000 };
907 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
908 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1950 %{public}d ret=%{public}d", __LINE__, ret);
909 ASSERT_NE(ret, 0);
910 }
911
912 /**
913 * @tc.name: SUB_USB_HDI_1960
914 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
915 * const std::vector<uint8_t> &data);
916 * @tc.desc: Positive test: parameters correctly
917 * @tc.type: FUNC
918 */
919 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1960, Function | MediumTest | Level1)
920 {
921 struct UsbDev dev = dev_;
922 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
923 bufferdata.push_back(SAMPLE_DATA_1);
924 bufferdata.push_back(SAMPLE_DATA_2);
925 bufferdata.push_back(SAMPLE_DATA_3);
926 struct UsbCtrlTransfer ctrlparmas = { 0b0010, 0X0C, 0, 0, 1000 };
927 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
928 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1960 %{public}d ret=%{public}d", __LINE__, ret);
929 ASSERT_EQ(0, ret);
930 }
931
932 /**
933 * @tc.name: SUB_USB_HDI_1970
934 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
935 * const std::vector<uint8_t> &data);
936 * @tc.desc: Negative test: parameters exception, busNum error
937 * @tc.type: FUNC
938 */
939 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1970, Function | MediumTest | Level1)
940 {
941 struct UsbDev dev = { BUS_NUM_255, dev_.devAddr };
942 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
943 bufferdata.push_back(SAMPLE_DATA_1);
944 bufferdata.push_back(SAMPLE_DATA_2);
945 bufferdata.push_back(SAMPLE_DATA_3);
946 struct UsbCtrlTransfer ctrlparmas = { 0b0010, 0X0C, 0, 0, 1000 };
947 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
948 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1970 %{public}d ret=%{public}d", __LINE__, ret);
949 ASSERT_NE(ret, 0);
950 }
951
952 /**
953 * @tc.name: SUB_USB_HDI_1980
954 * @tc.desc: Test functions to ControlTransferWrite(const UsbDev &dev, const UsbCtrlTransfer &ctrl,
955 * const std::vector<uint8_t> &data);
956 * @tc.desc: Negative test: parameters exception, devAddr error
957 * @tc.type: FUNC
958 */
959 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1980, Function | MediumTest | Level1)
960 {
961 struct UsbDev dev = { dev_.busNum, DEV_ADDR_255 };
962 std::vector<uint8_t> bufferdata(LENGTH_NUM_255);
963 bufferdata.push_back(SAMPLE_DATA_1);
964 bufferdata.push_back(SAMPLE_DATA_2);
965 bufferdata.push_back(SAMPLE_DATA_3);
966 struct UsbCtrlTransfer ctrlparmas = { 0b0010, 0X0C, 0, 0, 1000 };
967 auto ret = g_usbInterface->ControlTransferWrite(dev, ctrlparmas, bufferdata);
968 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1980 %{public}d ret=%{public}d", __LINE__, ret);
969 ASSERT_NE(ret, 0);
970 }
971
972 /**
973 * @tc.name: SUB_USB_HDI_0660
974 * @tc.desc: Test functions to BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
975 * std::vector<uint8_t> &data);
976 * @tc.desc: Positive test: parameters correctly
977 * @tc.type: FUNC
978 */
979 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0660, Function | MediumTest | Level1)
980 {
981 struct UsbDev dev = dev_;
982 uint8_t interfaceId = INTERFACEID_1;
983 uint8_t pointid = POINTID_BULK_IN;
984 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
985 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0660 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
986 ASSERT_EQ(0, ret);
987 uint8_t buffer[LENGTH_NUM_255] = { 0 };
988 uint32_t length = LENGTH_NUM_255;
989 struct UsbPipe pipe = { interfaceId, pointid };
990 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
991 ret = g_usbInterface->BulkTransferRead(dev, pipe, 1000, bufferdata);
992 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0660 %{public}d UsbdBulkTransferRead=%{public}d", __LINE__, ret);
993 ASSERT_EQ(0, ret);
994 }
995
996 /**
997 * @tc.name: SUB_USB_HDI_0670
998 * @tc.desc: Test functions to BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
999 * std::vector<uint8_t> &data);
1000 * @tc.desc: Negative test: parameters exception, busNum error
1001 * @tc.type: FUNC
1002 */
1003 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0670, Function | MediumTest | Level1)
1004 {
1005 struct UsbDev dev = dev_;
1006 uint8_t interfaceId = INTERFACEID_1;
1007 uint8_t pointid = POINTID_BULK_IN;
1008 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1009 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0670 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1010 ASSERT_EQ(0, ret);
1011 dev.busNum = BUS_NUM_222;
1012 uint32_t length = 100;
1013 uint8_t buffer[100] = { 0 };
1014 struct UsbPipe pipe = { interfaceId, pointid };
1015 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1016 ret = g_usbInterface->BulkTransferRead(dev, pipe, 1000, bufferdata);
1017 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0670 %{public}d UsbdBulkTransferRead=%{public}d", __LINE__, ret);
1018 ASSERT_NE(ret, 0);
1019 }
1020
1021 /**
1022 * @tc.name: SUB_USB_HDI_0680
1023 * @tc.desc: Test functions to BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1024 * std::vector<uint8_t> &data);
1025 * @tc.desc: Negative test: parameters exception, devAddr error
1026 * @tc.type: FUNC
1027 */
1028 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0680, Function | MediumTest | Level1)
1029 {
1030 struct UsbDev dev = dev_;
1031 uint8_t interfaceId = INTERFACEID_1;
1032 uint8_t pointid = POINTID_BULK_IN;
1033 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1034 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0680 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1035 ASSERT_EQ(0, ret);
1036 dev.devAddr = DEV_ADDR_244;
1037 uint32_t length = 100;
1038 uint8_t buffer[100] = { 0 };
1039 struct UsbPipe pipe = { interfaceId, pointid };
1040 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1041 ret = g_usbInterface->BulkTransferRead(dev, pipe, 1000, bufferdata);
1042 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0680 %{public}d UsbdBulkTransferRead=%{public}d", __LINE__, ret);
1043 ASSERT_NE(ret, 0);
1044 }
1045
1046 /**
1047 * @tc.name: SUB_USB_HDI_0690
1048 * @tc.desc: Test functions to BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1049 * std::vector<uint8_t> &data);
1050 * @tc.desc: Negative test: parameters exception, intfId error
1051 * @tc.type: FUNC
1052 */
1053 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0690, Function | MediumTest | Level1)
1054 {
1055 struct UsbDev dev = dev_;
1056 uint8_t interfaceId = INTERFACEID_1;
1057 uint8_t pointid = POINTID_BULK_IN;
1058 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1059 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0690 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1060 ASSERT_EQ(0, ret);
1061 uint8_t buffer[100] = { 0 };
1062 uint32_t length = 100;
1063 struct UsbPipe pipe = { interfaceId, pointid };
1064 pipe.intfId = PIPE_INTERFACEID_244;
1065 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1066 ret = g_usbInterface->BulkTransferRead(dev, pipe, 1000, bufferdata);
1067 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0690 %{public}d UsbdBulkTransferRead=%{public}d", __LINE__, ret);
1068 ASSERT_NE(ret, 0);
1069 }
1070
1071 /**
1072 * @tc.name: SUB_USB_HDI_0700
1073 * @tc.desc: Test functions to BulkTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1074 * std::vector<uint8_t> &data);
1075 * @tc.desc: Negative test: parameters exception, endpointId error
1076 * @tc.type: FUNC
1077 */
1078 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0700, Function | MediumTest | Level1)
1079 {
1080 struct UsbDev dev = dev_;
1081 uint8_t interfaceId = INTERFACEID_1;
1082 uint8_t pointid = POINTID_BULK_IN;
1083 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1084 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0700 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1085 ASSERT_EQ(0, ret);
1086 uint32_t length = 100;
1087 uint8_t buffer[100] = {};
1088 struct UsbPipe pipe = { interfaceId, pointid };
1089 pipe.endpointId = PIPE_ENDPOINTID_244;
1090 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1091 ret = g_usbInterface->BulkTransferRead(dev, pipe, 1000, bufferdata);
1092 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0700 %{public}d UsbdBulkTransferRead=%{public}d", __LINE__, ret);
1093 ASSERT_NE(ret, 0);
1094 }
1095
1096 /**
1097 * @tc.name: SUB_USB_HDI_0710
1098 * @tc.desc: Test functions to BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1099 * std::vector<uint8_t> &data);
1100 * @tc.desc: Positive test: parameters correctly
1101 * @tc.type: FUNC
1102 */
1103 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0710, Function | MediumTest | Level1)
1104 {
1105 struct UsbDev dev = dev_;
1106 uint8_t interfaceId = INTERFACEID_1;
1107 uint8_t pointid = POINTID_1;
1108 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1109 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0710 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1110 ASSERT_EQ(0, ret);
1111 uint32_t length = 100;
1112 uint8_t buffer[100] = "hello world bulk writ01";
1113 struct UsbPipe pipe = { interfaceId, pointid };
1114 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1115 ret = g_usbInterface->BulkTransferWrite(dev, pipe, 1000, bufferdata);
1116 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0710 %{public}d BulkTransferWrite=%{public}d", __LINE__, ret);
1117 ASSERT_EQ(0, ret);
1118 }
1119
1120 /**
1121 * @tc.name: SUB_USB_HDI_0720
1122 * @tc.desc: Test functions to BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1123 * std::vector<uint8_t> &data);
1124 * @tc.desc: Negative test: parameters exception, busNum error
1125 * @tc.type: FUNC
1126 */
1127 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0720, Function | MediumTest | Level1)
1128 {
1129 struct UsbDev dev = dev_;
1130 uint8_t interfaceId = INTERFACEID_1;
1131 uint8_t pointid = POINTID_1;
1132 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1133 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0720 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1134 ASSERT_EQ(0, ret);
1135 struct UsbPipe pipe = { interfaceId, pointid };
1136 dev.busNum = BUS_NUM_99;
1137 uint32_t length = 100;
1138 uint8_t buffer[100] = "hello world bulk writ02";
1139 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1140 ret = g_usbInterface->BulkTransferWrite(dev, pipe, 1000, bufferdata);
1141 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0720 %{public}d BulkTransferWrite=%{public}d", __LINE__, ret);
1142 ASSERT_NE(ret, 0);
1143 }
1144
1145 /**
1146 * @tc.name: SUB_USB_HDI_0730
1147 * @tc.desc: Test functions to BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1148 * std::vector<uint8_t> &data);
1149 * @tc.desc: Negative test: parameters exception, devAddr error
1150 * @tc.type: FUNC
1151 */
1152 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0730, Function | MediumTest | Level1)
1153 {
1154 struct UsbDev dev = dev_;
1155 uint8_t interfaceId = INTERFACEID_1;
1156 uint8_t pointid = POINTID_1;
1157 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1158 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0730 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1159 ASSERT_EQ(0, ret);
1160 dev.devAddr = DEV_ADDR_244;
1161 uint32_t length = 100;
1162 uint8_t buffer[100] = "hello world bulk writ03";
1163 struct UsbPipe pipe = { interfaceId, pointid };
1164 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1165 ret = g_usbInterface->BulkTransferWrite(dev, pipe, 1000, bufferdata);
1166 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0730 %{public}d BulkTransferWrite=%{public}d", __LINE__, ret);
1167 ASSERT_NE(ret, 0);
1168 }
1169
1170 /**
1171 * @tc.name: SUB_USB_HDI_0740
1172 * @tc.desc: Test functions to BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1173 * std::vector<uint8_t> &data);
1174 * @tc.desc: Negative test: parameters exception, intfId error
1175 * @tc.type: FUNC
1176 */
1177 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0740, Function | MediumTest | Level1)
1178 {
1179 struct UsbDev dev = dev_;
1180 uint8_t interfaceId = INTERFACEID_1;
1181 uint8_t pointid = POINTID_1;
1182 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1183 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0740 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1184 ASSERT_EQ(0, ret);
1185 struct UsbPipe pipe = { interfaceId, pointid };
1186 pipe.intfId = PIPE_INTERFACEID_255;
1187 uint32_t length = 100;
1188 uint8_t buffer[100] = "hello world bulk writ04";
1189 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1190 ret = g_usbInterface->BulkTransferWrite(dev, pipe, 1000, bufferdata);
1191 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0740 %{public}d BulkTransferWrite=%{public}d", __LINE__, ret);
1192 ASSERT_NE(ret, 0);
1193 }
1194
1195 /**
1196 * @tc.name: SUB_USB_HDI_0750
1197 * @tc.desc: Test functions to BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1198 * std::vector<uint8_t> &data);
1199 * @tc.desc: Negative test: parameters exception, endpointId error
1200 * @tc.type: FUNC
1201 */
1202 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0750, Function | MediumTest | Level1)
1203 {
1204 struct UsbDev dev = dev_;
1205 uint8_t interfaceId = INTERFACEID_1;
1206 uint8_t pointid = POINTID_1;
1207 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1208 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0750 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1209 ASSERT_EQ(0, ret);
1210 struct UsbPipe pipe = { interfaceId, pointid };
1211 pipe.endpointId = PIPE_ENDPOINTID_255;
1212 uint32_t length = 100;
1213 uint8_t buffer[100] = "hello world bulk writ05";
1214 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1215 ret = g_usbInterface->BulkTransferWrite(dev, pipe, 1000, bufferdata);
1216 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0750 %{public}d BulkTransferWrite=%{public}d", __LINE__, ret);
1217 ASSERT_NE(ret, 0);
1218 }
1219
1220 /**
1221 * @tc.name: SUB_USB_HDI_0760
1222 * @tc.desc: Test functions to BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1223 * std::vector<uint8_t> &data);
1224 * @tc.desc: Negative test: parameters exception, busNum && devAddr error
1225 * @tc.type: FUNC
1226 */
1227 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0760, Function | MediumTest | Level1)
1228 {
1229 struct UsbDev dev = dev_;
1230 uint8_t interfaceId = INTERFACEID_1;
1231 uint8_t pointid = POINTID_1;
1232 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1233 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0760 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1234 ASSERT_EQ(0, ret);
1235 struct UsbPipe pipe = { interfaceId, pointid };
1236 dev.busNum = BUS_NUM_99;
1237 dev.devAddr = DEV_ADDR_99;
1238 uint32_t length = 100;
1239 uint8_t buffer[100] = "hello world bulk writ06";
1240 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1241 ret = g_usbInterface->BulkTransferWrite(dev, pipe, 1000, bufferdata);
1242 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0760 %{public}d BulkTransferWrite=%{public}d", __LINE__, ret);
1243 ASSERT_NE(ret, 0);
1244 }
1245
1246 /**
1247 * @tc.name: SUB_USB_HDI_0770
1248 * @tc.desc: Test functions to BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1249 * std::vector<uint8_t> &data);
1250 * @tc.desc: Negative test: parameters exception, ClaimInterface failed first
1251 * @tc.type: FUNC
1252 */
1253 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0770, Function | MediumTest | Level1)
1254 {
1255 struct UsbDev dev = dev_;
1256 uint8_t interfaceId = INTERFACEID_1;
1257 uint8_t pointid = POINTID_99;
1258 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1259 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0770 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1260 ASSERT_EQ(0, ret);
1261 struct UsbPipe pipe = { interfaceId, pointid };
1262 uint32_t length = 100;
1263 uint8_t buffer[100] = "hello world bulk writ07";
1264 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1265 ret = g_usbInterface->BulkTransferWrite(dev, pipe, 1000, bufferdata);
1266 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0770 %{public}d BulkTransferWrite=%{public}d", __LINE__, ret);
1267 ASSERT_NE(ret, 0);
1268 }
1269
1270 /**
1271 * @tc.name: SUB_USB_HDI_0780
1272 * @tc.desc: Test functions to BulkTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1273 * std::vector<uint8_t> &data);
1274 * @tc.desc: Positive test: parameters correctly, different in timeout
1275 * @tc.type: FUNC
1276 */
1277 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_0780, Function | MediumTest | Level1)
1278 {
1279 struct UsbDev dev = dev_;
1280 uint8_t interfaceId = INTERFACEID_1;
1281 uint8_t pointid = POINTID_1;
1282 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1283 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0780 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1284 ASSERT_EQ(0, ret);
1285 struct UsbPipe pipe = { interfaceId, pointid };
1286 uint32_t length = 100;
1287 uint8_t buffer[100] = "hello world bulk writ08";
1288 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1289 ret = g_usbInterface->BulkTransferWrite(dev, pipe, -1, bufferdata);
1290 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_0780 %{public}d BulkTransferWrite=%{public}d", __LINE__, ret);
1291 ASSERT_EQ(0, ret);
1292 }
1293
1294 /**
1295 * @tc.name: SUB_USB_HDI_1440
1296 * @tc.desc: Test functions to InterruptTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1297 * std::vector<uint8_t> &data);
1298 * @tc.desc: Positive test: parameters correctly
1299 * @tc.type: FUNC
1300 */
1301 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1440, Function | MediumTest | Level1)
1302 {
1303 struct UsbDev dev = dev_;
1304 uint8_t interfaceId = INTERFACEID_1;
1305 uint8_t pointid = POINTID_129;
1306 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1307 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1440 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1308 ASSERT_EQ(0, ret);
1309 uint8_t buffer[LENGTH_NUM_255] = { 0 };
1310 uint32_t length = LENGTH_NUM_255;
1311 struct UsbPipe pipe = { interfaceId, pointid };
1312 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1313 ret = g_usbInterface->InterruptTransferRead(dev, pipe, 1000, bufferdata);
1314 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1440 %{public}d UsbdInterruptTransferRead=%{public}d", __LINE__, ret);
1315 ASSERT_EQ(0, ret);
1316 }
1317
1318 /**
1319 * @tc.name: SUB_USB_HDI_1450
1320 * @tc.desc: Test functions to InterruptTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1321 * std::vector<uint8_t> &data);
1322 * @tc.desc: Negative test: parameters exception, busNum error
1323 * @tc.type: FUNC
1324 */
1325 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1450, Function | MediumTest | Level1)
1326 {
1327 struct UsbDev dev = dev_;
1328 uint8_t interfaceId = INTERFACEID_1;
1329 uint8_t pointid = POINTID_129;
1330 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1331 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1450 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1332 ASSERT_EQ(0, ret);
1333 dev.busNum = BUS_NUM_222;
1334 uint32_t length = 100;
1335 uint8_t buffer[100] = { 0 };
1336 struct UsbPipe pipe = { interfaceId, pointid };
1337 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1338 ret = g_usbInterface->InterruptTransferRead(dev, pipe, 1000, bufferdata);
1339 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1450 %{public}d UsbdInterruptTransferRead=%{public}d", __LINE__, ret);
1340 ASSERT_NE(ret, 0);
1341 }
1342
1343 /**
1344 * @tc.name: SUB_USB_HDI_1460
1345 * @tc.desc: Test functions to InterruptTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1346 * std::vector<uint8_t> &data);
1347 * @tc.desc: Negative test: parameters exception, devAddr error
1348 * @tc.type: FUNC
1349 */
1350 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1460, Function | MediumTest | Level1)
1351 {
1352 struct UsbDev dev = dev_;
1353 uint8_t interfaceId = INTERFACEID_1;
1354 uint8_t pointid = POINTID_129;
1355 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1356 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1460 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1357 ASSERT_EQ(0, ret);
1358 dev.devAddr = DEV_ADDR_244;
1359 uint32_t length = 100;
1360 uint8_t buffer[100] = { 0 };
1361 struct UsbPipe pipe = { interfaceId, pointid };
1362 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1363 ret = g_usbInterface->InterruptTransferRead(dev, pipe, 1000, bufferdata);
1364 ASSERT_NE(ret, 0);
1365 }
1366
1367 /**
1368 * @tc.name: SUB_USB_HDI_1470
1369 * @tc.desc: Test functions to InterruptTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1370 * std::vector<uint8_t> &data);
1371 * @tc.desc: Negative test: parameters exception, intfId error
1372 * @tc.type: FUNC
1373 */
1374 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1470, Function | MediumTest | Level1)
1375 {
1376 struct UsbDev dev = dev_;
1377 uint8_t interfaceId = INTERFACEID_1;
1378 uint8_t pointid = POINTID_129;
1379 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1380 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1470 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1381 ASSERT_EQ(0, ret);
1382 uint8_t buffer[100] = { 0 };
1383 uint32_t length = 100;
1384 struct UsbPipe pipe = { interfaceId, pointid };
1385 pipe.intfId = PIPE_INTERFACEID_244;
1386 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1387 ret = g_usbInterface->InterruptTransferRead(dev, pipe, 1000, bufferdata);
1388 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1470 %{public}d UsbdInterruptTransferRead=%{public}d", __LINE__, ret);
1389 ASSERT_NE(ret, 0);
1390 }
1391
1392 /**
1393 * @tc.name: SUB_USB_HDI_1480
1394 * @tc.desc: Test functions to InterruptTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1395 * std::vector<uint8_t> &data);
1396 * @tc.desc: Negative test: parameters exception, endpointId error
1397 * @tc.type: FUNC
1398 */
1399 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1480, Function | MediumTest | Level1)
1400 {
1401 struct UsbDev dev = dev_;
1402 uint8_t interfaceId = INTERFACEID_1;
1403 uint8_t pointid = POINTID_129;
1404 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1405 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1480 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1406 ASSERT_EQ(0, ret);
1407 uint32_t length = 100;
1408 uint8_t buffer[100] = {};
1409 struct UsbPipe pipe = { interfaceId, pointid };
1410 pipe.endpointId = PIPE_ENDPOINTID_244;
1411 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1412 ret = g_usbInterface->InterruptTransferRead(dev, pipe, 1000, bufferdata);
1413 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1480 %{public}d UsbdInterruptTransferRead=%{public}d", __LINE__, ret);
1414 ASSERT_NE(ret, 0);
1415 }
1416
1417 /**
1418 * @tc.name: SUB_USB_HDI_1490
1419 * @tc.desc: Test functions to InterruptTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1420 * std::vector<uint8_t> &data);
1421 * @tc.desc: Positive test: parameters correctly
1422 * @tc.type: FUNC
1423 */
1424 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1490, Function | MediumTest | Level1)
1425 {
1426 struct UsbDev dev = dev_;
1427 uint8_t interfaceId = INTERFACEID_1;
1428 uint8_t pointid = POINTID_1;
1429 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1430 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1490 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1431 ASSERT_EQ(0, ret);
1432 uint32_t length = 100;
1433 uint8_t buffer[100] = "hello world Interrupt writ01";
1434 struct UsbPipe pipe = { interfaceId, pointid };
1435 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1436 ret = g_usbInterface->InterruptTransferWrite(dev, pipe, 1000, bufferdata);
1437 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1490 %{public}d InterruptTransferWrite=%{public}d", __LINE__, ret);
1438 ASSERT_EQ(0, ret);
1439 }
1440
1441 /**
1442 * @tc.name: SUB_USB_HDI_1500
1443 * @tc.desc: Test functions to InterruptTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1444 * std::vector<uint8_t> &data);
1445 * @tc.desc: Negative test: parameters exception, busNum error
1446 * @tc.type: FUNC
1447 */
1448 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1500, Function | MediumTest | Level1)
1449 {
1450 struct UsbDev dev = dev_;
1451 uint8_t interfaceId = INTERFACEID_1;
1452 uint8_t pointid = POINTID_1;
1453 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1454 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1500 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1455 ASSERT_EQ(0, ret);
1456 struct UsbPipe pipe = { interfaceId, pointid };
1457 dev.busNum = BUS_NUM_99;
1458 uint32_t length = 100;
1459 uint8_t buffer[100] = "hello world Interrupt writ02";
1460 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1461 ret = g_usbInterface->InterruptTransferWrite(dev, pipe, 1000, bufferdata);
1462 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1500 %{public}d InterruptTransferWrite=%{public}d", __LINE__, ret);
1463 ASSERT_NE(ret, 0);
1464 }
1465
1466 /**
1467 * @tc.name: SUB_USB_HDI_1510
1468 * @tc.desc: Test functions to InterruptTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1469 * std::vector<uint8_t> &data);
1470 * @tc.desc: Negative test: parameters exception, devAddr error
1471 * @tc.type: FUNC
1472 */
1473 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1510, Function | MediumTest | Level1)
1474 {
1475 struct UsbDev dev = dev_;
1476 uint8_t interfaceId = INTERFACEID_1;
1477 uint8_t pointid = POINTID_1;
1478 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1479 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1510 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1480 ASSERT_EQ(0, ret);
1481 dev.devAddr = DEV_ADDR_244;
1482 uint32_t length = 100;
1483 uint8_t buffer[100] = "hello world Interrupt writ03";
1484 struct UsbPipe pipe = { interfaceId, pointid };
1485 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1486 ret = g_usbInterface->InterruptTransferWrite(dev, pipe, 1000, bufferdata);
1487 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1510 %{public}d InterruptTransferWrite=%{public}d", __LINE__, ret);
1488 ASSERT_NE(ret, 0);
1489 }
1490
1491 /**
1492 * @tc.name: SUB_USB_HDI_1520
1493 * @tc.desc: Test functions to InterruptTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1494 * std::vector<uint8_t> &data);
1495 * @tc.desc: Negative test: parameters exception, intfId error
1496 * @tc.type: FUNC
1497 */
1498 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1520, Function | MediumTest | Level1)
1499 {
1500 struct UsbDev dev = dev_;
1501 uint8_t interfaceId = INTERFACEID_1;
1502 uint8_t pointid = POINTID_1;
1503 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1504 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1520 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1505 ASSERT_EQ(0, ret);
1506 struct UsbPipe pipe = { interfaceId, pointid };
1507 pipe.intfId = PIPE_INTERFACEID_255;
1508 uint32_t length = 100;
1509 uint8_t buffer[100] = "hello world Interrupt writ04";
1510 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1511 ret = g_usbInterface->InterruptTransferWrite(dev, pipe, 1000, bufferdata);
1512 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1520 %{public}d InterruptTransferWrite=%{public}d", __LINE__, ret);
1513 ASSERT_NE(ret, 0);
1514 }
1515
1516 /**
1517 * @tc.name: SUB_USB_HDI_1530
1518 * @tc.desc: Test functions to InterruptTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1519 * std::vector<uint8_t> &data);
1520 * @tc.desc: Negative test: parameters exception, endpointId error
1521 * @tc.type: FUNC
1522 */
1523 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1530, Function | MediumTest | Level1)
1524 {
1525 struct UsbDev dev = dev_;
1526 uint8_t interfaceId = INTERFACEID_1;
1527 uint8_t pointid = POINTID_1;
1528 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1529 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1530 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1530 ASSERT_EQ(0, ret);
1531 struct UsbPipe pipe = { interfaceId, pointid };
1532 pipe.endpointId = PIPE_ENDPOINTID_255;
1533 uint32_t length = 100;
1534 uint8_t buffer[100] = "hello world Interrupt writ05";
1535 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1536 ret = g_usbInterface->InterruptTransferWrite(dev, pipe, 1000, bufferdata);
1537 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1530 %{public}d InterruptTransferWrite=%{public}d", __LINE__, ret);
1538 ASSERT_NE(ret, 0);
1539 }
1540
1541 /**
1542 * @tc.name: SUB_USB_HDI_1540
1543 * @tc.desc: Test functions to InterruptTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1544 * std::vector<uint8_t> &data);
1545 * @tc.desc: Negative test: parameters exception, busNum && devAddr error
1546 * @tc.type: FUNC
1547 */
1548 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1540, Function | MediumTest | Level1)
1549 {
1550 struct UsbDev dev = dev_;
1551 uint8_t interfaceId = INTERFACEID_1;
1552 uint8_t pointid = POINTID_1;
1553 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1554 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1540 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1555 ASSERT_EQ(0, ret);
1556 struct UsbPipe pipe = { interfaceId, pointid };
1557 dev.busNum = BUS_NUM_99;
1558 dev.devAddr = DEV_ADDR_99;
1559 uint32_t length = 100;
1560 uint8_t buffer[100] = "hello world Interrupt writ06";
1561 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1562 ret = g_usbInterface->InterruptTransferWrite(dev, pipe, 1000, bufferdata);
1563 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1540 %{public}d InterruptTransferWrite=%{public}d", __LINE__, ret);
1564 ASSERT_NE(ret, 0);
1565 }
1566
1567 /**
1568 * @tc.name: SUB_USB_HDI_1550
1569 * @tc.desc: Test functions to InterruptTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1570 * std::vector<uint8_t> &data);
1571 * @tc.desc: Negative test: parameters exception, ClaimInterface failed first
1572 * @tc.type: FUNC
1573 */
1574 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1550, Function | MediumTest | Level1)
1575 {
1576 struct UsbDev dev = dev_;
1577 uint8_t interfaceId = INTERFACEID_1;
1578 uint8_t pointid = POINTID_99;
1579 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1580 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1550 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1581 ASSERT_EQ(0, ret);
1582 struct UsbPipe pipe = { interfaceId, pointid };
1583 uint32_t length = 100;
1584 uint8_t buffer[100] = "hello world Interrupt writ07";
1585 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1586 ret = g_usbInterface->InterruptTransferWrite(dev, pipe, 1000, bufferdata);
1587 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1550 %{public}d InterruptTransferWrite=%{public}d", __LINE__, ret);
1588 ASSERT_NE(ret, 0);
1589 }
1590
1591 /**
1592 * @tc.name: SUB_USB_HDI_1560
1593 * @tc.desc: Test functions to InterruptTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1594 * std::vector<uint8_t> &data);
1595 * Positive test: parameters correctly, different in timeout
1596 * @tc.type: FUNC
1597 */
1598 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1560, Function | MediumTest | Level1)
1599 {
1600 struct UsbDev dev = dev_;
1601 uint8_t interfaceId = INTERFACEID_1;
1602 uint8_t pointid = POINTID_1;
1603 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1604 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1560 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1605 ASSERT_EQ(0, ret);
1606 struct UsbPipe pipe = { interfaceId, pointid };
1607 uint32_t length = 100;
1608 uint8_t buffer[100] = "hello world Interrupt writ08";
1609 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1610 ret = g_usbInterface->InterruptTransferWrite(dev, pipe, -1, bufferdata);
1611 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1560 %{public}d InterruptTransferWrite=%{public}d", __LINE__, ret);
1612 ASSERT_EQ(0, ret);
1613 }
1614
1615 /**
1616 * @tc.name: SUB_USB_HDI_1570
1617 * @tc.desc: Test functions to IsoTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1618 * std::vector<uint8_t> &data);
1619 * @tc.desc: Positive test: parameters correctly
1620 * @tc.type: FUNC
1621 */
1622 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1570, Function | MediumTest | Level1)
1623 {
1624 struct UsbDev dev = dev_;
1625 uint8_t interfaceId = INTERFACEID_1;
1626 uint8_t pointid = POINTID_129;
1627 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1628 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1570 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1629 ASSERT_EQ(0, ret);
1630 uint8_t buffer[LENGTH_NUM_255] = { 0 };
1631 uint32_t length = LENGTH_NUM_255;
1632 struct UsbPipe pipe = { interfaceId, pointid };
1633 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1634 ret = g_usbInterface->IsoTransferRead(dev, pipe, 1000, bufferdata);
1635 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1570 %{public}d UsbdIsoTransferRead=%{public}d", __LINE__, ret);
1636 ASSERT_EQ(0, ret);
1637 }
1638
1639 /**
1640 * @tc.name: SUB_USB_HDI_1580
1641 * @tc.desc: Test functions to IsoTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1642 * std::vector<uint8_t> &data);
1643 * @tc.desc: Negative test: parameters exception, busNum error
1644 * @tc.type: FUNC
1645 */
1646 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1580, Function | MediumTest | Level1)
1647 {
1648 struct UsbDev dev = dev_;
1649 uint8_t interfaceId = INTERFACEID_1;
1650 uint8_t pointid = POINTID_129;
1651 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1580 %{public}d interfaceId=%{public}d", __LINE__, interfaceId);
1652 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1653 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1580 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1654 ASSERT_EQ(0, ret);
1655 dev.busNum = BUS_NUM_222;
1656 uint32_t length = 100;
1657 uint8_t buffer[100] = { 0 };
1658 struct UsbPipe pipe = { interfaceId, pointid };
1659 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1660 ret = g_usbInterface->IsoTransferRead(dev, pipe, 1000, bufferdata);
1661 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1580 %{public}d UsbdIsoTransferRead=%{public}d", __LINE__, ret);
1662 ASSERT_NE(ret, 0);
1663 }
1664
1665 /**
1666 * @tc.name: SUB_USB_HDI_1590
1667 * @tc.desc: Test functions to IsoTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1668 * std::vector<uint8_t> &data);
1669 * @tc.desc: Negative test: parameters exception, devAddr error
1670 * @tc.type: FUNC
1671 */
1672 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1590, Function | MediumTest | Level1)
1673 {
1674 struct UsbDev dev = dev_;
1675 uint8_t interfaceId = INTERFACEID_1;
1676 uint8_t pointid = POINTID_129;
1677 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1678 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1590 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1679 ASSERT_EQ(0, ret);
1680 dev.devAddr = DEV_ADDR_244;
1681 uint32_t length = 100;
1682 uint8_t buffer[100] = { 0 };
1683 struct UsbPipe pipe = { interfaceId, pointid };
1684 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1685 ret = g_usbInterface->IsoTransferRead(dev, pipe, 1000, bufferdata);
1686 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1590 %{public}d UsbdIsoTransferRead=%{public}d", __LINE__, ret);
1687 ASSERT_NE(ret, 0);
1688 }
1689
1690 /**
1691 * @tc.name: SUB_USB_HDI_1600
1692 * @tc.desc: Test functions to IsoTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1693 * std::vector<uint8_t> &data);
1694 * @tc.desc: Negative test: parameters exception, intfId error
1695 * @tc.type: FUNC
1696 */
1697 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1600, Function | MediumTest | Level1)
1698 {
1699 struct UsbDev dev = dev_;
1700 uint8_t interfaceId = INTERFACEID_1;
1701 uint8_t pointid = POINTID_129;
1702 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1703 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1600 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1704 ASSERT_EQ(0, ret);
1705 uint8_t buffer[100] = { 0 };
1706 uint32_t length = 100;
1707 struct UsbPipe pipe = { interfaceId, pointid };
1708 pipe.intfId = PIPE_INTERFACEID_244;
1709 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1710 ret = g_usbInterface->IsoTransferRead(dev, pipe, 1000, bufferdata);
1711 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1600 %{public}d UsbdIsoTransferRead=%{public}d", __LINE__, ret);
1712 ASSERT_NE(ret, 0);
1713 }
1714
1715 /**
1716 * @tc.name: SUB_USB_HDI_1610
1717 * @tc.desc: Test functions to IsoTransferRead(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1718 * std::vector<uint8_t> &data);
1719 * @tc.desc: Negative test: parameters exception, endpointId error
1720 * @tc.type: FUNC
1721 */
1722 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1610, Function | MediumTest | Level1)
1723 {
1724 struct UsbDev dev = dev_;
1725 uint8_t interfaceId = INTERFACEID_1;
1726 uint8_t pointid = POINTID_129;
1727 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1728 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1610 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1729 ASSERT_EQ(0, ret);
1730 uint32_t length = 100;
1731 uint8_t buffer[100] = {};
1732 struct UsbPipe pipe = { interfaceId, pointid };
1733 pipe.endpointId = PIPE_ENDPOINTID_244;
1734 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1735 ret = g_usbInterface->IsoTransferRead(dev, pipe, 1000, bufferdata);
1736 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1610 %{public}d UsbdIsoTransferRead=%{public}d", __LINE__, ret);
1737 ASSERT_NE(ret, 0);
1738 }
1739
1740 /**
1741 * @tc.name: SUB_USB_HDI_1620
1742 * @tc.desc: Test functions to IsoTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1743 * std::vector<uint8_t> &data);
1744 * @tc.desc: Positive test: parameters correctly
1745 * @tc.type: FUNC
1746 */
1747 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1620, Function | MediumTest | Level1)
1748 {
1749 struct UsbDev dev = dev_;
1750 uint8_t interfaceId = INTERFACEID_1;
1751 uint8_t pointid = POINTID_1;
1752 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1753 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1620 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1754 ASSERT_EQ(0, ret);
1755 uint32_t length = 100;
1756 uint8_t buffer[100] = "hello world Iso writ01";
1757 struct UsbPipe pipe = { interfaceId, pointid };
1758 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1759 ret = g_usbInterface->IsoTransferWrite(dev, pipe, 1000, bufferdata);
1760 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1620 %{public}d IsoTransferWrite=%{public}d", __LINE__, ret);
1761 ASSERT_EQ(0, ret);
1762 }
1763
1764 /**
1765 * @tc.name: SUB_USB_HDI_1630
1766 * @tc.desc: Test functions to IsoTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1767 * std::vector<uint8_t> &data);
1768 * @tc.desc: Negative test: parameters exception, busNum error
1769 * @tc.type: FUNC
1770 */
1771 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1630, Function | MediumTest | Level1)
1772 {
1773 struct UsbDev dev = dev_;
1774 uint8_t interfaceId = INTERFACEID_1;
1775 uint8_t pointid = POINTID_1;
1776 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1777 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1630 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1778 ASSERT_EQ(0, ret);
1779 struct UsbPipe pipe = { interfaceId, pointid };
1780 dev.busNum = BUS_NUM_99;
1781 uint32_t length = 100;
1782 uint8_t buffer[100] = "hello world Iso writ02";
1783 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1784 ret = g_usbInterface->IsoTransferWrite(dev, pipe, 1000, bufferdata);
1785 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1630 %{public}d IsoTransferWrite=%{public}d", __LINE__, ret);
1786 ASSERT_NE(ret, 0);
1787 }
1788
1789 /**
1790 * @tc.name: SUB_USB_HDI_1640
1791 * @tc.desc: Test functions to IsoTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1792 * std::vector<uint8_t> &data);
1793 * @tc.desc: Negative test: parameters exception, devAddr error
1794 * @tc.type: FUNC
1795 */
1796 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1640, Function | MediumTest | Level1)
1797 {
1798 struct UsbDev dev = dev_;
1799 uint8_t interfaceId = INTERFACEID_1;
1800 uint8_t pointid = POINTID_1;
1801 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1802 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1640 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1803 ASSERT_EQ(0, ret);
1804 dev.devAddr = DEV_ADDR_244;
1805 uint32_t length = 100;
1806 uint8_t buffer[100] = "hello world Iso writ03";
1807 struct UsbPipe pipe = { interfaceId, pointid };
1808 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1809 ret = g_usbInterface->IsoTransferWrite(dev, pipe, 1000, bufferdata);
1810 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1640 %{public}d IsoTransferWrite=%{public}d", __LINE__, ret);
1811 ASSERT_NE(ret, 0);
1812 }
1813
1814 /**
1815 * @tc.name: SUB_USB_HDI_1650
1816 * @tc.desc: Test functions to IsoTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1817 * std::vector<uint8_t> &data);
1818 * @tc.desc: Negative test: parameters exception, intfId error
1819 * @tc.type: FUNC
1820 */
1821 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1650, Function | MediumTest | Level1)
1822 {
1823 struct UsbDev dev = dev_;
1824 uint8_t interfaceId = INTERFACEID_1;
1825 uint8_t pointid = POINTID_1;
1826 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1827 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1650 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1828 ASSERT_EQ(0, ret);
1829 struct UsbPipe pipe = { interfaceId, pointid };
1830 pipe.intfId = PIPE_INTERFACEID_255;
1831 uint32_t length = 100;
1832 uint8_t buffer[100] = "hello world Iso writ04";
1833 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1834 ret = g_usbInterface->IsoTransferWrite(dev, pipe, 1000, bufferdata);
1835 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1650 %{public}d IsoTransferWrite=%{public}d", __LINE__, ret);
1836 ASSERT_NE(ret, 0);
1837 }
1838
1839 /**
1840 * @tc.name: SUB_USB_HDI_1660
1841 * @tc.desc: Test functions to IsoTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1842 * std::vector<uint8_t> &data);
1843 * @tc.desc: Negative test: parameters exception, endpointId error
1844 * @tc.type: FUNC
1845 */
1846 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1660, Function | MediumTest | Level1)
1847 {
1848 struct UsbDev dev = dev_;
1849 uint8_t interfaceId = INTERFACEID_1;
1850 uint8_t pointid = POINTID_1;
1851 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1852 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1660 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1853 ASSERT_EQ(0, ret);
1854 struct UsbPipe pipe = { interfaceId, pointid };
1855 pipe.endpointId = PIPE_ENDPOINTID_255;
1856 uint32_t length = 100;
1857 uint8_t buffer[100] = "hello world Iso writ05";
1858 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1859 ret = g_usbInterface->IsoTransferWrite(dev, pipe, 1000, bufferdata);
1860 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1660 %{public}d IsoTransferWrite=%{public}d", __LINE__, ret);
1861 ASSERT_NE(ret, 0);
1862 }
1863
1864 /**
1865 * @tc.name: SUB_USB_HDI_1670
1866 * @tc.desc: Test functions to IsoTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1867 * std::vector<uint8_t> &data);
1868 * @tc.desc: Negative test: parameters exception, busNum && devAddr error
1869 * @tc.type: FUNC
1870 */
1871 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1670, Function | MediumTest | Level1)
1872 {
1873 struct UsbDev dev = dev_;
1874 uint8_t interfaceId = INTERFACEID_1;
1875 uint8_t pointid = POINTID_1;
1876 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1877 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1670 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1878 ASSERT_EQ(0, ret);
1879 struct UsbPipe pipe = { interfaceId, pointid };
1880 dev.busNum = BUS_NUM_99;
1881 dev.devAddr = DEV_ADDR_99;
1882 uint32_t length = 100;
1883 uint8_t buffer[100] = "hello world Iso writ06";
1884 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1885 ret = g_usbInterface->IsoTransferWrite(dev, pipe, 1000, bufferdata);
1886 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1670 %{public}d IsoTransferWrite=%{public}d", __LINE__, ret);
1887 ASSERT_NE(ret, 0);
1888 }
1889
1890 /**
1891 * @tc.name: SUB_USB_HDI_1680
1892 * @tc.desc: Test functions to IsoTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1893 * std::vector<uint8_t> &data);
1894 * @tc.desc: Negative test: parameters exception, endpointId error, ClaimInterface failed first
1895 * @tc.type: FUNC
1896 */
1897 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1680, Function | MediumTest | Level1)
1898 {
1899 struct UsbDev dev = dev_;
1900 uint8_t interfaceId = INTERFACEID_1;
1901 uint8_t pointid = POINTID_99;
1902 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1903 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1680 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1904 ASSERT_EQ(0, ret);
1905 struct UsbPipe pipe = { interfaceId, pointid };
1906 uint32_t length = 100;
1907 uint8_t buffer[100] = "hello world Iso writ07";
1908 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1909 ret = g_usbInterface->IsoTransferWrite(dev, pipe, 1000, bufferdata);
1910 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1680 %{public}d IsoTransferWrite=%{public}d", __LINE__, ret);
1911 ASSERT_NE(ret, 0);
1912 }
1913
1914 /**
1915 * @tc.name: SUB_USB_HDI_1690
1916 * @tc.desc: Test functions to IsoTransferWrite(const UsbDev &dev, const UsbPipe &pipe, int32_t timeout,
1917 * std::vector<uint8_t> &data);
1918 * @tc.desc: Positive test: parameters correctly, different in timeout
1919 * @tc.type: FUNC
1920 */
1921 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_1690, Function | MediumTest | Level1)
1922 {
1923 struct UsbDev dev = dev_;
1924 uint8_t interfaceId = INTERFACEID_1;
1925 uint8_t pointid = POINTID_1;
1926 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1927 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1690 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1928 ASSERT_EQ(0, ret);
1929 struct UsbPipe pipe = { interfaceId, pointid };
1930 uint32_t length = 100;
1931 uint8_t buffer[100] = "hello world Iso writ08";
1932 std::vector<uint8_t> bufferdata = { buffer, buffer + length };
1933 ret = g_usbInterface->IsoTransferWrite(dev, pipe, -1, bufferdata);
1934 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_1690 %{public}d IsoTransferWrite=%{public}d", __LINE__, ret);
1935 ASSERT_EQ(0, ret);
1936 }
1937
1938 /**
1939 * @tc.name: SUB_USB_HDI_2040
1940 * @tc.desc: Test functions to int32_t BulkWrite(const UsbDev &dev, const UsbPipe &pipe, const sptr<Ashmem> &ashmem)
1941 * @tc.desc: Positive test: parameters correctly
1942 * @tc.type: FUNC
1943 */
1944 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2040, Function | MediumTest | Level1)
1945 {
1946 sptr<Ashmem> ashmem;
1947 uint8_t rflg = 0;
1948 int32_t asmSize = LENGTH_NUM_255;
1949 struct UsbDev dev = dev_;
1950 uint8_t interfaceId = INTERFACEID_1;
1951 uint8_t pointid = POINTID_129;
1952 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1953 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2040 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1954 ASSERT_EQ(0, ret);
1955 struct UsbPipe pipe = { interfaceId, pointid };
1956 (void)InitAshmemOne(ashmem, asmSize, rflg);
1957 ret = g_usbInterface->BulkWrite(dev, pipe, ashmem);
1958 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2040 %{public}d BulkWrite=%{public}d", __LINE__, ret);
1959 ASSERT_EQ(ret, 0);
1960 }
1961
1962 /**
1963 * @tc.name: SUB_USB_HDI_2050
1964 * @tc.desc: Test functions to int32_t BulkWrite(const UsbDev &dev, const UsbPipe &pipe, const sptr<Ashmem> &ashmem)
1965 * @tc.desc: Negative test: parameters exception, busNum error
1966 * @tc.type: FUNC
1967 */
1968 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2050, Function | MediumTest | Level1)
1969 {
1970 sptr<Ashmem> ashmem;
1971 uint8_t rflg = 0;
1972 int32_t asmSize = LENGTH_NUM_255;
1973 struct UsbDev dev = dev_;
1974 uint8_t interfaceId = INTERFACEID_1;
1975 uint8_t pointid = POINTID_1;
1976 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
1977 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2050 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1978 ASSERT_EQ(0, ret);
1979 struct UsbPipe pipe = { interfaceId, pointid };
1980 dev.busNum = BUS_NUM_99;
1981 (void)InitAshmemOne(ashmem, asmSize, rflg);
1982 ret = g_usbInterface->BulkWrite(dev, pipe, ashmem);
1983 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2050 %{public}d BulkWrite=%{public}d", __LINE__, ret);
1984 ASSERT_NE(ret, 0);
1985 }
1986
1987 /**
1988 * @tc.name: SUB_USB_HDI_2060
1989 * @tc.desc: Test functions to int32_t BulkWrite(const UsbDev &dev, const UsbPipe &pipe, const sptr<Ashmem> &ashmem)
1990 * @tc.desc: Negative test: parameters exception, devAddr error
1991 * @tc.type: FUNC
1992 */
1993 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2060, Function | MediumTest | Level1)
1994 {
1995 sptr<Ashmem> ashmem;
1996 uint8_t rflg = 0;
1997 int32_t asmSize = LENGTH_NUM_255;
1998 struct UsbDev dev = dev_;
1999 uint8_t interfaceId = INTERFACEID_1;
2000 uint8_t pointid = POINTID_1;
2001 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
2002 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2060 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
2003 ASSERT_EQ(0, ret);
2004 struct UsbPipe pipe = { interfaceId, pointid };
2005 dev.devAddr = DEV_ADDR_244;
2006 (void)InitAshmemOne(ashmem, asmSize, rflg);
2007 ret = g_usbInterface->BulkWrite(dev, pipe, ashmem);
2008 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2060 %{public}d BulkWrite=%{public}d", __LINE__, ret);
2009 ASSERT_NE(ret, 0);
2010 }
2011
2012 /**
2013 * @tc.name: SUB_USB_HDI_2070
2014 * @tc.desc: Test functions to int32_t BulkWrite(const UsbDev &dev, const UsbPipe &pipe, const sptr<Ashmem> &ashmem)
2015 * @tc.desc: Negative test: parameters exception, intfId error
2016 * @tc.type: FUNC
2017 */
2018 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2070, Function | MediumTest | Level1)
2019 {
2020 sptr<Ashmem> ashmem;
2021 uint8_t rflg = 0;
2022 int32_t asmSize = LENGTH_NUM_255;
2023 struct UsbDev dev = dev_;
2024 uint8_t interfaceId = INTERFACEID_1;
2025 uint8_t pointid = POINTID_1;
2026 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
2027 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2070 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
2028 ASSERT_EQ(0, ret);
2029 struct UsbPipe pipe = { interfaceId, pointid };
2030 pipe.intfId = PIPE_INTERFACEID_255;
2031 (void)InitAshmemOne(ashmem, asmSize, rflg);
2032 ret = g_usbInterface->BulkWrite(dev, pipe, ashmem);
2033 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2070 %{public}d BulkWrite=%{public}d", __LINE__, ret);
2034 ASSERT_NE(ret, 0);
2035 }
2036
2037 /**
2038 * @tc.name: SUB_USB_HDI_2080
2039 * @tc.desc: Test functions to int32_t BulkWrite(const UsbDev &dev, const UsbPipe &pipe, const sptr<Ashmem> &ashmem)
2040 * @tc.desc: Negative test: parameters exception, endpointId error
2041 * @tc.type: FUNC
2042 */
2043 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2080, Function | MediumTest | Level1)
2044 {
2045 sptr<Ashmem> ashmem;
2046 uint8_t rflg = 0;
2047 int32_t asmSize = LENGTH_NUM_255;
2048 struct UsbDev dev = dev_;
2049 uint8_t interfaceId = INTERFACEID_1;
2050 uint8_t pointid = POINTID_1;
2051 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
2052 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2080 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
2053 ASSERT_EQ(0, ret);
2054 struct UsbPipe pipe = { interfaceId, pointid };
2055 pipe.endpointId = PIPE_ENDPOINTID_255;
2056 (void)InitAshmemOne(ashmem, asmSize, rflg);
2057 ret = g_usbInterface->BulkWrite(dev, pipe, ashmem);
2058 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2080 %{public}d BulkWrite=%{public}d", __LINE__, ret);
2059 ASSERT_NE(ret, 0);
2060 }
2061
2062 /**
2063 * @tc.name: SUB_USB_HDI_2090
2064 * @tc.desc: Test functions to int32_t BulkRead(const UsbDev &dev, const UsbPipe &pipe, const sptr<Ashmem> &ashmem)
2065 * @tc.desc: Positive test: parameters correctly
2066 * @tc.type: FUNC
2067 */
2068 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2090, Function | MediumTest | Level1)
2069 {
2070 sptr<Ashmem> ashmem;
2071 uint8_t rflg = 0;
2072 int32_t asmSize = LENGTH_NUM_255;
2073 struct UsbDev dev = dev_;
2074 uint8_t interfaceId = INTERFACEID_1;
2075 uint8_t pointid = POINTID_129;
2076 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
2077 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2090 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
2078 ASSERT_EQ(0, ret);
2079 struct UsbPipe pipe = { interfaceId, pointid };
2080 (void)InitAshmemOne(ashmem, asmSize, rflg);
2081 ret = g_usbInterface->BulkRead(dev, pipe, ashmem);
2082 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2090 %{public}d BulkWrite=%{public}d", __LINE__, ret);
2083 ASSERT_EQ(ret, 0);
2084 }
2085
2086 /**
2087 * @tc.name: SUB_USB_HDI_2100
2088 * @tc.desc: Test functions to int32_t BulkRead(const UsbDev &dev, const UsbPipe &pipe, const sptr<Ashmem> &ashmem)
2089 * @tc.desc: Negative test: parameters exception, busNum error
2090 * @tc.type: FUNC
2091 */
2092 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2100, Function | MediumTest | Level1)
2093 {
2094 sptr<Ashmem> ashmem;
2095 uint8_t rflg = 0;
2096 int32_t asmSize = LENGTH_NUM_255;
2097 struct UsbDev dev = dev_;
2098 uint8_t interfaceId = INTERFACEID_1;
2099 uint8_t pointid = POINTID_1;
2100 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
2101 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2100 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
2102 ASSERT_EQ(0, ret);
2103 struct UsbPipe pipe = { interfaceId, pointid };
2104 dev.busNum = BUS_NUM_99;
2105 (void)InitAshmemOne(ashmem, asmSize, rflg);
2106 ret = g_usbInterface->BulkRead(dev, pipe, ashmem);
2107 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2100 %{public}d BulkWrite=%{public}d", __LINE__, ret);
2108 ASSERT_NE(ret, 0);
2109 }
2110
2111 /**
2112 * @tc.name: SUB_USB_HDI_2110
2113 * @tc.desc: Test functions to int32_t BulkRead(const UsbDev &dev, const UsbPipe &pipe, const sptr<Ashmem> &ashmem)
2114 * @tc.desc: Negative test: parameters exception, devAddr error
2115 * @tc.type: FUNC
2116 */
2117 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2110, Function | MediumTest | Level1)
2118 {
2119 sptr<Ashmem> ashmem;
2120 uint8_t rflg = 0;
2121 int32_t asmSize = LENGTH_NUM_255;
2122 struct UsbDev dev = dev_;
2123 uint8_t interfaceId = INTERFACEID_1;
2124 uint8_t pointid = POINTID_1;
2125 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
2126 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2110 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
2127 ASSERT_EQ(0, ret);
2128 struct UsbPipe pipe = { interfaceId, pointid };
2129 dev.devAddr = DEV_ADDR_244;
2130 (void)InitAshmemOne(ashmem, asmSize, rflg);
2131 ret = g_usbInterface->BulkRead(dev, pipe, ashmem);
2132 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2110 %{public}d BulkWrite=%{public}d", __LINE__, ret);
2133 ASSERT_NE(ret, 0);
2134 }
2135
2136 /**
2137 * @tc.name: SUB_USB_HDI_2120
2138 * @tc.desc: Test functions to int32_t BulkRead(const UsbDev &dev, const UsbPipe &pipe, const sptr<Ashmem> &ashmem)
2139 * @tc.desc: Negative test: parameters exception, intfId error
2140 * @tc.type: FUNC
2141 */
2142 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2120, Function | MediumTest | Level1)
2143 {
2144 sptr<Ashmem> ashmem;
2145 uint8_t rflg = 0;
2146 int32_t asmSize = LENGTH_NUM_255;
2147 struct UsbDev dev = dev_;
2148 uint8_t interfaceId = INTERFACEID_1;
2149 uint8_t pointid = POINTID_1;
2150 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
2151 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2120 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
2152 ASSERT_EQ(0, ret);
2153 struct UsbPipe pipe = { interfaceId, pointid };
2154 pipe.intfId = PIPE_INTERFACEID_255;
2155 (void)InitAshmemOne(ashmem, asmSize, rflg);
2156 ret = g_usbInterface->BulkRead(dev, pipe, ashmem);
2157 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2120 %{public}d BulkWrite=%{public}d", __LINE__, ret);
2158 ASSERT_NE(ret, 0);
2159 }
2160
2161 /**
2162 * @tc.name: SUB_USB_HDI_2130
2163 * @tc.desc: Test functions to int32_t BulkRead(const UsbDev &dev, const UsbPipe &pipe, const sptr<Ashmem> &ashmem)
2164 * @tc.desc: Negative test: parameters exception, endpointId error
2165 * @tc.type: FUNC
2166 */
2167 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2130, Function | MediumTest | Level1)
2168 {
2169 sptr<Ashmem> ashmem;
2170 uint8_t rflg = 0;
2171 int32_t asmSize = LENGTH_NUM_255;
2172 struct UsbDev dev = dev_;
2173 uint8_t interfaceId = INTERFACEID_1;
2174 uint8_t pointid = POINTID_1;
2175 auto ret = g_usbInterface->ClaimInterface(dev, interfaceId, 1);
2176 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2130 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
2177 ASSERT_EQ(0, ret);
2178 struct UsbPipe pipe = { interfaceId, pointid };
2179 pipe.endpointId = PIPE_ENDPOINTID_255;
2180 (void)InitAshmemOne(ashmem, asmSize, rflg);
2181 ret = g_usbInterface->BulkRead(dev, pipe, ashmem);
2182 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2130 %{public}d BulkWrite=%{public}d", __LINE__, ret);
2183 ASSERT_NE(ret, 0);
2184 }
2185
2186 /**
2187 * @tc.name: SUB_USB_HDI_2240
2188 * @tc.desc: Test functions to RegBulkCallback
2189 * @tc.desc: int32_t RegBulkCallback(const UsbDev &dev, const UsbPipe &pipe, const sptr<IUsbdBulkCallback> &cb)
2190 * @tc.desc: Positive test: parameters correctly
2191 * @tc.type: FUNC
2192 */
2193 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2240, Function | MediumTest | Level1)
2194 {
2195 struct UsbDev dev = dev_;
2196 uint8_t interfaceId = INTERFACEID_1;
2197 uint8_t pointid = POINTID_BULK_OUT;
2198 struct UsbPipe pipe = {interfaceId, pointid};
2199 sptr<UsbdBulkCallbackTest> usbdBulkCallback = new UsbdBulkCallbackTest();
2200 if (usbdBulkCallback == nullptr) {
2201 HDF_LOGE("%{public}s:UsbdBulkCallbackTest new failed.", __func__);
2202 exit(0);
2203 }
2204 auto ret = g_usbInterface->RegBulkCallback(dev, pipe, usbdBulkCallback);
2205 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2240 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
2206 ASSERT_EQ(ret, 0);
2207 }
2208
2209 /**
2210 * @tc.name: SUB_USB_HDI_2250
2211 * @tc.desc: Test functions to RegBulkCallback
2212 * @tc.desc: int32_t RegBulkCallback(const UsbDev &dev, const UsbPipe &pipe, const sptr<IUsbdBulkCallback> &cb)
2213 * @tc.desc: Negative test: parameters exception, busNum error
2214 * @tc.type: FUNC
2215 */
2216 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2250, Function | MediumTest | Level1)
2217 {
2218 struct UsbDev dev = dev_;
2219 uint8_t interfaceId = INTERFACEID_1;
2220 uint8_t pointid = POINTID_BULK_OUT;
2221 struct UsbPipe pipe = {interfaceId, pointid};
2222 dev.busNum = BUS_NUM_99;
2223 sptr<UsbdBulkCallbackTest> usbdBulkCallback = new UsbdBulkCallbackTest();
2224 if (usbdBulkCallback == nullptr) {
2225 HDF_LOGE("%{public}s:UsbdBulkCallbackTest new failed.", __func__);
2226 exit(0);
2227 }
2228 auto ret = g_usbInterface->RegBulkCallback(dev, pipe, usbdBulkCallback);
2229 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2250 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
2230 ASSERT_NE(ret, 0);
2231 }
2232
2233 /**
2234 * @tc.name: SUB_USB_HDI_2260
2235 * @tc.desc: Test functions to RegBulkCallback
2236 * @tc.desc: int32_t RegBulkCallback(const UsbDev &dev, const UsbPipe &pipe, const sptr<IUsbdBulkCallback> &cb)
2237 * @tc.desc: Negative test: parameters exception, devAddr error
2238 * @tc.type: FUNC
2239 */
2240 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2260, Function | MediumTest | Level1)
2241 {
2242 struct UsbDev dev = dev_;
2243 uint8_t interfaceId = INTERFACEID_1;
2244 uint8_t pointid = POINTID_BULK_OUT;
2245 struct UsbPipe pipe = {interfaceId, pointid};
2246 dev.devAddr = DEV_ADDR_244;
2247 sptr<UsbdBulkCallbackTest> usbdBulkCallback = new UsbdBulkCallbackTest();
2248 if (usbdBulkCallback == nullptr) {
2249 HDF_LOGE("%{public}s:UsbdBulkCallbackTest new failed.", __func__);
2250 exit(0);
2251 }
2252 auto ret = g_usbInterface->RegBulkCallback(dev, pipe, usbdBulkCallback);
2253 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2260 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
2254 ASSERT_NE(ret, 0);
2255 }
2256
2257 /**
2258 * @tc.name: SUB_USB_HDI_2270
2259 * @tc.desc: Test functions to RegBulkCallback
2260 * @tc.desc: int32_t RegBulkCallback(const UsbDev &dev, const UsbPipe &pipe, const sptr<IUsbdBulkCallback> &cb)
2261 * @tc.desc: Negative test: parameters exception, intfId error
2262 * @tc.type: FUNC
2263 */
2264 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2270, Function | MediumTest | Level1)
2265 {
2266 struct UsbDev dev = dev_;
2267 uint8_t interfaceId = INTERFACEID_1;
2268 uint8_t pointid = POINTID_BULK_OUT;
2269 struct UsbPipe pipe = {interfaceId, pointid};
2270 pipe.intfId = PIPE_INTERFACEID_255;
2271 sptr<UsbdBulkCallbackTest> usbdBulkCallback = new UsbdBulkCallbackTest();
2272 if (usbdBulkCallback == nullptr) {
2273 HDF_LOGE("%{public}s:UsbdBulkCallbackTest new failed.", __func__);
2274 exit(0);
2275 }
2276 auto ret = g_usbInterface->RegBulkCallback(dev, pipe, usbdBulkCallback);
2277 HDF_LOGI("UsbdTransferTest::RegBulkCallback004 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
2278 ASSERT_NE(ret, 0);
2279 }
2280
2281 /**
2282 * @tc.name: SUB_USB_HDI_2280
2283 * @tc.desc: Test functions to RegBulkCallback
2284 * @tc.desc: int32_t RegBulkCallback(const UsbDev &dev, const UsbPipe &pipe, const sptr<IUsbdBulkCallback> &cb)
2285 * @tc.desc: Negative test: parameters exception, cb error
2286 * @tc.type: FUNC
2287 */
2288 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2280, Function | MediumTest | Level1)
2289 {
2290 struct UsbDev dev = dev_;
2291 uint8_t interfaceId = INTERFACEID_1;
2292 uint8_t pointid = POINTID_BULK_OUT;
2293 struct UsbPipe pipe = {interfaceId, pointid};
2294 auto ret = g_usbInterface->RegBulkCallback(dev, pipe, nullptr);
2295 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2280 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
2296 ASSERT_NE(ret, 0);
2297 }
2298
2299 /**
2300 * @tc.name: SUB_USB_HDI_2290
2301 * @tc.desc: Test functions to int32_t UnRegBulkCallback(const UsbDev &dev, const UsbPipe &pipe)
2302 * @tc.desc: Positive test: parameters correctly
2303 * @tc.type: FUNC
2304 */
2305 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2290, Function | MediumTest | Level1)
2306 {
2307 struct UsbDev dev = dev_;
2308 uint8_t interfaceId = INTERFACEID_1;
2309 uint8_t pointid = POINTID_1;
2310 struct UsbPipe pipe = {interfaceId, pointid};
2311 sptr<UsbdBulkCallbackTest> usbdBulkCallback = new UsbdBulkCallbackTest();
2312 if (usbdBulkCallback == nullptr) {
2313 HDF_LOGE("%{public}s:UsbdBulkCallbackTest new failed.", __func__);
2314 exit(0);
2315 }
2316 auto ret = g_usbInterface->RegBulkCallback(dev, pipe, usbdBulkCallback);
2317 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2290 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
2318 ASSERT_EQ(ret, 0);
2319 ret = g_usbInterface->UnRegBulkCallback(dev, pipe);
2320 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2290 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
2321 ASSERT_EQ(ret, 0);
2322 }
2323
2324 /**
2325 * @tc.name: SUB_USB_HDI_2300
2326 * @tc.desc: Test functions to int32_t UnRegBulkCallback(const UsbDev &dev, const UsbPipe &pipe)
2327 * @tc.desc: Negative test: parameters exception, devAddr error
2328 * @tc.type: FUNC
2329 */
2330 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2300, Function | MediumTest | Level1)
2331 {
2332 struct UsbDev dev = dev_;
2333 uint8_t interfaceId = INTERFACEID_1;
2334 uint8_t pointid = POINTID_1;
2335 struct UsbPipe pipe = {interfaceId, pointid};
2336 sptr<UsbdBulkCallbackTest> usbdBulkCallback = new UsbdBulkCallbackTest();
2337 if (usbdBulkCallback == nullptr) {
2338 HDF_LOGE("%{public}s:UsbdBulkCallbackTest new failed.", __func__);
2339 exit(0);
2340 }
2341 auto ret = g_usbInterface->RegBulkCallback(dev, pipe, usbdBulkCallback);
2342 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2300 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
2343 ASSERT_EQ(ret, 0);
2344 dev.devAddr = DEV_ADDR_244;
2345 ret = g_usbInterface->UnRegBulkCallback(dev, pipe);
2346 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2300 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
2347 ASSERT_NE(ret, 0);
2348 dev = dev_;
2349 ret = g_usbInterface->UnRegBulkCallback(dev, pipe);
2350 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2300 %{public}d again UnRegBulkCallback=%{public}d", __LINE__, ret);
2351 ASSERT_EQ(ret, 0);
2352 }
2353
2354 /**
2355 * @tc.name: SUB_USB_HDI_2310
2356 * @tc.desc: Test functions to int32_t UnRegBulkCallback(const UsbDev &dev, const UsbPipe &pipe)
2357 * @tc.desc: Negative test: parameters exception, intfId error
2358 * @tc.type: FUNC
2359 */
2360 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2310, Function | MediumTest | Level1)
2361 {
2362 struct UsbDev dev = dev_;
2363 uint8_t interfaceId = INTERFACEID_1;
2364 uint8_t pointid = POINTID_1;
2365 struct UsbPipe pipe = {interfaceId, pointid};
2366 sptr<UsbdBulkCallbackTest> usbdBulkCallback = new UsbdBulkCallbackTest();
2367 if (usbdBulkCallback == nullptr) {
2368 HDF_LOGE("%{public}s:UsbdBulkCallbackTest new failed.", __func__);
2369 exit(0);
2370 }
2371 auto ret = g_usbInterface->RegBulkCallback(dev, pipe, usbdBulkCallback);
2372 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2310 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
2373 ASSERT_EQ(ret, 0);
2374 pipe.intfId = PIPE_INTERFACEID_244;
2375 ret = g_usbInterface->UnRegBulkCallback(dev, pipe);
2376 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2310 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
2377 ASSERT_NE(ret, 0);
2378 pipe = {interfaceId, pointid};
2379 ret = g_usbInterface->UnRegBulkCallback(dev, pipe);
2380 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2310 %{public}d again UnRegBulkCallback=%{public}d", __LINE__, ret);
2381 ASSERT_EQ(ret, 0);
2382 }
2383
2384 /**
2385 * @tc.name: SUB_USB_HDI_2320
2386 * @tc.desc: Test functions to int32_t UnRegBulkCallback(const UsbDev &dev, const UsbPipe &pipe)
2387 * @tc.desc: Positive test: call again
2388 * @tc.type: FUNC
2389 */
2390 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2320, Function | MediumTest | Level1)
2391 {
2392 struct UsbDev dev = dev_;
2393 uint8_t interfaceId = INTERFACEID_1;
2394 uint8_t pointid = POINTID_1;
2395 struct UsbPipe pipe = {interfaceId, pointid};
2396 sptr<UsbdBulkCallbackTest> usbdBulkCallback = new UsbdBulkCallbackTest();
2397 if (usbdBulkCallback == nullptr) {
2398 HDF_LOGE("%{public}s:UsbdBulkCallbackTest new failed.", __func__);
2399 exit(0);
2400 }
2401 auto ret = g_usbInterface->RegBulkCallback(dev, pipe, usbdBulkCallback);
2402 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2320 %{public}d RegBulkCallback=%{public}d", __LINE__, ret);
2403 ASSERT_EQ(ret, 0);
2404 ret = g_usbInterface->UnRegBulkCallback(dev, pipe);
2405 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2320 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
2406 ASSERT_EQ(ret, 0);
2407 ret = g_usbInterface->UnRegBulkCallback(dev, pipe);
2408 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2320 %{public}d again UnRegBulkCallback=%{public}d", __LINE__, ret);
2409 ASSERT_EQ(ret, 0);
2410 }
2411
2412 /**
2413 * @tc.name: SUB_USB_HDI_2330
2414 * @tc.desc: Test functions to int32_t UnRegBulkCallback(const UsbDev &dev, const UsbPipe &pipe)
2415 * @tc.desc: Positive test: no register
2416 * @tc.type: FUNC
2417 */
2418 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2330, Function | MediumTest | Level1)
2419 {
2420 struct UsbDev dev = dev_;
2421 uint8_t interfaceId = INTERFACEID_1;
2422 uint8_t pointid = POINTID_1;
2423 struct UsbPipe pipe = {interfaceId, pointid};
2424 auto ret = g_usbInterface->UnRegBulkCallback(dev, pipe);
2425 HDF_LOGI("UsbdTransferTest::UnRegBulkCallback005 %{public}d UnRegBulkCallback=%{public}d", __LINE__, ret);
2426 ASSERT_EQ(ret, 0);
2427 }
2428
2429 /**
2430 * @tc.name: SUB_USB_HDI_2140
2431 * @tc.desc: Test functions to int32_t BindUsbdSubscriber(const sptr<IUsbdSubscriber> &subscriber)
2432 * @tc.desc: Positive test: parameters correctly
2433 * @tc.type: FUNC
2434 */
2435 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2140, Function | MediumTest | Level1)
2436 {
2437 sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest();
2438 if (subscriber == nullptr) {
2439 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
2440 exit(0);
2441 }
2442 auto ret = g_usbInterface->BindUsbdSubscriber(subscriber);
2443 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2140 %{public}d BindUsbdSubscriber=%{public}d", __LINE__, ret);
2444 ASSERT_EQ(0, ret);
2445 }
2446
2447 /**
2448 * @tc.name: SUB_USB_HDI_2150
2449 * @tc.desc: Test functions to int32_t BindUsbdSubscriber(const sptr<IUsbdSubscriber> &subscriber)
2450 * @tc.desc: Positive test: bind different
2451 * @tc.type: FUNC
2452 */
2453 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2150, Function | MediumTest | Level1)
2454 {
2455 sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest();
2456 if (subscriber == nullptr) {
2457 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
2458 exit(0);
2459 }
2460 auto ret = g_usbInterface->BindUsbdSubscriber(subscriber);
2461 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2150 %{public}d BindUsbdSubscriber=%{public}d", __LINE__, ret);
2462 ASSERT_EQ(0, ret);
2463 sptr<UsbSubscriberTest> subscriber2 = new UsbSubscriberTest();
2464 if (subscriber == nullptr) {
2465 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
2466 exit(0);
2467 }
2468 ret = g_usbInterface->BindUsbdSubscriber(subscriber2);
2469 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2150 %{public}d again BindUsbdSubscriber=%{public}d", __LINE__, ret);
2470 ASSERT_EQ(0, ret);
2471 }
2472
2473 /**
2474 * @tc.name: SUB_USB_HDI_2160
2475 * @tc.desc: Test functions to int32_t BindUsbdSubscriber(const sptr<IUsbdSubscriber> &subscriber)
2476 * @tc.desc: Positive test: bind same
2477 * @tc.type: FUNC
2478 */
2479 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2160, Function | MediumTest | Level1)
2480 {
2481 sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest();
2482 if (subscriber == nullptr) {
2483 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
2484 exit(0);
2485 }
2486 auto ret = g_usbInterface->BindUsbdSubscriber(subscriber);
2487 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2160 %{public}d BindUsbdSubscriber=%{public}d", __LINE__, ret);
2488 ASSERT_EQ(0, ret);
2489 ret = g_usbInterface->BindUsbdSubscriber(subscriber);
2490 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2160 %{public}d again BindUsbdSubscriber=%{public}d", __LINE__, ret);
2491 ASSERT_EQ(0, ret);
2492 }
2493
2494 /**
2495 * @tc.name: SUB_USB_HDI_2170
2496 * @tc.desc: Test functions to int32_t BindUsbdSubscriber(const sptr<IUsbdSubscriber> &subscriber)
2497 * @tc.desc: Positive test: bind and unbind, then bind another
2498 * @tc.type: FUNC
2499 */
2500 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2170, Function | MediumTest | Level1)
2501 {
2502 sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest();
2503 if (subscriber == nullptr) {
2504 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
2505 exit(0);
2506 }
2507 auto ret = g_usbInterface->BindUsbdSubscriber(subscriber);
2508 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2170 %{public}d BindUsbdSubscriber=%{public}d", __LINE__, ret);
2509 ASSERT_EQ(0, ret);
2510 ret = g_usbInterface->UnbindUsbdSubscriber(subscriber);
2511 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2170 %{public}d UnbindUsbdSubscriber=%{public}d", __LINE__, ret);
2512 ASSERT_EQ(0, ret);
2513 sptr<UsbSubscriberTest> subscriber2 = new UsbSubscriberTest();
2514 if (subscriber == nullptr) {
2515 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
2516 exit(0);
2517 }
2518 ret = g_usbInterface->BindUsbdSubscriber(subscriber2);
2519 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2170 again %{public}d BindUsbdSubscriber=%{public}d", __LINE__, ret);
2520 ASSERT_EQ(0, ret);
2521 }
2522
2523 /**
2524 * @tc.name: SUB_USB_HDI_2180
2525 * @tc.desc: Test functions to int32_t BindUsbdSubscriber(const sptr<IUsbdSubscriber> &subscriber)
2526 * @tc.desc: Positive test: bind again after unbind
2527 * @tc.type: FUNC
2528 */
2529 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2180, Function | MediumTest | Level1)
2530 {
2531 sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest();
2532 if (subscriber == nullptr) {
2533 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
2534 exit(0);
2535 }
2536 auto ret = g_usbInterface->BindUsbdSubscriber(subscriber);
2537 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2180 %{public}d BindUsbdSubscriber=%{public}d", __LINE__, ret);
2538 ASSERT_EQ(0, ret);
2539 ret = g_usbInterface->UnbindUsbdSubscriber(subscriber);
2540 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2180 %{public}d UnbindUsbdSubscriber=%{public}d", __LINE__, ret);
2541 ASSERT_EQ(0, ret);
2542 ret = g_usbInterface->BindUsbdSubscriber(subscriber);
2543 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2180 %{public}d again BindUsbdSubscriber=%{public}d", __LINE__, ret);
2544 ASSERT_EQ(0, ret);
2545 }
2546
2547 /**
2548 * @tc.name: SUB_USB_HDI_2190
2549 * @tc.desc: Test functions to int32_t UnbindUsbdSubscriber(const sptr<IUsbdSubscriber> &subscriber)
2550 * @tc.desc: Positive test: parameters correctly
2551 * @tc.type: FUNC
2552 */
2553 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2190, Function | MediumTest | Level1)
2554 {
2555 sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest();
2556 if (subscriber == nullptr) {
2557 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
2558 exit(0);
2559 }
2560 auto ret = g_usbInterface->BindUsbdSubscriber(subscriber);
2561 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2190 %{public}d first BindUsbdSubscriber=%{public}d", __LINE__, ret);
2562 ASSERT_EQ(0, ret);
2563 ret = g_usbInterface->UnbindUsbdSubscriber(subscriber);
2564 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2190 %{public}d UnbindUsbdSubscriber=%{public}d", __LINE__, ret);
2565 ASSERT_EQ(0, ret);
2566 }
2567
2568 /**
2569 * @tc.name: SUB_USB_HDI_2200
2570 * @tc.desc: Test functions to int32_t UnbindUsbdSubscriber(const sptr<IUsbdSubscriber> &subscriber)
2571 * @tc.desc: Negative test: no bind first
2572 * @tc.type: FUNC
2573 */
2574 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2200, Function | MediumTest | Level1)
2575 {
2576 sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest();
2577 if (subscriber == nullptr) {
2578 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
2579 exit(0);
2580 }
2581 auto ret = g_usbInterface->UnbindUsbdSubscriber(subscriber);
2582 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2200 %{public}d UnbindUsbdSubscriber=%{public}d", __LINE__, ret);
2583 ASSERT_NE(0, ret);
2584 }
2585
2586 /**
2587 * @tc.name: SUB_USB_HDI_2210
2588 * @tc.desc: Test functions to int32_t UnbindUsbdSubscriber(const sptr<IUsbdSubscriber> &subscriber)
2589 * @tc.desc: Positive test: no bind first, unbind failed; then bind, unbind success
2590 * @tc.type: FUNC
2591 */
2592 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2210, Function | MediumTest | Level1)
2593 {
2594 sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest();
2595 if (subscriber == nullptr) {
2596 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
2597 exit(0);
2598 }
2599 auto ret = g_usbInterface->UnbindUsbdSubscriber(subscriber);
2600 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2210 %{public}d UnbindUsbdSubscriber=%{public}d", __LINE__, ret);
2601 ASSERT_NE(0, ret);
2602 ret = g_usbInterface->BindUsbdSubscriber(subscriber);
2603 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2210 %{public}d first BindUsbdSubscriber=%{public}d", __LINE__, ret);
2604 ASSERT_EQ(0, ret);
2605 ret = g_usbInterface->UnbindUsbdSubscriber(subscriber);
2606 HDF_LOGI(
2607 "UsbdTransferTest::SUB_USB_HDI_2210 %{public}d again UnbindUsbdSubscriber=%{public}d", __LINE__, ret);
2608 ASSERT_EQ(0, ret);
2609 }
2610
2611 /**
2612 * @tc.name: SUB_USB_HDI_2220
2613 * @tc.desc: Test functions to int32_t UnbindUsbdSubscriber(const sptr<IUsbdSubscriber> &subscriber)
2614 * @tc.desc: Negative test: call twice
2615 * @tc.type: FUNC
2616 */
2617 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2220, Function | MediumTest | Level1)
2618 {
2619 sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest();
2620 if (subscriber == nullptr) {
2621 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
2622 exit(0);
2623 }
2624 auto ret = g_usbInterface->BindUsbdSubscriber(subscriber);
2625 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2220 %{public}d first BindUsbdSubscriber=%{public}d", __LINE__, ret);
2626 ASSERT_EQ(0, ret);
2627 ret = g_usbInterface->UnbindUsbdSubscriber(subscriber);
2628 HDF_LOGI(
2629 "UsbdTransferTest::SUB_USB_HDI_2220 %{public}d first UnbindUsbdSubscriber=%{public}d", __LINE__, ret);
2630 ASSERT_EQ(0, ret);
2631 ret = g_usbInterface->UnbindUsbdSubscriber(subscriber);
2632 HDF_LOGI(
2633 "UsbdTransferTest::SUB_USB_HDI_2220 %{public}d again UnbindUsbdSubscriber=%{public}d", __LINE__, ret);
2634 ASSERT_NE(0, ret);
2635 }
2636
2637 /**
2638 * @tc.name: SUB_USB_HDI_2230
2639 * @tc.desc: Test functions to int32_t UnbindUsbdSubscriber(const sptr<IUsbdSubscriber> &subscriber)
2640 * @tc.desc: Positive test: test repeatedly
2641 * @tc.type: FUNC
2642 */
2643 HWTEST_F(UsbdTransferTest, SUB_USB_HDI_2230, Function | MediumTest | Level1)
2644 {
2645 sptr<UsbSubscriberTest> subscriber = new UsbSubscriberTest();
2646 if (subscriber == nullptr) {
2647 HDF_LOGE("%{public}s:UsbSubscriberTest new failed.", __func__);
2648 exit(0);
2649 }
2650 auto ret = g_usbInterface->BindUsbdSubscriber(subscriber);
2651 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2230 %{public}d first BindUsbdSubscriber=%{public}d", __LINE__, ret);
2652 ASSERT_EQ(0, ret);
2653 ret = g_usbInterface->UnbindUsbdSubscriber(subscriber);
2654 HDF_LOGI(
2655 "UsbdTransferTest::SUB_USB_HDI_2230 %{public}d first UnbindUsbdSubscriber=%{public}d", __LINE__, ret);
2656 ASSERT_EQ(0, ret);
2657 ret = g_usbInterface->BindUsbdSubscriber(subscriber);
2658 HDF_LOGI("UsbdTransferTest::SUB_USB_HDI_2230 %{public}d again BindUsbdSubscriber=%{public}d", __LINE__, ret);
2659 ASSERT_EQ(0, ret);
2660 ret = g_usbInterface->UnbindUsbdSubscriber(subscriber);
2661 HDF_LOGI(
2662 "UsbdTransferTest::SUB_USB_HDI_2230 %{public}d again UnbindUsbdSubscriber=%{public}d", __LINE__, ret);
2663 ASSERT_EQ(0, ret);
2664 }
2665 } // namespace