UsbFunctionsJsunitEx.test.js 22.0 KB
Newer Older
J
jiyong_sd 已提交
1
/*
L
lixiaofeng_154b 已提交
2
 * Copyright (C) 2021-2023 Huawei Device Co., Ltd.
J
jiyong_sd 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15
 * 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.
 */

L
lixiaofeng_154b 已提交
16
import usbManager from '@ohos.usbManager';
J
jiyong_sd 已提交
17 18 19 20 21 22
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'

/* usb core functions test */
export default function UsbFunctionsJsFunctionsTestEx() {
describe('UsbFunctionsJsFunctionsTestEx', function () {

23 24
  var invalidCode = 0;

J
jiyong_sd 已提交
25 26
  beforeAll(function () {
    console.log('*************Usb Unit UsbFunctionsJsFunctionsTestEx Begin*************');
L
lixiaofeng_154b 已提交
27
    var Version = usbManager.getVersion()
J
jiyong_sd 已提交
28 29
    console.info('begin test getversion :' + Version)
    //  17 version host currentMode = 2 device currentMode = 1
L
lixiaofeng_154b 已提交
30
    var usbPortList = usbManager.getPorts()
J
jiyong_sd 已提交
31 32
    if (usbPortList.length > 0) {
      if (usbPortList[0].status.currentMode == 2) {
L
lixiaofeng_154b 已提交
33
        usbManager.setPortRoles(usbPortList[0].id, usbManager.SINK, usbManager.DEVICE).then(data => {
J
jiyong_sd 已提交
34 35 36 37
          console.info('usb case setPortRoles return: ' + data);
        }).catch(error => {
          console.info('usb case setPortRoles error : ' + error);
        });
38
        CheckEmptyUtils.sleep(8000)
J
jiyong_sd 已提交
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
        console.log('*************Usb Unit switch to device Begin*************');
      }
    }
  })
  beforeEach(function () {
    console.info('beforeEach: *************Usb Unit Test Case*************');
  })

  afterEach(function () {
    console.info('afterEach: *************Usb Unit Test Case*************');
  })

  afterAll(function () {
    console.log('*************Usb Unit UsbFunctionsJsFunctionsTest End*************');
  })

  /**
56 57 58
   * @tc.number: SUB_USB_JS_0930
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 0, return 'none'
J
jiyong_sd 已提交
59 60 61
   */
  it('SUB_USB_JS_0930', 0, function () {
    console.info('usb SUB_USB_JS_0930 begin');
L
lixiaofeng_154b 已提交
62 63 64
    var maskCode = usbManager.NONE
    console.info('usb case maskCode : ' + usbManager.NONE);
    var strMaskCode = usbManager.usbFunctionsToString(maskCode)
J
jiyong_sd 已提交
65
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
66
    expect(strMaskCode).assertEqual('none');
J
jiyong_sd 已提交
67 68 69 70
    console.info('usb SUB_USB_JS_0930 :  PASS');
  })

  /**
71 72 73
   * @tc.number: SUB_USB_JS_0940
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 1, return 'acm'
J
jiyong_sd 已提交
74 75 76
   */
  it('SUB_USB_JS_0940', 0, function () {
    console.info('usb SUB_USB_JS_0940 begin');
L
lixiaofeng_154b 已提交
77 78 79
    var maskCode = usbManager.ACM
    console.info('usb case maskCode : ' + usbManager.ACM);
    var strMaskCode = usbManager.usbFunctionsToString(maskCode)
J
jiyong_sd 已提交
80
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
81
    expect(strMaskCode).assertEqual('acm');
J
jiyong_sd 已提交
82 83 84 85
    console.info('usb SUB_USB_JS_0940 :  PASS');
  })

  /**
86 87 88
   * @tc.number: SUB_USB_JS_0950
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 2, return 'ecm'
J
jiyong_sd 已提交
89 90 91
   */
  it('SUB_USB_JS_0950', 0, function () {
    console.info('usb SUB_USB_JS_0950 begin');
L
lixiaofeng_154b 已提交
92
    var maskCode = usbManager.ECM
J
jiyong_sd 已提交
93
    console.info('usb case maskCode : ' + maskCode);
L
lixiaofeng_154b 已提交
94
    var strMaskCode = usbManager.usbFunctionsToString(maskCode)
J
jiyong_sd 已提交
95
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
96
    expect(strMaskCode).assertEqual('ecm');
J
jiyong_sd 已提交
97 98 99 100
    console.info('usb SUB_USB_JS_0950 :  PASS');
  })

  /**
101 102 103
   * @tc.number: SUB_USB_JS_0960
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 3, return 'acm,ecm'
J
jiyong_sd 已提交
104 105 106
   */
  it('SUB_USB_JS_0960', 0, function () {
    console.info('usb SUB_USB_JS_0960 begin');
L
lixiaofeng_154b 已提交
107
    var maskCode = usbManager.ACM | usbManager.ECM
J
jiyong_sd 已提交
108
    console.info('usb case maskCode : ' + maskCode);
L
lixiaofeng_154b 已提交
109
    var strMaskCode = usbManager.usbFunctionsToString(maskCode)
J
jiyong_sd 已提交
110
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
111
    expect(strMaskCode).assertEqual('acm,ecm');
J
jiyong_sd 已提交
112 113 114 115
    console.info('usb SUB_USB_JS_0960 :  PASS');
  })

  /**
116 117 118
   * @tc.number: SUB_USB_JS_0970
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 4, return 'hdc'
J
jiyong_sd 已提交
119 120 121
   */
  it('SUB_USB_JS_0970', 0, function () {
    console.info('usb SUB_USB_JS_0970 begin');
L
lixiaofeng_154b 已提交
122
    var maskCode = usbManager.HDC
J
jiyong_sd 已提交
123
    console.info('usb case maskCode : ' + maskCode);
L
lixiaofeng_154b 已提交
124
    var strMaskCode = usbManager.usbFunctionsToString(maskCode)
J
jiyong_sd 已提交
125
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
126
    expect(strMaskCode).assertEqual('hdc');
J
jiyong_sd 已提交
127 128 129 130
    console.info('usb SUB_USB_JS_0970 :  PASS');
  })

  /**
131 132 133
   * @tc.number: SUB_USB_JS_0980
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 5, return 'acm,hdc'
J
jiyong_sd 已提交
134 135 136
   */
  it('SUB_USB_JS_0980', 0, function () {
    console.info('usb SUB_USB_JS_0980 begin');
L
lixiaofeng_154b 已提交
137
    var maskCode = usbManager.ACM | usbManager.HDC
J
jiyong_sd 已提交
138
    console.info('usb case maskCode : ' + maskCode);
L
lixiaofeng_154b 已提交
139
    var strMaskCode = usbManager.usbFunctionsToString(maskCode)
J
jiyong_sd 已提交
140
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
141
    expect(strMaskCode).assertEqual('acm,hdc');
J
jiyong_sd 已提交
142 143 144 145
    console.info('usb SUB_USB_JS_0980 :  PASS');
  })

  /**
146 147 148
   * @tc.number: SUB_USB_JS_0990
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 6, return 'ecm,hdc'
J
jiyong_sd 已提交
149 150 151
   */
  it('SUB_USB_JS_0990', 0, function () {
    console.info('usb SUB_USB_JS_0990 begin');
L
lixiaofeng_154b 已提交
152
    var maskCode = usbManager.ECM | usbManager.HDC
J
jiyong_sd 已提交
153
    console.info('usb case maskCode : ' + maskCode);
L
lixiaofeng_154b 已提交
154
    var strMaskCode = usbManager.usbFunctionsToString(maskCode)
J
jiyong_sd 已提交
155
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
156
    expect(strMaskCode).assertEqual('ecm,hdc');
J
jiyong_sd 已提交
157 158 159
    console.info('usb SUB_USB_JS_0990 :  PASS');
  })

L
lixiaofeng_154b 已提交
160 161 162 163 164 165 166
  /**
   * @tc.number: SUB_USB_JS_1770
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 8, return 'mtp'
   */
  it('SUB_USB_JS_1770', 0, function () {
    console.info('usb SUB_USB_JS_1770 begin');
L
lixiaofeng_154b 已提交
167
    var maskCode = usbManager.MTP;
L
lixiaofeng_154b 已提交
168
    console.info('usb case maskCode : ' + maskCode);
L
lixiaofeng_154b 已提交
169
    var strMaskCode = usbManager.usbFunctionsToString(maskCode);
L
lixiaofeng_154b 已提交
170 171 172 173 174 175 176 177 178 179 180 181
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
    expect(strMaskCode).assertEqual('mtp');
    console.info('usb SUB_USB_JS_1770 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1780
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 12, return 'hdc,mtp'
   */
  it('SUB_USB_JS_1780', 0, function () {
    console.info('usb SUB_USB_JS_1780 begin');
L
lixiaofeng_154b 已提交
182
    var maskCode = usbManager.MTP | usbManager.HDC;
L
lixiaofeng_154b 已提交
183
    console.info('usb case maskCode : ' + maskCode);
L
lixiaofeng_154b 已提交
184
    var strMaskCode = usbManager.usbFunctionsToString(maskCode);
L
lixiaofeng_154b 已提交
185 186 187 188 189 190 191 192 193 194 195 196
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
    expect(strMaskCode).assertEqual('hdc,mtp');
    console.info('usb SUB_USB_JS_1780 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1790
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 16, return 'ptp'
   */
  it('SUB_USB_JS_1790', 0, function () {
    console.info('usb SUB_USB_JS_1790 begin');
L
lixiaofeng_154b 已提交
197
    var maskCode = usbManager.PTP;
L
lixiaofeng_154b 已提交
198
    console.info('usb case maskCode : ' + maskCode);
L
lixiaofeng_154b 已提交
199
    var strMaskCode = usbManager.usbFunctionsToString(maskCode);
L
lixiaofeng_154b 已提交
200 201 202 203 204 205 206 207 208 209 210 211
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
    expect(strMaskCode).assertEqual('ptp');
    console.info('usb SUB_USB_JS_1790 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1800
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 20, return 'hdc,ptp'
   */
  it('SUB_USB_JS_1800', 0, function () {
    console.info('usb SUB_USB_JS_1800 begin');
L
lixiaofeng_154b 已提交
212
    var maskCode = usbManager.PTP | usbManager.HDC;
L
lixiaofeng_154b 已提交
213
    console.info('usb case maskCode : ' + maskCode);
L
lixiaofeng_154b 已提交
214
    var strMaskCode = usbManager.usbFunctionsToString(maskCode);
L
lixiaofeng_154b 已提交
215 216 217 218 219 220 221 222 223 224 225 226
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
    expect(strMaskCode).assertEqual('hdc,ptp');
    console.info('usb SUB_USB_JS_1800 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1810
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 32, return 'rndis'
   */
  it('SUB_USB_JS_1810', 0, function () {
    console.info('usb SUB_USB_JS_1810 begin');
L
lixiaofeng_154b 已提交
227
    var maskCode = usbManager.RNDIS;
L
lixiaofeng_154b 已提交
228
    console.info('usb case maskCode : ' + maskCode);
L
lixiaofeng_154b 已提交
229
    var strMaskCode = usbManager.usbFunctionsToString(maskCode);
L
lixiaofeng_154b 已提交
230 231 232 233 234 235 236 237 238 239 240 241
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
    expect(strMaskCode).assertEqual('rndis');
    console.info('usb SUB_USB_JS_1810 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1820
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 36, return 'hdc,rndis'
   */
  it('SUB_USB_JS_1820', 0, function () {
    console.info('usb SUB_USB_JS_1820 begin');
L
lixiaofeng_154b 已提交
242
    var maskCode = usbManager.RNDIS | usbManager.HDC;
L
lixiaofeng_154b 已提交
243
    console.info('usb case maskCode : ' + maskCode);
L
lixiaofeng_154b 已提交
244
    var strMaskCode = usbManager.usbFunctionsToString(maskCode);
L
lixiaofeng_154b 已提交
245 246 247 248 249 250 251 252 253 254 255 256
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
    expect(strMaskCode).assertEqual('hdc,rndis');
    console.info('usb SUB_USB_JS_1820 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1830
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 512, return 'storage'
   */
  it('SUB_USB_JS_1830', 0, function () {
    console.info('usb SUB_USB_JS_1830 begin');
L
lixiaofeng_154b 已提交
257
    var maskCode = usbManager.STORAGE;
L
lixiaofeng_154b 已提交
258
    console.info('usb case maskCode : ' + maskCode);
L
lixiaofeng_154b 已提交
259
    var strMaskCode = usbManager.usbFunctionsToString(maskCode);
L
lixiaofeng_154b 已提交
260 261 262 263 264 265 266 267 268 269 270 271
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
    expect(strMaskCode).assertEqual('storage');
    console.info('usb SUB_USB_JS_1830 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1840
   * @tc.name: usbFunctionsToString
   * @tc.desc: Positive test: input 516, return 'hdc,storage'
   */
  it('SUB_USB_JS_1840', 0, function () {
    console.info('usb SUB_USB_JS_1840 begin');
L
lixiaofeng_154b 已提交
272
    var maskCode = usbManager.STORAGE | usbManager.HDC;
L
lixiaofeng_154b 已提交
273
    console.info('usb case maskCode : ' + maskCode);
L
lixiaofeng_154b 已提交
274
    var strMaskCode = usbManager.usbFunctionsToString(maskCode);
L
lixiaofeng_154b 已提交
275 276 277 278 279
    console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode);
    expect(strMaskCode).assertEqual('hdc,storage');
    console.info('usb SUB_USB_JS_1840 :  PASS');
  })

280
  /**
281 282 283
   * @tc.number: SUB_USB_JS_1160
   * @tc.name: usbFunctionsToString
   * @tc.desc: Negative test: Mask converted to description character, parameter type error
284
   */
285
  it('SUB_USB_JS_1160', 0, function () {
286 287
    console.info('usb SUB_USB_JS_1160 begin');
    try {
L
lixiaofeng_154b 已提交
288
      var maskCode = usbManager.usbFunctionsToString("invalid");
289
      console.info('usb 1160 case usbFunctionsToString return: ' + maskCode);
290 291
      expect(false).assertTrue();
    } catch (err) {
292
      console.info('usb 1160 catch err code: ' + err.code + ' message: ' + err.message);
293 294 295 296 297
      expect(err.code).assertEqual(401);
      console.info('usb SUB_USB_JS_1160 :  PASS');
    }
  })

298
  /**
299 300 301 302
   * @tc.number: SUB_USB_JS_1360
   * @tc.name: usbFunctionsToString
   * @tc.desc: Negative test: Mask converted to description character,
   * parameter number exception, necessary parameters not input
303
   */
304
  it('SUB_USB_JS_1360', 0, function () {
305 306
    console.info('usb SUB_USB_JS_1360 begin');
    try {
L
lixiaofeng_154b 已提交
307
      var maskCode = usbManager.usbFunctionsToString();
308 309 310 311 312 313 314 315 316
      console.info('usb 1360 case usbFunctionsToString return: ' + maskCode);
      expect(false).assertTrue();
    } catch (err) {
      console.info('usb 1360 catch err code: ' + err.code + ' message: ' + err.message);
      expect(err.code).assertEqual(401);
      console.info('usb SUB_USB_JS_1360 :  PASS');
    }
  })

J
jiyong_sd 已提交
317
  /**
318 319 320
   * @tc.number: SUB_USB_JS_0860
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'none', return 0
J
jiyong_sd 已提交
321 322 323 324
   */
  it('SUB_USB_JS_0860', 0, function () {
    console.info('usb SUB_USB_JS_0860 begin');
    var strMaskCode = 'none'
L
lixiaofeng_154b 已提交
325
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
J
jiyong_sd 已提交
326
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
327
    expect(nMaskCode).assertEqual(usbManager.NONE);
J
jiyong_sd 已提交
328 329 330 331
    console.info('usb SUB_USB_JS_0860 :  PASS');
  })

  /**
332 333 334
   * @tc.number: SUB_USB_JS_0870
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'acm', return 1
J
jiyong_sd 已提交
335 336 337 338
   */
  it('SUB_USB_JS_0870', 0, function () {
    console.info('usb SUB_USB_JS_0870 begin');
    var strMaskCode = 'acm'
L
lixiaofeng_154b 已提交
339
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
J
jiyong_sd 已提交
340
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
341
    expect(nMaskCode).assertEqual(usbManager.ACM);
J
jiyong_sd 已提交
342 343 344 345
    console.info('usb SUB_USB_JS_0870 :  PASS');
  })

  /**
346 347 348
   * @tc.number: SUB_USB_JS_0880
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'ecm', return 2
J
jiyong_sd 已提交
349 350 351 352
   */
  it('SUB_USB_JS_0880', 0, function () {
    console.info('usb SUB_USB_JS_0880 begin');
    var strMaskCode = 'ecm'
L
lixiaofeng_154b 已提交
353
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
J
jiyong_sd 已提交
354
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
355
    expect(nMaskCode).assertEqual(usbManager.ECM);
J
jiyong_sd 已提交
356 357 358 359
    console.info('usb SUB_USB_JS_0880 :  PASS');
  })

  /**
360 361 362
   * @tc.number: SUB_USB_JS_0890
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'acm,ecm', return 3
J
jiyong_sd 已提交
363 364 365 366
   */
  it('SUB_USB_JS_0890', 0, function () {
    console.info('usb SUB_USB_JS_0890 begin');
    var strMaskCode = 'acm,ecm'
L
lixiaofeng_154b 已提交
367
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
J
jiyong_sd 已提交
368
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
369
    expect(nMaskCode).assertEqual(usbManager.ACM | usbManager.ECM);
J
jiyong_sd 已提交
370 371 372 373
    console.info('usb SUB_USB_JS_0890 :  PASS');
  })

  /**
374 375 376
   * @tc.number: SUB_USB_JS_0900
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'hdc', return 4
J
jiyong_sd 已提交
377 378 379 380
   */
  it('SUB_USB_JS_0900', 0, function () {
    console.info('usb SUB_USB_JS_0900 begin');
    var strMaskCode = 'hdc'
L
lixiaofeng_154b 已提交
381
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
J
jiyong_sd 已提交
382
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
383
    expect(nMaskCode).assertEqual(usbManager.HDC);
J
jiyong_sd 已提交
384 385 386 387
    console.info('usb SUB_USB_JS_0900 :  PASS');
  })

  /**
388 389 390
   * @tc.number: SUB_USB_JS_0910
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'acm,hdc', return 5
J
jiyong_sd 已提交
391 392 393 394
   */
  it('SUB_USB_JS_0910', 0, function () {
    console.info('usb SUB_USB_JS_0910 begin');
    var strMaskCode = 'acm,hdc'
L
lixiaofeng_154b 已提交
395
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
J
jiyong_sd 已提交
396
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
397
    expect(nMaskCode).assertEqual(usbManager.HDC | usbManager.ACM);
J
jiyong_sd 已提交
398 399 400 401
    console.info('usb SUB_USB_JS_0910 :  PASS');
  })

  /**
402 403 404
   * @tc.number: SUB_USB_JS_0920
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'ecm,hdc', return 6
J
jiyong_sd 已提交
405 406 407 408
   */
  it('SUB_USB_JS_0920', 0, function () {
    console.info('usb SUB_USB_JS_0920 begin');
    var strMaskCode = 'ecm,hdc'
L
lixiaofeng_154b 已提交
409
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
J
jiyong_sd 已提交
410
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
411
    expect(nMaskCode).assertEqual(usbManager.HDC | usbManager.ECM);
J
jiyong_sd 已提交
412 413 414
    console.info('usb SUB_USB_JS_0920 :  PASS');
  })

L
lixiaofeng_154b 已提交
415 416 417 418 419 420 421 422
  /**
   * @tc.number: SUB_USB_JS_1220
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'mtp', return 8
   */
  it('SUB_USB_JS_1220', 0, function () {
    console.info('usb SUB_USB_JS_1220 begin');
    var strMaskCode = 'mtp'
L
lixiaofeng_154b 已提交
423
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
L
lixiaofeng_154b 已提交
424
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
425
    expect(nMaskCode).assertEqual(usbManager.MTP);
L
lixiaofeng_154b 已提交
426 427 428 429 430 431 432 433 434 435 436
    console.info('usb SUB_USB_JS_1220 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1700
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'hdc,mtp', return 12
   */
  it('SUB_USB_JS_1700', 0, function () {
    console.info('usb SUB_USB_JS_1700 begin');
    var strMaskCode = 'hdc,mtp'
L
lixiaofeng_154b 已提交
437
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
L
lixiaofeng_154b 已提交
438
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
439
    expect(nMaskCode).assertEqual(usbManager.MTP | usbManager.HDC);
L
lixiaofeng_154b 已提交
440 441 442 443 444 445 446 447 448 449 450
    console.info('usb SUB_USB_JS_1700 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1710
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'ptp', return 16
   */
  it('SUB_USB_JS_1710', 0, function () {
    console.info('usb SUB_USB_JS_1710 begin');
    var strMaskCode = 'ptp'
L
lixiaofeng_154b 已提交
451
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
L
lixiaofeng_154b 已提交
452
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
453
    expect(nMaskCode).assertEqual(usbManager.PTP);
L
lixiaofeng_154b 已提交
454 455 456 457 458 459 460 461 462 463 464
    console.info('usb SUB_USB_JS_1710 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1720
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'hdc,ptp', return 20
   */
  it('SUB_USB_JS_1720', 0, function () {
    console.info('usb SUB_USB_JS_1720 begin');
    var strMaskCode = 'hdc,ptp'
L
lixiaofeng_154b 已提交
465
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
L
lixiaofeng_154b 已提交
466
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
467
    expect(nMaskCode).assertEqual(usbManager.PTP | usbManager.HDC);
L
lixiaofeng_154b 已提交
468 469 470 471 472 473 474 475 476 477 478
    console.info('usb SUB_USB_JS_1720 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1730
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'rndis', return 32
   */
  it('SUB_USB_JS_1730', 0, function () {
    console.info('usb SUB_USB_JS_1730 begin');
    var strMaskCode = 'rndis'
L
lixiaofeng_154b 已提交
479
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
L
lixiaofeng_154b 已提交
480
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
481
    expect(nMaskCode).assertEqual(usbManager.RNDIS);
L
lixiaofeng_154b 已提交
482 483 484 485 486 487 488 489 490 491 492
    console.info('usb SUB_USB_JS_1730 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1740
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'hdc,rndis', return 36
   */
  it('SUB_USB_JS_1740', 0, function () {
    console.info('usb SUB_USB_JS_1740 begin');
    var strMaskCode = 'hdc,rndis'
L
lixiaofeng_154b 已提交
493
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
L
lixiaofeng_154b 已提交
494
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
495
    expect(nMaskCode).assertEqual(usbManager.RNDIS | usbManager.HDC);
L
lixiaofeng_154b 已提交
496 497 498 499 500 501 502 503 504 505 506
    console.info('usb SUB_USB_JS_1740 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1750
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'storage', return 512
   */
  it('SUB_USB_JS_1750', 0, function () {
    console.info('usb SUB_USB_JS_1750 begin');
    var strMaskCode = 'storage'
L
lixiaofeng_154b 已提交
507
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
L
lixiaofeng_154b 已提交
508
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
509
    expect(nMaskCode).assertEqual(usbManager.STORAGE);
L
lixiaofeng_154b 已提交
510 511 512 513 514 515 516 517 518 519 520
    console.info('usb SUB_USB_JS_1750 :  PASS');
  })

  /**
   * @tc.number: SUB_USB_JS_1760
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Positive test: input 'hdc,storage', return 516
   */
  it('SUB_USB_JS_1760', 0, function () {
    console.info('usb SUB_USB_JS_1760 begin');
    var strMaskCode = 'hdc,storage'
L
lixiaofeng_154b 已提交
521
    var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
L
lixiaofeng_154b 已提交
522
    console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
L
lixiaofeng_154b 已提交
523
    expect(nMaskCode).assertEqual(usbManager.STORAGE | usbManager.HDC);
L
lixiaofeng_154b 已提交
524 525 526
    console.info('usb SUB_USB_JS_1760 :  PASS');
  })

527
  /**
528 529 530
   * @tc.number: SUB_USB_JS_1170
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Negative test: Description character converted to mask, parameter type error
531
   */
532
  it('SUB_USB_JS_1170', 0, function () {
533 534
    console.info('usb SUB_USB_JS_1170 begin');
    try {
L
lixiaofeng_154b 已提交
535
      var maskCode = usbManager.usbFunctionsFromString(invalidCode);
536
      console.info('usb 1170 case usbFunctionsFromString return: ' + maskCode);
537 538
      expect(false).assertTrue();
    } catch (err) {
539
      console.info('usb 1170 catch err code: ' + err.code + ' message: ' + err.message);
540 541 542 543
      expect(err.code).assertEqual(401);
      console.info('usb SUB_USB_JS_1170 :  PASS');
    }
  })
544 545

  /**
546 547 548 549
   * @tc.number: SUB_USB_JS_1370
   * @tc.name: usbFunctionsFromString
   * @tc.desc: Negative test: Description character converted to mask,
   * parameter number exception, necessary parameters not input
550
   */
551
  it('SUB_USB_JS_1370', 0, function () {
552 553
    console.info('usb SUB_USB_JS_1370 begin');
    try {
L
lixiaofeng_154b 已提交
554
      var maskCode = usbManager.usbFunctionsFromString();
555 556 557 558 559 560 561 562
      console.info('usb 1370 case usbFunctionsFromString return: ' + maskCode);
      expect(false).assertTrue();
    } catch (err) {
      console.info('usb 1370 catch err code: ' + err.code + ' message: ' + err.message);
      expect(err.code).assertEqual(401);
      console.info('usb SUB_USB_JS_1370 :  PASS');
    }
  })
J
jiyong_sd 已提交
563 564
})
}