提交 63644496 编写于 作者: L lixiaofeng_154b

feat: Add the js api error code case

Signed-off-by: Nlixiaofeng_154b <lixiaofeng54@huawei.com>
Change-Id: Icf0da1379c4edb7baf2b0d68f11e06663bb421bd
上级 74342a9d
...@@ -459,7 +459,7 @@ describe('UsbCoreJsFunctionsTest', function () { ...@@ -459,7 +459,7 @@ describe('UsbCoreJsFunctionsTest', function () {
/** /**
* @tc.number : SUB_USB_JS_1070 * @tc.number : SUB_USB_JS_1070
* @tc.name : getFileDescriptor * @tc.name : getFileDescriptor
* @tc.desc : 反向测试 关闭设备 传入错误参数 * @tc.desc : 反向测试 获取文件描述符 参数类型错误
*/ */
it('SUB_USB_JS_1070', 0, function () { it('SUB_USB_JS_1070', 0, function () {
console.info('usb SUB_USB_JS_1070 begin'); console.info('usb SUB_USB_JS_1070 begin');
...@@ -476,13 +476,42 @@ describe('UsbCoreJsFunctionsTest', function () { ...@@ -476,13 +476,42 @@ describe('UsbCoreJsFunctionsTest', function () {
gPipe = usb.connectDevice(gDeviceList[0]) gPipe = usb.connectDevice(gDeviceList[0])
try { try {
var maskCode = usb.getFileDescriptor("invalid"); var maskCode = usb.getFileDescriptor("invalid");
console.info('usb case getFileDescriptor return: ' + maskCode); console.info('usb 1070 case getFileDescriptor return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1070 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1070 : PASS'); console.info('usb SUB_USB_JS_1070 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1230
* @tc.name : getFileDescriptor
* @tc.desc : 反向测试 获取文件描述符 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1230', 0, function () {
console.info('usb SUB_USB_JS_1230 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null')
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
try {
var maskCode = usb.getFileDescriptor();
console.info('usb 1230 case getFileDescriptor return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1230 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1230 : PASS');
}
})
}) })
} }
...@@ -578,7 +578,7 @@ describe('UsbCoreJsFunctionsTestEx', function () { ...@@ -578,7 +578,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
/** /**
* @tc.number : SUB_USB_JS_1040 * @tc.number : SUB_USB_JS_1040
* @tc.name : connectDevice * @tc.name : connectDevice
* @tc.desc : 反向测试 请求权限 参数类型错误 * @tc.desc : 反向测试 打开设备 参数类型错误
*/ */
it('SUB_USB_JS_1040', 0, function () { it('SUB_USB_JS_1040', 0, function () {
console.info('usb SUB_USB_JS_1040 begin'); console.info('usb SUB_USB_JS_1040 begin');
...@@ -603,15 +603,86 @@ describe('UsbCoreJsFunctionsTestEx', function () { ...@@ -603,15 +603,86 @@ describe('UsbCoreJsFunctionsTestEx', function () {
} }
try { try {
var maskCode = usb.connectDevice("invalid"); var maskCode = usb.connectDevice("invalid");
console.info('usb case connectDevice return: ' + maskCode); console.info('usb 1040 case connectDevice return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1040 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1040 : PASS'); console.info('usb SUB_USB_JS_1040 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1240
* @tc.name : connectDevice
* @tc.desc : 反向测试 打开设备 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1240', 0, function () {
console.info('usb SUB_USB_JS_1240 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null')
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
console.info('usb 1240 requestRight hasRight:' + hasRight);
}).catch(error => {
console.info('usb 1240 requestRight error:' + error);
});
CheckEmptyUtils.sleep(5000)
}
try {
var maskCode = usb.connectDevice();
console.info('usb 1240 case connectDevice return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1240 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1240 : PASS');
}
})
/**
* @tc.number : SUB_USB_JS_1220
* @tc.name : connectDevice
* @tc.desc : 反向测试 打开设备 未授权
*/
it('SUB_USB_JS_1220', 0, function () {
console.info('usb SUB_USB_JS_1220 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null')
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
if (isRight) {
var remRight = usb.removeRight(gDeviceList[0].name);
console.info('usb 1220 removeRight remRight:' + remRight);
}
try {
var maskCode = usb.connectDevice(gDeviceList[0]);
console.info('usb 1220 case connectDevice return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1220 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(14400001);
console.info('usb SUB_USB_JS_1220 : PASS');
usb.requestRight(gDeviceList[0].name);
}
})
/** /**
* @tc.number : SUB_USB_JS_0720 * @tc.number : SUB_USB_JS_0720
* @tc.name : hasRight * @tc.name : hasRight
...@@ -691,15 +762,43 @@ describe('UsbCoreJsFunctionsTestEx', function () { ...@@ -691,15 +762,43 @@ describe('UsbCoreJsFunctionsTestEx', function () {
} }
try { try {
var maskCode = usb.hasRight(invalidCode); var maskCode = usb.hasRight(invalidCode);
console.info('usb case hasRight return: ' + maskCode); console.info('usb 1020 case hasRight return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1020 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1020 : PASS'); console.info('usb SUB_USB_JS_1020 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1250
* @tc.name : hasRight
* @tc.desc : 反向测试 权限查询 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1250', 0, function () {
console.info('usb SUB_USB_JS_1250 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null')
expect(false).assertTrue();
return
}
try {
var maskCode = usb.hasRight();
console.info('usb 1250 case hasRight return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1250 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1250 : PASS');
}
})
/** /**
* @tc.number : SUB_USB_JS_0690 * @tc.number : SUB_USB_JS_0690
* @tc.name : requestRight * @tc.name : requestRight
...@@ -785,20 +884,49 @@ describe('UsbCoreJsFunctionsTestEx', function () { ...@@ -785,20 +884,49 @@ describe('UsbCoreJsFunctionsTestEx', function () {
} }
try { try {
var maskCode = usb.requestRight(invalidCode); var maskCode = usb.requestRight(invalidCode);
console.info('usb case requestRight return: ' + maskCode); console.info('usb 1030 case requestRight return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1030 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1030 : PASS'); console.info('usb SUB_USB_JS_1030 : PASS');
} }
CheckEmptyUtils.sleep(5000); CheckEmptyUtils.sleep(5000);
}) })
/**
* @tc.number : SUB_USB_JS_1260
* @tc.name : requestRight
* @tc.desc : 反向测试 请求权限 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1260', 0, function () {
console.info('usb SUB_USB_JS_1260 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null')
expect(false).assertTrue();
return
}
try {
var maskCode = usb.requestRight();
console.info('usb 1260 case requestRight return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1260 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1260 : PASS');
}
CheckEmptyUtils.sleep(5000);
})
/** /**
* @tc.number : SUB_USB_JS_1010 * @tc.number : SUB_USB_JS_1010
* @tc.name : getDevices * @tc.name : getDevices
* @tc.desc : 反向测试 获取设备列表 参数类型错误 * @tc.desc : 反向测试 获取设备列表 入参错误(无参接口传参)
*/ */
it('SUB_USB_JS_1010', 0, function () { it('SUB_USB_JS_1010', 0, function () {
console.info('usb SUB_USB_JS_1010 begin'); console.info('usb SUB_USB_JS_1010 begin');
...@@ -809,10 +937,10 @@ describe('UsbCoreJsFunctionsTestEx', function () { ...@@ -809,10 +937,10 @@ describe('UsbCoreJsFunctionsTestEx', function () {
} }
try { try {
var maskCode = usb.getDevices("invalid"); var maskCode = usb.getDevices("invalid");
console.info('usb case getDevices return: ' + maskCode); console.info('usb 1010 case getDevices return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1010 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1010 : PASS'); console.info('usb SUB_USB_JS_1010 : PASS');
} }
...@@ -837,19 +965,47 @@ describe('UsbCoreJsFunctionsTestEx', function () { ...@@ -837,19 +965,47 @@ describe('UsbCoreJsFunctionsTestEx', function () {
} }
try { try {
var maskCode = usb.closePipe("invalid"); var maskCode = usb.closePipe("invalid");
console.info('usb case closePipe return: ' + maskCode); console.info('usb 1050 case closePipe return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1050 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1050 : PASS'); console.info('usb SUB_USB_JS_1050 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1270
* @tc.name : closePipe
* @tc.desc : 反向测试 关闭设备 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1270', 0, function () {
console.info('usb SUB_USB_JS_1270 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null')
expect(false).assertTrue();
return
}
try {
var maskCode = usb.closePipe();
console.info('usb 1270 case closePipe return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1270 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1270 : PASS');
}
})
/** /**
* @tc.number : SUB_USB_JS_1060 * @tc.number : SUB_USB_JS_1060
* @tc.name : getRawDescriptor * @tc.name : getRawDescriptor
* @tc.desc : 反向测试 关闭设备 参数类型错误 * @tc.desc : 反向测试 获取原始USB设备描述符 参数类型错误
*/ */
it('SUB_USB_JS_1060', 0, function () { it('SUB_USB_JS_1060', 0, function () {
console.info('usb SUB_USB_JS_1060 begin'); console.info('usb SUB_USB_JS_1060 begin');
...@@ -865,15 +1021,43 @@ describe('UsbCoreJsFunctionsTestEx', function () { ...@@ -865,15 +1021,43 @@ describe('UsbCoreJsFunctionsTestEx', function () {
} }
try { try {
var maskCode = usb.getRawDescriptor("invalid"); var maskCode = usb.getRawDescriptor("invalid");
console.info('usb case getRawDescriptor return: ' + maskCode); console.info('usb 1060 case getRawDescriptor return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1060 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1060 : PASS'); console.info('usb SUB_USB_JS_1060 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1280
* @tc.name : getRawDescriptor
* @tc.desc : 反向测试 获取原始USB设备描述符 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1280', 0, function () {
console.info('usb SUB_USB_JS_1280 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null')
expect(false).assertTrue();
return
}
try {
var maskCode = usb.getRawDescriptor();
console.info('usb 1280 case getRawDescriptor return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1280 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1280 : PASS');
}
})
/** /**
* @tc.number : SUB_USB_JS_1090 * @tc.number : SUB_USB_JS_1090
* @tc.name : removeRight * @tc.name : removeRight
...@@ -893,14 +1077,43 @@ describe('UsbCoreJsFunctionsTestEx', function () { ...@@ -893,14 +1077,43 @@ describe('UsbCoreJsFunctionsTestEx', function () {
} }
try { try {
var maskCode = usb.removeRight(invalidCode); var maskCode = usb.removeRight(invalidCode);
console.info('usb case removeRight return: ' + maskCode); console.info('usb 1090 case removeRight return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1090 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1090 : PASS'); console.info('usb SUB_USB_JS_1090 : PASS');
} }
CheckEmptyUtils.sleep(5000); CheckEmptyUtils.sleep(5000);
}) })
/**
* @tc.number : SUB_USB_JS_1290
* @tc.name : removeRight
* @tc.desc : 反向测试 移除权限 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1290', 0, function () {
console.info('usb SUB_USB_JS_1290 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null')
expect(false).assertTrue();
return
}
try {
var maskCode = usb.removeRight();
console.info('usb 1290 case removeRight return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1290 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1290 : PASS');
}
CheckEmptyUtils.sleep(5000);
})
}) })
} }
...@@ -283,7 +283,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -283,7 +283,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
/** /**
* @tc.number : SUB_USB_JS_0740 * @tc.number : SUB_USB_JS_0740
* @tc.name : setConfiguration * @tc.name : setConfiguration
* @tc.desc : 设置设备接口 * @tc.desc : 设置设备配置
*/ */
it('SUB_USB_JS_0740', 0, function () { it('SUB_USB_JS_0740', 0, function () {
console.info('usb SUB_USB_JS_0740 begin'); console.info('usb SUB_USB_JS_0740 begin');
...@@ -312,7 +312,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -312,7 +312,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
/** /**
* @tc.number : SUB_USB_JS_0750 * @tc.number : SUB_USB_JS_0750
* @tc.name : setConfiguration * @tc.name : setConfiguration
* @tc.desc : 反向测试 设置设备接口 * @tc.desc : 反向测试 设置设备配置
*/ */
it('SUB_USB_JS_0750', 0, function () { it('SUB_USB_JS_0750', 0, function () {
console.info('usb SUB_USB_JS_0750 begin'); console.info('usb SUB_USB_JS_0750 begin');
...@@ -653,13 +653,41 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -653,13 +653,41 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
} }
try { try {
var maskCode = usb.controlTransfer("invalid"); var maskCode = usb.controlTransfer("invalid");
console.info('usb case controlTransfer return: ' + maskCode); console.info('usb 1140 case controlTransfer return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1140 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1140 : PASS'); console.info('usb SUB_USB_JS_1140 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1300
* @tc.name : controlTransfer
* @tc.desc : 反向测试 控制传输 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1300', 0, function () {
console.info('usb SUB_USB_JS_1300 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
var testParam = getTransferTestParam()
if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) {
expect(false).assertTrue();
return
}
try {
var maskCode = usb.controlTransfer();
console.info('usb 1300 case controlTransfer return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1300 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1300 : PASS');
}
})
}) })
} }
...@@ -270,15 +270,43 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { ...@@ -270,15 +270,43 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
} }
try { try {
var maskCode = usb.bulkTransfer("invalid"); var maskCode = usb.bulkTransfer("invalid");
console.info('usb case bulkTransfer return: ' + maskCode); console.info('usb 1100 case bulkTransfer return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1100 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1100 : PASS'); console.info('usb SUB_USB_JS_1100 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1310
* @tc.name : bulkTransfer
* @tc.desc : 反向测试 批量传输 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1310', 0, function () {
console.info('usb SUB_USB_JS_1310 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null')
expect(false).assertTrue();
return
}
try {
var maskCode = usb.bulkTransfer();
console.info('usb 1310 case bulkTransfer return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1310 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1310 : PASS');
}
})
/** /**
* @tc.number : SUB_USB_JS_0430 * @tc.number : SUB_USB_JS_0430
* @tc.name : claimInterface * @tc.name : claimInterface
...@@ -508,15 +536,48 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { ...@@ -508,15 +536,48 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
} }
try { try {
var maskCode = usb.claimInterface("invalid"); var maskCode = usb.claimInterface("invalid");
console.info('usb case claimInterface return: ' + maskCode); console.info('usb 1110 case claimInterface return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1110 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1110 : PASS'); console.info('usb SUB_USB_JS_1110 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1320
* @tc.name : claimInterface
* @tc.desc : 反向测试 获取接口 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1320', 0, function () {
console.info('usb SUB_USB_JS_1320 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null')
expect(false).assertTrue();
return
}
if (gDeviceList[0].configs.length == 0) {
console.info('usb 1320 case current device.configs.length = 0');
expect(false).assertTrue();
return
}
try {
var maskCode = usb.claimInterface("invalid");
console.info('usb 1320 case claimInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1320 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1320 : PASS');
}
})
/** /**
* @tc.number : SUB_USB_JS_0280 * @tc.number : SUB_USB_JS_0280
* @tc.name : releaseInterface * @tc.name : releaseInterface
...@@ -747,15 +808,48 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { ...@@ -747,15 +808,48 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
gPipe = usb.connectDevice(gDeviceList[0]) gPipe = usb.connectDevice(gDeviceList[0])
try { try {
var maskCode = usb.releaseInterface("invalid"); var maskCode = usb.releaseInterface("invalid");
console.info('usb case releaseInterface return: ' + maskCode); console.info('usb 1150 case releaseInterface return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1150 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1150 : PASS'); console.info('usb SUB_USB_JS_1150 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1330
* @tc.name : releaseInterface
* @tc.desc : 反向测试 释放接口 参数类型错误
*/
it('SUB_USB_JS_1330', 0, function () {
console.info('usb SUB_USB_JS_1330 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null')
expect(false).assertTrue();
return
}
if (gDeviceList[0].configs.length == 0) {
console.info('usb 1330 case current device.configs.length = 0');
expect(false).assertTrue();
return
}
try {
var maskCode = usb.releaseInterface();
console.info('usb 1330 case releaseInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1330 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1330 : PASS');
}
})
/** /**
* @tc.number : SUB_USB_JS_0820 * @tc.number : SUB_USB_JS_0820
* @tc.name : setInterface * @tc.name : setInterface
...@@ -905,19 +999,47 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { ...@@ -905,19 +999,47 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
} }
try { try {
var maskCode = usb.setInterface("invalid"); var maskCode = usb.setInterface("invalid");
console.info('usb case setInterface return: ' + maskCode); console.info('usb 1130 case setInterface return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1130 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1130 : PASS'); console.info('usb SUB_USB_JS_1130 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1340
* @tc.name : setInterface
* @tc.desc : 反向测试 设置设备接口 参数类型错误
*/
it('SUB_USB_JS_1340', 0, function () {
console.info('usb SUB_USB_JS_1340 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null')
expect(false).assertTrue();
return
}
try {
var maskCode = usb.setInterface();
console.info('usb 1340 case setInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1340 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1340 : PASS');
}
})
/** /**
* @tc.number : SUB_USB_JS_0760 * @tc.number : SUB_USB_JS_0760
* @tc.name : setConfiguration * @tc.name : setConfiguration
* @tc.desc : 反向测试 USBConfig的name 赋值错误 设置设备接口 * @tc.desc : 反向测试 USBConfig的name 赋值错误 设置设备配置
*/ */
it('SUB_USB_JS_0760', 0, function () { it('SUB_USB_JS_0760', 0, function () {
console.info('usb SUB_USB_JS_0760 begin'); console.info('usb SUB_USB_JS_0760 begin');
...@@ -946,7 +1068,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { ...@@ -946,7 +1068,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
/** /**
* @tc.number : SUB_USB_JS_0770 * @tc.number : SUB_USB_JS_0770
* @tc.name : setConfiguration * @tc.name : setConfiguration
* @tc.desc : 反向测试 USBConfig的name 赋值错误 设置设备接口 * @tc.desc : 反向测试 USBConfig的name 赋值错误 设置设备配置
*/ */
it('SUB_USB_JS_0770', 0, function () { it('SUB_USB_JS_0770', 0, function () {
console.info('usb SUB_USB_JS_0770 begin'); console.info('usb SUB_USB_JS_0770 begin');
...@@ -976,7 +1098,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { ...@@ -976,7 +1098,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
/** /**
* @tc.number : SUB_USB_JS_0780 * @tc.number : SUB_USB_JS_0780
* @tc.name : setConfiguration * @tc.name : setConfiguration
* @tc.desc : 反向测试 USBConfig的attributes 赋值错误 设置设备接口 * @tc.desc : 反向测试 USBConfig的attributes 赋值错误 设置设备配置
*/ */
it('SUB_USB_JS_0780', 0, function () { it('SUB_USB_JS_0780', 0, function () {
console.info('usb SUB_USB_JS_0780 begin'); console.info('usb SUB_USB_JS_0780 begin');
...@@ -1005,7 +1127,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { ...@@ -1005,7 +1127,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
/** /**
* @tc.number : SUB_USB_JS_0790 * @tc.number : SUB_USB_JS_0790
* @tc.name : setConfiguration * @tc.name : setConfiguration
* @tc.desc : 反向测试 USBConfig的name interval(1-16) 赋值错误 设置设备接口 * @tc.desc : 反向测试 USBConfig的name interval(1-16) 赋值错误 设置设备配置
*/ */
it('SUB_USB_JS_0790', 0, function () { it('SUB_USB_JS_0790', 0, function () {
console.info('usb SUB_USB_JS_0790 begin'); console.info('usb SUB_USB_JS_0790 begin');
...@@ -1035,7 +1157,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { ...@@ -1035,7 +1157,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
/** /**
* @tc.number : SUB_USB_JS_1120 * @tc.number : SUB_USB_JS_1120
* @tc.name : setConfiguration * @tc.name : setConfiguration
* @tc.desc : 反向测试 设置设备接口 参数类型错误 * @tc.desc : 反向测试 设置设备配置 参数类型错误
*/ */
it('SUB_USB_JS_1120', 0, function () { it('SUB_USB_JS_1120', 0, function () {
console.info('usb SUB_USB_JS_1120 begin'); console.info('usb SUB_USB_JS_1120 begin');
...@@ -1051,13 +1173,41 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { ...@@ -1051,13 +1173,41 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
} }
try { try {
var maskCode = usb.setConfiguration("invalid"); var maskCode = usb.setConfiguration("invalid");
console.info('usb case setConfiguration return: ' + maskCode); console.info('usb 1120 case setConfiguration return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1120 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1120 : PASS'); console.info('usb SUB_USB_JS_1120 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1350
* @tc.name : setConfiguration
* @tc.desc : 反向测试 设置设备配置 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1350', 0, function () {
console.info('usb SUB_USB_JS_1350 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null')
expect(false).assertTrue();
return
}
try {
var maskCode = usb.setConfiguration();
console.info('usb 1350 case setConfiguration return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1350 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1350 : PASS');
}
})
}) })
} }
...@@ -106,10 +106,10 @@ describe('UsbFunctionsJsFunctionsTest', function () { ...@@ -106,10 +106,10 @@ describe('UsbFunctionsJsFunctionsTest', function () {
console.info('usb SUB_USB_JS_1000 begin'); console.info('usb SUB_USB_JS_1000 begin');
try { try {
var maskCode = usb.getCurrentFunctions("invalid"); var maskCode = usb.getCurrentFunctions("invalid");
console.info('usb case getCurrentFunctions return: ' + maskCode); console.info('usb 1000 case getCurrentFunctions return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1000 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1000 : PASS'); console.info('usb SUB_USB_JS_1000 : PASS');
} }
......
...@@ -166,15 +166,33 @@ describe('UsbFunctionsJsFunctionsTestEx', function () { ...@@ -166,15 +166,33 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
console.info('usb SUB_USB_JS_1160 begin'); console.info('usb SUB_USB_JS_1160 begin');
try { try {
var maskCode = usb.usbFunctionsToString("invalid"); var maskCode = usb.usbFunctionsToString("invalid");
console.info('usb case usbFunctionsToString return: ' + maskCode); console.info('usb 1160 case usbFunctionsToString return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1160 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1160 : PASS'); console.info('usb SUB_USB_JS_1160 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1360
* @tc.name : usbFunctionsToString
* @tc.desc : 反向测试 掩码转化成描述字符 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1360', 0, function () {
console.info('usb SUB_USB_JS_1360 begin');
try {
var maskCode = usb.usbFunctionsToString();
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');
}
})
/** /**
* @tc.number : SUB_USB_JS_0860 * @tc.number : SUB_USB_JS_0860
* @tc.name : usbFunctionsFromString * @tc.name : usbFunctionsFromString
...@@ -282,13 +300,31 @@ describe('UsbFunctionsJsFunctionsTestEx', function () { ...@@ -282,13 +300,31 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
console.info('usb SUB_USB_JS_1170 begin'); console.info('usb SUB_USB_JS_1170 begin');
try { try {
var maskCode = usb.usbFunctionsFromString(invalidCode); var maskCode = usb.usbFunctionsFromString(invalidCode);
console.info('usb case usbFunctionsFromString return: ' + maskCode); console.info('usb 1170 case usbFunctionsFromString return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1170 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1170 : PASS'); console.info('usb SUB_USB_JS_1170 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1370
* @tc.name : usbFunctionsFromString
* @tc.desc : 反向测试 描述字符转换成掩码 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1370', 0, function () {
console.info('usb SUB_USB_JS_1370 begin');
try {
var maskCode = usb.usbFunctionsFromString();
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');
}
})
}) })
} }
...@@ -72,15 +72,33 @@ describe('UsbPortJsFunctionsTestEx', function () { ...@@ -72,15 +72,33 @@ describe('UsbPortJsFunctionsTestEx', function () {
console.info('usb SUB_USB_JS_1210 begin'); console.info('usb SUB_USB_JS_1210 begin');
try { try {
var maskCode = usb.getSupportedModes("invalid"); var maskCode = usb.getSupportedModes("invalid");
console.info('usb case getSupportedModes return: ' + maskCode); console.info('usb 1210 case getSupportedModes return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1210 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1210 : PASS'); console.info('usb SUB_USB_JS_1210 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1380
* @tc.name : getSupportedModes
* @tc.desc : 反向测试 获取指定的端口支持的模式列表的组合掩码 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1380', 0, function () {
console.info('usb SUB_USB_JS_1380 begin');
try {
var maskCode = usb.getSupportedModes();
console.info('usb 1380 case getSupportedModes return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1380 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1380 : PASS');
}
})
/** /**
* @tc.number : SUB_USB_JS_0030 * @tc.number : SUB_USB_JS_0030
* @tc.name : setPortRoles * @tc.name : setPortRoles
...@@ -173,7 +191,7 @@ describe('UsbPortJsFunctionsTestEx', function () { ...@@ -173,7 +191,7 @@ describe('UsbPortJsFunctionsTestEx', function () {
/** /**
* @tc.number : SUB_USB_JS_0070 * @tc.number : SUB_USB_JS_0070
* @tc.name : setPortRoles * @tc.name : setPortRoles
* @tc.desc : portId,portId,dataRole参数错误 * @tc.desc : portId,powerRole,dataRole参数错误
*/ */
it('SUB_USB_JS_0070', 0, function () { it('SUB_USB_JS_0070', 0, function () {
var portId = gPort.id - 1; var portId = gPort.id - 1;
...@@ -223,28 +241,46 @@ describe('UsbPortJsFunctionsTestEx', function () { ...@@ -223,28 +241,46 @@ describe('UsbPortJsFunctionsTestEx', function () {
console.info('usb SUB_USB_JS_1190 begin'); console.info('usb SUB_USB_JS_1190 begin');
try { try {
var maskCode = usb.setPortRoles("invalid"); var maskCode = usb.setPortRoles("invalid");
console.info('usb case setPortRoles return: ' + maskCode); console.info('usb 1190 case setPortRoles return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1190 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1190 : PASS'); console.info('usb SUB_USB_JS_1190 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1390
* @tc.name : setPortRoles
* @tc.desc : 反向测试 port功能切换 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1390', 0, function () {
console.info('usb SUB_USB_JS_1390 begin');
try {
var maskCode = usb.setPortRoles();
console.info('usb 1390 case setPortRoles return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1390 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1390 : PASS');
}
})
/** /**
* @tc.number : SUB_USB_JS_1200 * @tc.number : SUB_USB_JS_1200
* @tc.name : getPorts * @tc.name : getPorts
* @tc.desc : 反向测试 port功能切换 入参错误(无参接口传参) * @tc.desc : 反向测试 获取USB端口描述信息列表 入参错误(无参接口传参)
*/ */
it('SUB_USB_JS_1200', 0, function () { it('SUB_USB_JS_1200', 0, function () {
console.info('usb SUB_USB_JS_1200 begin'); console.info('usb SUB_USB_JS_1200 begin');
try { try {
var maskCode = usb.getPorts("invalid"); var maskCode = usb.getPorts("invalid");
console.info('usb case getPorts return: ' + maskCode); console.info('usb 1200 case getPorts return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1200 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1200 : PASS'); console.info('usb SUB_USB_JS_1200 : PASS');
} }
...@@ -259,13 +295,31 @@ describe('UsbPortJsFunctionsTestEx', function () { ...@@ -259,13 +295,31 @@ describe('UsbPortJsFunctionsTestEx', function () {
console.info('usb SUB_USB_JS_1180 begin'); console.info('usb SUB_USB_JS_1180 begin');
try { try {
var maskCode = usb.setCurrentFunctions("invalid"); var maskCode = usb.setCurrentFunctions("invalid");
console.info('usb case setCurrentFunctions return: ' + maskCode); console.info('usb 1180 case setCurrentFunctions return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1180 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1180 : PASS'); console.info('usb SUB_USB_JS_1180 : PASS');
} }
}) })
/**
* @tc.number : SUB_USB_JS_1400
* @tc.name : setCurrentFunctions
* @tc.desc : 反向测试 在设备模式下设置当前的USB功能列表 参数个数错误,必要参数未传入
*/
it('SUB_USB_JS_1400', 0, function () {
console.info('usb SUB_USB_JS_1400 begin');
try {
var maskCode = usb.setCurrentFunctions();
console.info('usb 1400 case setCurrentFunctions return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1400 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1400 : PASS');
}
})
}) })
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册