未验证 提交 57dcd992 编写于 作者: O openharmony_ci 提交者: Gitee

!7642 【xts_acts】【monthly_20221018】新增用例及修改头文件

Merge pull request !7642 from 李晓枫/monthly_usb0220
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2021-2023 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
......
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2021-2023 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
......@@ -783,5 +783,34 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
console.info('usb SUB_USB_JS_1560 : PASS');
}
})
/**
* @tc.number: SUB_USB_JS_1570
* @tc.name: controlTransfer
* @tc.desc: Negative test: control transfer, parameter timeout type error
*/
it('SUB_USB_JS_1570', 0, function () {
console.info('usb SUB_USB_JS_1570 begin');
if (portCurrentMode == 1) {
console.info('usb 1570 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 timeout = "invalid";
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);
try {
callControlTransferEx(testParam.pip, controlParam, timeout, 'SUB_USB_JS_1570 ClearFeature');
} catch (err) {
console.info('usb 1570 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1570 : PASS');
}
})
})
}
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2021-2023 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
......@@ -448,6 +448,89 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
}
})
/**
* @tc.number: SUB_USB_JS_1500
* @tc.name: bulkTransfer
* @tc.desc: Negative test: bulk transfer, parameter Uint8Array type error
*/
it('SUB_USB_JS_1500', 0, function () {
console.info('usb SUB_USB_JS_1500 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device');
expect(false).assertFalse();
return
}
var testParam = getTransferTestParam()
if (testParam.interface == null || testParam.inEndpoint == null) {
console.info('usb case testParam_interface and testParam_inEndpoint is null');
expect(false).assertTrue();
return
}
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
expect(testParam.isClaimed).assertEqual(0);
console.info('usb case readData begin');
var tmpUint8Array = "invalid";
try {
usb.bulkTransfer(testParam.pip, testParam.inEndpoint, tmpUint8Array, 5000).then(data => {
console.info('usb case SUB_USB_JS_1500 ret: ' + data);
expect(false).assertTrue();
console.info('usb case SUB_USB_JS_1500 : FAILED');
}).catch(error => {
console.info('usb 1500 write error : ' + JSON.stringify(error));
expect(false).assertTrue();
console.info('usb case SUB_USB_JS_1500 : FAILED');
});
} catch (err) {
console.info('usb 1500 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1500 : PASS');
}
})
/**
* @tc.number: SUB_USB_JS_1530
* @tc.name: bulkTransfer
* @tc.desc: Negative test: bulk transfer, parameter timeout type error
*/
it('SUB_USB_JS_1530', 0, function () {
console.info('usb SUB_USB_JS_1530 begin');
if (portCurrentMode == 1) {
console.info('usb case get_device port is device');
expect(false).assertFalse();
return
}
var testParam = getTransferTestParam()
if (testParam.interface == null || testParam.inEndpoint == null) {
console.info('usb case testParam_interface and testParam_inEndpoint is null');
expect(false).assertTrue();
return
}
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
expect(testParam.isClaimed).assertEqual(0);
console.info('usb case readData begin');
var tmpTimeOut = "invalid";
var tmpUint8Array = new Uint8Array(testParam.maxInSize);
try {
usb.bulkTransfer(testParam.pip, testParam.inEndpoint, tmpUint8Array, tmpTimeOut).then(data => {
console.info('usb case SUB_USB_JS_1530 ret: ' + data);
expect(false).assertTrue();
console.info('usb case SUB_USB_JS_1530 : FAILED');
}).catch(error => {
console.info('usb 1530 write error : ' + JSON.stringify(error));
expect(false).assertTrue();
console.info('usb case SUB_USB_JS_1530 : FAILED');
});
} catch (err) {
console.info('usb 1530 catch err code: ' + err.code + ' message: ' + err.message);
expect(err.code).assertEqual(401);
console.info('usb SUB_USB_JS_1530 : PASS');
}
})
/**
* @tc.number: SUB_USB_JS_0430
* @tc.name: claimInterface
......@@ -1608,7 +1691,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
/**
* @tc.number: SUB_USB_JS_1540
* @tc.name: setConfiguration
* @tc.desc: Negative test: Set Device Configuration, parameter pipe type error
* @tc.desc: Negative test: Set Device Configuration, parameter config type error
*/
it('SUB_USB_JS_1540', 0, function () {
console.info('usb SUB_USB_JS_1540 begin');
......
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2021-2023 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
......
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2021-2023 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册