• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 <iostream>
17 
18 #include "hdf_log.h"
19 #include "if_system_ability_manager.h"
20 #include "system_ability_definition.h"
21 #include "usbd_function_test.h"
22 #include "v1_0/iusb_interface.h"
23 #include "v1_0/usb_types.h"
24 
25 constexpr int32_t SLEEP_TIME = 3;
26 constexpr int32_t USB_FUNCTION_INVALID = -1;
27 constexpr int32_t USB_PORT_ID_INVALID = 2;
28 constexpr int32_t USB_POWER_ROLE_INVALID = 4;
29 constexpr int32_t USB_DATA_ROLE_INVALID = 5;
30 constexpr int32_t USB_FUNCTION_UNSUPPORTED = 128;
31 
32 using namespace testing::ext;
33 using namespace OHOS;
34 using namespace std;
35 using namespace OHOS::HDI::Usb::V1_0;
36 
37 namespace {
38 sptr<IUsbInterface> g_usbInterface = nullptr;
39 
SetUpTestCase(void)40 void UsbdFunctionTest::SetUpTestCase(void)
41 {
42     g_usbInterface = IUsbInterface::Get();
43     if (g_usbInterface == nullptr) {
44         HDF_LOGE("%{public}s:IUsbInterface::Get() failed.", __func__);
45         exit(0);
46     }
47     auto ret = g_usbInterface->SetPortRole(DEFAULT_PORT_ID, POWER_ROLE_SINK, DATA_ROLE_DEVICE);
48     sleep(SLEEP_TIME);
49     HDF_LOGI("UsbdFunctionTest::[Device] %{public}d SetPortRole=%{public}d", __LINE__, ret);
50     ASSERT_EQ(0, ret);
51     if (ret != 0) {
52         exit(0);
53     }
54 }
55 
TearDownTestCase(void)56 void UsbdFunctionTest::TearDownTestCase(void) {}
57 
SetUp(void)58 void UsbdFunctionTest::SetUp(void) {}
59 
TearDown(void)60 void UsbdFunctionTest::TearDown(void) {}
61 
62 /**
63  * @tc.name: SUB_USB_HDI_1250
64  * @tc.desc: Test functions to GetCurrentFunctions
65  * @tc.desc: int32_t GetCurrentFunctions(int32_t &funcs);
66  * @tc.desc: Positive test: parameters correctly
67  * @tc.type: FUNC
68  */
69 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1250, Function | MediumTest | Level1)
70 {
71     int32_t funcs = USB_FUNCTION_NONE;
72     auto ret = g_usbInterface->GetCurrentFunctions(funcs);
73     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1250 %{public}d ret=%{public}d", __LINE__, ret);
74     ASSERT_EQ(0, ret);
75 }
76 
77 /**
78  * @tc.name: SUB_USB_HDI_1260
79  * @tc.desc: Test functions to GetCurrentFunctions
80  * @tc.desc: int32_t GetCurrentFunctions(int32_t &funcs);
81  * @tc.desc: Positive test: parameters correctly
82  * @tc.type: FUNC
83  */
84 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1260, Function | MediumTest | Level1)
85 {
86     auto ret = g_usbInterface->SetCurrentFunctions(USB_FUNCTION_ACM);
87     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1270 %{public}d SetCurrentFunctions=%{public}d", __LINE__, ret);
88     ASSERT_EQ(0, ret);
89     int32_t funcs = USB_FUNCTION_NONE;
90     ret = g_usbInterface->GetCurrentFunctions(funcs);
91     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1260 %{public}d ret=%{public}d", __LINE__, ret);
92     ASSERT_EQ(0, ret);
93 }
94 
95 /**********************************************************************************************************/
96 
97 /**
98  * @tc.name: SUB_USB_HDI_1270
99  * @tc.desc: Test functions to SetCurrentFunctions
100  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
101  * @tc.desc: Positive test: parameters correctly
102  * @tc.type: FUNC
103  */
104 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1270, Function | MediumTest | Level1)
105 {
106     auto ret = g_usbInterface->SetCurrentFunctions(USB_FUNCTION_ACM);
107     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1270 %{public}d SetCurrentFunctions=%{public}d", __LINE__, ret);
108     ASSERT_EQ(0, ret);
109 }
110 
111 /**
112  * @tc.name: SUB_USB_HDI_1280
113  * @tc.desc: Test functions to SetCurrentFunctions
114  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
115  * @tc.desc: Negative test: parameters exception, Funcs error
116  * @tc.type: FUNC
117  */
118 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1280, Function | MediumTest | Level1)
119 {
120     auto ret = g_usbInterface->SetCurrentFunctions(USB_FUNCTION_INVALID);
121     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1280 %{public}d, ret=%{public}d", __LINE__, ret);
122     ASSERT_NE(ret, 0);
123 }
124 /**
125  * @tc.name: SUB_USB_HDI_1290
126  * @tc.desc: Test functions to SetCurrentFunctions
127  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
128  * @tc.desc: Positive test: parameters correctly
129  * @tc.type: FUNC
130  */
131 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1290, Function | MediumTest | Level1)
132 {
133     auto ret = g_usbInterface->SetCurrentFunctions(USB_FUNCTION_ECM);
134     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1290 %{public}d ret=%{public}d", __LINE__, ret);
135     ASSERT_EQ(0, ret);
136 }
137 
138 /**
139  * @tc.name: SUB_USB_HDI_1300
140  * @tc.desc: Test functions to SetCurrentFunctions
141  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
142  * @tc.desc: Positive test: parameters correctly
143  * @tc.type: FUNC
144  */
145 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1300, Function | MediumTest | Level1)
146 {
147     int32_t funcs = USB_FUNCTION_ACM | USB_FUNCTION_ECM;
148     auto ret = g_usbInterface->SetCurrentFunctions(funcs);
149     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1300 %{public}d ret=%{public}d", __LINE__, ret);
150     ASSERT_EQ(0, ret);
151 }
152 
153 /**
154  * @tc.name: SUB_USB_HDI_1310
155  * @tc.desc: Test functions to SetCurrentFunctions
156  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
157  * @tc.desc: Positive test: parameters correctly
158  * @tc.type: FUNC
159  */
160 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1310, Function | MediumTest | Level1)
161 {
162     auto ret = g_usbInterface->SetCurrentFunctions(USB_FUNCTION_HDC);
163     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1310 %{public}d ret=%{public}d", __LINE__, ret);
164     ASSERT_EQ(0, ret);
165 }
166 
167 /**
168  * @tc.name: SUB_USB_HDI_1320
169  * @tc.desc: Test functions to SetCurrentFunctions
170  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
171  * @tc.desc: Positive test: parameters correctly
172  * @tc.type: FUNC
173  */
174 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1320, Function | MediumTest | Level1)
175 {
176     int32_t funcs = USB_FUNCTION_ACM | USB_FUNCTION_HDC;
177     auto ret = g_usbInterface->SetCurrentFunctions(funcs);
178     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1320 %{public}d ret=%{public}d", __LINE__, ret);
179     ASSERT_EQ(0, ret);
180 }
181 
182 /**
183  * @tc.name: SUB_USB_HDI_1330
184  * @tc.desc: Test functions to SetCurrentFunctions
185  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
186  * @tc.desc: Positive test: parameters correctly
187  * @tc.type: FUNC
188  */
189 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1330, Function | MediumTest | Level1)
190 {
191     int32_t funcs = USB_FUNCTION_ECM | USB_FUNCTION_HDC;
192     auto ret = g_usbInterface->SetCurrentFunctions(funcs);
193     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1330 %{public}d ret=%{public}d", __LINE__, ret);
194     ASSERT_EQ(0, ret);
195 }
196 
197 /**
198  * @tc.name: SUB_USB_HDI_1340
199  * @tc.desc: Test functions to SetCurrentFunctions
200  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
201  * @tc.desc: Positive test: parameters correctly
202  * @tc.type: FUNC
203  */
204 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1340, Function | MediumTest | Level1)
205 {
206     auto ret = g_usbInterface->SetCurrentFunctions(USB_FUNCTION_RNDIS);
207     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1340 %{public}d ret=%{public}d", __LINE__, ret);
208     ASSERT_EQ(0, ret);
209 }
210 
211 /**
212  * @tc.name: SUB_USB_HDI_2340
213  * @tc.desc: Test functions to SetCurrentFunctions
214  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
215  * @tc.desc: Positive test: parameters correctly
216  * @tc.type: FUNC
217  */
218 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_2340, Function | MediumTest | Level1)
219 {
220     auto ret = g_usbInterface->SetCurrentFunctions(USB_FUNCTION_STORAGE);
221     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_2340 %{public}d ret=%{public}d", __LINE__, ret);
222     ASSERT_EQ(0, ret);
223 }
224 
225 /**
226  * @tc.name: SUB_USB_HDI_2350
227  * @tc.desc: Test functions to SetCurrentFunctions
228  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
229  * @tc.desc: Positive test: parameters correctly
230  * @tc.type: FUNC
231  */
232 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_2350, Function | MediumTest | Level1)
233 {
234     int32_t funcs = USB_FUNCTION_RNDIS | USB_FUNCTION_HDC;
235     auto ret = g_usbInterface->SetCurrentFunctions(funcs);
236     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_2350 %{public}d ret=%{public}d", __LINE__, ret);
237     ASSERT_EQ(0, ret);
238 }
239 
240 /**
241  * @tc.name: SUB_USB_HDI_2360
242  * @tc.desc: Test functions to SetCurrentFunctions
243  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
244  * @tc.desc: Positive test: parameters correctly
245  * @tc.type: FUNC
246  */
247 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_2360, Function | MediumTest | Level1)
248 {
249     int32_t funcs = USB_FUNCTION_STORAGE | USB_FUNCTION_HDC;
250     auto ret = g_usbInterface->SetCurrentFunctions(funcs);
251     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_2360 %{public}d ret=%{public}d", __LINE__, ret);
252     ASSERT_EQ(0, ret);
253 }
254 
255 /**
256  * @tc.name: SUB_USB_HDI_2700
257  * @tc.desc: Test functions to SetCurrentFunctions
258  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
259  * @tc.desc: Positive test: parameters correctly
260  * @tc.type: FUNC
261  */
262 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_2700, Function | MediumTest | Level1)
263 {
264     int32_t funcs = USB_FUNCTION_MTP;
265     auto ret = g_usbInterface->SetCurrentFunctions(funcs);
266     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_2700 %{public}d ret=%{public}d", __LINE__, ret);
267     ASSERT_EQ(0, ret);
268 }
269 
270 /**
271  * @tc.name: SUB_USB_HDI_2710
272  * @tc.desc: Test functions to SetCurrentFunctions
273  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
274  * @tc.desc: Positive test: parameters correctly
275  * @tc.type: FUNC
276  */
277 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_2710, Function | MediumTest | Level1)
278 {
279     int32_t funcs = USB_FUNCTION_PTP;
280     auto ret = g_usbInterface->SetCurrentFunctions(funcs);
281     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_2710 %{public}d ret=%{public}d", __LINE__, ret);
282     ASSERT_EQ(0, ret);
283 }
284 
285 /**
286  * @tc.name: SUB_USB_HDI_2720
287  * @tc.desc: Test functions to SetCurrentFunctions
288  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
289  * @tc.desc: Positive test: parameters correctly
290  * @tc.type: FUNC
291  */
292 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_2720, Function | MediumTest | Level1)
293 {
294     int32_t funcs = USB_FUNCTION_MTP | USB_FUNCTION_HDC;
295     auto ret = g_usbInterface->SetCurrentFunctions(funcs);
296     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_2720 %{public}d ret=%{public}d", __LINE__, ret);
297     ASSERT_EQ(0, ret);
298 }
299 
300 /**
301  * @tc.name: SUB_USB_HDI_2730
302  * @tc.desc: Test functions to SetCurrentFunctions
303  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
304  * @tc.desc: Positive test: parameters correctly
305  * @tc.type: FUNC
306  */
307 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_2730, Function | MediumTest | Level1)
308 {
309     int32_t funcs = USB_FUNCTION_PTP | USB_FUNCTION_HDC;
310     auto ret = g_usbInterface->SetCurrentFunctions(funcs);
311     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_2730 %{public}d ret=%{public}d", __LINE__, ret);
312     ASSERT_EQ(0, ret);
313 }
314 
315 /**
316  * @tc.name: SUB_USB_HDI_2740
317  * @tc.desc: Test functions to SetCurrentFunctions
318  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
319  * @tc.desc: Positive test: parameters correctly
320  * @tc.type: FUNC
321  */
322 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_2740, Function | MediumTest | Level1)
323 {
324     int32_t funcs = USB_FUNCTION_MTP | USB_FUNCTION_RNDIS;
325     auto ret = g_usbInterface->SetCurrentFunctions(funcs);
326     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_2740 %{public}d ret=%{public}d", __LINE__, ret);
327     ASSERT_EQ(0, ret);
328 }
329 
330 /**
331  * @tc.name: SUB_USB_HDI_2750
332  * @tc.desc: Test functions to SetCurrentFunctions
333  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
334  * @tc.desc: Positive test: parameters correctly
335  * @tc.type: FUNC
336  */
337 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_2750, Function | MediumTest | Level1)
338 {
339     int32_t funcs = USB_FUNCTION_PTP | USB_FUNCTION_RNDIS;
340     auto ret = g_usbInterface->SetCurrentFunctions(funcs);
341     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_2750 %{public}d ret=%{public}d", __LINE__, ret);
342     ASSERT_EQ(0, ret);
343 }
344 
345 /**
346  * @tc.name: SUB_USB_HDI_2370
347  * @tc.desc: Test functions to SetCurrentFunctions
348  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
349  * @tc.desc: Negative test: parameters exception, funcs error
350  * @tc.type: FUNC
351  */
352 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_2370, Function | MediumTest | Level1)
353 {
354     auto ret = g_usbInterface->SetCurrentFunctions(USB_FUNCTION_UNSUPPORTED);
355     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_2370 %{public}d ret=%{public}d", __LINE__, ret);
356     ASSERT_NE(0, ret);
357 }
358 
359 /**
360  * @tc.name: SUB_USB_HDI_2380
361  * @tc.desc: Test functions to SetCurrentFunctions
362  * @tc.desc: int32_t SetCurrentFunctions(int32_t funcs)
363  * @tc.desc: Positive test: parameters correctly
364  * @tc.type: FUNC
365  */
366 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_2380, Function | MediumTest | Level1)
367 {
368     auto ret = g_usbInterface->SetCurrentFunctions(USB_FUNCTION_NONE);
369     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_2380 ret=%{public}d", ret);
370     ASSERT_EQ(0, ret);
371     HDF_LOGI("UsbdFunctionTest::the function was set to none successfully");
372     ret = g_usbInterface->SetCurrentFunctions(USB_FUNCTION_HDC);
373     ASSERT_EQ(0, ret);
374 }
375 
376 /**
377  * @tc.name: SUB_USB_HDI_1350
378  * @tc.desc: Test functions to SetPortRole
379  * @tc.desc: int32_t SetPortRole(int32_t portId,int32_t powerRole,int32_t dataRole)
380  * @tc.desc: Positive test: parameters correctly
381  * @tc.type: FUNC
382  */
383 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1350, Function | MediumTest | Level1)
384 {
385     auto ret = g_usbInterface->SetPortRole(DEFAULT_PORT_ID, POWER_ROLE_SOURCE, DATA_ROLE_HOST);
386     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1350 %{public}d ret=%{public}d", __LINE__, ret);
387     ASSERT_EQ(0, ret);
388 }
389 
390 /**
391  * @tc.name: SUB_USB_HDI_1360
392  * @tc.desc: Test functions to SetPortRole
393  * @tc.desc: int32_t SetPortRole(int32_t portId,int32_t powerRole,int32_t dataRole)
394  * @tc.desc: Negative test: parameters exception, portId error
395  * @tc.type: FUNC
396  */
397 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1360, Function | MediumTest | Level1)
398 {
399     auto ret = g_usbInterface->SetPortRole(USB_PORT_ID_INVALID, POWER_ROLE_SOURCE, DATA_ROLE_HOST);
400     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1360 %{public}d ret=%{public}d", __LINE__, ret);
401     ASSERT_NE(ret, 0);
402 }
403 
404 /**
405  * @tc.name: SUB_USB_HDI_1370
406  * @tc.desc: Test functions to SetPortRole
407  * @tc.desc: int32_t SetPortRole(int32_t portId,int32_t powerRole,int32_t dataRole)
408  * @tc.desc: Negative test: parameters exception, powerRole error
409  * @tc.type: FUNC
410  */
411 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1370, Function | MediumTest | Level1)
412 {
413     auto ret = g_usbInterface->SetPortRole(DEFAULT_PORT_ID, USB_POWER_ROLE_INVALID, DATA_ROLE_DEVICE);
414     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1370 %{public}d ret=%{public}d", __LINE__, ret);
415     ASSERT_NE(ret, 0);
416 }
417 
418 /**
419  * @tc.name: SUB_USB_HDI_1380
420  * @tc.desc: Test functions to SetPortRole
421  * @tc.desc: int32_t SetPortRole(int32_t portId,int32_t powerRole,int32_t dataRole)
422  * @tc.desc: Negative test: parameters exception, dataRole error
423  * @tc.type: FUNC
424  */
425 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1380, Function | MediumTest | Level1)
426 {
427     auto ret = g_usbInterface->SetPortRole(DEFAULT_PORT_ID, POWER_ROLE_SOURCE, USB_DATA_ROLE_INVALID);
428     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1380 %{public}d ret=%{public}d", __LINE__, ret);
429     ASSERT_NE(ret, 0);
430 }
431 
432 /**
433  * @tc.name: SUB_USB_HDI_1390
434  * @tc.desc: Test functions to SetPortRole
435  * @tc.desc: int32_t SetPortRole(int32_t portId,int32_t powerRole,int32_t dataRole)
436  * @tc.desc: Negative test: parameters exception, powerRole error
437  * @tc.type: FUNC
438  */
439 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1390, Function | MediumTest | Level1)
440 {
441     auto ret = g_usbInterface->SetPortRole(DEFAULT_PORT_ID, USB_POWER_ROLE_INVALID, DATA_ROLE_HOST);
442     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1390 %{public}d ret=%{public}d", __LINE__, ret);
443     ASSERT_NE(ret, 0);
444 }
445 
446 /**
447  * @tc.name: SUB_USB_HDI_1400
448  * @tc.desc: Test functions to SetPortRole
449  * @tc.desc: int32_t SetPortRole(int32_t portId,int32_t powerRole,int32_t dataRole)
450  * @tc.desc: Negative test: parameters exception, portId && dataRole error
451  * @tc.type: FUNC
452  */
453 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1400, Function | MediumTest | Level1)
454 {
455     auto ret = g_usbInterface->SetPortRole(USB_PORT_ID_INVALID, POWER_ROLE_SOURCE, USB_DATA_ROLE_INVALID);
456     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1400 %{public}d ret=%{public}d", __LINE__, ret);
457     ASSERT_NE(ret, 0);
458 }
459 
460 /**
461  * @tc.name: SUB_USB_HDI_1410
462  * @tc.desc: Test functions to SetPortRole
463  * @tc.desc: int32_t SetPortRole(int32_t portId,int32_t powerRole,int32_t dataRole)
464  * @tc.desc: Negative test: parameters exception, powerRole && dataRole error
465  * @tc.type: FUNC
466  */
467 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1410, Function | MediumTest | Level1)
468 {
469     auto ret = g_usbInterface->SetPortRole(DEFAULT_PORT_ID, USB_POWER_ROLE_INVALID, USB_DATA_ROLE_INVALID);
470     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1410 %{public}d ret=%{public}d", __LINE__, ret);
471     ASSERT_NE(ret, 0);
472 }
473 
474 /**
475  * @tc.name: SUB_USB_HDI_1420
476  * @tc.desc: Test functions to SetPortRole
477  * @tc.desc: int32_t SetPortRole(int32_t portId,int32_t powerRole,int32_t dataRole)
478  * @tc.desc: Negative test: parameters exception, portId && powerRole && dataRole error
479  * @tc.type: FUNC
480  */
481 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1420, Function | MediumTest | Level1)
482 {
483     auto ret = g_usbInterface->SetPortRole(USB_PORT_ID_INVALID, USB_POWER_ROLE_INVALID, USB_DATA_ROLE_INVALID);
484     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1420 %{public}d ret=%{public}d", __LINE__, ret);
485     ASSERT_NE(ret, 0);
486 }
487 
488 /**
489  * @tc.name: SUB_USB_HDI_1430
490  * @tc.desc: Test functions to SetPortRole
491  * @tc.desc: int32_t SetPortRole(int32_t portId,int32_t powerRole,int32_t dataRole)
492  * @tc.desc: Positive test: parameters correctly
493  * @tc.type: FUNC
494  */
495 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1430, Function | MediumTest | Level1)
496 {
497     auto ret = g_usbInterface->SetPortRole(DEFAULT_PORT_ID, POWER_ROLE_SINK, DATA_ROLE_DEVICE);
498     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1430 %{public}d ret=%{public}d", __LINE__, ret);
499     ASSERT_EQ(0, ret);
500 }
501 
502 /**
503  * @tc.name: SUB_USB_HDI_1700
504  * @tc.desc: Test functions to QueryPort
505  * @tc.desc: int32_t QueryPort(int32_t &portId, int32_t &powerRole, int32_t &dataRole, int32_t &mode);
506  * @tc.desc: Positive test: parameters correctly
507  * @tc.type: FUNC
508  */
509 HWTEST_F(UsbdFunctionTest, SUB_USB_HDI_1700, Function | MediumTest | Level1)
510 {
511     int32_t portId = DEFAULT_PORT_ID;
512     int32_t powerRole = POWER_ROLE_NONE;
513     int32_t dataRole = DATA_ROLE_NONE;
514     int32_t mode = PORT_MODE_NONE;
515     auto ret = g_usbInterface->QueryPort(portId, powerRole, dataRole, mode);
516     HDF_LOGI("UsbdFunctionTest::SUB_USB_HDI_1700 %{public}d ret=%{public}d", __LINE__, ret);
517     ASSERT_EQ(0, ret);
518 }
519 } // namespace
520