1 Star 0 Fork 149

梁琦/usb_usb_manager

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
UsbManagerParamExJsTest 67.82 KB
一键复制 编辑 原始数据 按行查看 历史
luzhiye 提交于 2024-10-31 03:18 . 补充js用例
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685
/*
* 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
*/
it('testConnectDeviceParamEx026', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx026 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devBusNum = devices.busNum + 1000;
devices.busNum = devBusNum;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.busNum, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(gPipe !== null).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx026 catch err code: ', err.code, ', message: ', err.message);
expect(err.code).assertEqual(14400001);
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_3500
* @tc.name : testConnectDeviceParamEx027
* @tc.desc : Negative test: devices devAddress is add number 10000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testConnectDeviceParamEx027', 0, function () {
console.info(TAG, 'usb testConnectDeviceParamEx027 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
try {
let devDevAddress = devices.devAddress + 1000;
devices.devAddress = devDevAddress;
let gPipe = usbManager.connectDevice(devices);
console.info(TAG, 'usb [', devices.devAddress, '] connectDevice ret : ', JSON.stringify(gPipe));
expect(gPipe !== null).assertFalse();
} catch (err) {
console.info(TAG, 'testConnectDeviceParamEx027 catch err code: ', err.code, ', message: ', err.message);
expect(err.code).assertEqual(14400001);
}
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_3600
* @tc.name : testClosePipeParamEx001
* @tc.desc : Negative test: pipe busNum add number 1000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testClosePipeParamEx001', 0, function () {
console.info(TAG, 'usb testClosePipeParamEx001 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testClosePipeParamEx001");
try {
gPipe.busNum = gPipe.busNum + 1000;
let ret = usbManager.closePipe(gPipe);
console.info(TAG, 'usb [', gPipe.busNum, '] closePipe ret : ', ret);
expect(ret !== 0).assertTrue();
} catch (err) {
console.info(TAG, 'testClosePipeParamEx001 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testClosePipeParamEx001");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_3700
* @tc.name : testClosePipeParamEx002
* @tc.desc : Negative test: pipe devAddress add number 10000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testClosePipeParamEx002', 0, function () {
console.info(TAG, 'usb testClosePipeParamEx002 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testClosePipeParamEx002");
try {
let pipDevAdd = gPipe.devAddress + 10000;
gPipe.devAddress = pipDevAdd;
let ret = usbManager.closePipe(gPipe);
console.info(TAG, 'usb [', gPipe.devAddress, '] closePipe ret : ', ret);
expect(ret !== 0).assertTrue();
} catch (err) {
console.info(TAG, 'testClosePipeParamEx002 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testClosePipeParamEx002");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_3800
* @tc.name : testGetRawDescriptorParamEx001
* @tc.desc : Negative test: pipe busNum add number 1000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testGetRawDescriptorParamEx001', 0, function () {
console.info(TAG, 'usb testGetRawDescriptorParamEx001 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testGetRawDescriptorParamEx001");
try {
let pipBusNum = gPipe.busNum + 1000;
gPipe.busNum = pipBusNum;
let ret = usbManager.getRawDescriptor(gPipe);
console.info(TAG, 'usb [', gPipe.busNum, '] getRawDescriptor ret : ', ret);
expect(ret).assertEqual(undefined);
} catch (err) {
console.info(TAG, 'testGetRawDescriptorParamEx001 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testGetRawDescriptorParamEx001");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_3900
* @tc.name : testGetRawDescriptorParamEx002
* @tc.desc : Negative test: pipe devAddress add number 10000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testGetRawDescriptorParamEx002', 0, function () {
console.info(TAG, 'usb testGetRawDescriptorParamEx002 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testGetRawDescriptorParamEx002");
try {
let pipDevAdd = gPipe.devAddress + 10000;
gPipe.devAddress = pipDevAdd;
let ret = usbManager.getRawDescriptor(gPipe);
console.info(TAG, 'usb [', gPipe.devAddress, '] getRawDescriptor ret : ', ret);
expect(ret).assertEqual(undefined);
} catch (err) {
console.info(TAG, 'testGetRawDescriptorParamEx002 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testGetRawDescriptorParamEx002");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_4000
* @tc.name : testGetRawDescriptorParamEx003
* @tc.desc : Negative test: pipe busNum -23
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testGetRawDescriptorParamEx003', 0, function () {
console.info(TAG, 'usb testGetRawDescriptorParamEx003 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testGetRawDescriptorParamEx003");
try {
gPipe.busNum = -23;
let ret = usbManager.getRawDescriptor(gPipe);
console.info(TAG, 'usb [', gPipe.busNum, '] getRawDescriptor ret : ', ret);
expect(ret).assertEqual(undefined);
} catch (err) {
console.info(TAG, 'testGetRawDescriptorParamEx003 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testGetRawDescriptorParamEx003");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_4100
* @tc.name : testGetRawDescriptorParamEx004
* @tc.desc : Negative test: pipe devAddress -23
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testGetRawDescriptorParamEx004', 0, function () {
console.info(TAG, 'usb testGetRawDescriptorParamEx004 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testGetRawDescriptorParamEx004");
try {
gPipe.devAddress = -23;
let ret = usbManager.getRawDescriptor(gPipe);
console.info(TAG, 'usb [', gPipe.devAddress, '] getRawDescriptor ret : ', ret);
expect(ret).assertEqual(undefined);
} catch (err) {
console.info(TAG, 'testGetRawDescriptorParamEx004 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testGetRawDescriptorParamEx004");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_4200
* @tc.name : testGetRawDescriptorParamEx005
* @tc.desc : Negative test: pipe busNum -23, devAddress -23
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testGetRawDescriptorParamEx005', 0, function () {
console.info(TAG, 'usb testGetRawDescriptorParamEx005 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testGetRawDescriptorParamEx005");
try {
gPipe.busNum = -23;
gPipe.devAddress = -23;
let ret = usbManager.getRawDescriptor(gPipe);
console.info(TAG, 'usb [', gPipe.devAddress, '] getRawDescriptor ret : ', ret);
expect(ret).assertEqual(undefined);
} catch (err) {
console.info(TAG, 'testGetRawDescriptorParamEx005 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testGetRawDescriptorParamEx005");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_4300
* @tc.name : testGetFileDescriptorParamEx001
* @tc.desc : Negative test: pipe busNum add number 1000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testGetFileDescriptorParamEx001', 0, function () {
console.info(TAG, 'usb testGetFileDescriptorParamEx001 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testGetFileDescriptorParamEx001");
try {
let pipBusNum = gPipe.busNum + 1000;
gPipe.busNum = pipBusNum;
let ret = usbManager.getFileDescriptor(gPipe);
console.info(TAG, 'usb [', gPipe.busNum, '] getFileDescriptor ret : ', ret);
expect(ret).assertEqual(-1);
} catch (err) {
console.info(TAG, 'testGetFileDescriptorParamEx001 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testGetFileDescriptorParamEx001");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_4400
* @tc.name : testGetFileDescriptorParamEx002
* @tc.desc : Negative test: pipe devAddress add number 10000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testGetFileDescriptorParamEx002', 0, function () {
console.info(TAG, 'usb testGetFileDescriptorParamEx002 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testGetFileDescriptorParamEx002");
try {
let pipDevAdd = gPipe.devAddress + 10000;
gPipe.devAddress = pipDevAdd;
let ret = usbManager.getFileDescriptor(gPipe);
console.info(TAG, 'usb [', gPipe.devAddress, '] getFileDescriptor ret : ', ret);
expect(ret).assertEqual(-1);
} catch (err) {
console.info(TAG, 'testGetFileDescriptorParamEx002 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testGetFileDescriptorParamEx002");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_4500
* @tc.name : testGetFileDescriptorParamEx003
* @tc.desc : Negative test: pipe busNum -23
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testGetFileDescriptorParamEx003', 0, function () {
console.info(TAG, 'usb testGetFileDescriptorParamEx003 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testGetFileDescriptorParamEx003");
try {
gPipe.busNum = -23;
let ret = usbManager.getFileDescriptor(gPipe);
console.info(TAG, 'usb [', gPipe.busNum, '] getFileDescriptor ret : ', ret);
expect(ret).assertEqual(-1);
} catch (err) {
console.info(TAG, 'testGetFileDescriptorParamEx003 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testGetFileDescriptorParamEx003");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_4600
* @tc.name : testGetFileDescriptorParamEx004
* @tc.desc : Negative test: pipe devAddress -23
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testGetFileDescriptorParamEx004', 0, function () {
console.info(TAG, 'usb testGetFileDescriptorParamEx004 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testGetFileDescriptorParamEx004");
try {
gPipe.devAddress = -23;
let ret = usbManager.getFileDescriptor(gPipe);
console.info(TAG, 'usb [', gPipe.devAddress, '] getFileDescriptor ret : ', ret);
expect(ret).assertEqual(-1);
} catch (err) {
console.info(TAG, 'testGetFileDescriptorParamEx004 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testGetFileDescriptorParamEx004");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_4700
* @tc.name : testGetFileDescriptorParamEx005
* @tc.desc : Negative test: pipe busNum -23, devAddress -23
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testGetFileDescriptorParamEx005', 0, function () {
console.info(TAG, 'usb testGetFileDescriptorParamEx005 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testGetFileDescriptorParamEx005");
try {
gPipe.busNum = -23;
gPipe.devAddress = -23;
let ret = usbManager.getFileDescriptor(gPipe);
console.info(TAG, 'usb [', gPipe.devAddress, '] getFileDescriptor ret : ', ret);
expect(ret).assertEqual(-1);
} catch (err) {
console.info(TAG, 'testGetFileDescriptorParamEx005 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testGetFileDescriptorParamEx005");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_4800
* @tc.name : testClaimInterfaceParamEx001
* @tc.desc : Negative test: interfaces id add 123
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testClaimInterfaceParamEx001', 0, function () {
console.info(TAG, 'usb testClaimInterfaceParamEx001 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testClaimInterfaceParamEx001");
try {
let tmpInterface = devices.configs[0].interfaces[0];
tmpInterface.id = tmpInterface.id + 123;
let ret = usbManager.claimInterface(gPipe, tmpInterface);
console.info(TAG, 'usb [', tmpInterface.id, '] claimInterface ret : ', ret);
expect(ret !== 0).assertTrue();
} catch (err) {
console.info(TAG, 'testClaimInterfaceParamEx001 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testClaimInterfaceParamEx001");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_4900
* @tc.name : testClaimInterfaceParamEx002
* @tc.desc : Negative test: interfaces id -1
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testClaimInterfaceParamEx002', 0, function () {
console.info(TAG, 'usb testClaimInterfaceParamEx002 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testClaimInterfaceParamEx002");
try {
let tmpInterface = devices.configs[0].interfaces[0];
tmpInterface.id = -1;
let ret = usbManager.claimInterface(gPipe, tmpInterface);
console.info(TAG, 'usb [', tmpInterface.id, '] claimInterface ret : ', ret);
expect(ret !== 0).assertTrue();
} catch (err) {
console.info(TAG, 'testClaimInterfaceParamEx002 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testClaimInterfaceParamEx002");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_5000
* @tc.name : testClaimInterfaceParamEx003
* @tc.desc : Negative test: pipe busNum add 1000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testClaimInterfaceParamEx003', 0, function () {
console.info(TAG, 'usb testClaimInterfaceParamEx003 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testClaimInterfaceParamEx003");
try {
gPipe.busNum = gPipe.busNum + 1000;
let tmpInterface = devices.configs[0].interfaces[0];
let ret = usbManager.claimInterface(gPipe, tmpInterface);
console.info(TAG, 'usb [', gPipe.busNum, '] claimInterface ret : ', ret);
expect(ret !== 0).assertTrue();
} catch (err) {
console.info(TAG, 'testClaimInterfaceParamEx003 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testClaimInterfaceParamEx003");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_5100
* @tc.name : testClaimInterfaceParamEx004
* @tc.desc : Negative test: pipe busNum -1
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testClaimInterfaceParamEx004', 0, function () {
console.info(TAG, 'usb testClaimInterfaceParamEx004 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testClaimInterfaceParamEx004");
try {
gPipe.busNum = -1;
let tmpInterface = devices.configs[0].interfaces[0];
let ret = usbManager.claimInterface(gPipe, tmpInterface);
console.info(TAG, 'usb [', gPipe.busNum, '] claimInterface ret : ', ret);
expect(ret !== 0).assertTrue();
} catch (err) {
console.info(TAG, 'testClaimInterfaceParamEx004 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testClaimInterfaceParamEx004");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_5200
* @tc.name : testClaimInterfaceParamEx005
* @tc.desc : Negative test: pipe devAddress add 10000
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testClaimInterfaceParamEx005', 0, function () {
console.info(TAG, 'usb testClaimInterfaceParamEx005 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testClaimInterfaceParamEx005");
try {
gPipe.devAddress = gPipe.devAddress + 10000;
let tmpInterface = devices.configs[0].interfaces[0];
let ret = usbManager.claimInterface(gPipe, tmpInterface);
console.info(TAG, 'usb [', gPipe.devAddress, '] claimInterface ret : ', ret);
expect(ret !== 0).assertTrue();
} catch (err) {
console.info(TAG, 'testClaimInterfaceParamEx005 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testClaimInterfaceParamEx005");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_5300
* @tc.name : testClaimInterfaceParamEx006
* @tc.desc : Negative test: pipe devAddress -1
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testClaimInterfaceParamEx006', 0, function () {
console.info(TAG, 'usb testClaimInterfaceParamEx006 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testClaimInterfaceParamEx006");
try {
gPipe.devAddress = -1;
let tmpInterface = devices.configs[0].interfaces[0];
let ret = usbManager.claimInterface(gPipe, tmpInterface);
console.info(TAG, 'usb [', gPipe.devAddress, '] claimInterface ret : ', ret);
expect(ret !== 0).assertTrue();
} catch (err) {
console.info(TAG, 'testClaimInterfaceParamEx006 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testClaimInterfaceParamEx006");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_5400
* @tc.name : testClaimInterfaceParamEx007
* @tc.desc : Negative test: pipe devAddress -1, busNum -1
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testClaimInterfaceParamEx007', 0, function () {
console.info(TAG, 'usb testClaimInterfaceParamEx007 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testClaimInterfaceParamEx007");
try {
gPipe.busNum = -1;
gPipe.devAddress = -1;
let tmpInterface = devices.configs[0].interfaces[0];
let ret = usbManager.claimInterface(gPipe, tmpInterface);
console.info(TAG, 'usb [', gPipe.busNum , ", ",gPipe.devAddress, '] claimInterface ret : ', ret);
expect(ret !== 0).assertTrue();
} catch (err) {
console.info(TAG, 'testClaimInterfaceParamEx007 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testClaimInterfaceParamEx007");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_5500
* @tc.name : testClaimInterfaceParamEx008
* @tc.desc : Negative test: interfaces protocol add 100
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testClaimInterfaceParamEx008', 0, function () {
console.info(TAG, 'usb testClaimInterfaceParamEx008 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testClaimInterfaceParamEx008");
try {
let tmpInterface = devices.configs[0].interfaces[0];
tmpInterface.protocol = tmpInterface.protocol + 100;
let ret = usbManager.claimInterface(gPipe, tmpInterface);
console.info(TAG, 'usb [', tmpInterface.protocol, '] claimInterface ret : ', ret);
expect(ret).assertEqual(0);
} catch (err) {
console.info(TAG, 'testClaimInterfaceParamEx008 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testClaimInterfaceParamEx008");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_5600
* @tc.name : testClaimInterfaceParamEx009
* @tc.desc : Negative test: interfaces clazz add 100
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testClaimInterfaceParamEx009', 0, function () {
console.info(TAG, 'usb testClaimInterfaceParamEx009 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testClaimInterfaceParamEx009");
try {
let tmpInterface = devices.configs[0].interfaces[0];
tmpInterface.clazz = tmpInterface.clazz + 100;
let ret = usbManager.claimInterface(gPipe, tmpInterface);
console.info(TAG, 'usb [', tmpInterface.clazz, '] claimInterface ret : ', ret);
expect(ret).assertEqual(0);
} catch (err) {
console.info(TAG, 'testClaimInterfaceParamEx009 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testClaimInterfaceParamEx009");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_5700
* @tc.name : testClaimInterfaceParamEx010
* @tc.desc : Negative test: interfaces name add 123
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testClaimInterfaceParamEx010', 0, function () {
console.info(TAG, 'usb testClaimInterfaceParamEx010 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testClaimInterfaceParamEx010");
try {
let tmpInterface = devices.configs[0].interfaces[0];
tmpInterface.name = tmpInterface.name + '123';
let ret = usbManager.claimInterface(gPipe, tmpInterface);
console.info(TAG, 'usb [', tmpInterface.name, '] claimInterface ret : ', ret);
expect(ret).assertEqual(0);
} catch (err) {
console.info(TAG, 'testClaimInterfaceParamEx010 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testClaimInterfaceParamEx010");
})
/**
* @tc.number : SUB_USB_HostManager_JS_ParamEx_5800
* @tc.name : testClaimInterfaceParamEx011
* @tc.desc : Negative test: interfaces name add @#
* @tc.size : MediumTest
* @tc.type : Function
* @tc.level : Level 3
*/
it('testClaimInterfaceParamEx011', 0, function () {
console.info(TAG, 'usb testClaimInterfaceParamEx011 begin');
if (!isDeviceConnected) {
expect(isDeviceConnected).assertFalse();
return
}
getPipe("testClaimInterfaceParamEx011");
try {
let tmpInterface = devices.configs[0].interfaces[0];
tmpInterface.name = tmpInterface.name + '@#';
let ret = usbManager.claimInterface(gPipe, tmpInterface);
console.info(TAG, 'usb [', tmpInterface.name, '] claimInterface ret : ', ret);
expect(ret).assertEqual(0);
} catch (err) {
console.info(TAG, 'testClaimInterfaceParamEx011 catch err code: ', err);
expect(err !== null).assertFalse();
}
toClosePipe("testClaimInterfaceParamEx011");
})
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/liangqi28/usb_usb_manager.git
[email protected]:liangqi28/usb_usb_manager.git
liangqi28
usb_usb_manager
usb_usb_manager
master

搜索帮助