• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #include "usb_request_test.h"
17 
18 #include <csignal>
19 #include <iostream>
20 #include <vector>
21 
22 #include "if_system_ability_manager.h"
23 #include "ipc_skeleton.h"
24 #include "iservice_registry.h"
25 #include "iusb_srv.h"
26 #include "system_ability_definition.h"
27 #include "usb_common.h"
28 #include "usb_common_test.h"
29 #include "usb_device_pipe.h"
30 #include "usb_request.h"
31 #include "usb_srv_client.h"
32 #include "v1_0/usb_types.h"
33 
34 using namespace testing::ext;
35 using namespace OHOS::USB;
36 using namespace OHOS;
37 using namespace std;
38 using namespace OHOS::USB::Common;
39 
40 namespace OHOS {
41 namespace USB {
42 namespace Request {
43 constexpr int32_t SLEEP_TIME = 3;
44 constexpr int32_t TAG_SIZE = 50;
45 constexpr int32_t BUFFER_SIZE = 255;
46 
SetUpTestCase(void)47 void UsbRequestTest::SetUpTestCase(void)
48 {
49     UsbCommonTest::GrantPermissionSysNative();
50     auto &srvClient = UsbSrvClient::GetInstance();
51     auto ret = srvClient.SetPortRole(1, 1, 1);
52     sleep(SLEEP_TIME);
53     USB_HILOGI(MODULE_USB_SERVICE, "UsbdRequestTest:: [Device] SetPortRole=%{public}d", ret);
54     ret = UsbCommonTest::SwitchErrCode(ret);
55     ASSERT_TRUE(ret == 0);
56     if (ret != 0) {
57         exit(0);
58     }
59     std::cout << "please connect device, press enter to continue" << std::endl;
60     int32_t c;
61     while ((c = getchar()) != '\n' && c != EOF) {
62         ;
63     }
64     USB_HILOGI(MODULE_USB_SERVICE, "Start UsbdRequestTest");
65 }
66 
TearDownTestCase(void)67 void UsbRequestTest::TearDownTestCase(void)
68 {
69     USB_HILOGI(MODULE_USB_SERVICE, "End UsbdRequestTest");
70 }
71 
SetUp(void)72 void UsbRequestTest::SetUp(void) {}
73 
TearDown(void)74 void UsbRequestTest::TearDown(void) {}
75 /**
76  * @tc.name: UsbRequestInitialize001
77  * @tc.desc: Test functions of Initialize(const USBDevicePipe &pipe, const USBEndpoint &endpoint)
78  * @tc.type: FUNC
79  */
80 HWTEST_F(UsbRequestTest, UsbRequestInitialize001, TestSize.Level1)
81 {
82     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbRequestInitialize001 : Initialize");
83     vector<UsbDevice> delist;
84     auto &UsbSrvClient = UsbSrvClient::GetInstance();
85     auto ret = UsbSrvClient.GetDevices(delist);
86     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize001 %{public}d ret=%{public}d size:%{public}zu",
87         __LINE__, ret, delist.size());
88     EXPECT_TRUE(ret == 0);
89     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
90     UsbDevice device = delist.front();
91     UsbSrvClient.RequestRight(device.GetName());
92     USBDevicePipe pip;
93     ret = UsbSrvClient.OpenDevice(device, pip);
94     USB_HILOGI(
95         MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize001 %{public}d OpenDevice=%{public}d", __LINE__, ret);
96     EXPECT_TRUE(ret == 0);
97     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
98     USBEndpoint point = interface.GetEndpoints().front();
99     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
100     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize001 %{public}d ClaimInterface=%{public}d",
101         __LINE__, ret);
102     EXPECT_TRUE(ret == 0);
103     UsbRequest request;
104     uint8_t tag[TAG_SIZE] = "request read";
105     std::vector<uint8_t> cdata = {tag, tag + 12};
106     request.SetClientData(cdata);
107     ret = request.Initialize(pip, point);
108     USB_HILOGI(
109         MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize001 %{public}d Initialize=%{public}d ", __LINE__, ret);
110     EXPECT_TRUE(ret == 0);
111     bool close = UsbSrvClient.Close(pip);
112     USB_HILOGI(
113         MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize001 %{public}d close=%{public}d", __LINE__, close);
114     EXPECT_TRUE(close);
115     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbRequestInitialize001 : Initialize");
116 }
117 
118 /**
119  * @tc.name: UsbRequestInitialize002
120  * @tc.desc: Test functions of Initialize(const USBDevicePipe &pipe, const USBEndpoint &endpoint)
121  * @tc.type: FUNC
122  */
123 HWTEST_F(UsbRequestTest, UsbRequestInitialize002, TestSize.Level1)
124 {
125     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbRequestInitialize002 : Initialize");
126     vector<UsbDevice> delist;
127     auto &UsbSrvClient = UsbSrvClient::GetInstance();
128     auto ret = UsbSrvClient.GetDevices(delist);
129     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize002 %{public}d ret=%{public}d size:%{public}zu",
130         __LINE__, ret, delist.size());
131     EXPECT_TRUE(ret == 0);
132     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
133     UsbDevice device = delist.front();
134     UsbSrvClient.RequestRight(device.GetName());
135     USBDevicePipe pip;
136     ret = UsbSrvClient.OpenDevice(device, pip);
137     USB_HILOGI(
138         MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize002 %{public}d OpenDevice=%{public}d", __LINE__, ret);
139     EXPECT_TRUE(ret == 0);
140     UsbRequest request;
141     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
142     USBEndpoint point = interface.GetEndpoints().at(1);
143     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
144     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize002 %{public}d ClaimInterface=%{public}d",
145         __LINE__, ret);
146     EXPECT_TRUE(ret == 0);
147     uint8_t tag[TAG_SIZE] = "request write";
148     std::vector<uint8_t> cdata = {tag, tag + 13};
149     request.SetClientData(cdata);
150     uint8_t buffer[BUFFER_SIZE] = "usb request test!";
151     std::vector<uint8_t> bufferdata = {buffer, buffer + 17};
152     request.SetReqData(bufferdata);
153     ret = request.Initialize(pip, point);
154     USB_HILOGI(
155         MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize002 %{public}d Initialize=%{public}d ", __LINE__, ret);
156     EXPECT_TRUE(ret == 0);
157     bool close = UsbSrvClient.Close(pip);
158     USB_HILOGI(
159         MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize002 %{public}d close=%{public}d", __LINE__, close);
160     EXPECT_TRUE(close);
161     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbRequestInitialize002 : Initialize");
162 }
163 
164 /**
165  * @tc.name: UsbRequestInitialize003
166  * @tc.desc: Test functions of Initialize(const USBDevicePipe &pipe, const USBEndpoint &endpoint)
167  * @tc.type: FUNC
168  */
169 HWTEST_F(UsbRequestTest, UsbRequestInitialize003, TestSize.Level1)
170 {
171     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbRequestInitialize003 : Initialize");
172     vector<UsbDevice> delist;
173     auto &UsbSrvClient = UsbSrvClient::GetInstance();
174     auto ret = UsbSrvClient.GetDevices(delist);
175     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize003 %{public}d ret=%{public}d size:%{public}zu",
176         __LINE__, ret, delist.size());
177     EXPECT_TRUE(ret == 0);
178     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
179     UsbDevice device = delist.front();
180     UsbSrvClient.RequestRight(device.GetName());
181     USBDevicePipe pip;
182     ret = UsbSrvClient.OpenDevice(device, pip);
183     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize003 %{public}d ret=%{public}d ", __LINE__, ret);
184     EXPECT_TRUE(ret == 0);
185     UsbRequest request;
186     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
187     USBEndpoint point = interface.GetEndpoints().at(0);
188     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
189     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize003 %{public}d ClaimInterface=%{public}d",
190         __LINE__, ret);
191     EXPECT_TRUE(ret == 0);
192     uint8_t tag[TAG_SIZE] = "request read";
193     std::vector<uint8_t> cdata = {tag, tag + 12};
194     request.SetClientData(cdata);
195     pip.SetBusNum(BUFFER_SIZE);
196     ret = request.Initialize(pip, point);
197     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize003 %{public}d ret=%{public}d ", __LINE__, ret);
198     EXPECT_TRUE(ret != 0);
199     pip.SetBusNum(device.GetBusNum());
200     bool close = UsbSrvClient.Close(pip);
201     USB_HILOGI(
202         MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize003 %{public}d close=%{public}d", __LINE__, close);
203     EXPECT_TRUE(close);
204     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbRequestInitialize003 : Initialize");
205 }
206 
207 /**
208  * @tc.name: UsbRequestInitialize004
209  * @tc.desc: Test functions of Initialize(const USBDevicePipe &pipe, const USBEndpoint &endpoint)
210  * @tc.type: FUNC
211  */
212 HWTEST_F(UsbRequestTest, UsbRequestInitialize004, TestSize.Level1)
213 {
214     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbRequestInitialize004 : Initialize");
215     vector<UsbDevice> delist;
216     auto &UsbSrvClient = UsbSrvClient::GetInstance();
217     auto ret = UsbSrvClient.GetDevices(delist);
218     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize004 %{public}d ret=%{public}d size:%{public}zu",
219         __LINE__, ret, delist.size());
220     EXPECT_TRUE(ret == 0);
221     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
222     UsbDevice device = delist.front();
223     UsbSrvClient.RequestRight(device.GetName());
224     USBDevicePipe pip;
225     ret = UsbSrvClient.OpenDevice(device, pip);
226     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize004 %{public}d ret=%{public}d ", __LINE__, ret);
227     EXPECT_TRUE(ret == 0);
228     UsbRequest request;
229     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
230     USBEndpoint point = interface.GetEndpoints().at(0);
231     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
232     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize004 %{public}d ClaimInterface=%{public}d",
233         __LINE__, ret);
234     EXPECT_TRUE(ret == 0);
235     uint8_t tag[TAG_SIZE] = "request read";
236     std::vector<uint8_t> cdata = {tag, tag + 12};
237     request.SetClientData(cdata);
238     pip.SetDevAddr(BUFFER_SIZE);
239     ret = request.Initialize(pip, point);
240     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize004 %{public}d ret=%{public}d ", __LINE__, ret);
241     EXPECT_TRUE(ret != 0);
242     pip.SetDevAddr(device.GetDevAddr());
243     bool close = UsbSrvClient.Close(pip);
244     USB_HILOGI(
245         MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize004 %{public}d close=%{public}d", __LINE__, close);
246     EXPECT_TRUE(close);
247     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbRequestInitialize004 : Initialize");
248 }
249 
250 /**
251  * @tc.name: UsbRequestInitialize005
252  * @tc.desc: Test functions of Initialize(const USBDevicePipe &pipe, const USBEndpoint &endpoint)
253  * @tc.type: FUNC
254  */
255 HWTEST_F(UsbRequestTest, UsbRequestInitialize005, TestSize.Level1)
256 {
257     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbRequestInitialize005 : Initialize");
258     vector<UsbDevice> delist;
259     auto &UsbSrvClient = UsbSrvClient::GetInstance();
260     auto ret = UsbSrvClient.GetDevices(delist);
261     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize005 %{public}d ret=%{public}d size:%{public}zu",
262         __LINE__, ret, delist.size());
263     EXPECT_TRUE(ret == 0);
264     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
265     UsbDevice device = delist.front();
266     UsbSrvClient.RequestRight(device.GetName());
267     USBDevicePipe pip;
268     ret = UsbSrvClient.OpenDevice(device, pip);
269     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize005 %{public}d ret=%{public}d ", __LINE__, ret);
270     EXPECT_TRUE(ret == 0);
271     UsbRequest request;
272     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
273     USBEndpoint point = interface.GetEndpoints().at(1);
274     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
275     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize005 %{public}d ClaimInterface=%{public}d",
276         __LINE__, ret);
277     EXPECT_TRUE(ret == 0);
278     uint8_t tag[TAG_SIZE] = "request write";
279     std::vector<uint8_t> cdata = {tag, tag + 13};
280     request.SetClientData(cdata);
281     uint8_t buffer[BUFFER_SIZE] = "usb request test!";
282     std::vector<uint8_t> bufferdata = {buffer, buffer + 17};
283     request.SetReqData(bufferdata);
284     pip.SetBusNum(BUFFER_SIZE);
285     ret = request.Initialize(pip, point);
286     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize005 %{public}d ret=%{public}d ", __LINE__, ret);
287     EXPECT_TRUE(ret != 0);
288     pip.SetBusNum(device.GetBusNum());
289     bool close = UsbSrvClient.Close(pip);
290     USB_HILOGI(
291         MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize005 %{public}d close=%{public}d", __LINE__, close);
292     EXPECT_TRUE(close);
293     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbRequestInitialize005 : Initialize");
294 }
295 
296 /**
297  * @tc.name: UsbRequestInitialize006
298  * @tc.desc: Test functions of Initialize(const USBDevicePipe &pipe, const USBEndpoint &endpoint)
299  * @tc.type: FUNC
300  */
301 HWTEST_F(UsbRequestTest, UsbRequestInitialize006, TestSize.Level1)
302 {
303     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbRequestInitialize006 : Initialize");
304     vector<UsbDevice> delist;
305     auto &UsbSrvClient = UsbSrvClient::GetInstance();
306     auto ret = UsbSrvClient.GetDevices(delist);
307     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize006 %{public}d ret=%{public}d size:%{public}zu",
308         __LINE__, ret, delist.size());
309     EXPECT_TRUE(ret == 0);
310     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
311     UsbDevice device = delist.front();
312     UsbSrvClient.RequestRight(device.GetName());
313     USBDevicePipe pip;
314     ret = UsbSrvClient.OpenDevice(device, pip);
315     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize006 %{public}d ret=%{public}d ", __LINE__, ret);
316     EXPECT_TRUE(ret == 0);
317     UsbRequest request;
318     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
319     USBEndpoint point = interface.GetEndpoints().at(1);
320     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
321     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize006 %{public}d ClaimInterface=%{public}d",
322         __LINE__, ret);
323     EXPECT_TRUE(ret == 0);
324     uint8_t tag[TAG_SIZE] = "request write";
325     std::vector<uint8_t> cdata = {tag, tag + 13};
326     request.SetClientData(cdata);
327     uint8_t buffer[BUFFER_SIZE] = "usb request test!";
328     std::vector<uint8_t> bufferdata = {buffer, buffer + 17};
329     request.SetReqData(bufferdata);
330     pip.SetDevAddr(BUFFER_SIZE);
331     ret = request.Initialize(pip, point);
332     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbRequestInitialize006 %{public}d ret=%{public}d ", __LINE__, ret);
333     EXPECT_TRUE(ret != 0);
334     pip.SetDevAddr(device.GetDevAddr());
335     bool close = UsbSrvClient.Close(pip);
336     USB_HILOGI(
337         MODULE_USB_SERVICE, "UsbRequestTest::UsbRequestInitialize006 %{public}d close=%{public}d", __LINE__, close);
338     EXPECT_TRUE(close);
339     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbRequestInitialize006 : Initialize");
340 }
341 
342 /**
343  * @tc.name: UsbrequestQueue001
344  * @tc.desc: Test functions of RequestQueue(UsbRequest &request, uint8_t *buffer, uint32_t length)
345  * @tc.type: FUNC
346  */
347 HWTEST_F(UsbRequestTest, UsbrequestQueue001, TestSize.Level1)
348 {
349     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbrequestQueue001 : RequestQueue");
350     vector<UsbDevice> delist;
351     auto &UsbSrvClient = UsbSrvClient::GetInstance();
352     auto ret = UsbSrvClient.GetDevices(delist);
353     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue001 %{public}d ret=%{public}d size:%{public}zu",
354         __LINE__, ret, delist.size());
355     EXPECT_TRUE(ret == 0);
356     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
357     UsbDevice device = delist.front();
358     UsbSrvClient.RequestRight(device.GetName());
359     USBDevicePipe pip;
360     ret = UsbSrvClient.OpenDevice(device, pip);
361     USB_HILOGI(
362         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue001 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
363     EXPECT_TRUE(ret == 0);
364     UsbRequest request;
365     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
366     USBEndpoint point = interface.GetEndpoints().at(0);
367     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
368     USB_HILOGI(
369         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue001 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
370     EXPECT_TRUE(ret == 0);
371     uint8_t buffer[BUFFER_SIZE] = "request queue read001";
372     std::vector<uint8_t> cdata = {buffer, buffer + 21};
373     request.SetClientData(cdata);
374     uint8_t buffer1[BUFFER_SIZE] = {0};
375     std::vector<uint8_t> bufferdata = {buffer1, buffer1 + 17};
376     request.SetReqData(bufferdata);
377     ret = request.Initialize(pip, point);
378     USB_HILOGI(
379         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue001 %{public}d initialize=%{public}d ", __LINE__, ret);
380     EXPECT_TRUE(ret == 0);
381     ret = UsbSrvClient.RequestQueue(request);
382     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue001 %{public}d queue=%{public}d ", __LINE__, ret);
383     EXPECT_TRUE(ret == 0);
384     bool close = UsbSrvClient.Close(pip);
385     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue001 %{public}d close=%{public}d", __LINE__, close);
386     EXPECT_TRUE(close);
387     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbrequestQueue001 : RequestQueue");
388 }
389 
390 /**
391  * @tc.name: UsbrequestQueue002
392  * @tc.desc: Test functions of RequestQueue(UsbRequest &request, uint8_t *buffer, uint32_t length)
393  * @tc.type: FUNC
394  */
395 HWTEST_F(UsbRequestTest, UsbrequestQueue002, TestSize.Level1)
396 {
397     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbrequestQueue002 : RequestQueue");
398     vector<UsbDevice> delist;
399     auto &UsbSrvClient = UsbSrvClient::GetInstance();
400     auto ret = UsbSrvClient.GetDevices(delist);
401     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue002 %{public}d ret=%{public}d size:%{public}zu",
402         __LINE__, ret, delist.size());
403     EXPECT_TRUE(ret == 0);
404     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
405     UsbDevice device = delist.front();
406     UsbSrvClient.RequestRight(device.GetName());
407     USBDevicePipe pip;
408     ret = UsbSrvClient.OpenDevice(device, pip);
409     USB_HILOGI(
410         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue002 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
411     EXPECT_TRUE(ret == 0);
412     UsbRequest request;
413     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
414     USBEndpoint point = interface.GetEndpoints().at(1);
415     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
416     USB_HILOGI(
417         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue002 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
418     EXPECT_TRUE(ret == 0);
419     uint8_t buffer[BUFFER_SIZE] = "request queue write 002";
420     std::vector<uint8_t> cdata = {buffer, buffer + 23};
421     request.SetClientData(cdata);
422     uint8_t buffer1[BUFFER_SIZE] = "usb request test!";
423     std::vector<uint8_t> bufferdata = {buffer1, buffer1 + 17};
424     request.SetReqData(bufferdata);
425     ret = request.Initialize(pip, point);
426     USB_HILOGI(
427         MODULE_USB_SERVICE, "UsbRequestTest:UsbrequestQueue002 %{public}d initialize=%{public}d ", __LINE__, ret);
428     EXPECT_TRUE(ret == 0);
429     ret = UsbSrvClient.RequestQueue(request);
430     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:UsbrequestQueue002 %{public}d queue=%{public}d ", __LINE__, ret);
431     EXPECT_TRUE(ret == 0);
432     bool close = UsbSrvClient.Close(pip);
433     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue002 %{public}d close=%{public}d", __LINE__, close);
434     EXPECT_TRUE(close);
435     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbrequestQueue002 : RequestQueue");
436 }
437 
438 /**
439  * @tc.name: UsbrequestQueue003
440  * @tc.desc: Test functions of RequestQueue(UsbRequest &request, uint8_t *buffer, uint32_t length)
441  * @tc.type: FUNC
442  */
443 HWTEST_F(UsbRequestTest, UsbrequestQueue003, TestSize.Level1)
444 {
445     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbrequestQueue003 : RequestQueue");
446     vector<UsbDevice> delist;
447     auto &UsbSrvClient = UsbSrvClient::GetInstance();
448     auto ret = UsbSrvClient.GetDevices(delist);
449     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue003 %{public}d ret=%{public}d size:%{public}zu",
450         __LINE__, ret, delist.size());
451     EXPECT_TRUE(ret == 0);
452     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
453     UsbDevice device = delist.front();
454     UsbSrvClient.RequestRight(device.GetName());
455     USBDevicePipe pip;
456     ret = UsbSrvClient.OpenDevice(device, pip);
457     USB_HILOGI(
458         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue003 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
459     EXPECT_TRUE(ret == 0);
460     UsbRequest request;
461     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
462     USBEndpoint point = interface.GetEndpoints().at(0);
463     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
464     USB_HILOGI(
465         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue003 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
466     EXPECT_TRUE(ret == 0);
467     uint8_t buffer[BUFFER_SIZE] = "request queue read003";
468     std::vector<uint8_t> cdata = {buffer, buffer + 21};
469     request.SetClientData(cdata);
470     uint8_t buffer1[BUFFER_SIZE] = {0};
471     std::vector<uint8_t> bufferdata = {buffer1, buffer1 + 17};
472     request.SetReqData(bufferdata);
473     ret = request.Initialize(pip, point);
474     USB_HILOGI(
475         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue003 %{public}d initialize=%{public}d ", __LINE__, ret);
476     EXPECT_TRUE(ret == 0);
477     pip.SetBusNum(BUFFER_SIZE);
478     request.SetPipe(pip);
479     ret = UsbSrvClient.RequestQueue(request);
480     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue003 %{public}d queue=%{public}d ", __LINE__, ret);
481     EXPECT_TRUE(ret != 0);
482     pip.SetBusNum(device.GetBusNum());
483     bool close = UsbSrvClient.Close(pip);
484     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue003 %{public}d close=%{public}d", __LINE__, close);
485     EXPECT_TRUE(close);
486     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbrequestQueue003 : RequestQueue");
487 }
488 
489 /**
490  * @tc.name: UsbrequestQueue004
491  * @tc.desc: Test functions of RequestQueue(UsbRequest &request, uint8_t *buffer, uint32_t length)
492  * @tc.type: FUNC
493  */
494 HWTEST_F(UsbRequestTest, UsbrequestQueue004, TestSize.Level1)
495 {
496     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbrequestQueue004 : RequestQueue");
497     vector<UsbDevice> delist;
498     auto &UsbSrvClient = UsbSrvClient::GetInstance();
499     auto ret = UsbSrvClient.GetDevices(delist);
500     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue004 %{public}d ret=%{public}d size:%{public}zu",
501         __LINE__, ret, delist.size());
502     EXPECT_TRUE(ret == 0);
503     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
504     UsbDevice device = delist.front();
505     UsbSrvClient.RequestRight(device.GetName());
506     USBDevicePipe pip;
507     ret = UsbSrvClient.OpenDevice(device, pip);
508     USB_HILOGI(
509         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue004 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
510     EXPECT_TRUE(ret == 0);
511     UsbRequest request;
512     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
513     USBEndpoint point = interface.GetEndpoints().at(0);
514     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
515     USB_HILOGI(
516         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue004 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
517     EXPECT_TRUE(ret == 0);
518     uint8_t buffer[BUFFER_SIZE] = "request queue read004";
519     std::vector<uint8_t> cdata = {buffer, buffer + 21};
520     request.SetClientData(cdata);
521     uint8_t buffer1[BUFFER_SIZE] = {0};
522     std::vector<uint8_t> bufferdata = {buffer1, buffer1 + 17};
523     request.SetReqData(bufferdata);
524     ret = request.Initialize(pip, point);
525     USB_HILOGI(
526         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue004 %{public}d initialize=%{public}d ", __LINE__, ret);
527     EXPECT_TRUE(ret == 0);
528     pip.SetDevAddr(BUFFER_SIZE);
529     request.SetPipe(pip);
530     ret = UsbSrvClient.RequestQueue(request);
531     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue004 %{public}d queue=%{public}d ", __LINE__, ret);
532     EXPECT_TRUE(ret != 0);
533     pip.SetDevAddr(device.GetDevAddr());
534     bool close = UsbSrvClient.Close(pip);
535     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue004 %{public}d close=%{public}d", __LINE__, close);
536     EXPECT_TRUE(close);
537     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbrequestQueue004 : RequestQueue");
538 }
539 
540 /**
541  * @tc.name: UsbrequestQueue005
542  * @tc.desc: Test functions of RequestQueue(UsbRequest &request, uint8_t *buffer, uint32_t length)
543  * @tc.type: FUNC
544  */
545 HWTEST_F(UsbRequestTest, UsbrequestQueue005, TestSize.Level1)
546 {
547     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbrequestQueue005 : RequestQueue");
548     vector<UsbDevice> delist;
549     auto &UsbSrvClient = UsbSrvClient::GetInstance();
550     auto ret = UsbSrvClient.GetDevices(delist);
551     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue005 %{public}d ret=%{public}d size:%{public}zu",
552         __LINE__, ret, delist.size());
553     EXPECT_TRUE(ret == 0);
554     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
555     UsbDevice device = delist.front();
556     UsbSrvClient.RequestRight(device.GetName());
557     USBDevicePipe pip;
558     ret = UsbSrvClient.OpenDevice(device, pip);
559     USB_HILOGI(
560         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue005 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
561     EXPECT_TRUE(ret == 0);
562     UsbRequest request;
563     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
564     USBEndpoint point = interface.GetEndpoints().at(1);
565     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
566     USB_HILOGI(
567         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue005 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
568     EXPECT_TRUE(ret == 0);
569     uint8_t buffer[BUFFER_SIZE] = "request queue write005";
570     std::vector<uint8_t> cdata = {buffer, buffer + 22};
571     request.SetClientData(cdata);
572     uint8_t buffer1[BUFFER_SIZE] = "usb request test!";
573     std::vector<uint8_t> databuffer = {buffer1, buffer1 + 17};
574     request.SetReqData(databuffer);
575     ret = request.Initialize(pip, point);
576     USB_HILOGI(
577         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue005 %{public}d initialize=%{public}d ", __LINE__, ret);
578     EXPECT_TRUE(ret == 0);
579     pip.SetBusNum(BUFFER_SIZE);
580     request.SetPipe(pip);
581     ret = UsbSrvClient.RequestQueue(request);
582     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue005 %{public}d queue=%{public}d ", __LINE__, ret);
583     EXPECT_TRUE(ret != 0);
584     pip.SetBusNum(device.GetBusNum());
585     bool close = UsbSrvClient.Close(pip);
586     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue005 %{public}d close=%{public}d", __LINE__, close);
587     EXPECT_TRUE(close);
588     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbrequestQueue005 : RequestQueue");
589 }
590 
591 /**
592  * @tc.name: UsbrequestQueue006
593  * @tc.desc: Test functions of RequestQueue(UsbRequest &request, uint8_t *buffer, uint32_t length)
594  * @tc.type: FUNC
595  */
596 HWTEST_F(UsbRequestTest, UsbrequestQueue006, TestSize.Level1)
597 {
598     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbrequestQueue006 : RequestQueue");
599     vector<UsbDevice> delist;
600     auto &UsbSrvClient = UsbSrvClient::GetInstance();
601     auto ret = UsbSrvClient.GetDevices(delist);
602     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue006 %{public}d ret=%{public}d size:%{public}zu",
603         __LINE__, ret, delist.size());
604     EXPECT_TRUE(ret == 0);
605     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
606     UsbDevice device = delist.front();
607     UsbSrvClient.RequestRight(device.GetName());
608     USBDevicePipe pip;
609     ret = UsbSrvClient.OpenDevice(device, pip);
610     USB_HILOGI(
611         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue006 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
612     EXPECT_TRUE(ret == 0);
613     UsbRequest request;
614     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
615     USBEndpoint point = interface.GetEndpoints().at(1);
616     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
617     USB_HILOGI(
618         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue006 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
619     EXPECT_TRUE(ret == 0);
620     uint8_t buffer[BUFFER_SIZE] = "request queue write006";
621     std::vector<uint8_t> cdata = {buffer, buffer + 22};
622     request.SetClientData(cdata);
623     uint8_t buffer1[BUFFER_SIZE] = "usb request test!";
624     std::vector<uint8_t> databuffer = {buffer1, buffer1 + 17};
625     request.SetReqData(databuffer);
626     ret = request.Initialize(pip, point);
627     USB_HILOGI(
628         MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue006 %{public}d initialize=%{public}d ", __LINE__, ret);
629     EXPECT_TRUE(ret == 0);
630     pip.SetDevAddr(BUFFER_SIZE);
631     request.SetPipe(pip);
632     ret = UsbSrvClient.RequestQueue(request);
633     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue006 %{public}d queue=%{public}d ", __LINE__, ret);
634     EXPECT_TRUE(ret != 0);
635     pip.SetDevAddr(device.GetDevAddr());
636     bool close = UsbSrvClient.Close(pip);
637     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbrequestQueue006 %{public}d close=%{public}d", __LINE__, close);
638     EXPECT_TRUE(close);
639     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbrequestQueue006 : RequestQueue");
640 }
641 
642 /**
643  * @tc.name: Usbrequestfree001
644  * @tc.desc: Test functions of RequestFree(UsbRequest &request);
645  * @tc.type: FUNC
646  */
647 HWTEST_F(UsbRequestTest, Usbrequestfree001, TestSize.Level1)
648 {
649     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestfree001 : RequestQueue");
650     vector<UsbDevice> delist;
651     auto &UsbSrvClient = UsbSrvClient::GetInstance();
652     auto ret = UsbSrvClient.GetDevices(delist);
653     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree001 %{public}d ret=%{public}d size:%{public}zu",
654         __LINE__, ret, delist.size());
655     EXPECT_TRUE(ret == 0);
656     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
657     UsbDevice device = delist.front();
658     UsbSrvClient.RequestRight(device.GetName());
659     USBDevicePipe pip;
660     ret = UsbSrvClient.OpenDevice(device, pip);
661     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree001 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
662     EXPECT_TRUE(ret == 0);
663     UsbRequest request;
664     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
665     USBEndpoint point = interface.GetEndpoints().at(0);
666     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
667     USB_HILOGI(
668         MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree001 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
669     EXPECT_TRUE(ret == 0);
670     uint8_t tag[TAG_SIZE] = "request free 001";
671     std::vector<uint8_t> cdata = {tag, tag + 16};
672     request.SetClientData(cdata);
673     ret = request.Initialize(pip, point);
674     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree001 %{public}d initialize=%{public}d ", __LINE__, ret);
675     EXPECT_TRUE(ret == 0);
676     ret = UsbSrvClient.RequestFree(request);
677     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree001 %{public}d free=%{public}d ", __LINE__, ret);
678     EXPECT_TRUE(ret == 0);
679     bool close = UsbSrvClient.Close(pip);
680     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree001 %{public}d close=%{public}d", __LINE__, close);
681     EXPECT_TRUE(close);
682     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestfree001 : RequestFree");
683 }
684 
685 /**
686  * @tc.name: Usbrequestfree002
687  * @tc.desc: Test functions of RequestFree(UsbRequest &request);
688  * @tc.type: FUNC
689  */
690 HWTEST_F(UsbRequestTest, Usbrequestfree002, TestSize.Level1)
691 {
692     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestfree002 : RequestQueue");
693     vector<UsbDevice> delist;
694     auto &UsbSrvClient = UsbSrvClient::GetInstance();
695     auto ret = UsbSrvClient.GetDevices(delist);
696     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree002 %{public}d ret=%{public}d size:%{public}zu",
697         __LINE__, ret, delist.size());
698     EXPECT_TRUE(ret == 0);
699     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
700     UsbDevice device = delist.front();
701     UsbSrvClient.RequestRight(device.GetName());
702     USBDevicePipe pip;
703     ret = UsbSrvClient.OpenDevice(device, pip);
704     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree002 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
705     EXPECT_TRUE(ret == 0);
706     UsbRequest request;
707     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
708     USBEndpoint point = interface.GetEndpoints().at(0);
709     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
710     USB_HILOGI(
711         MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree002 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
712     EXPECT_TRUE(ret == 0);
713     uint8_t tag[TAG_SIZE] = "request free 002";
714     std::vector<uint8_t> cdata = {tag, tag + 16};
715     request.SetClientData(cdata);
716     ret = request.Initialize(pip, point);
717     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree002 %{public}d initialize=%{public}d ", __LINE__, ret);
718     EXPECT_TRUE(ret == 0);
719     pip.SetBusNum(BUFFER_SIZE);
720     request.SetPipe(pip);
721     ret = UsbSrvClient.RequestFree(request);
722     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree002 %{public}d free=%{public}d ", __LINE__, ret);
723     EXPECT_TRUE(ret != 0);
724     pip.SetBusNum(device.GetBusNum());
725     bool close = UsbSrvClient.Close(pip);
726     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree002 %{public}d close=%{public}d", __LINE__, close);
727     EXPECT_TRUE(close);
728     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestfree002 : RequestFree");
729 }
730 
731 /**
732  * @tc.name: Usbrequestfree003
733  * @tc.desc: Test functions of RequestFree(UsbRequest &request);
734  * @tc.type: FUNC
735  */
736 HWTEST_F(UsbRequestTest, Usbrequestfree003, TestSize.Level1)
737 {
738     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestfree003 : RequestQueue");
739     vector<UsbDevice> delist;
740     auto &UsbSrvClient = UsbSrvClient::GetInstance();
741     auto ret = UsbSrvClient.GetDevices(delist);
742     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree003 %{public}d ret=%{public}d size:%{public}zu",
743         __LINE__, ret, delist.size());
744     EXPECT_TRUE(ret == 0);
745     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
746     UsbDevice device = delist.front();
747     UsbSrvClient.RequestRight(device.GetName());
748     USBDevicePipe pip;
749     ret = UsbSrvClient.OpenDevice(device, pip);
750     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree003 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
751     EXPECT_TRUE(ret == 0);
752     UsbRequest request;
753     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
754     USBEndpoint point = interface.GetEndpoints().at(0);
755     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
756     USB_HILOGI(
757         MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree003 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
758     EXPECT_TRUE(ret == 0);
759     uint8_t tag[TAG_SIZE] = "request free 003";
760     std::vector<uint8_t> cdata = {tag, tag + 16};
761     request.SetClientData(cdata);
762     ret = request.Initialize(pip, point);
763     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree003 %{public}d initialize=%{public}d ", __LINE__, ret);
764     EXPECT_TRUE(ret == 0);
765     pip.SetDevAddr(BUFFER_SIZE);
766     request.SetPipe(pip);
767     ret = UsbSrvClient.RequestFree(request);
768     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree003 %{public}d free=%{public}d ", __LINE__, ret);
769     EXPECT_TRUE(ret != 0);
770     pip.SetDevAddr(device.GetDevAddr());
771     bool close = UsbSrvClient.Close(pip);
772     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree003 %{public}d close=%{public}d", __LINE__, close);
773     EXPECT_TRUE(close);
774     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestfree003 : RequestFree");
775 }
776 
777 /**
778  * @tc.name: Usbrequestfree004
779  * @tc.desc: Test functions of RequestFree(UsbRequest &request);
780  * @tc.type: FUNC
781  */
782 HWTEST_F(UsbRequestTest, Usbrequestfree004, TestSize.Level1)
783 {
784     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestfree004 : Requestfree");
785     vector<UsbDevice> delist;
786     auto &UsbSrvClient = UsbSrvClient::GetInstance();
787     auto ret = UsbSrvClient.GetDevices(delist);
788     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree004 %{public}d ret=%{public}d size:%{public}zu",
789         __LINE__, ret, delist.size());
790     EXPECT_TRUE(ret == 0);
791     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
792     UsbDevice device = delist.front();
793     UsbSrvClient.RequestRight(device.GetName());
794     USBDevicePipe pip;
795     ret = UsbSrvClient.OpenDevice(device, pip);
796     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree004 %{public}d OpenDevice=%{public}d", __LINE__, ret);
797     EXPECT_TRUE(ret == 0);
798     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
799     UsbRequest request;
800     USBEndpoint point = interface.GetEndpoints().at(1);
801     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
802     USB_HILOGI(
803         MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree004 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
804     EXPECT_TRUE(ret == 0);
805     uint8_t tag[TAG_SIZE] = "request free 004";
806     std::vector<uint8_t> cdata = {tag, tag + 16};
807     request.SetClientData(cdata);
808     uint8_t buffer[BUFFER_SIZE] = "usb request test!";
809     std::vector<uint8_t> databuffer = {buffer, buffer + 17};
810     request.SetReqData(databuffer);
811     ret = request.Initialize(pip, point);
812     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree004 %{public}d initialize=%{public}d ", __LINE__, ret);
813     EXPECT_TRUE(ret == 0);
814     ret = UsbSrvClient.RequestFree(request);
815     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree004 %{public}d free=%{public}d ", __LINE__, ret);
816     EXPECT_TRUE(ret == 0);
817     bool close = UsbSrvClient.Close(pip);
818     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree004 %{public}d close=%{public}d", __LINE__, close);
819     EXPECT_TRUE(close);
820     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestfree004 : Requestfree");
821 }
822 
823 /**
824  * @tc.name: Usbrequestfree005
825  * @tc.desc: Test functions of RequestFree(UsbRequest &request);
826  * @tc.type: FUNC
827  */
828 HWTEST_F(UsbRequestTest, Usbrequestfree005, TestSize.Level1)
829 {
830     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestfree005 : RequestQueue");
831     vector<UsbDevice> delist;
832     auto &UsbSrvClient = UsbSrvClient::GetInstance();
833     auto ret = UsbSrvClient.GetDevices(delist);
834     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree005 %{public}d ret=%{public}d size:%{public}zu",
835         __LINE__, ret, delist.size());
836     EXPECT_TRUE(ret == 0);
837     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
838     UsbDevice device = delist.front();
839     UsbSrvClient.RequestRight(device.GetName());
840     USBDevicePipe pip;
841     ret = UsbSrvClient.OpenDevice(device, pip);
842     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree005 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
843     EXPECT_TRUE(ret == 0);
844     UsbRequest request;
845     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
846     USBEndpoint point = interface.GetEndpoints().at(1);
847     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
848     USB_HILOGI(
849         MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree005 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
850     EXPECT_TRUE(ret == 0);
851     uint8_t tag[TAG_SIZE] = "request free 005";
852     std::vector<uint8_t> cdata = {tag, tag + 16};
853     request.SetClientData(cdata);
854     uint8_t buffer[BUFFER_SIZE] = "usb request test!";
855     std::vector<uint8_t> databuffer = {buffer, buffer + 17};
856     request.SetReqData(databuffer);
857     ret = request.Initialize(pip, point);
858     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree005 %{public}d initialize=%{public}d ", __LINE__, ret);
859     EXPECT_TRUE(ret == 0);
860     pip.SetBusNum(BUFFER_SIZE);
861     request.SetPipe(pip);
862     ret = UsbSrvClient.RequestFree(request);
863     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree005 %{public}d free=%{public}d ", __LINE__, ret);
864     EXPECT_TRUE(ret != 0);
865     pip.SetBusNum(device.GetBusNum());
866     bool close = UsbSrvClient.Close(pip);
867     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree005 %{public}d close=%{public}d", __LINE__, close);
868     EXPECT_TRUE(close);
869     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestfree005 : RequestFree");
870 }
871 
872 /**
873  * @tc.name: Usbrequestfree006
874  * @tc.desc: Test functions of RequestFree(UsbRequest &request);
875  * @tc.type: FUNC
876  */
877 HWTEST_F(UsbRequestTest, Usbrequestfree006, TestSize.Level1)
878 {
879     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestfree006 : RequestQueue");
880     vector<UsbDevice> delist;
881     auto &UsbSrvClient = UsbSrvClient::GetInstance();
882     auto ret = UsbSrvClient.GetDevices(delist);
883     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree006 %{public}d ret=%{public}d size:%{public}zu",
884         __LINE__, ret, delist.size());
885     EXPECT_TRUE(ret == 0);
886     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
887     UsbDevice device = delist.front();
888     UsbSrvClient.RequestRight(device.GetName());
889     USBDevicePipe pip;
890     ret = UsbSrvClient.OpenDevice(device, pip);
891     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree006 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
892     EXPECT_TRUE(ret == 0);
893     UsbRequest request;
894     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
895     USBEndpoint point = interface.GetEndpoints().at(1);
896     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
897     USB_HILOGI(
898         MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree006 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
899     EXPECT_TRUE(ret == 0);
900     uint8_t tag[TAG_SIZE] = "request free 006";
901     std::vector<uint8_t> cdata = {tag, tag + 16};
902     request.SetClientData(cdata);
903     uint8_t buffer[BUFFER_SIZE] = "usb request test!";
904     std::vector<uint8_t> databuffer = {buffer, buffer + 17};
905     request.SetReqData(databuffer);
906     ret = request.Initialize(pip, point);
907     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree006 %{public}d initialize=%{public}d ", __LINE__, ret);
908     EXPECT_TRUE(ret == 0);
909     pip.SetDevAddr(BUFFER_SIZE);
910     request.SetPipe(pip);
911     ret = UsbSrvClient.RequestFree(request);
912     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestfree006 %{public}d free=%{public}d ", __LINE__, ret);
913     EXPECT_TRUE(ret != 0);
914     pip.SetDevAddr(device.GetDevAddr());
915     bool close = UsbSrvClient.Close(pip);
916     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestfree006 %{public}d close=%{public}d", __LINE__, close);
917     EXPECT_TRUE(close);
918     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestfree006 : RequestFree");
919 }
920 
921 /**
922  * @tc.name: Usbrequestabort001
923  * @tc.desc: Test functions of RequestAbort(request)
924  * @tc.type: FUNC
925  */
926 HWTEST_F(UsbRequestTest, Usbrequestabort001, TestSize.Level1)
927 {
928     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestabort001 : Requestabort");
929     vector<UsbDevice> delist;
930     auto &UsbSrvClient = UsbSrvClient::GetInstance();
931     auto ret = UsbSrvClient.GetDevices(delist);
932     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort001 %{public}d ret=%{public}d size:%{public}zu",
933         __LINE__, ret, delist.size());
934     EXPECT_TRUE(ret == 0);
935     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
936     UsbDevice device = delist.front();
937     UsbSrvClient.RequestRight(device.GetName());
938     USBDevicePipe pip;
939     ret = UsbSrvClient.OpenDevice(device, pip);
940     USB_HILOGI(
941         MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort001 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
942     EXPECT_TRUE(ret == 0);
943     UsbRequest request;
944     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
945     USBEndpoint point = interface.GetEndpoints().at(0);
946     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
947     USB_HILOGI(
948         MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort001 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
949     EXPECT_TRUE(ret == 0);
950     uint8_t tag[TAG_SIZE] = "hello world request013";
951     std::vector<uint8_t> cdata = {tag, tag + 22};
952     request.SetClientData(cdata);
953     ret = request.Initialize(pip, point);
954     USB_HILOGI(
955         MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort001 %{public}d initialize=%{public}d ", __LINE__, ret);
956     EXPECT_TRUE(ret == 0);
957     uint8_t buffer[BUFFER_SIZE] = "request abort 001";
958     std::vector<uint8_t> databuffer = {buffer, buffer + 17};
959     request.SetReqData(databuffer);
960     ret = UsbSrvClient.RequestQueue(request);
961     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort001 %{public}d queue=%{public}d ", __LINE__, ret);
962     EXPECT_TRUE(ret == 0);
963     ret = UsbSrvClient.RequestAbort(request);
964     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort001 %{public}d Abort=%{public}d ", __LINE__, ret);
965     EXPECT_TRUE(ret == 0);
966     bool close = UsbSrvClient.Close(pip);
967     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort001 %{public}d close=%{public}d", __LINE__, close);
968     EXPECT_TRUE(close);
969     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestabort001 : Requestabort");
970 }
971 
972 /**
973  * @tc.name: Usbrequestabort002
974  * @tc.desc: Test functions of RequestAbort(request)
975  * @tc.type: FUNC
976  */
977 HWTEST_F(UsbRequestTest, Usbrequestabort002, TestSize.Level1)
978 {
979     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestabort002 : Requestabort");
980     vector<UsbDevice> delist;
981     auto &UsbSrvClient = UsbSrvClient::GetInstance();
982     auto ret = UsbSrvClient.GetDevices(delist);
983     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort002 %{public}d ret=%{public}d size:%{public}zu",
984         __LINE__, ret, delist.size());
985     EXPECT_TRUE(ret == 0);
986     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
987     UsbDevice device = delist.front();
988     UsbSrvClient.RequestRight(device.GetName());
989     USBDevicePipe pip;
990     ret = UsbSrvClient.OpenDevice(device, pip);
991     USB_HILOGI(
992         MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort002 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
993     EXPECT_TRUE(ret == 0);
994     UsbRequest request;
995     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
996     USBEndpoint point = interface.GetEndpoints().at(0);
997     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
998     USB_HILOGI(
999         MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort002 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1000     EXPECT_TRUE(ret == 0);
1001     uint8_t tag[TAG_SIZE] = "request abort 002";
1002     std::vector<uint8_t> cdata = {tag, tag + 17};
1003     request.SetClientData(cdata);
1004     uint8_t buffer1[BUFFER_SIZE] = {0};
1005     std::vector<uint8_t> bufferdata = {buffer1, buffer1 + 17};
1006     request.SetReqData(bufferdata);
1007     ret = request.Initialize(pip, point);
1008     USB_HILOGI(
1009         MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort002 %{public}d initialize=%{public}d ", __LINE__, ret);
1010     EXPECT_TRUE(ret == 0);
1011     ret = UsbSrvClient.RequestQueue(request);
1012     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort002 %{public}d queue=%{public}d ", __LINE__, ret);
1013     EXPECT_TRUE(ret == 0);
1014     pip.SetBusNum(BUFFER_SIZE);
1015     request.SetPipe(pip);
1016     ret = UsbSrvClient.RequestAbort(request);
1017     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort002 %{public}d Abort=%{public}d ", __LINE__, ret);
1018     EXPECT_TRUE(ret != 0);
1019     pip.SetBusNum(device.GetBusNum());
1020     bool close = UsbSrvClient.Close(pip);
1021     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort002 %{public}d close=%{public}d", __LINE__, close);
1022     EXPECT_TRUE(close);
1023     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestabort002 : Requestabort");
1024 }
1025 
1026 /**
1027  * @tc.name: Usbrequestabort003
1028  * @tc.desc: Test functions of RequestAbort(request)
1029  * @tc.type: FUNC
1030  */
1031 HWTEST_F(UsbRequestTest, Usbrequestabort003, TestSize.Level1)
1032 {
1033     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestabort003 : Requestabort");
1034     vector<UsbDevice> delist;
1035     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1036     auto ret = UsbSrvClient.GetDevices(delist);
1037     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort003 %{public}d ret=%{public}d size:%{public}zu",
1038         __LINE__, ret, delist.size());
1039     EXPECT_TRUE(ret == 0);
1040     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1041     UsbDevice device = delist.front();
1042     UsbSrvClient.RequestRight(device.GetName());
1043     USBDevicePipe pip;
1044     ret = UsbSrvClient.OpenDevice(device, pip);
1045     USB_HILOGI(
1046         MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort003 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
1047     EXPECT_TRUE(ret == 0);
1048     UsbRequest request;
1049     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
1050     USBEndpoint point = interface.GetEndpoints().at(0);
1051     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
1052     USB_HILOGI(
1053         MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort003 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1054     EXPECT_TRUE(ret == 0);
1055     uint8_t tag[TAG_SIZE] = "request abort 003";
1056     std::vector<uint8_t> cdata = {tag, tag + 17};
1057     request.SetClientData(cdata);
1058     uint8_t buffer1[BUFFER_SIZE] = {0};
1059     std::vector<uint8_t> bufferdata = {buffer1, buffer1 + 17};
1060     request.SetReqData(bufferdata);
1061     ret = request.Initialize(pip, point);
1062     USB_HILOGI(
1063         MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort003 %{public}d initialize=%{public}d ", __LINE__, ret);
1064     EXPECT_TRUE(ret == 0);
1065     ret = UsbSrvClient.RequestQueue(request);
1066     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort003 %{public}d queue=%{public}d ", __LINE__, ret);
1067     EXPECT_TRUE(ret == 0);
1068     pip.SetDevAddr(BUFFER_SIZE);
1069     request.SetPipe(pip);
1070     ret = UsbSrvClient.RequestAbort(request);
1071     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort003 %{public}d Abort=%{public}d ", __LINE__, ret);
1072     EXPECT_TRUE(ret != 0);
1073     pip.SetDevAddr(device.GetDevAddr());
1074     bool close = UsbSrvClient.Close(pip);
1075     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort003 %{public}d close=%{public}d", __LINE__, close);
1076     EXPECT_TRUE(close);
1077     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestabort003 : Requestabort");
1078 }
1079 
1080 /**
1081  * @tc.name: Usbrequestabort004
1082  * @tc.desc: Test functions of RequestAbort(request)
1083  * @tc.type: FUNC
1084  */
1085 HWTEST_F(UsbRequestTest, Usbrequestabort004, TestSize.Level1)
1086 {
1087     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestabort004 : Requestabort");
1088     vector<UsbDevice> delist;
1089     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1090     auto ret = UsbSrvClient.GetDevices(delist);
1091     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort004 %{public}d ret=%{public}d size:%{public}zu",
1092         __LINE__, ret, delist.size());
1093     EXPECT_TRUE(ret == 0);
1094     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1095     UsbDevice device = delist.front();
1096     UsbSrvClient.RequestRight(device.GetName());
1097     USBDevicePipe pip;
1098     ret = UsbSrvClient.OpenDevice(device, pip);
1099     USB_HILOGI(
1100         MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort004 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
1101     EXPECT_TRUE(ret == 0);
1102     UsbRequest request;
1103     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
1104     USBEndpoint point = interface.GetEndpoints().at(1);
1105     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort004 %{public}d GetDirection=%{public}d ", __LINE__,
1106         point.GetDirection());
1107     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort004 %{public}d GetInterfaceId=%{public}d ", __LINE__,
1108         point.GetInterfaceId());
1109     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
1110     EXPECT_TRUE(ret == 0);
1111     uint8_t tag[TAG_SIZE] = "hello world request013";
1112     std::vector<uint8_t> cdata = {tag, tag + 22};
1113     request.SetClientData(cdata);
1114     ret = request.Initialize(pip, point);
1115     EXPECT_TRUE(ret == 0);
1116     uint8_t buffer[BUFFER_SIZE] = "request abort 004";
1117     std::vector<uint8_t> databuffer = {buffer, buffer + 17};
1118     request.SetReqData(databuffer);
1119     ret = UsbSrvClient.RequestQueue(request);
1120     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort004 %{public}d queue=%{public}d ", __LINE__, ret);
1121     EXPECT_TRUE(ret == 0);
1122     ret = UsbSrvClient.RequestAbort(request);
1123     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort004 %{public}d abort=%{public}d ", __LINE__, ret);
1124     EXPECT_TRUE(ret == 0);
1125     bool close = UsbSrvClient.Close(pip);
1126     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort004 %{public}d close=%{public}d", __LINE__, close);
1127     EXPECT_TRUE(close);
1128     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestabort004 : Requestabort");
1129 }
1130 
1131 /**
1132  * @tc.name: Usbrequestabort005
1133  * @tc.desc: Test functions of RequestAbort(request)
1134  * @tc.type: FUNC
1135  */
1136 HWTEST_F(UsbRequestTest, Usbrequestabort005, TestSize.Level1)
1137 {
1138     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestabort005 : Requestabort");
1139     vector<UsbDevice> delist;
1140     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1141     auto ret = UsbSrvClient.GetDevices(delist);
1142     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort005 %{public}d ret=%{public}d size:%{public}zu",
1143         __LINE__, ret, delist.size());
1144     EXPECT_TRUE(ret == 0);
1145     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1146     UsbDevice device = delist.front();
1147     UsbSrvClient.RequestRight(device.GetName());
1148     USBDevicePipe pip;
1149     ret = UsbSrvClient.OpenDevice(device, pip);
1150     USB_HILOGI(
1151         MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort005 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
1152     EXPECT_TRUE(ret == 0);
1153     UsbRequest request;
1154     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
1155     USBEndpoint point = interface.GetEndpoints().at(1);
1156     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
1157     EXPECT_TRUE(ret == 0);
1158     uint8_t tag[TAG_SIZE] = "request abort 005";
1159     std::vector<uint8_t> cdata = {tag, tag + 17};
1160     request.SetClientData(cdata);
1161     ret = request.Initialize(pip, point);
1162     EXPECT_TRUE(ret == 0);
1163     uint8_t buffer[BUFFER_SIZE] = "usb request test 005";
1164     std::vector<uint8_t> databuffer = {buffer, buffer + 20};
1165     request.SetReqData(databuffer);
1166     ret = UsbSrvClient.RequestQueue(request);
1167     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort005 %{public}d queue=%{public}d ", __LINE__, ret);
1168     EXPECT_TRUE(ret == 0);
1169     pip.SetBusNum(BUFFER_SIZE);
1170     request.SetPipe(pip);
1171     ret = UsbSrvClient.RequestAbort(request);
1172     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort005 %{public}d Abort=%{public}d ", __LINE__, ret);
1173     EXPECT_TRUE(ret != 0);
1174     pip.SetBusNum(device.GetBusNum());
1175     bool close = UsbSrvClient.Close(pip);
1176     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort005 %{public}d close=%{public}d", __LINE__, close);
1177     EXPECT_TRUE(close);
1178     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestabort005 : Requestabort");
1179 }
1180 
1181 /**
1182  * @tc.name: Usbrequestabort006
1183  * @tc.desc: Test functions of RequestAbort(request)
1184  * @tc.type: FUNC
1185  */
1186 HWTEST_F(UsbRequestTest, Usbrequestabort006, TestSize.Level1)
1187 {
1188     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestabort006 : Requestabort");
1189     vector<UsbDevice> delist;
1190     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1191     auto ret = UsbSrvClient.GetDevices(delist);
1192     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort006 %{public}d ret=%{public}d size:%{public}zu",
1193         __LINE__, ret, delist.size());
1194     EXPECT_TRUE(ret == 0);
1195     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1196     UsbDevice device = delist.front();
1197     UsbSrvClient.RequestRight(device.GetName());
1198     USBDevicePipe pip;
1199     ret = UsbSrvClient.OpenDevice(device, pip);
1200     USB_HILOGI(
1201         MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort006 %{public}d OpenDevice=%{public}d ", __LINE__, ret);
1202     EXPECT_TRUE(ret == 0);
1203     UsbRequest request;
1204     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
1205     USBEndpoint point = interface.GetEndpoints().at(1);
1206     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
1207     EXPECT_TRUE(ret == 0);
1208     uint8_t tag[TAG_SIZE] = "request abort 006";
1209     std::vector<uint8_t> cdata = {tag, tag + 17};
1210     request.SetClientData(cdata);
1211     ret = request.Initialize(pip, point);
1212     EXPECT_TRUE(ret == 0);
1213     uint8_t buffer[BUFFER_SIZE] = "usb request test 006";
1214     std::vector<uint8_t> databuffer = {buffer, buffer + 20};
1215     request.SetReqData(databuffer);
1216     ret = UsbSrvClient.RequestQueue(request);
1217     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort006 %{public}d queue=%{public}d ", __LINE__, ret);
1218     EXPECT_TRUE(ret == 0);
1219     pip.SetDevAddr(BUFFER_SIZE);
1220     request.SetPipe(pip);
1221     ret = UsbSrvClient.RequestAbort(request);
1222     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort006 %{public}d Abort=%{public}d ", __LINE__, ret);
1223     EXPECT_TRUE(ret != 0);
1224     pip.SetDevAddr(device.GetDevAddr());
1225     bool close = UsbSrvClient.Close(pip);
1226     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestabort006 %{public}d close=%{public}d", __LINE__, close);
1227     EXPECT_TRUE(close);
1228     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestabort006 : Requestabort");
1229 }
1230 
1231 /**
1232  * @tc.name: PipeRequestWait001
1233  * @tc.desc: Test functions of PipeRequestWait(USBDevicePipe &pip, int64_t timeout, UsbRequest &req)
1234  * @tc.type: FUNC
1235  */
1236 HWTEST_F(UsbRequestTest, PipeRequestWait001, TestSize.Level1)
1237 {
1238     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : PipeRequestWait001 : Initialize");
1239     vector<UsbDevice> delist;
1240     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1241     auto ret = UsbSrvClient.GetDevices(delist);
1242     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:PipeRequestWait001 %{public}d ret=%{public}d size:%{public}zu",
1243         __LINE__, ret, delist.size());
1244     EXPECT_TRUE(ret == 0);
1245     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1246     UsbDevice device = delist.front();
1247     UsbSrvClient.RequestRight(device.GetName());
1248     USBDevicePipe pip;
1249     ret = UsbSrvClient.OpenDevice(device, pip);
1250     USB_HILOGI(
1251         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait001 %{public}d OpenDevice=%{public}d", __LINE__, ret);
1252     EXPECT_TRUE(ret == 0);
1253     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
1254     USBEndpoint point = interface.GetEndpoints().front();
1255     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
1256     USB_HILOGI(
1257         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait001 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1258     EXPECT_TRUE(ret == 0);
1259     UsbRequest request;
1260     uint8_t tag[TAG_SIZE] = "request wait 001";
1261     std::vector<uint8_t> cdata = {tag, tag + 16};
1262     request.SetClientData(cdata);
1263     uint8_t buffer1[BUFFER_SIZE] = {0};
1264     std::vector<uint8_t> bufferdata = {buffer1, buffer1 + 17};
1265     request.SetReqData(bufferdata);
1266     ret = request.Initialize(pip, point);
1267     USB_HILOGI(
1268         MODULE_USB_SERVICE, "UsbRequestTest:Usbrequestabort006 %{public}d initialize=%{public}d ", __LINE__, ret);
1269     EXPECT_TRUE(ret == 0);
1270     ret = UsbSrvClient.RequestQueue(request);
1271     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait002 %{public}d queue=%{public}d ", __LINE__, ret);
1272     EXPECT_TRUE(ret == 0);
1273     UsbRequest reqwait;
1274     ret = UsbSrvClient.PipeRequestWait(pip, 5000, reqwait);
1275     USB_HILOGI(
1276         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait001 %{public}d PipeRequestWait=%{public}d", __LINE__, ret);
1277     EXPECT_TRUE(ret == 0);
1278     bool close = UsbSrvClient.Close(pip);
1279     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait001 %{public}d close=%{public}d", __LINE__, close);
1280     EXPECT_TRUE(close);
1281     USB_HILOGI(MODULE_USB_SERVICE, "Case End : PipeRequestWait001 : Initialize");
1282 }
1283 
1284 /**
1285  * @tc.name: PipeRequestWait002
1286  * @tc.desc: Test functions of PipeRequestWait(USBDevicePipe &pip, int64_t timeout, UsbRequest &req)
1287  * @tc.type: FUNC
1288  */
1289 HWTEST_F(UsbRequestTest, PipeRequestWait002, TestSize.Level1)
1290 {
1291     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : PipeRequestWait002 : Initialize");
1292     vector<UsbDevice> delist;
1293     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1294     auto ret = UsbSrvClient.GetDevices(delist);
1295     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:PipeRequestWait002 %{public}d ret=%{public}d size:%{public}zu",
1296         __LINE__, ret, delist.size());
1297     EXPECT_TRUE(ret == 0);
1298     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1299     UsbDevice device = delist.front();
1300     UsbSrvClient.RequestRight(device.GetName());
1301     USBDevicePipe pip;
1302     ret = UsbSrvClient.OpenDevice(device, pip);
1303     USB_HILOGI(
1304         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait002 %{public}d OpenDevice=%{public}d", __LINE__, ret);
1305     EXPECT_TRUE(ret == 0);
1306     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
1307     USBEndpoint point = interface.GetEndpoints().front();
1308     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
1309     USB_HILOGI(
1310         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait002 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1311     EXPECT_TRUE(ret == 0);
1312     UsbRequest request;
1313     uint8_t tag[TAG_SIZE] = "request wait 002";
1314     std::vector<uint8_t> cdata = {tag, tag + 16};
1315     request.SetClientData(cdata);
1316     uint8_t buffer1[BUFFER_SIZE] = {0};
1317     std::vector<uint8_t> bufferdata = {buffer1, buffer1 + 17};
1318     request.SetReqData(bufferdata);
1319     ret = request.Initialize(pip, point);
1320     USB_HILOGI(
1321         MODULE_USB_SERVICE, "UsbRequestTest:PipeRequestWait002 %{public}d initialize=%{public}d ", __LINE__, ret);
1322     EXPECT_TRUE(ret == 0);
1323     ret = UsbSrvClient.RequestQueue(request);
1324     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait002 %{public}d queue=%{public}d ", __LINE__, ret);
1325     EXPECT_TRUE(ret == 0);
1326     UsbRequest reqwait;
1327     pip.SetBusNum(BUFFER_SIZE);
1328     ret = UsbSrvClient.PipeRequestWait(pip, 5000, reqwait);
1329     USB_HILOGI(
1330         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait002 %{public}d PipeRequestWait=%{public}d", __LINE__, ret);
1331     EXPECT_TRUE(ret != 0);
1332     pip.SetBusNum(device.GetBusNum());
1333     bool close = UsbSrvClient.Close(pip);
1334     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait002 %{public}d close=%{public}d", __LINE__, close);
1335     EXPECT_TRUE(close);
1336     USB_HILOGI(MODULE_USB_SERVICE, "Case End : PipeRequestWait002 : Initialize");
1337 }
1338 
1339 /**
1340  * @tc.name: PipeRequestWait003
1341  * @tc.desc: Test functions of PipeRequestWait(USBDevicePipe &pip, int64_t timeout, UsbRequest &req)
1342  * @tc.type: FUNC
1343  */
1344 HWTEST_F(UsbRequestTest, PipeRequestWait003, TestSize.Level1)
1345 {
1346     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : PipeRequestWait003 : Initialize");
1347     vector<UsbDevice> delist;
1348     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1349     auto ret = UsbSrvClient.GetDevices(delist);
1350     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:PipeRequestWait003 %{public}d ret=%{public}d size:%{public}zu",
1351         __LINE__, ret, delist.size());
1352     EXPECT_TRUE(ret == 0);
1353     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1354     UsbDevice device = delist.front();
1355     UsbSrvClient.RequestRight(device.GetName());
1356     USBDevicePipe pip;
1357     ret = UsbSrvClient.OpenDevice(device, pip);
1358     USB_HILOGI(
1359         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait003 %{public}d OpenDevice=%{public}d", __LINE__, ret);
1360     EXPECT_TRUE(ret == 0);
1361     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
1362     USBEndpoint point = interface.GetEndpoints().front();
1363     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
1364     USB_HILOGI(
1365         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait003 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1366     EXPECT_TRUE(ret == 0);
1367     UsbRequest request;
1368     uint8_t tag[TAG_SIZE] = "request wait 003";
1369     std::vector<uint8_t> cdata = {tag, tag + 16};
1370     request.SetClientData(cdata);
1371     uint8_t buffer1[BUFFER_SIZE] = {0};
1372     std::vector<uint8_t> bufferdata = {buffer1, buffer1 + 17};
1373     request.SetReqData(bufferdata);
1374     ret = request.Initialize(pip, point);
1375     USB_HILOGI(
1376         MODULE_USB_SERVICE, "UsbRequestTest:PipeRequestWait003 %{public}d initialize=%{public}d ", __LINE__, ret);
1377     EXPECT_TRUE(ret == 0);
1378     ret = UsbSrvClient.RequestQueue(request);
1379     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait003 %{public}d queue=%{public}d ", __LINE__, ret);
1380     EXPECT_TRUE(ret == 0);
1381     UsbRequest reqwait;
1382     pip.SetDevAddr(BUFFER_SIZE);
1383     ret = UsbSrvClient.PipeRequestWait(pip, 5000, reqwait);
1384     USB_HILOGI(
1385         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait003 %{public}d PipeRequestWait=%{public}d", __LINE__, ret);
1386     EXPECT_TRUE(ret != 0);
1387     pip.SetDevAddr(device.GetDevAddr());
1388     bool close = UsbSrvClient.Close(pip);
1389     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait003 %{public}d close=%{public}d", __LINE__, close);
1390     EXPECT_TRUE(close);
1391     USB_HILOGI(MODULE_USB_SERVICE, "Case End : PipeRequestWait003 : Initialize");
1392 }
1393 
1394 /**
1395  * @tc.name: PipeRequestWait004
1396  * @tc.desc: Test functions of PipeRequestWait(USBDevicePipe &pip, int64_t timeout, UsbRequest &req)
1397  * @tc.type: FUNC
1398  */
1399 HWTEST_F(UsbRequestTest, PipeRequestWait004, TestSize.Level1)
1400 {
1401     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : PipeRequestWait004 : Initialize");
1402     vector<UsbDevice> delist;
1403     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1404     auto ret = UsbSrvClient.GetDevices(delist);
1405     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:PipeRequestWait004 %{public}d ret=%{public}d size:%{public}zu",
1406         __LINE__, ret, delist.size());
1407     EXPECT_TRUE(ret == 0);
1408     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1409     UsbDevice device = delist.front();
1410     UsbSrvClient.RequestRight(device.GetName());
1411     USBDevicePipe pip;
1412     ret = UsbSrvClient.OpenDevice(device, pip);
1413     USB_HILOGI(
1414         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait004 %{public}d OpenDevice=%{public}d", __LINE__, ret);
1415     EXPECT_TRUE(ret == 0);
1416     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
1417     USBEndpoint point = interface.GetEndpoints().at(1);
1418     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
1419     EXPECT_TRUE(ret == 0);
1420     UsbRequest request;
1421     uint8_t tag[TAG_SIZE] = "request wait 004";
1422     std::vector<uint8_t> cdata = {tag, tag + 16};
1423     request.SetClientData(cdata);
1424     ret = request.Initialize(pip, point);
1425     USB_HILOGI(
1426         MODULE_USB_SERVICE, "UsbRequestTest:PipeRequestWait004 %{public}d initialize=%{public}d ", __LINE__, ret);
1427     EXPECT_TRUE(ret == 0);
1428     uint8_t buffer[BUFFER_SIZE] = "usb request wait test004";
1429     std::vector<uint8_t> databuffer = {buffer, buffer + 24};
1430     request.SetReqData(databuffer);
1431     ret = UsbSrvClient.RequestQueue(request);
1432     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait004 %{public}d queue=%{public}d ", __LINE__, ret);
1433     EXPECT_TRUE(ret == 0);
1434     UsbRequest reqwait;
1435     ret = UsbSrvClient.PipeRequestWait(pip, 5000, reqwait);
1436     USB_HILOGI(
1437         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait004 %{public}d PipeRequestWait=%{public}d", __LINE__, ret);
1438     EXPECT_TRUE(ret == 0);
1439     bool close = UsbSrvClient.Close(pip);
1440     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait004 %{public}d close=%{public}d", __LINE__, close);
1441     EXPECT_TRUE(close);
1442     USB_HILOGI(MODULE_USB_SERVICE, "Case End : PipeRequestWait004 : Initialize");
1443 }
1444 
1445 /**
1446  * @tc.name: PipeRequestWait005
1447  * @tc.desc: Test functions of PipeRequestWait(USBDevicePipe &pip, int64_t timeout, UsbRequest &req)
1448  * @tc.type: FUNC
1449  */
1450 HWTEST_F(UsbRequestTest, PipeRequestWait005, TestSize.Level1)
1451 {
1452     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : PipeRequestWait005 : Initialize");
1453     vector<UsbDevice> delist;
1454     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1455     auto ret = UsbSrvClient.GetDevices(delist);
1456     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:PipeRequestWait005 %{public}d ret=%{public}d size:%{public}zu",
1457         __LINE__, ret, delist.size());
1458     EXPECT_TRUE(ret == 0);
1459     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1460     UsbDevice device = delist.front();
1461     UsbSrvClient.RequestRight(device.GetName());
1462     USBDevicePipe pip;
1463     ret = UsbSrvClient.OpenDevice(device, pip);
1464     USB_HILOGI(
1465         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait005 %{public}d OpenDevice=%{public}d", __LINE__, ret);
1466     EXPECT_TRUE(ret == 0);
1467     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
1468     USBEndpoint point = interface.GetEndpoints().at(1);
1469     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
1470     EXPECT_TRUE(ret == 0);
1471     UsbRequest request;
1472     uint8_t tag[TAG_SIZE] = "request wait 005";
1473     std::vector<uint8_t> cdata = {tag, tag + 16};
1474     request.SetClientData(cdata);
1475     ret = request.Initialize(pip, point);
1476     EXPECT_TRUE(ret == 0);
1477     uint8_t buffer[BUFFER_SIZE] = "usb request wait test005";
1478     std::vector<uint8_t> databuffer = {buffer, buffer + 24};
1479     request.SetReqData(databuffer);
1480     ret = UsbSrvClient.RequestQueue(request);
1481     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait005 %{public}d queue=%{public}d ", __LINE__, ret);
1482     EXPECT_TRUE(ret == 0);
1483     UsbRequest reqwait;
1484     pip.SetBusNum(BUFFER_SIZE);
1485     ret = UsbSrvClient.PipeRequestWait(pip, 5000, reqwait);
1486     USB_HILOGI(
1487         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait005 %{public}d PipeRequestWait=%{public}d", __LINE__, ret);
1488     EXPECT_TRUE(ret != 0);
1489     pip.SetBusNum(device.GetBusNum());
1490     bool close = UsbSrvClient.Close(pip);
1491     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait005 %{public}d close=%{public}d", __LINE__, close);
1492     EXPECT_TRUE(close);
1493     USB_HILOGI(MODULE_USB_SERVICE, "Case End : PipeRequestWait005 : Initialize");
1494 }
1495 
1496 /**
1497  * @tc.name: PipeRequestWait006
1498  * @tc.desc: Test functions of PipeRequestWait(USBDevicePipe &pip, int64_t timeout, UsbRequest &req)
1499  * @tc.type: FUNC
1500  */
1501 HWTEST_F(UsbRequestTest, PipeRequestWait006, TestSize.Level1)
1502 {
1503     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : PipeRequestWait006 : Initialize");
1504     vector<UsbDevice> delist;
1505     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1506     auto ret = UsbSrvClient.GetDevices(delist);
1507     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest:PipeRequestWait006 %{public}d ret=%{public}d size:%{public}zu",
1508         __LINE__, ret, delist.size());
1509     EXPECT_TRUE(ret == 0);
1510     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1511     UsbDevice device = delist.front();
1512     UsbSrvClient.RequestRight(device.GetName());
1513     USBDevicePipe pip;
1514     ret = UsbSrvClient.OpenDevice(device, pip);
1515     USB_HILOGI(
1516         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait006 %{public}d OpenDevice=%{public}d", __LINE__, ret);
1517     EXPECT_TRUE(ret == 0);
1518     UsbInterface interface = device.GetConfigs().front().GetInterfaces().at(1);
1519     USBEndpoint point = interface.GetEndpoints().at(1);
1520     ret = UsbSrvClient.ClaimInterface(pip, interface, true);
1521     USB_HILOGI(
1522         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait006 %{public}d ClaimInterface=%{public}d", __LINE__, ret);
1523     EXPECT_TRUE(ret == 0);
1524     UsbRequest request;
1525     uint8_t tag[TAG_SIZE] = "request abort 006";
1526     std::vector<uint8_t> cdata = {tag, tag + 16};
1527     request.SetClientData(cdata);
1528     ret = request.Initialize(pip, point);
1529     EXPECT_TRUE(ret == 0);
1530     uint8_t buffer[BUFFER_SIZE] = "usb request wait test006";
1531     std::vector<uint8_t> databuffer = {buffer, buffer + 24};
1532     request.SetReqData(databuffer);
1533     ret = UsbSrvClient.RequestQueue(request);
1534     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait006 %{public}d queue=%{public}d ", __LINE__, ret);
1535     EXPECT_TRUE(ret == 0);
1536     UsbRequest reqwait;
1537     pip.SetDevAddr(BUFFER_SIZE);
1538     ret = UsbSrvClient.PipeRequestWait(pip, 5000, reqwait);
1539     USB_HILOGI(
1540         MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait006 %{public}d PipeRequestWait=%{public}d", __LINE__, ret);
1541     EXPECT_TRUE(ret != 0);
1542     pip.SetDevAddr(device.GetDevAddr());
1543     bool close = UsbSrvClient.Close(pip);
1544     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::PipeRequestWait006 %{public}d close=%{public}d", __LINE__, close);
1545     EXPECT_TRUE(close);
1546     USB_HILOGI(MODULE_USB_SERVICE, "Case End : PipeRequestWait006 : Initialize");
1547 }
1548 
1549 /**
1550  * @tc.name: UsbHasRight001
1551  * @tc.desc: Test functions of HasRight
1552  * @tc.desc: bool HasRight(std::string deviceName)
1553  * @tc.desc: Setup case as system hap: Before RequestRight, HasRight return true.
1554  * @tc.type: FUNC
1555  */
1556 HWTEST_F(UsbRequestTest, UsbHasRight001, TestSize.Level1)
1557 {
1558     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbHasRight001: SetConfig");
1559     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1560     vector<UsbDevice> delist;
1561     auto ret = UsbSrvClient.GetDevices(delist);
1562     EXPECT_TRUE(ret == 0);
1563     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1564     UsbDevice device = delist.front();
1565     std::string deviceName = std::to_string(device.GetBusNum()) + "-" + std::to_string(device.GetDevAddr());
1566     bool result = UsbSrvClient.HasRight(deviceName);
1567     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight001 HasRight=%{public}d", result);
1568     ASSERT_TRUE(result);
1569     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbHasRight001: SetConfig");
1570 }
1571 
1572 /**
1573  * @tc.name: UsbHasRight002
1574  * @tc.desc: Test functions of HasRight
1575  * @tc.desc: bool HasRight(std::string deviceName)
1576  * @tc.desc: Setup case as system hap: After RequestRight, HasRight return true.
1577  * @tc.type: FUNC
1578  */
1579 HWTEST_F(UsbRequestTest, UsbHasRight002, TestSize.Level1)
1580 {
1581     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbHasRight002: SetConfig");
1582     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1583     vector<UsbDevice> delist;
1584     auto ret = UsbSrvClient.GetDevices(delist);
1585     EXPECT_TRUE(ret == 0);
1586     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1587     UsbDevice device = delist.front();
1588     std::string deviceName = std::to_string(device.GetBusNum()) + "-" + std::to_string(device.GetDevAddr());
1589     bool result = UsbSrvClient.HasRight(deviceName);
1590     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight002 HasRight=%{public}d", result);
1591     ASSERT_TRUE(result);
1592     ret = UsbSrvClient.RequestRight(deviceName);
1593     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight002 RequestRight=%{public}d", result);
1594     ASSERT_EQ(0, ret);
1595     result = UsbSrvClient.HasRight(deviceName);
1596     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight002 HasRight=%{public}d", result);
1597     ASSERT_TRUE(result);
1598     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbHasRight002: SetConfig");
1599 }
1600 
1601 /**
1602  * @tc.name: UsbHasRight003
1603  * @tc.desc: Test functions of HasRight
1604  * @tc.desc: bool HasRight(std::string deviceName)
1605  * @tc.desc: Setup case as system hap: After RemoveRight, HasRight return true.
1606  * @tc.type: FUNC
1607  */
1608 HWTEST_F(UsbRequestTest, UsbHasRight003, TestSize.Level1)
1609 {
1610     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbHasRight003: SetConfig");
1611     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1612     vector<UsbDevice> delist;
1613     auto ret = UsbSrvClient.GetDevices(delist);
1614     EXPECT_TRUE(ret == 0);
1615     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1616     UsbDevice device = delist.front();
1617     std::string deviceName = std::to_string(device.GetBusNum()) + "-" + std::to_string(device.GetDevAddr());
1618     bool result = UsbSrvClient.HasRight(deviceName);
1619     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight003 HasRight=%{public}d", result);
1620     ASSERT_TRUE(result);
1621     ret = UsbSrvClient.RemoveRight(deviceName);
1622     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight003 RemoveRight=%{public}d", result);
1623     ASSERT_EQ(0, ret);
1624     deviceName = "device_81";
1625     result = UsbSrvClient.HasRight(deviceName);
1626     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight003 HasRight=%{public}d", result);
1627     ASSERT_FALSE(result);
1628     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbHasRight003: SetConfig");
1629 }
1630 
1631 /**
1632  * @tc.name: UsbHasRight004
1633  * @tc.desc: Test functions of HasRight
1634  * @tc.desc: bool HasRight(std::string deviceName)
1635  * @tc.desc: Setup case as system hap: RequestRight then RemoveRight
1636  * @tc.type: FUNC
1637  */
1638 HWTEST_F(UsbRequestTest, UsbHasRight004, TestSize.Level1)
1639 {
1640     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbHasRight004: SetConfig");
1641     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1642     vector<UsbDevice> delist;
1643     auto ret = UsbSrvClient.GetDevices(delist);
1644     EXPECT_TRUE(ret == 0);
1645     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1646     UsbDevice device = delist.front();
1647     std::string deviceName = std::to_string(device.GetBusNum()) + "-" + std::to_string(device.GetDevAddr());
1648     bool result = UsbSrvClient.HasRight(deviceName);
1649     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight004 HasRight=%{public}d", result);
1650     ASSERT_TRUE(result);
1651     ret = UsbSrvClient.RequestRight(deviceName);
1652     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight004 RequestRight=%{public}d", result);
1653     ASSERT_EQ(0, ret);
1654     result = UsbSrvClient.HasRight(deviceName);
1655     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight004 HasRight=%{public}d", result);
1656     ASSERT_TRUE(result);
1657     ret = UsbSrvClient.RemoveRight(deviceName);
1658     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestright003 RemoveRight=%{public}d", result);
1659     ASSERT_EQ(0, ret);
1660     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbHasRight004: SetConfig");
1661 }
1662 
1663 /**
1664  * @tc.name: UsbHasRight005
1665  * @tc.desc: Test functions of HasRight
1666  * @tc.desc: bool HasRight(std::string deviceName)
1667  * @tc.desc: Setup case as system hap: deviceName not in delist.
1668  * @tc.type: FUNC
1669  */
1670 HWTEST_F(UsbRequestTest, UsbHasRight005, TestSize.Level1)
1671 {
1672     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : UsbHasRight005: SetConfig");
1673     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1674     std::string deviceName = "device_80";
1675     bool result = UsbSrvClient.HasRight(deviceName);
1676     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight005 HasRight=%{public}d", result);
1677     ASSERT_FALSE(result);
1678     int32_t ret = UsbSrvClient.RequestRight(deviceName);
1679     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight005 RequestRight=%{public}d", result);
1680     ASSERT_NE(0, ret);
1681     result = UsbSrvClient.HasRight(deviceName);
1682     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight005 HasRight=%{public}d", result);
1683     ASSERT_FALSE(result);
1684     ret = UsbSrvClient.RemoveRight(deviceName);
1685     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::UsbHasRight005 RemoveRight=%{public}d", result);
1686     ASSERT_NE(0, ret);
1687     USB_HILOGI(MODULE_USB_SERVICE, "Case End : UsbHasRight005: SetConfig");
1688 }
1689 
1690 /**
1691  * @tc.name: Usbrequestright001
1692  * @tc.desc: Test functions of requestright
1693  * @tc.desc: int32_t requestright(std::string deviceName)
1694  * @tc.desc: Setup case as system hap: RequestRight then RemoveRight
1695  * @tc.type: FUNC
1696  */
1697 HWTEST_F(UsbRequestTest, Usbrequestright001, TestSize.Level1)
1698 {
1699     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestright001: SetConfig");
1700     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1701     vector<UsbDevice> delist;
1702     auto ret = UsbSrvClient.GetDevices(delist);
1703     EXPECT_TRUE(ret == 0);
1704     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1705     UsbDevice device = delist.front();
1706     std::string deviceName = std::to_string(device.GetBusNum()) + "-" + std::to_string(device.GetDevAddr());
1707     ret = UsbSrvClient.RequestRight(deviceName);
1708     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestright001 RequestRight=%{public}d", ret);
1709     ASSERT_EQ(0, ret);
1710     bool result = UsbSrvClient.HasRight(deviceName);
1711     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestright001 HasRight=%{public}d", result);
1712     ASSERT_TRUE(result);
1713     ret = UsbSrvClient.RemoveRight(deviceName);
1714     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestright003 RemoveRight=%{public}d", result);
1715     ASSERT_EQ(0, ret);
1716     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestright001: SetConfig");
1717 }
1718 
1719 /**
1720  * @tc.name: Usbrequestright003
1721  * @tc.desc: Test functions of requestright
1722  * @tc.desc: int32_t requestright(std::string deviceName)
1723  * @tc.type: FUNC
1724  */
1725 HWTEST_F(UsbRequestTest, Usbrequestright003, TestSize.Level1)
1726 {
1727     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestright003: SetConfig");
1728     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1729     vector<UsbDevice> delist;
1730     auto ret = UsbSrvClient.GetDevices(delist);
1731     EXPECT_TRUE(ret == 0);
1732     EXPECT_TRUE(!(delist.empty())) << "delist NULL";
1733     UsbDevice device = delist.front();
1734     std::string deviceName = std::to_string(device.GetBusNum()) + "-" + std::to_string(device.GetDevAddr());
1735     ret = UsbSrvClient.RequestRight(deviceName);
1736     bool result = UsbSrvClient.HasRight(deviceName);
1737     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestright003 HasRight=%{public}d", result);
1738     ASSERT_TRUE(result);
1739     ret = UsbSrvClient.RequestRight(deviceName);
1740     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestright003 RequestRight=%{public}d", result);
1741     ASSERT_EQ(0, ret);
1742     result = UsbSrvClient.HasRight(deviceName);
1743     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestright003 HasRight=%{public}d", result);
1744     ASSERT_TRUE(result);
1745     ret = UsbSrvClient.RemoveRight(deviceName);
1746     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestright003 RemoveRight=%{public}d", result);
1747     ASSERT_EQ(0, ret);
1748     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestright003: SetConfig");
1749 }
1750 
1751 /**
1752  * @tc.name: Usbrequestright004
1753  * @tc.desc: Test functions of requestright
1754  * @tc.desc: int32_t requestright(std::string deviceName)
1755  * @tc.type: FUNC
1756  */
1757 HWTEST_F(UsbRequestTest, Usbrequestright004, TestSize.Level1)
1758 {
1759     USB_HILOGI(MODULE_USB_SERVICE, "Case Start : Usbrequestright004: SetConfig");
1760     auto &UsbSrvClient = UsbSrvClient::GetInstance();
1761     std::string deviceName = "device_81";
1762     bool result = UsbSrvClient.HasRight(deviceName);
1763     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestright004 HasRight=%{public}d", result);
1764     ASSERT_FALSE(result);
1765     int32_t ret = UsbSrvClient.RequestRight(deviceName);
1766     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestright004 RequestRight=%{public}d", result);
1767     ASSERT_NE(0, ret);
1768     result = UsbSrvClient.HasRight(deviceName);
1769     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestright004 HasRight=%{public}d", result);
1770     ASSERT_FALSE(result);
1771     ret = UsbSrvClient.RemoveRight(deviceName);
1772     USB_HILOGI(MODULE_USB_SERVICE, "UsbRequestTest::Usbrequestright004 RemoveRight=%{public}d", result);
1773     ASSERT_NE(0, ret);
1774     USB_HILOGI(MODULE_USB_SERVICE, "Case End : Usbrequestright004: SetConfig");
1775 }
1776 } // namespace Request
1777 } // namespace USB
1778 } // namespace OHOS
1779