-
Notifications
You must be signed in to change notification settings - Fork 0
/
UsbManagerParamExJsTest
1685 lines (1611 loc) · 67.8 KB
/
UsbManagerParamExJsTest
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import usbManager from '@ohos.usbManager';
//import CheckEmptyUtils from './CheckEmptyUtils.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe('UsbApiParamExceJsunitTest', function () {
const TAG = "[UsbApiParamExceJsunitTest]";
const PARAM_NULL = null;
const PARAM_UNDEFINED = undefined;
const PARAM_NULLSTRING = "";
const PARAM_NUMBEREX = 123;
let gDeviceList;
let devices;
let gPipe;
let isDeviceConnected;
let tmpPipe = {
busNum: null,
devAddress: null
};
function deviceConnected() {
if (gDeviceList.length > 0) {
console.info(TAG, "Test USB device is connected");
return true;
}
console.info(TAG, "Test USB device is not connected");
return false;
}
beforeAll(async function () {
console.log(TAG, '*************Usb Unit UsbApiParamExceJsunitTest Begin*************');
const Version = usbManager.getVersion();
console.info(TAG, 'usb unit begin test getversion :' + Version);
// version > 17 host currentMode = 2 device currentMode = 1
gDeviceList = usbManager.getDevices();
isDeviceConnected = deviceConnected();
if (isDeviceConnected) {
let hasRight = usbManager.hasRight(gDeviceList[0].name);
if (!hasRight) {
console.info(TAG, `beforeAll: usb requestRight start`);
await getPermission();
CheckEmptyUtils.sleep(1000);
await driveFn();
CheckEmptyUtils.sleep(1000);
}
tmpPipe.busNum = gDeviceList[0].busNum;
tmpPipe.devAddress = gDeviceList[0].devAddress;
}
})
beforeEach(function () {
console.info(TAG, 'beforeEach: *************Usb Unit Test CaseEx*************');
gDeviceList = usbManager.getDevices();
if (isDeviceConnected) {
devices = gDeviceList[0];
console.info(TAG, 'beforeEach return devices : ' + JSON.stringify(devices));
}
})
afterEach(function () {
console.info(TAG, 'afterEach: *************Usb Unit Test CaseEx*************');
devices = null;
gPipe = null;
console.info(TAG, 'afterEach return devices : ' + JSON.stringify(devices));
})
afterAll(function () {
console.log(TAG, '*************Usb Unit UsbApiParamExceJsunitTest End*************');
})
async function driveFn() {
console.info('**************driveFn**************');
try {
let driver = await UiDriver.create();
console.info(TAG, ` come in driveFn`);
console.info(TAG, `driver is ${JSON.stringify(driver)}`);
CheckEmptyUtils.sleep(1000);
let button = await driver.findComponent(BY.text('允许'));
console.info(TAG, `button is ${JSON.stringify(button)}`);
CheckEmptyUtils.sleep(1000);
await button.click();
} catch (err) {
console.info(TAG, 'err is ' + err);
return;
}
}
async function getPermission() {
console.info('**************getPermission**************');
try {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
console.info(TAG, `usb requestRight success, hasRight: ${hasRight}`);
})
} catch (err) {
console.info(TAG, `usb getPermission to requestRight hasRight fail: `, err);
return
}
}
function getPipe(testCaseName) {
gPipe = usbManager.connectDevice(devices);
console.info(TAG, `usb ${testCaseName} connectDevice getPipe ret: ${JSON.stringify(gPipe)}`);
expect(gPipe !== null).assertTrue();
}
function toReleaseInterface(testCaseName, tInterface) {
let ret = usbManager.releaseInterface(tmpPipe, tInterface);
console.info(TAG, `usb ${testCaseName} releaseInterface ret: ${ret}`);
expect(ret).assertEqual(0);
}
function toClosePipe(testCaseName) {
let isPipClose = usbManager.closePipe(tmpPipe);
console.info(TAG, `usb ${testCaseName} closePipe ret: ${isPipClose}`);
expect(isPipClose).assertEqual(0);
}
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_0100
* @tc.name : testHasRightParamEx001
* @tc.desc : Negative test: Param is null string
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testHasRightParamEx001', 0, function () {
console.info(TAG, 'usb testHasRightParamEx001 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let isHasRight = usbManager.hasRight(PARAM_NULLSTRING);
console.info(TAG, 'usb case hasRight ret : ' + isHasRight);
expect(isHasRight).assertFalse();
} catch (err) {
console.info(TAG, 'testHasRightParamEx001 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_0200
* @tc.name : testHasRightParamEx002
* @tc.desc : Negative test: Param add number '123'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testHasRightParamEx002', 0, function () {
console.info(TAG, 'usb testHasRightParamEx002 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
for (var i = 0; i < gDeviceList.length; i++) {
let deviceName = gDeviceList[i].name;
deviceName = deviceName + "123";
let isHasRight = usbManager.hasRight(deviceName);
console.info(TAG, 'usb [', deviceName, '] hasRight ret : ' + isHasRight);
expect(isHasRight).assertFalse();
}
} catch (err) {
console.info(TAG, 'testHasRightParamEx002 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_0300
* @tc.name : testRequestRightParamEx001
* @tc.desc : Negative test: Param is null string
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testRequestRightParamEx001', 0, async function () {
console.info(TAG, 'usb testRequestRightParamEx001 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let isHasRight = await usbManager.requestRight(PARAM_NULLSTRING);
console.info(TAG, 'usb case requestRight ret : ' + isHasRight);
expect(isHasRight).assertFalse();
} catch (err) {
console.info(TAG, 'testRequestRightParamEx001 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_0400
* @tc.name : testRequestRightParamEx002
* @tc.desc : Negative test: Param add number 'abc'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testRequestRightParamEx002', 0, async function () {
console.info(TAG, 'usb testRequestRightParamEx002 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
for (var i = 0; i < gDeviceList.length; i++) {
let deviceName = gDeviceList[i].name;
deviceName = deviceName + "abc";
let isHasRight = await usbManager.requestRight(deviceName);
console.info(TAG, 'usb [', deviceName, '] requestRight ret : ' + isHasRight);
expect(isHasRight).assertFalse();
}
} catch (err) {
console.info(TAG, 'testRequestRightParamEx002 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_0500
* @tc.name : testRemoveRightParamEx001
* @tc.desc : Negative test: Param is null string
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testRemoveRightParamEx001', 0, function () {
console.info(TAG, 'usb testRemoveRightParamEx001 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let remRight = usbManager.removeRight(PARAM_NULLSTRING);
console.info(TAG, 'usb case removeRight ret : ' + remRight);
expect(remRight).assertFalse();
} catch (err) {
console.info(TAG, 'testRemoveRightParamEx001 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_0600
* @tc.name : testRemoveRightParamEx002
* @tc.desc : Negative test: Param add letter 'abc'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testRemoveRightParamEx002', 0, function () {
console.info(TAG, 'usb testRemoveRightParamEx002 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
for (var i = 0; i < gDeviceList.length; i++) {
let deviceName = gDeviceList[i].name;
deviceName = deviceName + "abc";
let remRight = usbManager.removeRight(deviceName);
console.info(TAG, 'usb [', deviceName, '] removeRight ret : ', remRight);
expect(remRight).assertFalse();
}
} catch (err) {
console.info(TAG, 'testRemoveRightParamEx002 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_0700
* @tc.name : testRemoveRightParamEx003
* @tc.desc : Negative test: Param add special characters '@#'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testRemoveRightParamEx003', 0, function () {
console.info(TAG, 'usb testRemoveRightParamEx003 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
for (var i = 0; i < gDeviceList.length; i++) {
let deviceName = gDeviceList[i].name;
deviceName = deviceName + "@#";
let remRight = usbManager.removeRight(deviceName);
console.info(TAG, 'usb [', deviceName, '] removeRight ret : ', remRight);
expect(remRight).assertFalse();
}
} catch (err) {
console.info(TAG, 'testRemoveRightParamEx003 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_0800
* @tc.name : testRemoveRightParamEx004
* @tc.desc : Negative test: Param add number '123'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testRemoveRightParamEx004', 0, function () {
console.info(TAG, 'usb testRemoveRightParamEx004 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
for (var i = 0; i < gDeviceList.length; i++) {
let deviceName = gDeviceList[i].name;
deviceName = deviceName + "123";
let remRight = usbManager.removeRight(deviceName);
console.info(TAG, 'usb [', deviceName, '] removeRight ret : ', remRight);
expect(remRight).assertFalse();
}
} catch (err) {
console.info(TAG, 'testRemoveRightParamEx004 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_0900
* @tc.name : testConnectDeviceParamEx001
* @tc.desc : Negative test: Param add number '123'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx001', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx001 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let deviceName = devices.name + "123";
devices.name = deviceName;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.name, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx001 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_1000
* @tc.name : testConnectDeviceParamEx002
* @tc.desc : Negative test: Param add letter 'abc'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx002', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx002 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let deviceName = devices.name + "abc";
devices.name = deviceName;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.name, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx002 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_1100
* @tc.name : testConnectDeviceParamEx003
* @tc.desc : Negative test: Param add special characters '@#'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx003', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx003 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let deviceName = devices.name + "@#";
devices.name = deviceName;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.name, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx003 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_1200
* @tc.name : testConnectDeviceParamEx004
* @tc.desc : Negative test: devices name is null string ""
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx004', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx004 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
devices.name = PARAM_NULLSTRING;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.name, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx004 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_1300
* @tc.name : testConnectDeviceParamEx005
* @tc.desc : Negative test: devices serial is null string ""
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx005', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx005 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
devices.serial = PARAM_NULLSTRING;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.serial, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx005 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_1400
* @tc.name : testConnectDeviceParamEx006
* @tc.desc : Negative test: devices serial add letter abc
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx006', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx006 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devSerial = devices.serial + "abc";
devices.serial = devSerial;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.serial, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx006 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_1500
* @tc.name : testConnectDeviceParamEx007
* @tc.desc : Negative test: devices serial add number 123
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx007', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx007 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devSerial = devices.serial + "123";
devices.serial = devSerial;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.serial, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx007 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_1600
* @tc.name : testConnectDeviceParamEx008
* @tc.desc : Negative test: devices serial add special characters '@#'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx008', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx008 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devSerial = devices.serial + "@#";
devices.serial = devSerial;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.serial, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx008 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_1700
* @tc.name : testConnectDeviceParamEx009
* @tc.desc : Negative test: devices manufacturerName add special characters '@#'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx009', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx009 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devManufacturerName = devices.manufacturerName + "@#";
devices.manufacturerName = devManufacturerName;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.manufacturerName, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx009 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_1800
* @tc.name : testConnectDeviceParamEx010
* @tc.desc : Negative test: devices manufacturerName add special characters 'abc'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx010', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx010 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devManufacturerName = devices.manufacturerName + "abc";
devices.manufacturerName = devManufacturerName;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.manufacturerName, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx010 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_1900
* @tc.name : testConnectDeviceParamEx011
* @tc.desc : Negative test: devices manufacturerName add special characters '123'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx011', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx011 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devManufacturerName = devices.manufacturerName + "123";
devices.manufacturerName = devManufacturerName;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.manufacturerName, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx011 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_2000
* @tc.name : testConnectDeviceParamEx012
* @tc.desc : Negative test: devices manufacturerName add special characters ""
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx012', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx012 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
devices.manufacturerName = PARAM_NULLSTRING;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.manufacturerName, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx012 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_2100
* @tc.name : testConnectDeviceParamEx013
* @tc.desc : Negative test: devices productName add special characters '@#'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx013', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx013 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devProductName = devices.productName + "@#";
devices.productName = devProductName;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.productName, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx013 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_2200
* @tc.name : testConnectDeviceParamEx014
* @tc.desc : Negative test: devices productName add special characters 'abc'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx014', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx014 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devProductName = devices.productName + "abc";
devices.productName = devProductName;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.productName, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx014 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_2300
* @tc.name : testConnectDeviceParamEx015
* @tc.desc : Negative test: devices productName add special characters '123'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx015', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx015 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devProductName = devices.productName + "123";
devices.productName = devProductName;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.productName, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx015 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_2400
* @tc.name : testConnectDeviceParamEx016
* @tc.desc : Negative test: devices productName is null string ""
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx016', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx016 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
devices.productName = PARAM_NULLSTRING;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.productName, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx016 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_2500
* @tc.name : testConnectDeviceParamEx017
* @tc.desc : Negative test: devices version add special characters '@#'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx017', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx017 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devVersion = devices.version + "@#";
devices.version = devVersion;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.version, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx017 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_2600
* @tc.name : testConnectDeviceParamEx018
* @tc.desc : Negative test: devices version add special characters 'abc'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx018', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx018 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devVersion = devices.version + "abc";
devices.version = devVersion;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.version, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx018 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_2700
* @tc.name : testConnectDeviceParamEx019
* @tc.desc : Negative test: devices version add special characters '123'
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx019', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx019 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devVersion = devices.version + "123";
devices.version = devVersion;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.version, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx019 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_2800
* @tc.name : testConnectDeviceParamEx020
* @tc.desc : Negative test: devices version is null string ""
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx020', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx020 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
devices.version = PARAM_NULLSTRING;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.version, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx020 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_2900
* @tc.name : testConnectDeviceParamEx021
* @tc.desc : Negative test: devices vendorId is add number 1000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx021', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx021 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devVendorId = devices.vendorId + 1000;
devices.vendorId = devVendorId;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.vendorId, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx021 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_3000
* @tc.name : testConnectDeviceParamEx022
* @tc.desc : Negative test: devices productId is add number 1000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx022', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx022 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devProductId = devices.productId + 1000;
devices.productId = devProductId;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.productId, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx022 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_3100
* @tc.name : testConnectDeviceParamEx023
* @tc.desc : Negative test: devices clazz is add number 1000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx023', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx023 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devClazz = devices.clazz + 1000;
devices.clazz = devClazz;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.clazz, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx023 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_3200
* @tc.name : testConnectDeviceParamEx024
* @tc.desc : Negative test: devices subClass is add number 1000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx024', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx024 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devSubClass = devices.subClass + 1000;
devices.subClass = devSubClass;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.subClass, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx024 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_3300
* @tc.name : testConnectDeviceParamEx025
* @tc.desc : Negative test: devices protocol is add number 1000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx025', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx025 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devProtocol = devices.protocol + 1000;
devices.protocol = devProtocol;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.protocol, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx025 catch err code: ', err.code, ', message: ', err.message);
expect(err !== null).assertFalse();
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_3400
* @tc.name : testConnectDeviceParamEx026
* @tc.desc : Negative test: devices busNum is add number 1000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/