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