提交 7e8d6928 编写于 作者: L lixiaofeng_154b

添加401错误码用例

Signed-off-by: Nlixiaofeng_154b <lixiaofeng54@huawei.com>
Change-Id: Ie1187f816f73396bcaeac602f8889ec1d3ff1936
上级 b7b18b4f
...@@ -648,6 +648,19 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -648,6 +648,19 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0620 ClearFeature') callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0620 ClearFeature')
}) })
function callControlTransferEx(pip, controlParam, timeout, caseName) {
usb.controlTransfer(pip, controlParam, timeout).then(data => {
console.info('usb controlTransfer ret data : ' + data + ' ' + caseName);
expect(false).assertTrue();
console.info('usb' + caseName + ': FAILED');
}).catch(error => {
console.info('usb controlTransfer error : ' + JSON.stringify(error));
console.info('usb' + caseName + ': FAILED');
expect(false).assertTrue();
});
CheckEmptyUtils.sleep(3000);
}
/** /**
* @tc.number: SUB_USB_JS_1140 * @tc.number: SUB_USB_JS_1140
* @tc.name: controlTransfer * @tc.name: controlTransfer
...@@ -666,9 +679,13 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -666,9 +679,13 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
return return
} }
try { try {
var maskCode = usb.controlTransfer("invalid"); usb.controlTransfer("invalid").then(data => {
console.info('usb 1140 case controlTransfer return: ' + maskCode); console.info('usb 1140 case controlTransfer ret data : ' + data);
expect(false).assertTrue(); expect(false).assertTrue();
}).catch(error => {
console.info('usb 1140 case controlTransfer error : ' + JSON.stringify(error));
expect(false).assertTrue();
});
} catch (err) { } catch (err) {
console.info('usb 1140 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);
...@@ -694,7 +711,13 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -694,7 +711,13 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
return return
} }
try { try {
var maskCode = usb.controlTransfer(); usb.controlTransfer().then(data => {
console.info('usb 1300 case controlTransfer ret data : ' + data);
expect(false).assertTrue();
}).catch(error => {
console.info('usb 1300 case controlTransfer error : ' + JSON.stringify(error));
expect(false).assertTrue();
});
console.info('usb 1300 case controlTransfer return: ' + maskCode); console.info('usb 1300 case controlTransfer return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} catch (err) { } catch (err) {
...@@ -716,7 +739,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -716,7 +739,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
expect(false).assertFalse(); expect(false).assertFalse();
return return
} }
var testParam = getTransferTestParam() var testParam = getTransferTestParam();
if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) { if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) {
expect(false).assertTrue(); expect(false).assertTrue();
return return
...@@ -726,14 +749,41 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -726,14 +749,41 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
var controlParam = getTransferParam(255, usb.USB_REQUEST_TARGET_OTHER, (usb.USB_REQUEST_DIR_TO_DEVICE) var controlParam = getTransferParam(255, usb.USB_REQUEST_TARGET_OTHER, (usb.USB_REQUEST_DIR_TO_DEVICE)
| (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0); | (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0);
try { try {
var maskCode = usb.controlTransfer(testParamPip, controlParam, timeout); callControlTransferEx(testParamPip, controlParam, timeout, 'SUB_USB_JS_1440 ClearFeature');
console.info('usb 1440 case controlTransfer return: ' + maskCode);
expect(false).assertTrue();
} catch (err) { } catch (err) {
console.info('usb 1440 catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1440 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1440 : PASS'); console.info('usb SUB_USB_JS_1440 : PASS');
} }
}) })
/**
* @tc.number: SUB_USB_JS_1560
* @tc.name: controlTransfer
* @tc.desc: Negative test: control transfer,
* parameter contrlparam type error(The controlParam should have the data property)
*/
it('SUB_USB_JS_1560', 0, function () {
console.info('usb SUB_USB_JS_1560 begin');
if (portCurrentMode == 1) {
console.info('usb 1560 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
}
var controlParam = "invalid";
var timeout = 5000;
try {
callControlTransferEx(testParam.pip, controlParam, timeout, 'SUB_USB_JS_1560 ClearFeature');
} catch (err) {
console.info('usb 1560 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1560 : PASS');
}
})
}) })
} }
...@@ -1121,6 +1121,31 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { ...@@ -1121,6 +1121,31 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
} }
}) })
/**
* @tc.number: SUB_USB_JS_1580
* @tc.name: releaseInterface
* @tc.desc: Negative test: release Interface, parameter iface type error
*/
it('SUB_USB_JS_1580', 0, function () {
console.info('usb SUB_USB_JS_1580 begin');
if (portCurrentMode == 1) {
console.info('usb 1580 case get_device port is device')
expect(false).assertFalse();
return
}
var TmpInterface = "invalid";
try {
var maskCode = usb.releaseInterface(gPipe, TmpInterface);
console.info('usb 1580 case releaseInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1580 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1580 : PASS');
}
})
/** /**
* @tc.number: SUB_USB_JS_0820 * @tc.number: SUB_USB_JS_0820
* @tc.name: setInterface * @tc.name: setInterface
...@@ -1257,6 +1282,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { ...@@ -1257,6 +1282,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
console.info('usb case get_device port is device') console.info('usb case get_device port is device')
expect(false).assertFalse(); expect(false).assertFalse();
return return
} }
if (gDeviceList.length == 0) { if (gDeviceList.length == 0) {
console.info('usb case get_device_list is null') console.info('usb case get_device_list is null')
...@@ -1341,6 +1367,36 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { ...@@ -1341,6 +1367,36 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
} }
}) })
/**
* @tc.number: SUB_USB_JS_1550
* @tc.name: setInterface
* @tc.desc: Negative test: Set device interface, parameter iface type error
*/
it('SUB_USB_JS_1550', 0, function () {
console.info('usb SUB_USB_JS_1550 begin');
if (portCurrentMode == 1) {
console.info('usb case 1550 get_device port is device')
expect(false).assertFalse();
return
}
if (gDeviceList.length == 0) {
console.info('usb case 1550 get_device_list is null')
expect(false).assertTrue();
return
}
var TmpInterface = "invalid";
try {
var maskCode = usb.setInterface(gPipe, TmpInterface);
console.info('usb 1550 case setInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1550 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1550 : PASS');
}
})
/** /**
* @tc.number: SUB_USB_JS_0760 * @tc.number: SUB_USB_JS_0760
* @tc.name: setConfiguration * @tc.name: setConfiguration
...@@ -1537,21 +1593,47 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { ...@@ -1537,21 +1593,47 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
try { try {
for (var j = 0; j < gDeviceList[0].configs.length; j++) { for (var j = 0; j < gDeviceList[0].configs.length; j++) {
if (gDeviceList[0].configs[j].interfaces.length == 0) { var TmpConfig = gDeviceList[0].configs[j];
console.info('usb case SUB_USB_JS_1470 current device.configs.interfaces.length = 0'); var maskCode = usb.setConfiguration(testParamPip, TmpConfig);
}
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var TmpInterface = gDeviceList[0].configs[j].interfaces[k];
var maskCode = usb.setConfiguration(testParamPip, TmpInterface);
console.info('usb 1470 case setConfiguration return: ' + maskCode); console.info('usb 1470 case setConfiguration return: ' + maskCode);
expect(false).assertTrue(); expect(false).assertTrue();
} }
}
} catch (err) { } catch (err) {
console.info('usb 1470 catch err code: ' + err.code + ' message: ' + err.message); console.info('usb 1470 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401); expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1470 : PASS'); console.info('usb SUB_USB_JS_1470 : PASS');
} }
}) })
/**
* @tc.number: SUB_USB_JS_1540
* @tc.name: setConfiguration
* @tc.desc: Negative test: Set Device Configuration, parameter pipe type error
*/
it('SUB_USB_JS_1540', 0, function () {
console.info('usb SUB_USB_JS_1540 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 TmpConfig = "invalid";
try {
var maskCode = usb.setConfiguration(gPipe, TmpConfig);
console.info('usb 1540 case setConfiguration return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1540 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1540 : PASS');
}
})
}) })
} }
...@@ -223,7 +223,7 @@ describe('UsbPortJsFunctionsTestEx', function () { ...@@ -223,7 +223,7 @@ describe('UsbPortJsFunctionsTestEx', function () {
/** /**
* @tc.number: SUB_USB_JS_1410 * @tc.number: SUB_USB_JS_1410
* @tc.name: setPortRoles * @tc.name: setPortRoles
* @tc.desc: Negative test: parameter type exception * @tc.desc: Negative test: parameter portId type exception
*/ */
it('SUB_USB_JS_1410', 0, function () { it('SUB_USB_JS_1410', 0, function () {
console.info('usb SUB_USB_JS_1410 begin'); console.info('usb SUB_USB_JS_1410 begin');
...@@ -277,6 +277,68 @@ describe('UsbPortJsFunctionsTestEx', function () { ...@@ -277,6 +277,68 @@ describe('UsbPortJsFunctionsTestEx', function () {
} }
}) })
/**
* @tc.number: SUB_USB_JS_1590
* @tc.name: setPortRoles
* @tc.desc: Negative test: parameter number exception, parameter powerRole type exception
*/
it('SUB_USB_JS_1590', 0, function () {
console.info('usb SUB_USB_JS_1590 begin');
var portId = gPort.id;
var powerRole = "invalid";
var dataRole = usb.DEVICE;
try {
var maskCode = usb.setPortRoles(portId, powerRole, dataRole);
console.info('usb 1590 case setPortRoles return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1590 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1590 : PASS');
}
})
/**
* @tc.number: SUB_USB_JS_1600
* @tc.name: setPortRoles
* @tc.desc: Negative test: parameter number exception, parameter dataRole type exception
*/
it('SUB_USB_JS_1600', 0, function () {
console.info('usb SUB_USB_JS_1600 begin');
var portId = gPort.id;
var powerRole = usb.SINK;
var dataRole = "invalid";
try {
var maskCode = usb.setPortRoles(portId, powerRole, dataRole);
console.info('usb 1600 case setPortRoles return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1600 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1600 : PASS');
}
})
/**
* @tc.number: SUB_USB_JS_1610
* @tc.name: setPortRoles
* @tc.desc: Negative test: parameter number exception, input two parameter
*/
it('SUB_USB_JS_1610', 0, function () {
console.info('usb SUB_USB_JS_1610 begin');
var portId = gPort.id;
var powerRole = usb.SINK;
try {
var maskCode = usb.setPortRoles(portId, powerRole);
console.info('usb 1610 case setPortRoles return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
console.info('usb 1610 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1610 : PASS');
}
})
/** /**
* @tc.number: SUB_USB_JS_1200 * @tc.number: SUB_USB_JS_1200
* @tc.name: getPorts * @tc.name: getPorts
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册