• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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
16import usbManager from '@ohos.usbManager';
17import { UiDriver, BY } from '@ohos.UiTest';
18import CheckEmptyUtils from '../../../../../ohos_master/test/xts/acts/usb/usb_standard/entry/src/ohosTest/js/test/CheckEmptyUtils.js';
19import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
20
21
22export default function UsbApiParamExceJsunitTest() {
23describe('UsbApiParamExceJsunitTest', function () {
24
25    const TAG = "[UsbApiParamExceJsunitTest]";
26    const PARAM_NULL = null;
27    const PARAM_UNDEFINED = undefined;
28    const PARAM_NULLSTRING = "";
29    const PARAM_NUMBEREX = 123;
30    let gDeviceList;
31    let devices;
32    let gPipe;
33    let isDeviceConnected;
34    let tmpPipe = {
35        busNum: null,
36        devAddress: null
37    };
38    function deviceConnected() {
39        if (gDeviceList.length > 0) {
40            console.info(TAG, "Test USB device is connected");
41            return true;
42        }
43        console.info(TAG, "Test USB device is not connected");
44        return false;
45    }
46
47    beforeAll(async function () {
48        console.log(TAG, '*************Usb Unit UsbApiParamExceJsunitTest Begin*************');
49        const Version = usbManager.getVersion();
50        console.info(TAG, 'usb unit begin test getversion :' + Version);
51
52        // version > 17  host currentMode = 2 device currentMode = 1
53        gDeviceList = usbManager.getDevices();
54        isDeviceConnected = deviceConnected();
55        if (isDeviceConnected) {
56            let hasRight = usbManager.hasRight(gDeviceList[0].name);
57            if (!hasRight) {
58                console.info(TAG, `beforeAll: usb requestRight start`);
59                await getPermission();
60                CheckEmptyUtils.sleep(1000);
61                await driveFn();
62                CheckEmptyUtils.sleep(1000);
63            }
64
65            tmpPipe.busNum = gDeviceList[0].busNum;
66            tmpPipe.devAddress = gDeviceList[0].devAddress;
67        }
68    })
69
70    beforeEach(function () {
71        console.info(TAG, 'beforeEach: *************Usb Unit Test CaseEx*************');
72        gDeviceList = usbManager.getDevices();
73        if (isDeviceConnected) {
74            devices = gDeviceList[0];
75            console.info(TAG, 'beforeEach return devices : ' + JSON.stringify(devices));
76        }
77    })
78
79    afterEach(function () {
80        console.info(TAG, 'afterEach: *************Usb Unit Test CaseEx*************');
81        devices = null;
82        gPipe = null;
83        console.info(TAG, 'afterEach return devices : ' + JSON.stringify(devices));
84    })
85
86    afterAll(function () {
87        console.log(TAG, '*************Usb Unit UsbApiParamExceJsunitTest End*************');
88    })
89
90    async function driveFn() {
91        console.info('**************driveFn**************');
92        try {
93            let driver = await UiDriver.create();
94            console.info(TAG, ` come in driveFn`);
95            console.info(TAG, `driver is ${JSON.stringify(driver)}`);
96            CheckEmptyUtils.sleep(1000);
97            let button = await driver.findComponent(BY.text('允许'));
98            console.info(TAG, `button is ${JSON.stringify(button)}`);
99            CheckEmptyUtils.sleep(1000);
100            await button.click();
101        } catch (err) {
102            console.info(TAG, 'err is ' + err);
103            return;
104        }
105    }
106
107    async function getPermission() {
108        console.info('**************getPermission**************');
109        try {
110            usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
111                console.info(TAG, `usb requestRight success, hasRight: ${hasRight}`);
112            })
113        } catch (err) {
114            console.info(TAG, `usb getPermission to requestRight hasRight fail: `, err);
115            return
116        }
117    }
118
119    function getPipe(testCaseName) {
120        gPipe = usbManager.connectDevice(devices);
121        console.info(TAG, `usb ${testCaseName} connectDevice getPipe ret: ${JSON.stringify(gPipe)}`);
122        expect(gPipe !== null).assertTrue();
123    }
124
125    function toReleaseInterface(testCaseName, tInterface) {
126        let ret = usbManager.releaseInterface(tmpPipe, tInterface);
127        console.info(TAG, `usb ${testCaseName} releaseInterface ret: ${ret}`);
128        expect(ret).assertEqual(0);
129    }
130
131    function toClosePipe(testCaseName) {
132        let isPipClose = usbManager.closePipe(tmpPipe);
133        console.info(TAG, `usb ${testCaseName} closePipe ret: ${isPipClose}`);
134        expect(isPipClose).assertEqual(0);
135    }
136
137    /**
138     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_0100
139     * @tc.name     : testHasRightParamEx001
140     * @tc.desc     : Negative test: Param is null string
141     * @tc.size     : MediumTest
142     * @tc.type     : Function
143     * @tc.level    : Level 3
144     */
145    it('testHasRightParamEx001', 0, function () {
146        console.info(TAG, 'usb testHasRightParamEx001 begin');
147        if (!isDeviceConnected) {
148            expect(isDeviceConnected).assertFalse();
149            return
150        }
151        try {
152            let isHasRight = usbManager.hasRight(PARAM_NULLSTRING);
153            console.info(TAG, 'usb case hasRight ret : ' + isHasRight);
154            expect(isHasRight).assertFalse();
155        } catch (err) {
156            console.info(TAG, 'testHasRightParamEx001 catch err code: ', err.code, ', message: ', err.message);
157            expect(err !== null).assertFalse();
158        }
159    })
160
161    /**
162     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_0200
163     * @tc.name     : testHasRightParamEx002
164     * @tc.desc     : Negative test: Param add number '123'
165     * @tc.size     : MediumTest
166     * @tc.type     : Function
167     * @tc.level    : Level 3
168     */
169    it('testHasRightParamEx002', 0, function () {
170        console.info(TAG, 'usb testHasRightParamEx002 begin');
171        if (!isDeviceConnected) {
172            expect(isDeviceConnected).assertFalse();
173            return
174        }
175        try {
176            for (var i = 0; i < gDeviceList.length; i++) {
177                let deviceName = gDeviceList[i].name;
178                deviceName = deviceName + "123";
179                let isHasRight = usbManager.hasRight(deviceName);
180                console.info(TAG, 'usb [', deviceName, '] hasRight ret : ' + isHasRight);
181                expect(isHasRight).assertFalse();
182            }
183        } catch (err) {
184            console.info(TAG, 'testHasRightParamEx002 catch err code: ', err.code, ', message: ', err.message);
185            expect(err !== null).assertFalse();
186        }
187    })
188
189    /**
190     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_0300
191     * @tc.name     : testRequestRightParamEx001
192     * @tc.desc     : Negative test: Param is null string
193     * @tc.size     : MediumTest
194     * @tc.type     : Function
195     * @tc.level    : Level 3
196     */
197    it('testRequestRightParamEx001', 0, async function () {
198        console.info(TAG, 'usb testRequestRightParamEx001 begin');
199        if (!isDeviceConnected) {
200            expect(isDeviceConnected).assertFalse();
201            return
202        }
203        try {
204            let isHasRight = await usbManager.requestRight(PARAM_NULLSTRING);
205            console.info(TAG, 'usb case requestRight ret : ' + isHasRight);
206            expect(isHasRight).assertFalse();
207        } catch (err) {
208            console.info(TAG, 'testRequestRightParamEx001 catch err code: ', err.code, ', message: ', err.message);
209            expect(err !== null).assertFalse();
210        }
211    })
212
213    /**
214     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_0400
215     * @tc.name     : testRequestRightParamEx002
216     * @tc.desc     : Negative test: Param add number 'abc'
217     * @tc.size     : MediumTest
218     * @tc.type     : Function
219     * @tc.level    : Level 3
220     */
221    it('testRequestRightParamEx002', 0, async function () {
222        console.info(TAG, 'usb testRequestRightParamEx002 begin');
223        if (!isDeviceConnected) {
224            expect(isDeviceConnected).assertFalse();
225            return
226        }
227        try {
228            for (var i = 0; i < gDeviceList.length; i++) {
229                let deviceName = gDeviceList[i].name;
230                deviceName = deviceName + "abc";
231                let isHasRight = await usbManager.requestRight(deviceName);
232                console.info(TAG, 'usb [', deviceName, '] requestRight ret : ' + isHasRight);
233                expect(isHasRight).assertFalse();
234            }
235        } catch (err) {
236            console.info(TAG, 'testRequestRightParamEx002 catch err code: ', err.code, ', message: ', err.message);
237            expect(err !== null).assertFalse();
238        }
239    })
240
241    /**
242     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_0500
243     * @tc.name     : testRemoveRightParamEx001
244     * @tc.desc     : Negative test: Param is null string
245     * @tc.size     : MediumTest
246     * @tc.type     : Function
247     * @tc.level    : Level 3
248     */
249    it('testRemoveRightParamEx001', 0, function () {
250        console.info(TAG, 'usb testRemoveRightParamEx001 begin');
251        if (!isDeviceConnected) {
252            expect(isDeviceConnected).assertFalse();
253            return
254        }
255        try {
256            let remRight = usbManager.removeRight(PARAM_NULLSTRING);
257            console.info(TAG, 'usb case removeRight ret : ' + remRight);
258            expect(remRight).assertFalse();
259        } catch (err) {
260            console.info(TAG, 'testRemoveRightParamEx001 catch err code: ', err.code, ', message: ', err.message);
261            expect(err !== null).assertFalse();
262        }
263    })
264
265    /**
266     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_0600
267     * @tc.name     : testRemoveRightParamEx002
268     * @tc.desc     : Negative test: Param add letter 'abc'
269     * @tc.size     : MediumTest
270     * @tc.type     : Function
271     * @tc.level    : Level 3
272     */
273    it('testRemoveRightParamEx002', 0, function () {
274        console.info(TAG, 'usb testRemoveRightParamEx002 begin');
275        if (!isDeviceConnected) {
276            expect(isDeviceConnected).assertFalse();
277            return
278        }
279        try {
280            for (var i = 0; i < gDeviceList.length; i++) {
281                let deviceName = gDeviceList[i].name;
282                deviceName = deviceName + "abc";
283                let remRight = usbManager.removeRight(deviceName);
284                console.info(TAG, 'usb [', deviceName, '] removeRight ret : ', remRight);
285                expect(remRight).assertFalse();
286            }
287        } catch (err) {
288            console.info(TAG, 'testRemoveRightParamEx002 catch err code: ', err.code, ', message: ', err.message);
289            expect(err !== null).assertFalse();
290        }
291    })
292
293    /**
294     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_0700
295     * @tc.name     : testRemoveRightParamEx003
296     * @tc.desc     : Negative test: Param add special characters '@#'
297     * @tc.size     : MediumTest
298     * @tc.type     : Function
299     * @tc.level    : Level 3
300     */
301    it('testRemoveRightParamEx003', 0, function () {
302        console.info(TAG, 'usb testRemoveRightParamEx003 begin');
303        if (!isDeviceConnected) {
304            expect(isDeviceConnected).assertFalse();
305            return
306        }
307        try {
308            for (var i = 0; i < gDeviceList.length; i++) {
309                let deviceName = gDeviceList[i].name;
310                deviceName = deviceName + "@#";
311                let remRight = usbManager.removeRight(deviceName);
312                console.info(TAG, 'usb [', deviceName, '] removeRight ret : ', remRight);
313                expect(remRight).assertFalse();
314            }
315        } catch (err) {
316            console.info(TAG, 'testRemoveRightParamEx003 catch err code: ', err.code, ', message: ', err.message);
317            expect(err !== null).assertFalse();
318        }
319    })
320
321    /**
322     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_0800
323     * @tc.name     : testRemoveRightParamEx004
324     * @tc.desc     : Negative test: Param add number '123'
325     * @tc.size     : MediumTest
326     * @tc.type     : Function
327     * @tc.level    : Level 3
328     */
329    it('testRemoveRightParamEx004', 0, function () {
330        console.info(TAG, 'usb testRemoveRightParamEx004 begin');
331        if (!isDeviceConnected) {
332            expect(isDeviceConnected).assertFalse();
333            return
334        }
335        try {
336            for (var i = 0; i < gDeviceList.length; i++) {
337                let deviceName = gDeviceList[i].name;
338                deviceName = deviceName + "123";
339                let remRight = usbManager.removeRight(deviceName);
340                console.info(TAG, 'usb [', deviceName, '] removeRight ret : ', remRight);
341                expect(remRight).assertFalse();
342            }
343        } catch (err) {
344            console.info(TAG, 'testRemoveRightParamEx004 catch err code: ', err.code, ', message: ', err.message);
345            expect(err !== null).assertFalse();
346        }
347    })
348
349    /**
350     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_0900
351     * @tc.name     : testConnectDeviceParamEx001
352     * @tc.desc     : Negative test: Param add number '123'
353     * @tc.size     : MediumTest
354     * @tc.type     : Function
355     * @tc.level    : Level 3
356     */
357    it('testConnectDeviceParamEx001', 0, function () {
358        console.info(TAG, 'usb testConnectDeviceParamEx001 begin');
359        if (!isDeviceConnected) {
360            expect(isDeviceConnected).assertFalse();
361            return
362        }
363        try {
364            let deviceName = devices.name + "123";
365            devices.name = deviceName;
366            let gPipe = usbManager.connectDevice(devices);
367
368            console.info(TAG, 'usb [', devices.name, '] connectDevice ret : ', JSON.stringify(gPipe));
369            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
370        } catch (err) {
371            console.info(TAG, 'testConnectDeviceParamEx001 catch err code: ', err.code, ', message: ', err.message);
372            expect(err !== null).assertFalse();
373        }
374    })
375
376    /**
377     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_1000
378     * @tc.name     : testConnectDeviceParamEx002
379     * @tc.desc     : Negative test: Param add letter 'abc'
380     * @tc.size     : MediumTest
381     * @tc.type     : Function
382     * @tc.level    : Level 3
383     */
384    it('testConnectDeviceParamEx002', 0, function () {
385        console.info(TAG, 'usb testConnectDeviceParamEx002 begin');
386        if (!isDeviceConnected) {
387            expect(isDeviceConnected).assertFalse();
388            return
389        }
390        try {
391            let deviceName = devices.name + "abc";
392            devices.name = deviceName;
393            let gPipe = usbManager.connectDevice(devices);
394            console.info(TAG, 'usb [', devices.name, '] connectDevice ret : ', JSON.stringify(gPipe));
395            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
396        } catch (err) {
397            console.info(TAG, 'testConnectDeviceParamEx002 catch err code: ', err.code, ', message: ', err.message);
398            expect(err !== null).assertFalse();
399        }
400    })
401
402    /**
403     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_1100
404     * @tc.name     : testConnectDeviceParamEx003
405     * @tc.desc     : Negative test: Param add special characters '@#'
406     * @tc.size     : MediumTest
407     * @tc.type     : Function
408     * @tc.level    : Level 3
409     */
410    it('testConnectDeviceParamEx003', 0, function () {
411        console.info(TAG, 'usb testConnectDeviceParamEx003 begin');
412        if (!isDeviceConnected) {
413            expect(isDeviceConnected).assertFalse();
414            return
415        }
416        try {
417            let deviceName = devices.name + "@#";
418            devices.name = deviceName;
419            let gPipe = usbManager.connectDevice(devices);
420            console.info(TAG, 'usb [', devices.name, '] connectDevice ret : ', JSON.stringify(gPipe));
421            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
422        } catch (err) {
423            console.info(TAG, 'testConnectDeviceParamEx003 catch err code: ', err.code, ', message: ', err.message);
424            expect(err !== null).assertFalse();
425        }
426    })
427
428    /**
429     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_1200
430     * @tc.name     : testConnectDeviceParamEx004
431     * @tc.desc     : Negative test: devices name is null string ""
432     * @tc.size     : MediumTest
433     * @tc.type     : Function
434     * @tc.level    : Level 3
435     */
436    it('testConnectDeviceParamEx004', 0, function () {
437        console.info(TAG, 'usb testConnectDeviceParamEx004 begin');
438        if (!isDeviceConnected) {
439            expect(isDeviceConnected).assertFalse();
440            return
441        }
442        try {
443            devices.name = PARAM_NULLSTRING;
444            let gPipe = usbManager.connectDevice(devices);
445            console.info(TAG, 'usb [', devices.name, '] connectDevice ret : ', JSON.stringify(gPipe));
446            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
447        } catch (err) {
448            console.info(TAG, 'testConnectDeviceParamEx004 catch err code: ', err.code, ', message: ', err.message);
449            expect(err !== null).assertFalse();
450        }
451    })
452
453    /**
454     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_1300
455     * @tc.name     : testConnectDeviceParamEx005
456     * @tc.desc     : Negative test: devices serial is null string ""
457     * @tc.size     : MediumTest
458     * @tc.type     : Function
459     * @tc.level    : Level 3
460     */
461    it('testConnectDeviceParamEx005', 0, function () {
462        console.info(TAG, 'usb testConnectDeviceParamEx005 begin');
463        if (!isDeviceConnected) {
464            expect(isDeviceConnected).assertFalse();
465            return
466        }
467        try {
468            devices.serial = PARAM_NULLSTRING;
469            let gPipe = usbManager.connectDevice(devices);
470            console.info(TAG, 'usb [', devices.serial, '] connectDevice ret : ', JSON.stringify(gPipe));
471            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
472        } catch (err) {
473            console.info(TAG, 'testConnectDeviceParamEx005 catch err code: ', err.code, ', message: ', err.message);
474            expect(err !== null).assertFalse();
475        }
476    })
477
478    /**
479     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_1400
480     * @tc.name     : testConnectDeviceParamEx006
481     * @tc.desc     : Negative test: devices serial add letter abc
482     * @tc.size     : MediumTest
483     * @tc.type     : Function
484     * @tc.level    : Level 3
485     */
486    it('testConnectDeviceParamEx006', 0, function () {
487        console.info(TAG, 'usb testConnectDeviceParamEx006 begin');
488        if (!isDeviceConnected) {
489            expect(isDeviceConnected).assertFalse();
490            return
491        }
492        try {
493            let devSerial = devices.serial + "abc";
494            devices.serial = devSerial;
495            let gPipe = usbManager.connectDevice(devices);
496            console.info(TAG, 'usb [', devices.serial, '] connectDevice ret : ', JSON.stringify(gPipe));
497            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
498        } catch (err) {
499            console.info(TAG, 'testConnectDeviceParamEx006 catch err code: ', err.code, ', message: ', err.message);
500            expect(err !== null).assertFalse();
501        }
502    })
503
504    /**
505     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_1500
506     * @tc.name     : testConnectDeviceParamEx007
507     * @tc.desc     : Negative test: devices serial add number 123
508     * @tc.size     : MediumTest
509     * @tc.type     : Function
510     * @tc.level    : Level 3
511     */
512    it('testConnectDeviceParamEx007', 0, function () {
513        console.info(TAG, 'usb testConnectDeviceParamEx007 begin');
514        if (!isDeviceConnected) {
515            expect(isDeviceConnected).assertFalse();
516            return
517        }
518        try {
519            let devSerial = devices.serial + "123";
520            devices.serial = devSerial;
521            let gPipe = usbManager.connectDevice(devices);
522            console.info(TAG, 'usb [', devices.serial, '] connectDevice ret : ', JSON.stringify(gPipe));
523            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
524        } catch (err) {
525            console.info(TAG, 'testConnectDeviceParamEx007 catch err code: ', err.code, ', message: ', err.message);
526            expect(err !== null).assertFalse();
527        }
528    })
529
530    /**
531     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_1600
532     * @tc.name     : testConnectDeviceParamEx008
533     * @tc.desc     : Negative test: devices serial add special characters '@#'
534     * @tc.size     : MediumTest
535     * @tc.type     : Function
536     * @tc.level    : Level 3
537     */
538    it('testConnectDeviceParamEx008', 0, function () {
539        console.info(TAG, 'usb testConnectDeviceParamEx008 begin');
540        if (!isDeviceConnected) {
541            expect(isDeviceConnected).assertFalse();
542            return
543        }
544        try {
545            let devSerial = devices.serial + "@#";
546            devices.serial = devSerial;
547            let gPipe = usbManager.connectDevice(devices);
548            console.info(TAG, 'usb [', devices.serial, '] connectDevice ret : ', JSON.stringify(gPipe));
549            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
550        } catch (err) {
551            console.info(TAG, 'testConnectDeviceParamEx008 catch err code: ', err.code, ', message: ', err.message);
552            expect(err !== null).assertFalse();
553        }
554    })
555
556    /**
557     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_1700
558     * @tc.name     : testConnectDeviceParamEx009
559     * @tc.desc     : Negative test: devices manufacturerName add special characters '@#'
560     * @tc.size     : MediumTest
561     * @tc.type     : Function
562     * @tc.level    : Level 3
563     */
564    it('testConnectDeviceParamEx009', 0, function () {
565        console.info(TAG, 'usb testConnectDeviceParamEx009 begin');
566        if (!isDeviceConnected) {
567            expect(isDeviceConnected).assertFalse();
568            return
569        }
570        try {
571            let devManufacturerName = devices.manufacturerName + "@#";
572            devices.manufacturerName = devManufacturerName;
573            let gPipe = usbManager.connectDevice(devices);
574            console.info(TAG, 'usb [', devices.manufacturerName, '] connectDevice ret : ', JSON.stringify(gPipe));
575            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
576        } catch (err) {
577            console.info(TAG, 'testConnectDeviceParamEx009 catch err code: ', err.code, ', message: ', err.message);
578            expect(err !== null).assertFalse();
579        }
580    })
581
582    /**
583     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_1800
584     * @tc.name     : testConnectDeviceParamEx010
585     * @tc.desc     : Negative test: devices manufacturerName add special characters 'abc'
586     * @tc.size     : MediumTest
587     * @tc.type     : Function
588     * @tc.level    : Level 3
589     */
590    it('testConnectDeviceParamEx010', 0, function () {
591        console.info(TAG, 'usb testConnectDeviceParamEx010 begin');
592        if (!isDeviceConnected) {
593            expect(isDeviceConnected).assertFalse();
594            return
595        }
596        try {
597            let devManufacturerName = devices.manufacturerName + "abc";
598            devices.manufacturerName = devManufacturerName;
599            let gPipe = usbManager.connectDevice(devices);
600            console.info(TAG, 'usb [', devices.manufacturerName, '] connectDevice ret : ', JSON.stringify(gPipe));
601            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
602        } catch (err) {
603            console.info(TAG, 'testConnectDeviceParamEx010 catch err code: ', err.code, ', message: ', err.message);
604            expect(err !== null).assertFalse();
605        }
606    })
607
608    /**
609     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_1900
610     * @tc.name     : testConnectDeviceParamEx011
611     * @tc.desc     : Negative test: devices manufacturerName add special characters '123'
612     * @tc.size     : MediumTest
613     * @tc.type     : Function
614     * @tc.level    : Level 3
615     */
616    it('testConnectDeviceParamEx011', 0, function () {
617        console.info(TAG, 'usb testConnectDeviceParamEx011 begin');
618        if (!isDeviceConnected) {
619            expect(isDeviceConnected).assertFalse();
620            return
621        }
622        try {
623            let devManufacturerName = devices.manufacturerName + "123";
624            devices.manufacturerName = devManufacturerName;
625            let gPipe = usbManager.connectDevice(devices);
626            console.info(TAG, 'usb [', devices.manufacturerName, '] connectDevice ret : ', JSON.stringify(gPipe));
627            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
628        } catch (err) {
629            console.info(TAG, 'testConnectDeviceParamEx011 catch err code: ', err.code, ', message: ', err.message);
630            expect(err !== null).assertFalse();
631        }
632    })
633
634    /**
635     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_2000
636     * @tc.name     : testConnectDeviceParamEx012
637     * @tc.desc     : Negative test: devices manufacturerName add special characters ""
638     * @tc.size     : MediumTest
639     * @tc.type     : Function
640     * @tc.level    : Level 3
641     */
642    it('testConnectDeviceParamEx012', 0, function () {
643        console.info(TAG, 'usb testConnectDeviceParamEx012 begin');
644        if (!isDeviceConnected) {
645            expect(isDeviceConnected).assertFalse();
646            return
647        }
648        try {
649            devices.manufacturerName = PARAM_NULLSTRING;
650            let gPipe = usbManager.connectDevice(devices);
651            console.info(TAG, 'usb [', devices.manufacturerName, '] connectDevice ret : ', JSON.stringify(gPipe));
652            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
653        } catch (err) {
654            console.info(TAG, 'testConnectDeviceParamEx012 catch err code: ', err.code, ', message: ', err.message);
655            expect(err !== null).assertFalse();
656        }
657    })
658
659    /**
660     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_2100
661     * @tc.name     : testConnectDeviceParamEx013
662     * @tc.desc     : Negative test: devices productName add special characters '@#'
663     * @tc.size     : MediumTest
664     * @tc.type     : Function
665     * @tc.level    : Level 3
666     */
667    it('testConnectDeviceParamEx013', 0, function () {
668        console.info(TAG, 'usb testConnectDeviceParamEx013 begin');
669        if (!isDeviceConnected) {
670            expect(isDeviceConnected).assertFalse();
671            return
672        }
673        try {
674            let devProductName = devices.productName + "@#";
675            devices.productName = devProductName;
676            let gPipe = usbManager.connectDevice(devices);
677            console.info(TAG, 'usb [', devices.productName, '] connectDevice ret : ', JSON.stringify(gPipe));
678            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
679        } catch (err) {
680            console.info(TAG, 'testConnectDeviceParamEx013 catch err code: ', err.code, ', message: ', err.message);
681            expect(err !== null).assertFalse();
682        }
683    })
684
685    /**
686     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_2200
687     * @tc.name     : testConnectDeviceParamEx014
688     * @tc.desc     : Negative test: devices productName add special characters 'abc'
689     * @tc.size     : MediumTest
690     * @tc.type     : Function
691     * @tc.level    : Level 3
692     */
693    it('testConnectDeviceParamEx014', 0, function () {
694        console.info(TAG, 'usb testConnectDeviceParamEx014 begin');
695        if (!isDeviceConnected) {
696            expect(isDeviceConnected).assertFalse();
697            return
698        }
699        try {
700            let devProductName = devices.productName + "abc";
701            devices.productName = devProductName;
702            let gPipe = usbManager.connectDevice(devices);
703            console.info(TAG, 'usb [', devices.productName, '] connectDevice ret : ', JSON.stringify(gPipe));
704            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
705        } catch (err) {
706            console.info(TAG, 'testConnectDeviceParamEx014 catch err code: ', err.code, ', message: ', err.message);
707            expect(err !== null).assertFalse();
708        }
709    })
710
711    /**
712     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_2300
713     * @tc.name     : testConnectDeviceParamEx015
714     * @tc.desc     : Negative test: devices productName add special characters '123'
715     * @tc.size     : MediumTest
716     * @tc.type     : Function
717     * @tc.level    : Level 3
718     */
719    it('testConnectDeviceParamEx015', 0, function () {
720        console.info(TAG, 'usb testConnectDeviceParamEx015 begin');
721        if (!isDeviceConnected) {
722            expect(isDeviceConnected).assertFalse();
723            return
724        }
725        try {
726            let devProductName = devices.productName + "123";
727            devices.productName = devProductName;
728            let gPipe = usbManager.connectDevice(devices);
729            console.info(TAG, 'usb [', devices.productName, '] connectDevice ret : ', JSON.stringify(gPipe));
730            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
731        } catch (err) {
732            console.info(TAG, 'testConnectDeviceParamEx015 catch err code: ', err.code, ', message: ', err.message);
733            expect(err !== null).assertFalse();
734        }
735    })
736
737    /**
738     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_2400
739     * @tc.name     : testConnectDeviceParamEx016
740     * @tc.desc     : Negative test: devices productName is null string ""
741     * @tc.size     : MediumTest
742     * @tc.type     : Function
743     * @tc.level    : Level 3
744     */
745    it('testConnectDeviceParamEx016', 0, function () {
746        console.info(TAG, 'usb testConnectDeviceParamEx016 begin');
747        if (!isDeviceConnected) {
748            expect(isDeviceConnected).assertFalse();
749            return
750        }
751        try {
752            devices.productName = PARAM_NULLSTRING;
753            let gPipe = usbManager.connectDevice(devices);
754            console.info(TAG, 'usb [', devices.productName, '] connectDevice ret : ', JSON.stringify(gPipe));
755            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
756        } catch (err) {
757            console.info(TAG, 'testConnectDeviceParamEx016 catch err code: ', err.code, ', message: ', err.message);
758            expect(err !== null).assertFalse();
759        }
760    })
761
762    /**
763     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_2500
764     * @tc.name     : testConnectDeviceParamEx017
765     * @tc.desc     : Negative test: devices version add special characters '@#'
766     * @tc.size     : MediumTest
767     * @tc.type     : Function
768     * @tc.level    : Level 3
769     */
770    it('testConnectDeviceParamEx017', 0, function () {
771        console.info(TAG, 'usb testConnectDeviceParamEx017 begin');
772        if (!isDeviceConnected) {
773            expect(isDeviceConnected).assertFalse();
774            return
775        }
776        try {
777            let devVersion = devices.version + "@#";
778            devices.version = devVersion;
779            let gPipe = usbManager.connectDevice(devices);
780            console.info(TAG, 'usb [', devices.version, '] connectDevice ret : ', JSON.stringify(gPipe));
781            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
782        } catch (err) {
783            console.info(TAG, 'testConnectDeviceParamEx017 catch err code: ', err.code, ', message: ', err.message);
784            expect(err !== null).assertFalse();
785        }
786    })
787
788    /**
789     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_2600
790     * @tc.name     : testConnectDeviceParamEx018
791     * @tc.desc     : Negative test: devices version add special characters 'abc'
792     * @tc.size     : MediumTest
793     * @tc.type     : Function
794     * @tc.level    : Level 3
795     */
796    it('testConnectDeviceParamEx018', 0, function () {
797        console.info(TAG, 'usb testConnectDeviceParamEx018 begin');
798        if (!isDeviceConnected) {
799            expect(isDeviceConnected).assertFalse();
800            return
801        }
802        try {
803            let devVersion = devices.version + "abc";
804            devices.version = devVersion;
805            let gPipe = usbManager.connectDevice(devices);
806            console.info(TAG, 'usb [', devices.version, '] connectDevice ret : ', JSON.stringify(gPipe));
807            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
808        } catch (err) {
809            console.info(TAG, 'testConnectDeviceParamEx018 catch err code: ', err.code, ', message: ', err.message);
810            expect(err !== null).assertFalse();
811        }
812    })
813
814    /**
815     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_2700
816     * @tc.name     : testConnectDeviceParamEx019
817     * @tc.desc     : Negative test: devices version add special characters '123'
818     * @tc.size     : MediumTest
819     * @tc.type     : Function
820     * @tc.level    : Level 3
821     */
822    it('testConnectDeviceParamEx019', 0, function () {
823        console.info(TAG, 'usb testConnectDeviceParamEx019 begin');
824        if (!isDeviceConnected) {
825            expect(isDeviceConnected).assertFalse();
826            return
827        }
828        try {
829            let devVersion = devices.version + "123";
830            devices.version = devVersion;
831            let gPipe = usbManager.connectDevice(devices);
832            console.info(TAG, 'usb [', devices.version, '] connectDevice ret : ', JSON.stringify(gPipe));
833            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
834        } catch (err) {
835            console.info(TAG, 'testConnectDeviceParamEx019 catch err code: ', err.code, ', message: ', err.message);
836            expect(err !== null).assertFalse();
837        }
838    })
839
840    /**
841     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_2800
842     * @tc.name     : testConnectDeviceParamEx020
843     * @tc.desc     : Negative test: devices version is null string ""
844     * @tc.size     : MediumTest
845     * @tc.type     : Function
846     * @tc.level    : Level 3
847     */
848    it('testConnectDeviceParamEx020', 0, function () {
849        console.info(TAG, 'usb testConnectDeviceParamEx020 begin');
850        if (!isDeviceConnected) {
851            expect(isDeviceConnected).assertFalse();
852            return
853        }
854        try {
855            devices.version = PARAM_NULLSTRING;
856            let gPipe = usbManager.connectDevice(devices);
857            console.info(TAG, 'usb [', devices.version, '] connectDevice ret : ', JSON.stringify(gPipe));
858            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
859        } catch (err) {
860            console.info(TAG, 'testConnectDeviceParamEx020 catch err code: ', err.code, ', message: ', err.message);
861            expect(err !== null).assertFalse();
862        }
863    })
864
865    /**
866     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_2900
867     * @tc.name     : testConnectDeviceParamEx021
868     * @tc.desc     : Negative test: devices vendorId is add number 1000
869     * @tc.size     : MediumTest
870     * @tc.type     : Function
871     * @tc.level    : Level 3
872     */
873    it('testConnectDeviceParamEx021', 0, function () {
874        console.info(TAG, 'usb testConnectDeviceParamEx021 begin');
875        if (!isDeviceConnected) {
876            expect(isDeviceConnected).assertFalse();
877            return
878        }
879        try {
880            let devVendorId = devices.vendorId + 1000;
881            devices.vendorId = devVendorId;
882            let gPipe = usbManager.connectDevice(devices);
883            console.info(TAG, 'usb [', devices.vendorId, '] connectDevice ret : ', JSON.stringify(gPipe));
884            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
885        } catch (err) {
886            console.info(TAG, 'testConnectDeviceParamEx021 catch err code: ', err.code, ', message: ', err.message);
887            expect(err !== null).assertFalse();
888        }
889    })
890
891    /**
892     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_3000
893     * @tc.name     : testConnectDeviceParamEx022
894     * @tc.desc     : Negative test: devices productId is add number 1000
895     * @tc.size     : MediumTest
896     * @tc.type     : Function
897     * @tc.level    : Level 3
898     */
899    it('testConnectDeviceParamEx022', 0, function () {
900        console.info(TAG, 'usb testConnectDeviceParamEx022 begin');
901        if (!isDeviceConnected) {
902            expect(isDeviceConnected).assertFalse();
903            return
904        }
905        try {
906            let devProductId = devices.productId + 1000;
907            devices.productId = devProductId;
908            let gPipe = usbManager.connectDevice(devices);
909            console.info(TAG, 'usb [', devices.productId, '] connectDevice ret : ', JSON.stringify(gPipe));
910            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
911        } catch (err) {
912            console.info(TAG, 'testConnectDeviceParamEx022 catch err code: ', err.code, ', message: ', err.message);
913            expect(err !== null).assertFalse();
914        }
915    })
916
917    /**
918     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_3100
919     * @tc.name     : testConnectDeviceParamEx023
920     * @tc.desc     : Negative test: devices clazz is add number 1000
921     * @tc.size     : MediumTest
922     * @tc.type     : Function
923     * @tc.level    : Level 3
924     */
925    it('testConnectDeviceParamEx023', 0, function () {
926        console.info(TAG, 'usb testConnectDeviceParamEx023 begin');
927        if (!isDeviceConnected) {
928            expect(isDeviceConnected).assertFalse();
929            return
930        }
931        try {
932            let devClazz = devices.clazz + 1000;
933            devices.clazz = devClazz;
934            let gPipe = usbManager.connectDevice(devices);
935            console.info(TAG, 'usb [', devices.clazz, '] connectDevice ret : ', JSON.stringify(gPipe));
936            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
937        } catch (err) {
938            console.info(TAG, 'testConnectDeviceParamEx023 catch err code: ', err.code, ', message: ', err.message);
939            expect(err !== null).assertFalse();
940        }
941    })
942
943    /**
944     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_3200
945     * @tc.name     : testConnectDeviceParamEx024
946     * @tc.desc     : Negative test: devices subClass is add number 1000
947     * @tc.size     : MediumTest
948     * @tc.type     : Function
949     * @tc.level    : Level 3
950     */
951    it('testConnectDeviceParamEx024', 0, function () {
952        console.info(TAG, 'usb testConnectDeviceParamEx024 begin');
953        if (!isDeviceConnected) {
954            expect(isDeviceConnected).assertFalse();
955            return
956        }
957        try {
958            let devSubClass = devices.subClass + 1000;
959            devices.subClass = devSubClass;
960            let gPipe = usbManager.connectDevice(devices);
961            console.info(TAG, 'usb [', devices.subClass, '] connectDevice ret : ', JSON.stringify(gPipe));
962            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
963        } catch (err) {
964            console.info(TAG, 'testConnectDeviceParamEx024 catch err code: ', err.code, ', message: ', err.message);
965            expect(err !== null).assertFalse();
966        }
967    })
968
969    /**
970     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_3300
971     * @tc.name     : testConnectDeviceParamEx025
972     * @tc.desc     : Negative test: devices protocol is add number 1000
973     * @tc.size     : MediumTest
974     * @tc.type     : Function
975     * @tc.level    : Level 3
976     */
977    it('testConnectDeviceParamEx025', 0, function () {
978        console.info(TAG, 'usb testConnectDeviceParamEx025 begin');
979        if (!isDeviceConnected) {
980            expect(isDeviceConnected).assertFalse();
981            return
982        }
983        try {
984            let devProtocol = devices.protocol + 1000;
985            devices.protocol = devProtocol;
986            let gPipe = usbManager.connectDevice(devices);
987            console.info(TAG, 'usb [', devices.protocol, '] connectDevice ret : ', JSON.stringify(gPipe));
988            expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
989        } catch (err) {
990            console.info(TAG, 'testConnectDeviceParamEx025 catch err code: ', err.code, ', message: ', err.message);
991            expect(err !== null).assertFalse();
992        }
993    })
994
995    /**
996     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_3400
997     * @tc.name     : testConnectDeviceParamEx026
998     * @tc.desc     : Negative test: devices busNum is add number 1000
999     * @tc.size     : MediumTest
1000     * @tc.type     : Function
1001     * @tc.level    : Level 3
1002     */
1003    it('testConnectDeviceParamEx026', 0, function () {
1004        console.info(TAG, 'usb testConnectDeviceParamEx026 begin');
1005        if (!isDeviceConnected) {
1006            expect(isDeviceConnected).assertFalse();
1007            return
1008        }
1009        try {
1010            let devBusNum = devices.busNum + 1000;
1011            devices.busNum = devBusNum;
1012            let gPipe = usbManager.connectDevice(devices);
1013            console.info(TAG, 'usb [', devices.busNum, '] connectDevice ret : ', JSON.stringify(gPipe));
1014            expect(gPipe !== null).assertFalse();
1015        } catch (err) {
1016            console.info(TAG, 'testConnectDeviceParamEx026 catch err code: ', err.code, ', message: ', err.message);
1017            expect(err.code).assertEqual(14400001);
1018        }
1019    })
1020
1021    /**
1022     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_3500
1023     * @tc.name     : testConnectDeviceParamEx027
1024     * @tc.desc     : Negative test: devices devAddress is add number 10000
1025     * @tc.size     : MediumTest
1026     * @tc.type     : Function
1027     * @tc.level    : Level 3
1028     */
1029    it('testConnectDeviceParamEx027', 0, function () {
1030        console.info(TAG, 'usb testConnectDeviceParamEx027 begin');
1031        if (!isDeviceConnected) {
1032            expect(isDeviceConnected).assertFalse();
1033            return
1034        }
1035        try {
1036            let devDevAddress = devices.devAddress + 1000;
1037            devices.devAddress = devDevAddress;
1038            let gPipe = usbManager.connectDevice(devices);
1039            console.info(TAG, 'usb [', devices.devAddress, '] connectDevice ret : ', JSON.stringify(gPipe));
1040            expect(gPipe !== null).assertFalse();
1041        } catch (err) {
1042            console.info(TAG, 'testConnectDeviceParamEx027 catch err code: ', err.code, ', message: ', err.message);
1043            expect(err.code).assertEqual(14400001);
1044        }
1045    })
1046
1047    /**
1048     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_3600
1049     * @tc.name     : testClosePipeParamEx001
1050     * @tc.desc     : Negative test: pipe busNum add number 1000
1051     * @tc.size     : MediumTest
1052     * @tc.type     : Function
1053     * @tc.level    : Level 3
1054     */
1055    it('testClosePipeParamEx001', 0, function () {
1056        console.info(TAG, 'usb testClosePipeParamEx001 begin');
1057        if (!isDeviceConnected) {
1058            expect(isDeviceConnected).assertFalse();
1059            return
1060        }
1061        getPipe("testClosePipeParamEx001");
1062        try {
1063            gPipe.busNum = gPipe.busNum + 1000;
1064            let ret = usbManager.closePipe(gPipe);
1065            console.info(TAG, 'usb [', gPipe.busNum, '] closePipe ret : ', ret);
1066            expect(ret !== 0).assertTrue();
1067        } catch (err) {
1068            console.info(TAG, 'testClosePipeParamEx001 catch err code: ', err);
1069            expect(err !== null).assertFalse();
1070        }
1071        toClosePipe("testClosePipeParamEx001");
1072    })
1073
1074    /**
1075     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_3700
1076     * @tc.name     : testClosePipeParamEx002
1077     * @tc.desc     : Negative test: pipe devAddress add number 10000
1078     * @tc.size     : MediumTest
1079     * @tc.type     : Function
1080     * @tc.level    : Level 3
1081     */
1082    it('testClosePipeParamEx002', 0, function () {
1083        console.info(TAG, 'usb testClosePipeParamEx002 begin');
1084        if (!isDeviceConnected) {
1085            expect(isDeviceConnected).assertFalse();
1086            return
1087        }
1088        getPipe("testClosePipeParamEx002");
1089        try {
1090            let pipDevAdd = gPipe.devAddress + 10000;
1091            gPipe.devAddress = pipDevAdd;
1092            let ret = usbManager.closePipe(gPipe);
1093            console.info(TAG, 'usb [', gPipe.devAddress, '] closePipe ret : ', ret);
1094            expect(ret !== 0).assertTrue();
1095        } catch (err) {
1096            console.info(TAG, 'testClosePipeParamEx002 catch err code: ', err);
1097            expect(err !== null).assertFalse();
1098        }
1099        toClosePipe("testClosePipeParamEx002");
1100    })
1101
1102    /**
1103     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_3800
1104     * @tc.name     : testGetRawDescriptorParamEx001
1105     * @tc.desc     : Negative test: pipe busNum add number 1000
1106     * @tc.size     : MediumTest
1107     * @tc.type     : Function
1108     * @tc.level    : Level 3
1109     */
1110    it('testGetRawDescriptorParamEx001', 0, function () {
1111        console.info(TAG, 'usb testGetRawDescriptorParamEx001 begin');
1112        if (!isDeviceConnected) {
1113            expect(isDeviceConnected).assertFalse();
1114            return
1115        }
1116        getPipe("testGetRawDescriptorParamEx001");
1117        try {
1118            let pipBusNum = gPipe.busNum + 1000;
1119            gPipe.busNum = pipBusNum;
1120            let ret = usbManager.getRawDescriptor(gPipe);
1121            console.info(TAG, 'usb [', gPipe.busNum, '] getRawDescriptor ret : ', ret);
1122            expect(ret).assertEqual(undefined);
1123        } catch (err) {
1124            console.info(TAG, 'testGetRawDescriptorParamEx001 catch err code: ', err);
1125            expect(err !== null).assertFalse();
1126        }
1127        toClosePipe("testGetRawDescriptorParamEx001");
1128    })
1129
1130    /**
1131     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_3900
1132     * @tc.name     : testGetRawDescriptorParamEx002
1133     * @tc.desc     : Negative test: pipe devAddress add number 10000
1134     * @tc.size     : MediumTest
1135     * @tc.type     : Function
1136     * @tc.level    : Level 3
1137     */
1138    it('testGetRawDescriptorParamEx002', 0, function () {
1139        console.info(TAG, 'usb testGetRawDescriptorParamEx002 begin');
1140        if (!isDeviceConnected) {
1141            expect(isDeviceConnected).assertFalse();
1142            return
1143        }
1144        getPipe("testGetRawDescriptorParamEx002");
1145        try {
1146            let pipDevAdd = gPipe.devAddress + 10000;
1147            gPipe.devAddress = pipDevAdd;
1148            let ret = usbManager.getRawDescriptor(gPipe);
1149            console.info(TAG, 'usb [', gPipe.devAddress, '] getRawDescriptor ret : ', ret);
1150            expect(ret).assertEqual(undefined);
1151        } catch (err) {
1152            console.info(TAG, 'testGetRawDescriptorParamEx002 catch err code: ', err);
1153            expect(err !== null).assertFalse();
1154        }
1155        toClosePipe("testGetRawDescriptorParamEx002");
1156    })
1157
1158    /**
1159     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_4000
1160     * @tc.name     : testGetRawDescriptorParamEx003
1161     * @tc.desc     : Negative test: pipe busNum -23
1162     * @tc.size     : MediumTest
1163     * @tc.type     : Function
1164     * @tc.level    : Level 3
1165     */
1166    it('testGetRawDescriptorParamEx003', 0, function () {
1167        console.info(TAG, 'usb testGetRawDescriptorParamEx003 begin');
1168        if (!isDeviceConnected) {
1169            expect(isDeviceConnected).assertFalse();
1170            return
1171        }
1172        getPipe("testGetRawDescriptorParamEx003");
1173        try {
1174            gPipe.busNum = -23;
1175            let ret = usbManager.getRawDescriptor(gPipe);
1176            console.info(TAG, 'usb [', gPipe.busNum, '] getRawDescriptor ret : ', ret);
1177            expect(ret).assertEqual(undefined);
1178        } catch (err) {
1179            console.info(TAG, 'testGetRawDescriptorParamEx003 catch err code: ', err);
1180            expect(err !== null).assertFalse();
1181        }
1182        toClosePipe("testGetRawDescriptorParamEx003");
1183    })
1184
1185    /**
1186     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_4100
1187     * @tc.name     : testGetRawDescriptorParamEx004
1188     * @tc.desc     : Negative test: pipe devAddress -23
1189     * @tc.size     : MediumTest
1190     * @tc.type     : Function
1191     * @tc.level    : Level 3
1192     */
1193    it('testGetRawDescriptorParamEx004', 0, function () {
1194        console.info(TAG, 'usb testGetRawDescriptorParamEx004 begin');
1195        if (!isDeviceConnected) {
1196            expect(isDeviceConnected).assertFalse();
1197            return
1198        }
1199        getPipe("testGetRawDescriptorParamEx004");
1200        try {
1201            gPipe.devAddress = -23;
1202            let ret = usbManager.getRawDescriptor(gPipe);
1203            console.info(TAG, 'usb [', gPipe.devAddress, '] getRawDescriptor ret : ', ret);
1204            expect(ret).assertEqual(undefined);
1205        } catch (err) {
1206            console.info(TAG, 'testGetRawDescriptorParamEx004 catch err code: ', err);
1207            expect(err !== null).assertFalse();
1208        }
1209        toClosePipe("testGetRawDescriptorParamEx004");
1210    })
1211
1212    /**
1213     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_4200
1214     * @tc.name     : testGetRawDescriptorParamEx005
1215     * @tc.desc     : Negative test: pipe busNum -23, devAddress -23
1216     * @tc.size     : MediumTest
1217     * @tc.type     : Function
1218     * @tc.level    : Level 3
1219     */
1220    it('testGetRawDescriptorParamEx005', 0, function () {
1221        console.info(TAG, 'usb testGetRawDescriptorParamEx005 begin');
1222        if (!isDeviceConnected) {
1223            expect(isDeviceConnected).assertFalse();
1224            return
1225        }
1226        getPipe("testGetRawDescriptorParamEx005");
1227        try {
1228            gPipe.busNum = -23;
1229            gPipe.devAddress = -23;
1230            let ret = usbManager.getRawDescriptor(gPipe);
1231            console.info(TAG, 'usb [', gPipe.devAddress, '] getRawDescriptor ret : ', ret);
1232            expect(ret).assertEqual(undefined);
1233        } catch (err) {
1234            console.info(TAG, 'testGetRawDescriptorParamEx005 catch err code: ', err);
1235            expect(err !== null).assertFalse();
1236        }
1237        toClosePipe("testGetRawDescriptorParamEx005");
1238    })
1239
1240    /**
1241     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_4300
1242     * @tc.name     : testGetFileDescriptorParamEx001
1243     * @tc.desc     : Negative test: pipe busNum add number 1000
1244     * @tc.size     : MediumTest
1245     * @tc.type     : Function
1246     * @tc.level    : Level 3
1247     */
1248    it('testGetFileDescriptorParamEx001', 0, function () {
1249        console.info(TAG, 'usb testGetFileDescriptorParamEx001 begin');
1250        if (!isDeviceConnected) {
1251            expect(isDeviceConnected).assertFalse();
1252            return
1253        }
1254        getPipe("testGetFileDescriptorParamEx001");
1255        try {
1256            let pipBusNum = gPipe.busNum + 1000;
1257            gPipe.busNum = pipBusNum;
1258            let ret = usbManager.getFileDescriptor(gPipe);
1259            console.info(TAG, 'usb [', gPipe.busNum, '] getFileDescriptor ret : ', ret);
1260            expect(ret).assertEqual(-1);
1261        } catch (err) {
1262            console.info(TAG, 'testGetFileDescriptorParamEx001 catch err code: ', err);
1263            expect(err !== null).assertFalse();
1264        }
1265        toClosePipe("testGetFileDescriptorParamEx001");
1266    })
1267
1268    /**
1269     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_4400
1270     * @tc.name     : testGetFileDescriptorParamEx002
1271     * @tc.desc     : Negative test: pipe devAddress add number 10000
1272     * @tc.size     : MediumTest
1273     * @tc.type     : Function
1274     * @tc.level    : Level 3
1275     */
1276    it('testGetFileDescriptorParamEx002', 0, function () {
1277        console.info(TAG, 'usb testGetFileDescriptorParamEx002 begin');
1278        if (!isDeviceConnected) {
1279            expect(isDeviceConnected).assertFalse();
1280            return
1281        }
1282        getPipe("testGetFileDescriptorParamEx002");
1283        try {
1284            let pipDevAdd = gPipe.devAddress + 10000;
1285            gPipe.devAddress = pipDevAdd;
1286            let ret = usbManager.getFileDescriptor(gPipe);
1287            console.info(TAG, 'usb [', gPipe.devAddress, '] getFileDescriptor ret : ', ret);
1288            expect(ret).assertEqual(-1);
1289        } catch (err) {
1290            console.info(TAG, 'testGetFileDescriptorParamEx002 catch err code: ', err);
1291            expect(err !== null).assertFalse();
1292        }
1293        toClosePipe("testGetFileDescriptorParamEx002");
1294    })
1295
1296    /**
1297     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_4500
1298     * @tc.name     : testGetFileDescriptorParamEx003
1299     * @tc.desc     : Negative test: pipe busNum -23
1300     * @tc.size     : MediumTest
1301     * @tc.type     : Function
1302     * @tc.level    : Level 3
1303     */
1304    it('testGetFileDescriptorParamEx003', 0, function () {
1305        console.info(TAG, 'usb testGetFileDescriptorParamEx003 begin');
1306        if (!isDeviceConnected) {
1307            expect(isDeviceConnected).assertFalse();
1308            return
1309        }
1310        getPipe("testGetFileDescriptorParamEx003");
1311        try {
1312            gPipe.busNum = -23;
1313            let ret = usbManager.getFileDescriptor(gPipe);
1314            console.info(TAG, 'usb [', gPipe.busNum, '] getFileDescriptor ret : ', ret);
1315            expect(ret).assertEqual(-1);
1316        } catch (err) {
1317            console.info(TAG, 'testGetFileDescriptorParamEx003 catch err code: ', err);
1318            expect(err !== null).assertFalse();
1319        }
1320        toClosePipe("testGetFileDescriptorParamEx003");
1321    })
1322
1323    /**
1324     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_4600
1325     * @tc.name     : testGetFileDescriptorParamEx004
1326     * @tc.desc     : Negative test: pipe devAddress -23
1327     * @tc.size     : MediumTest
1328     * @tc.type     : Function
1329     * @tc.level    : Level 3
1330     */
1331    it('testGetFileDescriptorParamEx004', 0, function () {
1332        console.info(TAG, 'usb testGetFileDescriptorParamEx004 begin');
1333        if (!isDeviceConnected) {
1334            expect(isDeviceConnected).assertFalse();
1335            return
1336        }
1337        getPipe("testGetFileDescriptorParamEx004");
1338        try {
1339            gPipe.devAddress = -23;
1340            let ret = usbManager.getFileDescriptor(gPipe);
1341            console.info(TAG, 'usb [', gPipe.devAddress, '] getFileDescriptor ret : ', ret);
1342            expect(ret).assertEqual(-1);
1343        } catch (err) {
1344            console.info(TAG, 'testGetFileDescriptorParamEx004 catch err code: ', err);
1345            expect(err !== null).assertFalse();
1346        }
1347        toClosePipe("testGetFileDescriptorParamEx004");
1348    })
1349
1350    /**
1351     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_4700
1352     * @tc.name     : testGetFileDescriptorParamEx005
1353     * @tc.desc     : Negative test: pipe busNum -23, devAddress -23
1354     * @tc.size     : MediumTest
1355     * @tc.type     : Function
1356     * @tc.level    : Level 3
1357     */
1358    it('testGetFileDescriptorParamEx005', 0, function () {
1359        console.info(TAG, 'usb testGetFileDescriptorParamEx005 begin');
1360        if (!isDeviceConnected) {
1361            expect(isDeviceConnected).assertFalse();
1362            return
1363        }
1364        getPipe("testGetFileDescriptorParamEx005");
1365        try {
1366            gPipe.busNum = -23;
1367            gPipe.devAddress = -23;
1368            let ret = usbManager.getFileDescriptor(gPipe);
1369            console.info(TAG, 'usb [', gPipe.devAddress, '] getFileDescriptor ret : ', ret);
1370            expect(ret).assertEqual(-1);
1371        } catch (err) {
1372            console.info(TAG, 'testGetFileDescriptorParamEx005 catch err code: ', err);
1373            expect(err !== null).assertFalse();
1374        }
1375        toClosePipe("testGetFileDescriptorParamEx005");
1376    })
1377
1378    /**
1379     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_4800
1380     * @tc.name     : testClaimInterfaceParamEx001
1381     * @tc.desc     : Negative test: interfaces id add 123
1382     * @tc.size     : MediumTest
1383     * @tc.type     : Function
1384     * @tc.level    : Level 3
1385     */
1386    it('testClaimInterfaceParamEx001', 0, function () {
1387        console.info(TAG, 'usb testClaimInterfaceParamEx001 begin');
1388        if (!isDeviceConnected) {
1389            expect(isDeviceConnected).assertFalse();
1390            return
1391        }
1392        getPipe("testClaimInterfaceParamEx001");
1393        try {
1394            let tmpInterface = devices.configs[0].interfaces[0];
1395            tmpInterface.id = tmpInterface.id + 123;
1396            let ret = usbManager.claimInterface(gPipe, tmpInterface);
1397            console.info(TAG, 'usb [', tmpInterface.id, '] claimInterface ret : ', ret);
1398            expect(ret !== 0).assertTrue();
1399        } catch (err) {
1400            console.info(TAG, 'testClaimInterfaceParamEx001 catch err code: ', err);
1401            expect(err !== null).assertFalse();
1402        }
1403        toClosePipe("testClaimInterfaceParamEx001");
1404    })
1405
1406    /**
1407     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_4900
1408     * @tc.name     : testClaimInterfaceParamEx002
1409     * @tc.desc     : Negative test: interfaces id -1
1410     * @tc.size     : MediumTest
1411     * @tc.type     : Function
1412     * @tc.level    : Level 3
1413     */
1414    it('testClaimInterfaceParamEx002', 0, function () {
1415        console.info(TAG, 'usb testClaimInterfaceParamEx002 begin');
1416        if (!isDeviceConnected) {
1417            expect(isDeviceConnected).assertFalse();
1418            return
1419        }
1420        getPipe("testClaimInterfaceParamEx002");
1421        try {
1422            let tmpInterface = devices.configs[0].interfaces[0];
1423            tmpInterface.id = -1;
1424            let ret = usbManager.claimInterface(gPipe, tmpInterface);
1425            console.info(TAG, 'usb [', tmpInterface.id, '] claimInterface ret : ', ret);
1426            expect(ret !== 0).assertTrue();
1427        } catch (err) {
1428            console.info(TAG, 'testClaimInterfaceParamEx002 catch err code: ', err);
1429            expect(err !== null).assertFalse();
1430        }
1431        toClosePipe("testClaimInterfaceParamEx002");
1432    })
1433
1434    /**
1435     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_5000
1436     * @tc.name     : testClaimInterfaceParamEx003
1437     * @tc.desc     : Negative test: pipe busNum add 1000
1438     * @tc.size     : MediumTest
1439     * @tc.type     : Function
1440     * @tc.level    : Level 3
1441     */
1442    it('testClaimInterfaceParamEx003', 0, function () {
1443        console.info(TAG, 'usb testClaimInterfaceParamEx003 begin');
1444        if (!isDeviceConnected) {
1445            expect(isDeviceConnected).assertFalse();
1446            return
1447        }
1448        getPipe("testClaimInterfaceParamEx003");
1449        try {
1450            gPipe.busNum = gPipe.busNum + 1000;
1451            let tmpInterface = devices.configs[0].interfaces[0];
1452            let ret = usbManager.claimInterface(gPipe, tmpInterface);
1453            console.info(TAG, 'usb [', gPipe.busNum, '] claimInterface ret : ', ret);
1454            expect(ret !== 0).assertTrue();
1455        } catch (err) {
1456            console.info(TAG, 'testClaimInterfaceParamEx003 catch err code: ', err);
1457            expect(err !== null).assertFalse();
1458        }
1459        toClosePipe("testClaimInterfaceParamEx003");
1460    })
1461
1462    /**
1463     * @tc.number   : SUB_USB_HostManager_JS_ParamEx_5100
1464     * @tc.name     : testClaimInterfaceParamEx004
1465     * @tc.desc     : Negative test: pipe busNum -1
1466     * @tc.size     : MediumTest
1467     * @tc.type     : Function
1468     * @tc.level    : Level 3
1469     */
1470    it('testClaimInterfaceParamEx004', 0, function () {
1471        console.info(TAG, 'usb testClaimInterfaceParamEx004 begin');
1472        if (!isDeviceConnected) {
1473            expect(isDeviceConnected).assertFalse();
1474            return
1475        }
1476        getPipe("testClaimInterfaceParamEx004");
1477        try {
1478            gPipe.busNum = -1;
1479            let tmpInterface = devices.configs[0].interfaces[0];
1480            let ret = usbManager.claimInterface(gPipe, tmpInterface);
1481            console.info(TAG, 'usb [', gPipe.busNum, '] claimInterface ret : ', ret);
1482            expect(ret !== 0).assertTrue();
1483        } catch (err) {
1484            console.info(TAG, 'testClaimInterfaceParamEx004 catch err code: ', err);
1485            expect(err !== null).assertFalse();
1486        }
1487        toClosePipe("testClaimInterfaceParamEx004");
1488    })
1489})
1490}
1491