diff --git a/usb/BUILD.gn b/usb/BUILD.gn index c48a2b3bd56048f68cf59f29d27c80f4e6ce4f73..6e37eabef7c52dedfe058058c0d2ca624e6cd144 100644 --- a/usb/BUILD.gn +++ b/usb/BUILD.gn @@ -15,11 +15,7 @@ import("//build/ohos_var.gni") group("usb") { testonly = true - if (device_name == "rk3568") { + if (is_standard_system) { deps = [ "usb_standard:usb_js_test" ] - } else { - if (is_standard_system) { - deps = [ "usb_standard:usb_js_test" ] - } } } diff --git a/usb/usb_standard/src/main/config.json b/usb/usb_standard/src/main/config.json index 1c2c2de3d5eac2b1fa6eaf1ee4355b7ee7452a50..dd4c6074f8964523fa2bb5cb67a5cb94c8bb1fa3 100644 --- a/usb/usb_standard/src/main/config.json +++ b/usb/usb_standard/src/main/config.json @@ -16,8 +16,8 @@ "package": "ohos.acts.usb.usb.function", "name": ".entry", "deviceType": [ - "tablet", - "default", + "tablet", + "default", "phone" ], "distro": { diff --git a/usb/usb_standard/src/main/js/test/List.test.js b/usb/usb_standard/src/main/js/test/List.test.js index a2bab8571ca492dc39e825e56e83b0cc79d0d2d0..d045a52092f7ac43a5cfc7ae5647acb41fd7c071 100644 --- a/usb/usb_standard/src/main/js/test/List.test.js +++ b/usb/usb_standard/src/main/js/test/List.test.js @@ -12,28 +12,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import UsbAutoJsunit from './UsbAutoJsunit.test.js' import UsbPortAndFunctionsJsFunctionsTest from './UsbPortAndFunctionJsunit.test.js' import UsbPortJsFunctionsTest from './UsbPortJsunit.test.js' import UsbPortJsFunctionsTestEx from './UsbPortJsunitEx.test.js' import UsbFunctionsJsFunctionsTestEx from './UsbFunctionsJsunitEx.test.js' import UsbFunctionsJsFunctionsTest from './UsbFunctionsJsunit.test.js' import UsbDevicePipeJsFunctionsTest from './UsbDevicePipeJsunit.test.js' -import UsbDevicePipeJsFunctionsTestA from './UsbDevicePipeJsunit_A.test.js' import UsbDevicePipeJsFunctionsTestEx from './UsbDevicePipeJsunitEx.test.js' import UsbCoreJsFunctionsTest from './UsbCoreJsunit.test.js' import UsbCoreJsFunctionsTestEx from './UsbCoreJsunitEx.test.js' /* host test case */ export default function testsuite() { -UsbAutoJsunit() UsbCoreJsFunctionsTest() UsbCoreJsFunctionsTestEx() UsbDevicePipeJsFunctionsTest() -UsbDevicePipeJsFunctionsTestA() UsbDevicePipeJsFunctionsTestEx() UsbFunctionsJsFunctionsTest() UsbFunctionsJsFunctionsTestEx() -//UsbPortAndFunctionsJsFunctionsTest() +// UsbPortAndFunctionsJsFunctionsTest() UsbPortJsFunctionsTest() UsbPortJsFunctionsTestEx() } diff --git a/usb/usb_standard/src/main/js/test/UsbAutoJsunit.test.js b/usb/usb_standard/src/main/js/test/UsbAutoJsunit.test.js deleted file mode 100644 index fc3dc3b551bc08a614e48472ecf6659dd397249a..0000000000000000000000000000000000000000 --- a/usb/usb_standard/src/main/js/test/UsbAutoJsunit.test.js +++ /dev/null @@ -1,367 +0,0 @@ -/* - * Copyright (C) 2021-2022 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 usb from '@ohos.usb'; -import CheckEmptyUtils from './CheckEmptyUtils.js'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' - -/* usb core functions test */ -export default function UsbAutoJsunit() { -describe('UsbAutoJsunit', function () { - - beforeAll(function () { - console.log('*************Usb Unit UsbAutoJsunit Begin*************'); - var Version = usb.getVersion() - console.info('begin test getversion :' + Version) - - // 切换到 device - var usbPortList = usb.getPorts() - if (usbPortList.length > 0) { - if (usbPortList[0].status.currentMode == 2) { - console.info('usb case set data role 1, data role 1'); - usb.setPortRoles(usbPortList[0].id, 2, 2).then(data => { - console.info('usb case setPortRoles return: ' + data); - }).catch(error => { - console.info('usb case setPortRoles error : ' + error); - }); - CheckEmptyUtils.sleep(8000) - console.log('*************Usb Unit switch to device Begin*************'); - } - } - }) - beforeEach(function () { - console.info('beforeEach: *************Usb Unit Test Case*************'); - }) - - afterEach(function () { - console.info('afterEach: *************Usb Unit Test Case*************'); - }) - - afterAll(function () { - console.log('*************Usb Unit UsbAutoJsunit End*************'); - }) - - /** - * @tc.number : SUB_USB_JS_0930 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 0 返回 'none' - */ - it('SUB_USB_JS_0930', 0, function () { - console.info('usb SUB_USB_JS_0930 begin'); - var maskCode = 0 - var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('none'); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - console.info('usb SUB_USB_JS_0930 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0940 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 1 返回 'acm' - */ - it('SUB_USB_JS_0940', 0, function () { - console.info('usb SUB_USB_JS_0940 begin'); - var maskCode = 1 - var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('acm'); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - console.info('usb SUB_USB_JS_0940 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0950 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 2 返回 'ecm' - */ - it('SUB_USB_JS_0950', 0, function () { - console.info('usb SUB_USB_JS_0950 begin'); - var maskCode = 2 - var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('ecm'); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - console.info('usb SUB_USB_JS_0950 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0960 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 3 返回 'acm,ecm' - */ - it('SUB_USB_JS_0960', 0, function () { - console.info('usb SUB_USB_JS_0960 begin'); - var maskCode = 3 - var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('acm,ecm'); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - console.info('usb SUB_USB_JS_0960 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0970 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 4 返回 'hdc' - */ - it('SUB_USB_JS_0970', 0, function () { - console.info('usb SUB_USB_JS_0970 begin'); - var maskCode = 4 - var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('hdc'); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - console.info('usb SUB_USB_JS_0970 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0980 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 5 返回 'acm,hdc' - */ - it('SUB_USB_JS_0980', 0, function () { - console.info('usb SUB_USB_JS_0980 begin'); - var maskCode = 5 - var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('acm,hdc'); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - console.info('usb SUB_USB_JS_0980 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0990 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 6 返回 'ecm,hdc' - */ - it('SUB_USB_JS_0990', 0, function () { - console.info('usb SUB_USB_JS_0990 begin'); - var maskCode = 6 - var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('ecm,hdc'); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - console.info('usb SUB_USB_JS_0990 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0860 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'none' 返回 0 - */ - it('SUB_USB_JS_0860', 0, function () { - console.info('usb SUB_USB_JS_0860 begin'); - var strMaskCode = 'none' - var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(0); - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - console.info('usb SUB_USB_JS_0860 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0870 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'acm' 返回 1 - */ - it('SUB_USB_JS_0870', 0, function () { - console.info('usb SUB_USB_JS_0870 begin'); - var strMaskCode = 'acm' - var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(1); - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - console.info('usb SUB_USB_JS_0870 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0880 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'ecm' 返回 2 - */ - it('SUB_USB_JS_0880', 0, function () { - console.info('usb SUB_USB_JS_0880 begin'); - var strMaskCode = 'ecm' - var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(2); - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - console.info('usb SUB_USB_JS_0880 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0890 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'acm,ecm' 返回 3 - */ - it('SUB_USB_JS_0890', 0, function () { - console.info('usb SUB_USB_JS_0890 begin'); - var strMaskCode = 'acm,ecm' - var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(3); - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - console.info('usb SUB_USB_JS_0890 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0900 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'hdc' 返回 4 - */ - it('SUB_USB_JS_0900', 0, function () { - console.info('usb SUB_USB_JS_0900 begin'); - var strMaskCode = 'hdc' - var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(4); - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - console.info('usb SUB_USB_JS_0900 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0910 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'acm,hdc' 返回 5 - */ - it('SUB_USB_JS_0910', 0, function () { - console.info('usb SUB_USB_JS_0910 begin'); - var strMaskCode = 'acm,hdc' - var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(5); - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - console.info('usb SUB_USB_JS_0910 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0920 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'ecm,hdc' 返回 6 - */ - it('SUB_USB_JS_0920', 0, function () { - console.info('usb SUB_USB_JS_0920 begin'); - var strMaskCode = 'ecm,hdc' - var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(6); - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - console.info('usb SUB_USB_JS_0920 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0330 - * @tc.name : getCurrentFunctions - * @tc.desc : 获取当前设备模式 掩码与描述字符转换 - */ - it('SUB_USB_JS_0330', 0, function () { - console.info('usb SUB_USB_JS_0330 begin'); - var maskCode = usb.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - - var strMaskCode = usb.usbFunctionsToString(maskCode) - console.info('usb case usbFunctionsToString return str: ' + strMaskCode); - var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(maskCode); - console.info('usb SUB_USB_JS_0330 : PASS'); - expect(true).assertTrue(); - }) - - /** - * @tc.number : SUB_USB_JS_0340 - * @tc.name : usbFunctionString - * @tc.desc : 反向测试 获取当前设备模式 掩码与描述字符转换 - */ - it('SUB_USB_JS_0340', 0, function () { - console.info('usb SUB_USB_JS_0340 begin'); - var maskCode = usb.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - - var strMaskCode = usb.usbFunctionsToString(maskCode) - console.info('usb case usbFunctionsToString return str: ' + strMaskCode); - var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode); - - var errmaskCode = 0 - var strMaskCode = usb.usbFunctionsToString(errmaskCode) - - console.info('usb case ' + errmaskCode + ' usbFunctionsToString return str: ' + strMaskCode); - - var errStrMaskCode = 'none' - var nMaskCode = usb.usbFunctionsFromString(errStrMaskCode) - expect(nMaskCode).assertEqual(0); - console.info('usb case errStrMaskCode ' + errStrMaskCode + - ' usbFunctionsFromString return int: ' + nMaskCode); - - console.info('usb SUB_USB_JS_0340 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0410 - * @tc.name : getPorts - * @tc.desc : 获取USB端口描述信息列表 - */ - it('SUB_USB_JS_0410', 0, function () { - console.info('usb SUB_USB_JS_0410 begin'); - var usbPortList = usb.getPorts() - if (usbPortList.length == 0) { - console.info('usb SUB_USB_JS_0410 usbPortList is null'); - expect(false).assertTrue(); - return - } - expect(usbPortList.length > 0).assertTrue(); - console.info('usb SUB_USB_JS_0410 : PASS'); - expect(true).assertTrue(); - }) - - /** - * @tc.number : SUB_USB_JS_0220 - * @tc.name : getSupportedModes - * @tc.desc : 获取指定的端口支持的模式列表的组合掩码 - */ - it('SUB_USB_JS_0220', 0, function () { - console.info('usb SUB_USB_JS_0220 begin'); - var usbPortList = usb.getPorts() - if (usbPortList.length == 0) { - console.info('usb SUB_USB_JS_0220 usbPortList is null'); - expect(false).assertTrue(); - return - } - - expect(usbPortList.length > 0).assertTrue(); - for (var i = 0; i < usbPortList.length; i++) { - var maskCode = usb.getSupportedModes(usbPortList[i].id) - expect(maskCode).assertEqual(usbPortList[i].supportedModes); - } - - console.info('usb SUB_USB_JS_0220 : PASS'); - expect(true).assertTrue(); - }) - - /** - * @tc.number : SUB_USB_JS_0230 - * @tc.name : getSupportedModes - * @tc.desc : 反向测试 改变id 获取指定的端口支持的模式列表的组合掩码 - */ - it('SUB_USB_JS_0230', 0, function () { - console.info('usb SUB_USB_JS_0230 begin'); - var usbPortList = usb.getPorts() - if (usbPortList.length == 0) { - console.info('usb SUB_USB_JS_0230 usbPortList is null'); - expect(false).assertTrue(); - return - } - - expect(usbPortList.length > 0).assertTrue(); - - var portID = usbPortList[0].id + 10 - var maskCode = usb.getSupportedModes(portID) - expect(maskCode).assertEqual(0); - - console.info('usb SUB_USB_JS_0230 : PASS'); - expect(true).assertTrue(); - }) - -}) -} diff --git a/usb/usb_standard/src/main/js/test/UsbCoreJsunit.test.js b/usb/usb_standard/src/main/js/test/UsbCoreJsunit.test.js index 5a82800e6c10d344874739b6e03e5b323bec1b1f..10e5222a5d296aceac979e3f2172a9f0a8a00253 100644 --- a/usb/usb_standard/src/main/js/test/UsbCoreJsunit.test.js +++ b/usb/usb_standard/src/main/js/test/UsbCoreJsunit.test.js @@ -62,9 +62,9 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0480 - * @tc.name : getDevices - * @tc.desc : 获取设备列表 + * @tc.number: SUB_USB_JS_0480 + * @tc.name: getDevices + * @tc.desc: Positive test: Get device list */ it('SUB_USB_JS_0480', 0, function () { console.info('usb SUB_USB_JS_0480 begin'); @@ -80,15 +80,15 @@ describe('UsbCoreJsFunctionsTest', function () { expect(false).assertTrue(); return } - expect(gDeviceList.length).assertLarger(0); console.info('usb case getDevices ret length: ' + gDeviceList.length); + expect(gDeviceList.length).assertLarger(0); console.info('usb SUB_USB_JS_0480: PASS'); }) /** - * @tc.number : SUB_USB_JS_0710 - * @tc.name : hasRight - * @tc.desc : 权限查询 连接设备 关闭设备 + * @tc.number: SUB_USB_JS_0710 + * @tc.name: hasRight + * @tc.desc: Positive test: Permission query */ it('SUB_USB_JS_0710', 0, function () { console.info('usb has_right_01 begin'); @@ -108,14 +108,14 @@ describe('UsbCoreJsFunctionsTest', function () { console.info('usb has_right ret :' + hasRight); } - console.info('usb SUB_USB_JS_0710 : PASS'); expect(true).assertTrue(); + console.info('usb SUB_USB_JS_0710 : PASS'); }) /** - * @tc.number : SUB_USB_JS_0680 - * @tc.name : requestRight - * @tc.desc : 请求权限 + * @tc.number: SUB_USB_JS_0680 + * @tc.name: requestRight + * @tc.desc: Positive test: Request permission */ it('SUB_USB_JS_0680', 0, function () { console.info('usb SUB_USB_JS_0680 begin'); @@ -132,8 +132,8 @@ describe('UsbCoreJsFunctionsTest', function () { for (var i = 0; i < gDeviceList.length; i++) { usb.requestRight(gDeviceList[i].name).then(hasRight => { - expect(hasRight).assertTrue(); console.info('usb request_right ret :' + hasRight); + expect(hasRight).assertTrue(); console.info('usb SUB_USB_JS_0680 : PASS'); }).catch(error => { console.info('usb case device request right failed : ' + error + ' :' + gDeviceList[i].name); @@ -144,11 +144,11 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_1080 - * @tc.name : removeRight - * @tc.desc : 移除权限 + * @tc.number: SUB_USB_JS_1080 + * @tc.name: removeRight + * @tc.desc: Positive test: Remove Permissions */ - it('SUB_USB_JS_1080', 0, function () { + it('SUB_USB_JS_1080', 0, function () { console.info('usb SUB_USB_JS_1080 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -176,9 +176,9 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0090 - * @tc.name : connectDevice - * @tc.desc : 打开设备 + * @tc.number: SUB_USB_JS_0090 + * @tc.name: connectDevice + * @tc.desc: Positive test: open device */ it('SUB_USB_JS_0090', 0, function () { console.info('usb SUB_USB_JS_0090 begin'); @@ -210,9 +210,9 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0250 - * @tc.name : closePipe - * @tc.desc : 反向测试 关闭设备 错误 busNum + * @tc.number: SUB_USB_JS_0250 + * @tc.name: closePipe + * @tc.desc: Negative test: close device, busNum error */ it('SUB_USB_JS_0250', 0, function () { console.info('usb SUB_USB_JS_0250 begin'); @@ -237,9 +237,9 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0260 - * @tc.name : closePipe - * @tc.desc : 反向测试 关闭设备 错误 devAddress + * @tc.number: SUB_USB_JS_0260 + * @tc.name: closePipe + * @tc.desc: Negative test: close device, devAddress error */ it('SUB_USB_JS_0260', 0, function () { console.info('usb SUB_USB_JS_0260 begin'); @@ -263,9 +263,9 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0270 - * @tc.name : closePipe - * @tc.desc : 反向测试 关闭设备 错误 devAddress busNum + * @tc.number: SUB_USB_JS_0270 + * @tc.name: closePipe + * @tc.desc: Negative test: close device, devAddress && busNum error */ it('SUB_USB_JS_0270', 0, function () { console.info('usb SUB_USB_JS_0270 begin'); @@ -290,9 +290,9 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0240 - * @tc.name : closePipe - * @tc.desc : 关闭设备 + * @tc.number: SUB_USB_JS_0240 + * @tc.name: closePipe + * @tc.desc: Positive test: close device */ it('SUB_USB_JS_0240', 0, function () { console.info('usb SUB_USB_JS_0240 begin'); @@ -316,9 +316,9 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0530 - * @tc.name : getRawDescriptor - * @tc.desc : 获取原始的USB描述符 + * @tc.number: SUB_USB_JS_0530 + * @tc.name: getRawDescriptor + * @tc.desc: Positive test: Get the original USB descriptor */ it('SUB_USB_JS_0530', 0, function () { console.info('usb SUB_USB_JS_0530 begin'); @@ -337,7 +337,7 @@ describe('UsbCoreJsFunctionsTest', function () { console.info('usb case getRawDescriptor param: ' + JSON.stringify(gPipe)); var descriptor = usb.getRawDescriptor(gPipe); console.info('usb case getRawDescriptor ret: ' + descriptor); - expect(true).assertTrue(); + expect(descriptor.length).assertLarger(0); var isPipClose = usb.closePipe(gPipe); expect(isPipClose).assertEqual(0); @@ -345,9 +345,9 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0490 - * @tc.name : getFileDescriptor - * @tc.desc : 获取文件描述符 + * @tc.number: SUB_USB_JS_0490 + * @tc.name: getFileDescriptor + * @tc.desc: Positive test: Get file descriptor */ it('SUB_USB_JS_0490', 0, function () { console.info('usb SUB_USB_JS_0490 begin'); @@ -365,7 +365,7 @@ describe('UsbCoreJsFunctionsTest', function () { console.info('usb case getFileDescriptor param: ' + JSON.stringify(gPipe)); var fileDescriptor = usb.getFileDescriptor(gPipe); console.info('usb case getFileDescriptor ret: ' + fileDescriptor); - expect(true).assertTrue(); + expect(fileDescriptor >= 0).assertTrue(); var isPipClose = usb.closePipe(gPipe); expect(isPipClose).assertEqual(0); @@ -373,9 +373,9 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0500 - * @tc.name : getFileDescriptor - * @tc.desc : 获取文件描述符,反向测试,错误参数busNum=512 + * @tc.number: SUB_USB_JS_0500 + * @tc.name: getFileDescriptor + * @tc.desc: Negative test: Get file descriptor, error busNum=512 */ it('SUB_USB_JS_0500', 0, function () { console.info('usb SUB_USB_JS_0500 begin'); @@ -401,12 +401,12 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0510 - * @tc.name : getFileDescriptor - * @tc.desc : 获取文件描述符,反向测试,错误参数devAddress=512 + * @tc.number: SUB_USB_JS_0510 + * @tc.name: getFileDescriptor + * @tc.desc: Negative test: Get file descriptor,error devAddress=512 */ it('SUB_USB_JS_0510', 0, function () { - console.info('usb get_file_descriptor_03 begin'); + console.info('usb SUB_USB_JS_0510 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') expect(false).assertFalse(); @@ -429,12 +429,12 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0520 - * @tc.name : getFileDescriptor - * @tc.desc : 获取文件描述符,反向测试,错误参数busNum=512,devAddress=512 + * @tc.number: SUB_USB_JS_0520 + * @tc.name: getFileDescriptor + * @tc.desc: Negative test: Get file descriptor,error busNum=512 && devAddress=512 */ it('SUB_USB_JS_0520', 0, function () { - console.info('usb get_file_descriptor_04 begin'); + console.info('usb SUB_USB_JS_0520 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') expect(false).assertFalse(); @@ -457,11 +457,11 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_1070 - * @tc.name : getFileDescriptor - * @tc.desc : 反向测试 获取文件描述符 参数类型错误 + * @tc.number: SUB_USB_JS_1070 + * @tc.name: getFileDescriptor + * @tc.desc: Negative test: Get file descriptor, parameter type error */ - it('SUB_USB_JS_1070', 0, function () { + it('SUB_USB_JS_1070', 0, function () { console.info('usb SUB_USB_JS_1070 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -486,11 +486,11 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_1230 - * @tc.name : getFileDescriptor - * @tc.desc : 反向测试 获取文件描述符 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1230 + * @tc.name: getFileDescriptor + * @tc.desc: Negative test: Get file descriptor, parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1230', 0, function () { + 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') diff --git a/usb/usb_standard/src/main/js/test/UsbCoreJsunitEx.test.js b/usb/usb_standard/src/main/js/test/UsbCoreJsunitEx.test.js index 2fdf53511387fdc4837d5a0e601d617e50c86666..f1c8b0651f0500c7152487591b34d87f79ff509c 100644 --- a/usb/usb_standard/src/main/js/test/UsbCoreJsunitEx.test.js +++ b/usb/usb_standard/src/main/js/test/UsbCoreJsunitEx.test.js @@ -62,9 +62,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { /** - * @tc.number : SUB_USB_JS_0100 - * @tc.name : connectDevice - * @tc.desc : 反向测试 错误参数 devAddress 打开设备 + * @tc.number: SUB_USB_JS_0100 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, error devAddress */ it('SUB_USB_JS_0100', 0, function () { console.info('usb SUB_USB_JS_0100 begin'); @@ -105,9 +105,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0110 - * @tc.name : connectDevice - * @tc.desc : 反向测试 busNum错误参数 打开设备 + * @tc.number: SUB_USB_JS_0110 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, error busNum */ it('SUB_USB_JS_0110', 0, function () { console.info('usb SUB_USB_JS_0110 begin'); @@ -146,9 +146,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0120 - * @tc.name : connectDevice - * @tc.desc : 反向测试 serial错误参数 打开设备 + * @tc.number: SUB_USB_JS_0120 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, error serial */ it('SUB_USB_JS_0120', 0, function () { console.info('usb SUB_USB_JS_0120 begin'); @@ -190,9 +190,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0130 - * @tc.name : connectDevice - * @tc.desc : 反向测试 name错误参数 打开设备 + * @tc.number: SUB_USB_JS_0130 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, error name */ it('SUB_USB_JS_0130', 0, function () { console.info('usb SUB_USB_JS_0130 begin'); @@ -230,9 +230,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0140 - * @tc.name : connectDevice - * @tc.desc : 反向测试 manufacturerName错误参数 打开设备 + * @tc.number: SUB_USB_JS_0140 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, error manufacturerName */ it('SUB_USB_JS_0140', 0, function () { console.info('usb connect_device_06 begin'); @@ -271,9 +271,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0150 - * @tc.name : connectDevice - * @tc.desc : 反向测试 productName错误参数 打开设备 + * @tc.number: SUB_USB_JS_0150 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, error productName */ it('SUB_USB_JS_0150', 0, function () { console.info('usb SUB_USB_JS_0150 begin'); @@ -315,9 +315,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0160 - * @tc.name : connectDevice - * @tc.desc : 反向测试 version错误参数 打开设备 + * @tc.number: SUB_USB_JS_0160 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, error version */ it('SUB_USB_JS_0160', 0, function () { console.info('usb connect_device_08 begin'); @@ -359,9 +359,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0170 - * @tc.name : connectDevice - * @tc.desc : 反向测试 vendorId错误参数 打开设备 + * @tc.number: SUB_USB_JS_0170 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, error vendorId */ it('SUB_USB_JS_0170', 0, function () { console.info('usb connect_device_09 begin'); @@ -403,9 +403,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0180 - * @tc.name : connectDevice - * @tc.desc : 反向测试 productId错误参数 打开设备 + * @tc.number: SUB_USB_JS_0180 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, error productId */ it('SUB_USB_JS_0180', 0, function () { console.info('usb connect_device_10 begin'); @@ -447,9 +447,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0190 - * @tc.name : connectDevice - * @tc.desc : 反向测试 clazz错误参数 打开设备 + * @tc.number: SUB_USB_JS_0190 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, error clazz */ it('SUB_USB_JS_0190', 0, function () { console.info('usb connect_device_11 begin'); @@ -490,9 +490,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0200 - * @tc.name : connectDevice - * @tc.desc : 反向测试 subclass错误参数 打开设备 + * @tc.number: SUB_USB_JS_0200 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, error subclass */ it('SUB_USB_JS_0200', 0, function () { console.info('usb connect_device_12 begin'); @@ -509,10 +509,11 @@ describe('UsbCoreJsFunctionsTestEx', function () { var isRight = usb.hasRight(gDeviceList[0].name); if (!isRight) { usb.requestRight(gDeviceList[0].name).then(hasRight => { + console.info('usb SUB_USB_JS_0200 requestRight hasRight: ' + hasRight); }).catch(error => { console.info('usb SUB_USB_JS_0200 requestRight error:' + error); }); - console.info('usb SUB_USB_JS_0200 requestRight end:'); + console.info('usb SUB_USB_JS_0200 requestRight end'); CheckEmptyUtils.sleep(5000) } @@ -533,9 +534,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0210 - * @tc.name : connectDevice - * @tc.desc : 反向测试 protocol错误参数 打开设备 + * @tc.number: SUB_USB_JS_0210 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, error protocol */ it('SUB_USB_JS_0210', 0, function () { console.info('usb connect_device_13 begin'); @@ -576,11 +577,11 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1040 - * @tc.name : connectDevice - * @tc.desc : 反向测试 打开设备 参数类型错误 + * @tc.number: SUB_USB_JS_1040 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, parameter type error */ - it('SUB_USB_JS_1040', 0, function () { + it('SUB_USB_JS_1040', 0, function () { console.info('usb SUB_USB_JS_1040 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -613,11 +614,11 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1240 - * @tc.name : connectDevice - * @tc.desc : 反向测试 打开设备 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1240 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1240', 0, function () { + 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') @@ -650,11 +651,11 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1220 - * @tc.name : connectDevice - * @tc.desc : 反向测试 打开设备 未授权 + * @tc.number: SUB_USB_JS_1220 + * @tc.name: connectDevice + * @tc.desc: Negative test: open device, Unauthorized */ - it('SUB_USB_JS_1220', 0, function () { + 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') @@ -679,14 +680,20 @@ describe('UsbCoreJsFunctionsTestEx', function () { 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); } + usb.requestRight(gDeviceList[0].name).then(hasRight => { + console.info('usb 1220 requestRight hasRight:' + hasRight); + expect(hasRight).assertTrue(); + }).catch(error => { + console.info('usb 1220 requestRight error:' + error); + }); + CheckEmptyUtils.sleep(5000) }) /** - * @tc.number : SUB_USB_JS_0720 - * @tc.name : hasRight - * @tc.desc : 反向测试 给错误设备名字 + * @tc.number: SUB_USB_JS_0720 + * @tc.name: hasRight + * @tc.desc: Negative test: parameters exception, error deviceName */ it('SUB_USB_JS_0720', 0, function () { console.info('usb SUB_USB_JS_0720 begin'); @@ -706,17 +713,15 @@ describe('UsbCoreJsFunctionsTestEx', function () { deviceName = deviceName + '$#' var hasRight = usb.hasRight(deviceName) console.info('usb has_right ret :' + hasRight); - expect(hasRight == false).assertTrue(); + expect(hasRight).assertFalse(); } - console.info('usb SUB_USB_JS_0720 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0730 - * @tc.name : hasRight - * @tc.desc : 反向测试 给设备名字为字母 + * @tc.number: SUB_USB_JS_0730 + * @tc.name: hasRight + * @tc.desc: Negative test: parameters exception, the device a letter name */ it('SUB_USB_JS_0730', 0, function () { console.info('usb SUB_USB_JS_0730 begin'); @@ -736,19 +741,17 @@ describe('UsbCoreJsFunctionsTestEx', function () { deviceName = deviceName + 'abcdg' var hasRight = usb.hasRight(deviceName) console.info('usb hasRight ret :' + hasRight); - expect(hasRight == false).assertTrue(); + expect(hasRight).assertFalse(); } - console.info('usb SUB_USB_JS_0730 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_1020 - * @tc.name : hasRight - * @tc.desc : 反向测试 权限查询 参数类型错误 + * @tc.number: SUB_USB_JS_1020 + * @tc.name: hasRight + * @tc.desc: Negative test: Permission query, parameter type error */ - it('SUB_USB_JS_1020', 0, function () { + it('SUB_USB_JS_1020', 0, function () { console.info('usb SUB_USB_JS_1020 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -772,11 +775,11 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1250 - * @tc.name : hasRight - * @tc.desc : 反向测试 权限查询 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1250 + * @tc.name: hasRight + * @tc.desc: Negative test: Permission query, parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1250', 0, function () { + 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') @@ -800,9 +803,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0690 - * @tc.name : requestRight - * @tc.desc : 反向测试 错误设备名字 请求权限 + * @tc.number: SUB_USB_JS_0690 + * @tc.name: requestRight + * @tc.desc: Negative test: Request permission, error diviceName */ it('SUB_USB_JS_0690', 0, function () { console.info('usb SUB_USB_JS_0690 begin'); @@ -833,9 +836,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0700 - * @tc.name : requestRight - * @tc.desc : 反向测试 设备名字为数字 请求权限 + * @tc.number: SUB_USB_JS_0700 + * @tc.name: requestRight + * @tc.desc: Negative test: Request permission, the device name is a number */ it('SUB_USB_JS_0700', 0, function () { console.info('usb SUB_USB_JS_0700 begin'); @@ -866,11 +869,11 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1030 - * @tc.name : requestRight - * @tc.desc : 反向测试 请求权限 参数类型错误 + * @tc.number: SUB_USB_JS_1030 + * @tc.name: requestRight + * @tc.desc: Negative test: Request permission, parameter type error */ - it('SUB_USB_JS_1030', 0, function () { + it('SUB_USB_JS_1030', 0, function () { console.info('usb SUB_USB_JS_1030 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -895,11 +898,11 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1260 - * @tc.name : requestRight - * @tc.desc : 反向测试 请求权限 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1260 + * @tc.name: requestRight + * @tc.desc: Negative test: Request permission, parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1260', 0, function () { + 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') @@ -924,11 +927,11 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1010 - * @tc.name : getDevices - * @tc.desc : 反向测试 获取设备列表 入参错误(无参接口传参) + * @tc.number: SUB_USB_JS_1010 + * @tc.name: getDevices + * @tc.desc: Negative test: Get device list, parameters exception(parameter transfer without parameter interface) */ - it('SUB_USB_JS_1010', 0, function () { + it('SUB_USB_JS_1010', 0, function () { console.info('usb SUB_USB_JS_1010 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -947,11 +950,11 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1050 - * @tc.name : closePipe - * @tc.desc : 反向测试 关闭设备 参数类型错误 + * @tc.number: SUB_USB_JS_1050 + * @tc.name: closePipe + * @tc.desc: Negative test: close device, parameter type error */ - it('SUB_USB_JS_1050', 0, function () { + it('SUB_USB_JS_1050', 0, function () { console.info('usb SUB_USB_JS_1050 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -975,11 +978,11 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1270 - * @tc.name : closePipe - * @tc.desc : 反向测试 关闭设备 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1270 + * @tc.name: closePipe + * @tc.desc: Negative test: close device, parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1270', 0, function () { + 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') @@ -1003,11 +1006,11 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1060 - * @tc.name : getRawDescriptor - * @tc.desc : 反向测试 获取原始USB设备描述符 参数类型错误 + * @tc.number: SUB_USB_JS_1060 + * @tc.name: getRawDescriptor + * @tc.desc: Negative test: Get the original USB descriptor, parameter type error */ - it('SUB_USB_JS_1060', 0, function () { + it('SUB_USB_JS_1060', 0, function () { console.info('usb SUB_USB_JS_1060 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -1031,11 +1034,12 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1280 - * @tc.name : getRawDescriptor - * @tc.desc : 反向测试 获取原始USB设备描述符 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1280 + * @tc.name: getRawDescriptor + * @tc.desc: Negative test: Get the original USB descriptor, parameter number exception, + * necessary parameters not input */ - it('SUB_USB_JS_1280', 0, function () { + 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') @@ -1059,11 +1063,11 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1090 - * @tc.name : removeRight - * @tc.desc : 反向测试 移除权限 参数类型错误 + * @tc.number: SUB_USB_JS_1090 + * @tc.name: removeRight + * @tc.desc: Negative test: Remove Permissions, parameter type error */ - it('SUB_USB_JS_1090', 0, function () { + it('SUB_USB_JS_1090', 0, function () { console.info('usb SUB_USB_JS_1090 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -1088,11 +1092,11 @@ describe('UsbCoreJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1290 - * @tc.name : removeRight - * @tc.desc : 反向测试 移除权限 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1290 + * @tc.name: removeRight + * @tc.desc: Negative test: Remove Permissions, parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1290', 0, function () { + 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') diff --git a/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js b/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js index f56e023419dbb295de68dd0b2e4a72f590b718da..6128aaca5f5596847805d82eecf378c3f8be23f0 100644 --- a/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js +++ b/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js @@ -51,6 +51,10 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } } + gDeviceList = usb.getDevices(); + gDeviceList[0].name; + gDeviceList[0].version; + gDeviceList[0].configs; gPipe = usb.connectDevice(gDeviceList[0]) console.info('usb unit connectDevice gPipe ret : ' + JSON.stringify(gPipe)); }) @@ -72,6 +76,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var bfind = false for (var k = 0; k < testParam.config.interfaces[j].endpoints.length; k++) { var endpoint = testParam.config.interfaces[j].endpoints[k]; + endpoint.number = 1; + endpoint.type = 2; + endpoint.interfaceid = 1; if (endpoint.type == EventConstants.USB_ENDPOINT_XFER_BULK) { bfind = true if (endpoint.direction == usb.USB_REQUEST_DIR_TO_DEVICE) { @@ -113,7 +120,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } } - // 预制传输相关参数 + // Prefabrication transmission related parameters function getTransferTestParam() { var testParam = { config: null, @@ -140,9 +147,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } /** - * @tc.number : SUB_USB_JS_0630 - * @tc.name : bulkTransfer - * @tc.desc : 批量传输 收数据 + * @tc.number: SUB_USB_JS_0630 + * @tc.name: bulkTransfer + * @tc.desc: Positive test: bulk transfer, receive data */ it('SUB_USB_JS_0630', 0, function () { console.info('usb SUB_USB_JS_0630 begin'); @@ -166,8 +173,8 @@ describe('UsbDevicePipeJsFunctionsTest', function () { usb.bulkTransfer(testParam.pip, testParam.inEndpoint, tmpUint8Array, 5000).then(data => { console.info('usb case readData tmpUint8Array buffer : ' + CheckEmptyUtils.ab2str(tmpUint8Array)); console.info('usb case readData ret: ' + data); - console.info('usb case SUB_USB_JS_0630 : PASS'); expect(data >= 0).assertTrue(); + console.info('usb case SUB_USB_JS_0630 : PASS'); }).catch(error => { console.info('usb case readData error : ' + JSON.stringify(error)); expect(false).assertTrue(); @@ -176,9 +183,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0640 - * @tc.name : bulkTransfer - * @tc.desc : 批量传输 发数据 + * @tc.number: SUB_USB_JS_0640 + * @tc.name: bulkTransfer + * @tc.desc: Positive test: bulk transfer, send data */ it('SUB_USB_JS_0640', 0, function () { console.info('usb SUB_USB_JS_0640 begin'); @@ -208,8 +215,8 @@ describe('UsbDevicePipeJsFunctionsTest', function () { usb.bulkTransfer(testParam.pip, testParam.outEndpoint, tmpUint8Array, 5000).then(data => { console.info('usb case SUB_USB_JS_0640 ret: ' + data); console.info('usb case SUB_USB_JS_0640 send data: ' + testParam.sendData); + expect(data > 0).assertTrue(); console.info('usb case SUB_USB_JS_0640 : PASS'); - expect(true).assertTrue(); }).catch(error => { console.info('usb write error : ' + JSON.stringify(error)); expect(false).assertTrue(); @@ -218,9 +225,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0420 - * @tc.name : claimInterface - * @tc.desc : 获取接口 并释放 + * @tc.number: SUB_USB_JS_0420 + * @tc.name: claimInterface + * @tc.desc: Positive test: Get interface, and release */ it('SUB_USB_JS_0420', 0, function () { console.info('usb SUB_USB_JS_0420 begin'); @@ -246,6 +253,11 @@ describe('UsbDevicePipeJsFunctionsTest', function () { console.info('usb case current device.configs.interfaces.length = 0'); } for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { + //Attribute Prefabrication + var interfaces = gDeviceList[0].configs[j].interfaces[k]; + interfaces.id = 1; + interfaces.name = ''; + interfaces.alternateSetting = 0; var isClaim = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[k], true) console.info('usb case claimInterface function return: ' + isClaim); expect(isClaim).assertEqual(0); @@ -259,7 +271,6 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } console.info('usb SUB_USB_JS_0420 : PASS'); - expect(true).assertTrue(); }) function getTransferParam(iCmd, iReqTarType, iReqType, iValue, iIndex) { @@ -281,9 +292,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } /** - * @tc.number : SUB_USB_JS_0740 - * @tc.name : setConfiguration - * @tc.desc : 设置设备配置 + * @tc.number: SUB_USB_JS_0740 + * @tc.name: setConfiguration + * @tc.desc: Positive test: Set Device Configuration */ it('SUB_USB_JS_0740', 0, function () { console.info('usb SUB_USB_JS_0740 begin'); @@ -300,19 +311,24 @@ describe('UsbDevicePipeJsFunctionsTest', function () { gPipe = usb.connectDevice(gDeviceList[0]) for (var j = 0; j < gDeviceList[0].configs.length; j++) { + var configs = gDeviceList[0].configs[j]; + configs.id = 1; + configs.name = ''; + configs.maxPower = 1; + configs.isRemoteWakeup = true; + configs.isSelfPowered = true; var ret = usb.setConfiguration(gPipe, gDeviceList[0].configs[j]) console.info('usb case setConfiguration return : ' + ret); expect(ret).assertEqual(0); } console.info('usb SUB_USB_JS_0740 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0750 - * @tc.name : setConfiguration - * @tc.desc : 反向测试 设置设备配置 + * @tc.number: SUB_USB_JS_0750 + * @tc.name: setConfiguration + * @tc.desc: Negative test: Set Device Configuration */ it('SUB_USB_JS_0750', 0, function () { console.info('usb SUB_USB_JS_0750 begin'); @@ -339,9 +355,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0800 - * @tc.name : setInterface - * @tc.desc : 设置设备接口 + * @tc.number: SUB_USB_JS_0800 + * @tc.name: setInterface + * @tc.desc: Positive test: Set device interface */ it('SUB_USB_JS_0800', 0, function () { console.info('usb SUB_USB_JS_0800 begin'); @@ -361,19 +377,18 @@ describe('UsbDevicePipeJsFunctionsTest', function () { expect(isClaim).assertEqual(0) if (isClaim == 0) { var ret = usb.setInterface(gPipe, gDeviceList[0].configs[j].interfaces[0]) - expect(ret).assertEqual(0); console.info('usb case setInterface return : ' + ret); + expect(ret).assertEqual(0); } } console.info('usb SUB_USB_JS_0800 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0810 - * @tc.name : setInterface - * @tc.desc : 反向测试 设置设备接口 + * @tc.number: SUB_USB_JS_0810 + * @tc.name: setInterface + * @tc.desc: Negative test: Set device interface, error tmpInterface.id */ it('SUB_USB_JS_0810', 0, function () { console.info('usb SUB_USB_JS_0810 begin'); @@ -395,21 +410,20 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var tmpInterface = JSON.parse(JSON.stringify(gDeviceList[0].configs[j].interfaces[0])); tmpInterface.id = 234 var ret = usb.setInterface(gPipe, tmpInterface) - expect(ret).assertLess(0) console.info('usb case setInterface return : ' + ret) + expect(ret).assertLess(0) } } console.info('usb SUB_USB_JS_0810 : PASS'); - expect(true).assertTrue(); }) function callControlTransfer(pip, controlParam, timeout, caseName) { usb.controlTransfer(pip, controlParam, timeout).then(data => { console.info('usb controlTransfer ret data : ' + data + ' ' + caseName); console.info('usb controlTransfer controlParam.data buffer : ' + controlParam.data + ' ' + caseName); + expect(data >= 0).assertTrue(); console.info('usb' + caseName + ': PASS'); - expect(true).assertTrue(); }).catch(error => { console.info('usb controlTransfer error : ' + JSON.stringify(error)); console.info('usb' + caseName + ': FAILED'); @@ -419,9 +433,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } /** - * @tc.number : SUB_USB_JS_0540 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 GetDescriptor: cmd 6 target 2 reqType 128 value 512 index 0 + * @tc.number: SUB_USB_JS_0540 + * @tc.name: controlTransfer + * @tc.desc: Positive test: control transfer, GetDescriptor: cmd 6 target 2 reqType 128 value 512 index 0 */ it('SUB_USB_JS_0540', 0, function () { console.info('usb SUB_USB_JS_0540 begin'); @@ -443,9 +457,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0550 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 GetStatus: cmd 0 target 0 reqType 128 value 0 index 0 + * @tc.number: SUB_USB_JS_0550 + * @tc.name: controlTransfer + * @tc.desc: Positive test: control transfer, GetStatus: cmd 0 target 0 reqType 128 value 0 index 0 */ it('SUB_USB_JS_0550', 0, function () { console.info('usb SUB_USB_JS_0550 begin'); @@ -467,9 +481,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0560 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 GetConfiguration: cmd 8 target 0 reqType 128 value 0 index 0 + * @tc.number: SUB_USB_JS_0560 + * @tc.name: controlTransfer + * @tc.desc: Positive test: control transfer, GetConfiguration: cmd 8 target 0 reqType 128 value 0 index 0 */ it('SUB_USB_JS_0560', 0, function () { console.info('usb SUB_USB_JS_0560 begin'); @@ -491,9 +505,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0570 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 GetInterface: cmd 10 target 0 reqType 129 value 0 index 1 + * @tc.number: SUB_USB_JS_0570 + * @tc.name: controlTransfer + * @tc.desc: Positive test: control transfer, GetInterface: cmd 10 target 0 reqType 129 value 0 index 1 */ it('SUB_USB_JS_0570', 0, function () { console.info('usb SUB_USB_JS_0570 begin'); @@ -515,9 +529,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0580 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 ClearFeature: cmd 1 target 0 reqType 0 value 0 index 0 + * @tc.number: SUB_USB_JS_0580 + * @tc.name: controlTransfer + * @tc.desc: Positive test: control transfer, ClearFeature: cmd 1 target 0 reqType 0 value 0 index 0 */ it('SUB_USB_JS_0580', 0, function () { console.info('usb SUB_USB_JS_0580 begin'); @@ -539,11 +553,11 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0590 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 ClearFeature: cmd 255 target 1 reqType 129 value 512 index 0 + * @tc.number: SUB_USB_JS_0590 + * @tc.name: controlTransfer + * @tc.desc: Positive test: control transfer, ClearFeature: cmd 255 target 1 reqType 129 value 512 index 0 */ - it('SUB_USB_JS_0590', 0, function () { + it('SUB_USB_JS_0590', 0, function () { console.info('usb SUB_USB_JS_0590 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -563,11 +577,11 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0600 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 ClearFeature: cmd 255 target 2 reqType 34 value 512 index 0 + * @tc.number: SUB_USB_JS_0600 + * @tc.name: controlTransfer + * @tc.desc: Positive test: control transfer, ClearFeature: cmd 255 target 2 reqType 34 value 512 index 0 */ - it('SUB_USB_JS_0600', 0, function () { + it('SUB_USB_JS_0600', 0, function () { console.info('usb SUB_USB_JS_0600 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -587,11 +601,11 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0610 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 ClearFeature: cmd 255 target 3 reqType 67 value 512 index 0 + * @tc.number: SUB_USB_JS_0610 + * @tc.name: controlTransfer + * @tc.desc: Positive test: control transfer, ClearFeature: cmd 255 target 3 reqType 67 value 512 index 0 */ - it('SUB_USB_JS_0610', 0, function () { + it('SUB_USB_JS_0610', 0, function () { console.info('usb SUB_USB_JS_0610 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -611,11 +625,11 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0620 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 ClearFeature: cmd 255 target 3 reqType 35 value 0 index 0 + * @tc.number: SUB_USB_JS_0620 + * @tc.name: controlTransfer + * @tc.desc: Positive test: control transfer, ClearFeature: cmd 255 target 3 reqType 35 value 0 index 0 */ - it('SUB_USB_JS_0620', 0, function () { + it('SUB_USB_JS_0620', 0, function () { console.info('usb SUB_USB_JS_0620 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -635,11 +649,11 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_1140 - * @tc.name : controlTransfer - * @tc.desc : 反向测试 控制传输 参数类型错误 + * @tc.number: SUB_USB_JS_1140 + * @tc.name: controlTransfer + * @tc.desc: Negative test: control transfer, parameter number exception, input a parameter */ - it('SUB_USB_JS_1140', 0, function () { + it('SUB_USB_JS_1140', 0, function () { console.info('usb SUB_USB_JS_1140 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -663,11 +677,11 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_1300 - * @tc.name : controlTransfer - * @tc.desc : 反向测试 控制传输 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1300 + * @tc.name: controlTransfer + * @tc.desc: Negative test: control transfer, parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1300', 0, function () { + 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') @@ -689,5 +703,37 @@ describe('UsbDevicePipeJsFunctionsTest', function () { console.info('usb SUB_USB_JS_1300 : PASS'); } }) + + /** + * @tc.number: SUB_USB_JS_1440 + * @tc.name: controlTransfer + * @tc.desc: Negative test: control transfer, parameter pipe type error + */ + it('SUB_USB_JS_1440', 0, function () { + console.info('usb SUB_USB_JS_1440 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 + } + var testParamPip = "invalid"; + var timeout = 5000; + 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 { + var maskCode = usb.controlTransfer(testParamPip, controlParam, timeout); + console.info('usb 1440 case controlTransfer return: ' + maskCode); + expect(false).assertTrue(); + } catch (err) { + console.info('usb 1440 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1440 : PASS'); + } + }) }) } diff --git a/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunitEx.test.js b/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunitEx.test.js index cb5c3fb42ae383e89998d5c5352fcb4b30e462f9..beebaea2c42a0996220450c7d8d828b218f744fd 100644 --- a/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunitEx.test.js +++ b/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunitEx.test.js @@ -114,7 +114,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } } - // 预制传输相关参数 + // Prefabrication transmission related parameters function getTransferTestParam() { var testParam = { device: null, @@ -141,9 +141,9 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } /** - * @tc.number : SUB_USB_JS_0650 - * @tc.name : bulkTransfer - * @tc.desc : 反向测试 批量传输 发数据 修改 outEndpoint.address = 123 + * @tc.number: SUB_USB_JS_0650 + * @tc.name: bulkTransfer + * @tc.desc: Negative test: bulk transfer, send data, error outEndpoint.address = 123 */ it('SUB_USB_JS_0650', 0, function () { console.info('usb SUB_USB_JS_0650 begin'); @@ -167,8 +167,8 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { TmpTestParam.outEndpoint.address = 123 usb.bulkTransfer(TmpTestParam.pip, TmpTestParam.outEndpoint, tmpUint8Array, 5000).then(data => { console.info('usb case SUB_USB_JS_0650 ret: ' + data); - console.info('usb case SUB_USB_JS_0650 : PASS'); expect(data).assertEqual(-1); + console.info('usb case SUB_USB_JS_0650 : PASS'); }).catch(error => { console.info('usb 03 write error : ' + JSON.stringify(error)); expect(false).assertFalse(); @@ -178,9 +178,9 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0660 - * @tc.name : bulkTransfer - * @tc.desc : 反向测试 批量传输 发数据 修改 outEndpoint.number = 123 + * @tc.number: SUB_USB_JS_0660 + * @tc.name: bulkTransfer + * @tc.desc: Negative test: bulk transfer, send data, error outEndpoint.number = 123 */ it('SUB_USB_JS_0660', 0, function () { console.info('usb SUB_USB_JS_0660 begin'); @@ -204,8 +204,8 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { TmpTestParam.outEndpoint.number = 123 usb.bulkTransfer(TmpTestParam.pip, TmpTestParam.outEndpoint, tmpUint8Array, 5000).then(data => { console.info('usb case SUB_USB_JS_0660 ret: ' + data); - console.info('usb case SUB_USB_JS_0660 : PASS'); expect(data).assertEqual(-1); + console.info('usb case SUB_USB_JS_0660 : PASS'); }).catch(error => { console.info('usb 04 write error : ' + JSON.stringify(error)); expect(false).assertFalse(); @@ -215,9 +215,9 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0670 - * @tc.name : bulkTransfer - * @tc.desc : 反向测试 批量传输 发数据 修改 outEndpoint.type = 123 + * @tc.number: SUB_USB_JS_0670 + * @tc.name: bulkTransfer + * @tc.desc: Negative test: bulk transfer, send data, error outEndpoint.type = 123 */ it('SUB_USB_JS_0670', 0, function () { console.info('usb SUB_USB_JS_0670 begin'); @@ -241,8 +241,8 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { TmpTestParam.outEndpoint.type = 123 usb.bulkTransfer(TmpTestParam.pip, TmpTestParam.outEndpoint, tmpUint8Array, 5000).then(data => { console.info('usb case SUB_USB_JS_0670 ret: ' + data); - console.info('usb case SUB_USB_JS_0670 : PASS'); expect(data).assertEqual(-1); + console.info('usb case SUB_USB_JS_0670 : PASS'); }).catch(error => { console.info('usb 05 write error : ' + JSON.stringify(error)); expect(false).assertFalse(); @@ -252,9 +252,9 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1100 - * @tc.name : bulkTransfer - * @tc.desc : 反向测试 批量传输 参数类型错误 + * @tc.number: SUB_USB_JS_1100 + * @tc.name: bulkTransfer + * @tc.desc: Negative test: bulk transfer, parameter number exception, input a parameter */ it('SUB_USB_JS_1100', 0, function () { console.info('usb SUB_USB_JS_1100 begin'); @@ -263,11 +263,15 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { expect(false).assertFalse(); return } - if (gDeviceList.length == 0) { - console.info('usb case get_device_list is null') + var testParam = getTransferTestParam() + if (testParam.interface == null || testParam.inEndpoint == null) { expect(false).assertTrue(); return } + + testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true); + expect(testParam.isClaimed).assertEqual(0); + try { var maskCode = usb.bulkTransfer("invalid"); console.info('usb 1100 case bulkTransfer return: ' + maskCode); @@ -280,11 +284,11 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1310 - * @tc.name : bulkTransfer - * @tc.desc : 反向测试 批量传输 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1310 + * @tc.name: bulkTransfer + * @tc.desc: Negative test: bulk transfer, parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1310', 0, function () { + 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') @@ -308,9 +312,46 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0430 - * @tc.name : claimInterface - * @tc.desc : 反向测试 USBInterface传入异常id 获取接口 失败 + * @tc.number: SUB_USB_JS_1420 + * @tc.name: bulkTransfer + * @tc.desc: Negative test: bulk transfer, parameter pipe type error + */ + it('SUB_USB_JS_1420', 0, function () { + console.info('usb SUB_USB_JS_1420 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 tmpTestParam = testParam; + tmpTestParam.pip = "invalid"; + var tmpUint8Array = new Uint8Array(testParam.maxInSize); + try { + var maskCode = usb.bulkTransfer(tmpTestParam.pip, tmpTestParam.inEndpoint, tmpUint8Array, 5000); + console.info('usb 1420 case bulkTransfer return: ' + maskCode); + expect(false).assertTrue(); + } catch (err) { + console.info('usb 1420 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1420 : PASS'); + } + }) + + /** + * @tc.number: SUB_USB_JS_0430 + * @tc.name: claimInterface + * @tc.desc: Negative test: Get interface, USBInterface afferent error id */ it('SUB_USB_JS_0430', 0, function () { console.info('usb SUB_USB_JS_0430 begin'); @@ -336,22 +377,21 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { console.info('usb case SUB_USB_JS_0430 current device.configs.interfaces.length = 0'); } for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { - var TmpInterface = gDeviceList[0].configs[j].interfaces[k] - TmpInterface.id = 123 - var isClaim = usb.claimInterface(gPipe, TmpInterface, true) + var TmpInterface = gDeviceList[0].configs[j].interfaces[k]; + TmpInterface.id = 123; + var isClaim = usb.claimInterface(gPipe, TmpInterface, true); console.info('usb case claimInterface function return: ' + isClaim); expect(isClaim).assertLess(0); } } console.info('usb SUB_USB_JS_0430 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0440 - * @tc.name : claimInterface - * @tc.desc : 反向测试 USBInterface传入异常protocol 获取接口 失败 + * @tc.number: SUB_USB_JS_0440 + * @tc.name: claimInterface + * @tc.desc: Negative test: Get interface, USBInterface afferent error protocol */ it('SUB_USB_JS_0440', 0, function () { console.info('usb SUB_USB_JS_0440 begin'); @@ -386,13 +426,12 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } console.info('usb SUB_USB_JS_0440 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0450 - * @tc.name : claimInterface - * @tc.desc : 反向测试 USBInterface传入异常clazz 获取接口 失败 + * @tc.number: SUB_USB_JS_0450 + * @tc.name: claimInterface + * @tc.desc: Negative test: Get interface, USBInterface afferent error clazz */ it('SUB_USB_JS_0450', 0, function () { console.info('usb SUB_USB_JS_0450 begin'); @@ -427,13 +466,12 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } console.info('usb SUB_USB_JS_0450 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0460 - * @tc.name : claimInterface - * @tc.desc : 反向测试 USBInterface传入异常name 获取接口 失败 + * @tc.number: SUB_USB_JS_0460 + * @tc.name: claimInterface + * @tc.desc: Negative test: Get interface, USBInterface afferent error name */ it('SUB_USB_JS_0460', 0, function () { console.info('usb SUB_USB_JS_0460 begin'); @@ -468,13 +506,12 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } console.info('usb SUB_USB_JS_0460 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0470 - * @tc.name : claimInterface - * @tc.desc : 反向测试 USBInterface传入异常subClass 获取接口 失败 + * @tc.number: SUB_USB_JS_0470 + * @tc.name: claimInterface + * @tc.desc: Negative test: Get interface, USBInterface afferent error subClass */ it('SUB_USB_JS_0470', 0, function () { console.info('usb SUB_USB_JS_0470 begin'); @@ -509,15 +546,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } console.info('usb SUB_USB_JS_0470 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_1110 - * @tc.name : claimInterface - * @tc.desc : 反向测试 获取接口 参数类型错误 + * @tc.number: SUB_USB_JS_1110 + * @tc.name: claimInterface + * @tc.desc: Negative test: Get interface, parameter number exception, input a parameter */ - it('SUB_USB_JS_1110', 0, function () { + it('SUB_USB_JS_1110', 0, function () { console.info('usb SUB_USB_JS_1110 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -546,11 +582,11 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1320 - * @tc.name : claimInterface - * @tc.desc : 反向测试 获取接口 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1320 + * @tc.name: claimInterface + * @tc.desc: Negative test: Get interface, parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1320', 0, function () { + 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') @@ -568,7 +604,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { return } try { - var maskCode = usb.claimInterface("invalid"); + var maskCode = usb.claimInterface(); console.info('usb 1320 case claimInterface return: ' + maskCode); expect(false).assertTrue(); } catch (err) { @@ -579,9 +615,48 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0280 - * @tc.name : releaseInterface - * @tc.desc : 反向测试 获取接口 release传入Interface的错误ID 并释放 + * @tc.number: SUB_USB_JS_1430 + * @tc.name: claimInterface + * @tc.desc: Negative test: Get interface, parameter pipe type error + */ + it('SUB_USB_JS_1430', 0, function () { + console.info('usb SUB_USB_JS_1430 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 testParamPip = "invalid"; + + try { + for (var j = 0; j < gDeviceList[0].configs.length; j++) { + if (gDeviceList[0].configs[j].interfaces.length == 0) { + console.info('usb case SUB_USB_JS_1430 current device.configs.interfaces.length = 0'); + } + for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { + var TmpInterface = gDeviceList[0].configs[j].interfaces[k]; + var maskCode = usb.claimInterface(testParamPip, TmpInterface, true); + console.info('usb 1430 case claimInterface return: ' + maskCode); + expect(false).assertTrue(); + } + } + } catch (err) { + console.info('usb 1430 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1430 : PASS'); + } + }) + + /** + * @tc.number: SUB_USB_JS_0280 + * @tc.name: releaseInterface + * @tc.desc: Negative test: release Interface, error Interface id */ it('SUB_USB_JS_0280', 0, function () { console.info('usb SUB_USB_JS_0280 begin'); @@ -616,13 +691,12 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } console.info('usb SUB_USB_JS_0280 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0290 - * @tc.name : releaseInterface - * @tc.desc : 反向测试 获取接口 release传入Interface的错误name 并释放 + * @tc.number: SUB_USB_JS_0290 + * @tc.name: releaseInterface + * @tc.desc: Negative test: release Interface, error Interface name */ it('SUB_USB_JS_0290', 0, function () { console.info('usb SUB_USB_JS_0290 begin'); @@ -657,13 +731,12 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } console.info('usb SUB_USB_JS_0290 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0300 - * @tc.name : releaseInterface - * @tc.desc : 反向测试 获取接口 release传入Interface的错误clazz 并释放 + * @tc.number: SUB_USB_JS_0300 + * @tc.name: releaseInterface + * @tc.desc: Negative test: release Interface, error Interface clazz */ it('SUB_USB_JS_0300', 0, function () { console.info('usb SUB_USB_JS_0300 begin'); @@ -698,13 +771,12 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } console.info('usb SUB_USB_JS_0300 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0310 - * @tc.name : releaseInterface - * @tc.desc : 反向测试 获取接口 release传入Interface的错误protocol 并释放 + * @tc.number: SUB_USB_JS_0310 + * @tc.name: releaseInterface + * @tc.desc: Negative test: release Interface, error Interface protocol */ it('SUB_USB_JS_0310', 0, function () { console.info('usb SUB_USB_JS_0310 begin'); @@ -739,13 +811,12 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } console.info('usb SUB_USB_JS_0310 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0320 - * @tc.name : releaseInterface - * @tc.desc : 反向测试 获取接口 release传入Interface的错误subClass 并释放 + * @tc.number: SUB_USB_JS_0320 + * @tc.name: releaseInterface + * @tc.desc: Negative test: release Interface, error Interface subClass */ it('SUB_USB_JS_0320', 0, function () { console.info('usb SUB_USB_JS_0320 begin'); @@ -780,15 +851,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } console.info('usb SUB_USB_JS_0320 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_1150 - * @tc.name : releaseInterface - * @tc.desc : 反向测试 释放接口 参数类型错误 + * @tc.number: SUB_USB_JS_1150 + * @tc.name: releaseInterface + * @tc.desc: Negative test: release Interface, parameter number exception, input a parameter */ - it('SUB_USB_JS_1150', 0, function () { + it('SUB_USB_JS_1150', 0, function () { console.info('usb SUB_USB_JS_1150 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -801,7 +871,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { return } if (gDeviceList[0].configs.length == 0) { - console.info('usb 1110 case current device.configs.length = 0'); + console.info('usb 1150 case current device.configs.length = 0'); expect(false).assertTrue(); return } @@ -818,11 +888,11 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1330 - * @tc.name : releaseInterface - * @tc.desc : 反向测试 释放接口 参数类型错误 + * @tc.number: SUB_USB_JS_1330 + * @tc.name: releaseInterface + * @tc.desc: Negative test: release Interface, parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1330', 0, function () { + 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') @@ -851,9 +921,43 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0820 - * @tc.name : setInterface - * @tc.desc : 反向测试 Interface的protocol 设置设备接口 + * @tc.number: SUB_USB_JS_1450 + * @tc.name: releaseInterface + * @tc.desc: Negative test: release Interface, parameter pipe type error + */ + it('SUB_USB_JS_1450', 0, function () { + console.info('usb SUB_USB_JS_1450 begin'); + if (portCurrentMode == 1) { + console.info('usb case get_device port is device') + expect(false).assertFalse(); + return + } + + var testParamPip = "invalid"; + + try { + for (var j = 0; j < gDeviceList[0].configs.length; j++) { + if (gDeviceList[0].configs[j].interfaces.length == 0) { + console.info('usb case SUB_USB_JS_1450 current device.configs.interfaces.length = 0'); + } + for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { + var TmpInterface = gDeviceList[0].configs[j].interfaces[k]; + var maskCode = usb.releaseInterface(testParamPip, TmpInterface); + console.info('usb 1450 case releaseInterface return: ' + maskCode); + expect(false).assertTrue(); + } + } + } catch (err) { + console.info('usb 1450 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1450 : PASS'); + } + }) + + /** + * @tc.number: SUB_USB_JS_0820 + * @tc.name: setInterface + * @tc.desc: Negative test: Set device interface, Interface protocol error */ it('SUB_USB_JS_0820', 0, function () { console.info('usb SUB_USB_JS_0820 begin'); @@ -874,18 +978,17 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { var tmpInterface = gDeviceList[0].configs[j].interfaces[0] tmpInterface.protocol = 482 var ret = usb.setInterface(gPipe, tmpInterface) - expect(ret).assertLess(0) console.info('usb case setInterface return : ' + ret) + expect(ret).assertLess(0); } console.info('usb SUB_USB_JS_0820 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0830 - * @tc.name : setInterface - * @tc.desc : 反向测试 Interface的clazz 设置设备接口 + * @tc.number: SUB_USB_JS_0830 + * @tc.name: setInterface + * @tc.desc: Negative test: Set device interface, Interface clazz error */ it('SUB_USB_JS_0830', 0, function () { console.info('usb SUB_USB_JS_0830 begin'); @@ -906,19 +1009,17 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { var tmpInterface = gDeviceList[0].configs[j].interfaces[0] tmpInterface.clazz = 482 var ret = usb.setInterface(gPipe, tmpInterface) - expect(ret).assertLess(0) console.info('usb case setInterface return : ' + ret) - + expect(ret).assertLess(0); } console.info('usb SUB_USB_JS_0830 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0840 - * @tc.name : setInterface - * @tc.desc : 反向测试 Interface的subClass 设置设备接口 + * @tc.number: SUB_USB_JS_0840 + * @tc.name: setInterface + * @tc.desc: Negative test: Set device interface, Interface subClass error */ it('SUB_USB_JS_0840', 0, function () { console.info('usb SUB_USB_JS_0840 begin'); @@ -939,19 +1040,18 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { var tmpInterface = gDeviceList[0].configs[j].interfaces[0] tmpInterface.subClass = 482 var ret = usb.setInterface(gPipe, tmpInterface) - expect(ret).assertLess(0) console.info('usb case setInterface return : ' + ret) + expect(ret).assertLess(0); } console.info('usb SUB_USB_JS_0840 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0850 - * @tc.name : setInterface - * @tc.desc : 反向测试 Interface的name 设置设备接口 + * @tc.number: SUB_USB_JS_0850 + * @tc.name: setInterface + * @tc.desc: Negative test: Set device interface, Interface name error */ it('SUB_USB_JS_0850', 0, function () { console.info('usb SUB_USB_JS_0840 begin'); @@ -972,20 +1072,19 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { var tmpInterface = gDeviceList[0].configs[j].interfaces[0] tmpInterface.name = 'wer32' var ret = usb.setInterface(gPipe, tmpInterface) - expect(ret).assertLess(0) console.info('usb case setInterface return : ' + ret) + expect(ret).assertLess(0); } console.info('usb SUB_USB_JS_0850 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_1130 - * @tc.name : setInterface - * @tc.desc : 反向测试 设置设备接口 参数类型错误 + * @tc.number: SUB_USB_JS_1130 + * @tc.name: setInterface + * @tc.desc: Negative test: Set device interface, parameter number exception, input a parameter */ - it('SUB_USB_JS_1130', 0, function () { + it('SUB_USB_JS_1130', 0, function () { console.info('usb SUB_USB_JS_1130 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -1009,11 +1108,11 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1340 - * @tc.name : setInterface - * @tc.desc : 反向测试 设置设备接口 参数类型错误 + * @tc.number: SUB_USB_JS_1340 + * @tc.name: setInterface + * @tc.desc: Negative test: Set device interface, parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1340', 0, function () { + 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') @@ -1037,9 +1136,48 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0760 - * @tc.name : setConfiguration - * @tc.desc : 反向测试 USBConfig的name 赋值错误 设置设备配置 + * @tc.number: SUB_USB_JS_1460 + * @tc.name: setInterface + * @tc.desc: Negative test: Set device interface, parameter pipe type error + */ + it('SUB_USB_JS_1460', 0, function () { + console.info('usb SUB_USB_JS_1460 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 testParamPip = "invalid"; + + try { + for (var j = 0; j < gDeviceList[0].configs.length; j++) { + if (gDeviceList[0].configs[j].interfaces.length == 0) { + console.info('usb case SUB_USB_JS_1460 current device.configs.interfaces.length = 0'); + } + for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { + var TmpInterface = gDeviceList[0].configs[j].interfaces[k]; + var maskCode = usb.setInterface(testParamPip, TmpInterface); + console.info('usb 1460 case setInterface return: ' + maskCode); + expect(false).assertTrue(); + } + } + } catch (err) { + console.info('usb 1460 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1460 : PASS'); + } + }) + + /** + * @tc.number: SUB_USB_JS_0760 + * @tc.name: setConfiguration + * @tc.desc: Negative test: Set Device Configuration, USBConfig name error */ it('SUB_USB_JS_0760', 0, function () { console.info('usb SUB_USB_JS_0760 begin'); @@ -1066,9 +1204,9 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0770 - * @tc.name : setConfiguration - * @tc.desc : 反向测试 USBConfig的name 赋值错误 设置设备配置 + * @tc.number: SUB_USB_JS_0770 + * @tc.name: setConfiguration + * @tc.desc: Negative test: Set Device Configuration, USBConfig name error */ it('SUB_USB_JS_0770', 0, function () { console.info('usb SUB_USB_JS_0770 begin'); @@ -1096,9 +1234,9 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0780 - * @tc.name : setConfiguration - * @tc.desc : 反向测试 USBConfig的attributes 赋值错误 设置设备配置 + * @tc.number: SUB_USB_JS_0780 + * @tc.name: setConfiguration + * @tc.desc: Negative test: Set Device Configuration, USBConfig attributes error */ it('SUB_USB_JS_0780', 0, function () { console.info('usb SUB_USB_JS_0780 begin'); @@ -1125,11 +1263,11 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0790 - * @tc.name : setConfiguration - * @tc.desc : 反向测试 USBConfig的name interval(1-16) 赋值错误 设置设备配置 + * @tc.number: SUB_USB_JS_0790 + * @tc.name: setConfiguration + * @tc.desc: Negative test: Set Device Configuration, USBConfig name interval(1-16) error */ - it('SUB_USB_JS_0790', 0, function () { + it('SUB_USB_JS_0790', 0, function () { console.info('usb SUB_USB_JS_0790 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -1155,11 +1293,11 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1120 - * @tc.name : setConfiguration - * @tc.desc : 反向测试 设置设备配置 参数类型错误 + * @tc.number: SUB_USB_JS_1120 + * @tc.name: setConfiguration + * @tc.desc: Negative test: Set Device Configuration, parameter number exception, input a parameter */ - it('SUB_USB_JS_1120', 0, function () { + it('SUB_USB_JS_1120', 0, function () { console.info('usb SUB_USB_JS_1120 begin'); if (portCurrentMode == 1) { console.info('usb case get_device port is device') @@ -1183,11 +1321,11 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1350 - * @tc.name : setConfiguration - * @tc.desc : 反向测试 设置设备配置 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1350 + * @tc.name: setConfiguration + * @tc.desc: Negative test: Set Device Configuration, parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1350', 0, function () { + 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') @@ -1209,5 +1347,44 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { console.info('usb SUB_USB_JS_1350 : PASS'); } }) + + /** + * @tc.number: SUB_USB_JS_1470 + * @tc.name: setConfiguration + * @tc.desc: Negative test: Set Device Configuration, parameter pipe type error + */ + it('SUB_USB_JS_1470', 0, function () { + console.info('usb SUB_USB_JS_1470 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 testParamPip = "invalid"; + + try { + for (var j = 0; j < gDeviceList[0].configs.length; j++) { + if (gDeviceList[0].configs[j].interfaces.length == 0) { + console.info('usb case SUB_USB_JS_1470 current device.configs.interfaces.length = 0'); + } + 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); + expect(false).assertTrue(); + } + } + } catch (err) { + console.info('usb 1470 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1470 : PASS'); + } + }) }) } diff --git a/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit_A.test.js b/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit_A.test.js deleted file mode 100644 index 77b4dc02681537d02e9bd824ce24efcc4412298b..0000000000000000000000000000000000000000 --- a/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit_A.test.js +++ /dev/null @@ -1,653 +0,0 @@ -/* - * Copyright (c) 2021-2022 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 usb from '@ohos.usb'; -import CheckEmptyUtils from './CheckEmptyUtils.js'; -import EventConstants from './EventConstants.js'; -import parameter from '@ohos.systemparameter'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' - -/* usb device pipe test */ -export default function UsbDevicePipeJsFunctionsTestA() { -describe('UsbDevicePipeJsFunctionsTestA', function () { - var gDeviceList - var gPipe - var portCurrentMode - - beforeAll(function () { - console.log('*************Usb Unit UsbDevicePipeJsFunctionsTestA Begin*************'); - var Version = usb.getVersion() - console.info('usb unit begin test getversion :' + Version) - // version > 17 host currentMode = 2 device currentMode = 1 - var usbPortList = usb.getPorts() - gDeviceList = usb.getDevices(); - if (usbPortList.length > 0) { - if (gDeviceList.length > 0) { - if (usbPortList[0].status.currentMode == 1) { - usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => { - portCurrentMode = 2 - console.info('usb case setPortRoles return: ' + data); - }).catch(error => { - console.info('usb case setPortRoles error : ' + error); - }); - CheckEmptyUtils.sleep(8000) - console.log('*************Usb Unit switch to host Begin*************'); - } - } else { - portCurrentMode = 1 - } - - } - - gDeviceList = usb.getDevices(); - gDeviceList[0].name; - gDeviceList[0].version; - gDeviceList[0].configs; - gPipe = usb.connectDevice(gDeviceList[0]) - console.info('usb unit connectDevice gPipe ret : ' + JSON.stringify(gPipe)); - }) - - beforeEach(function () { - console.info('beforeEach: *************Usb Unit Test Case*************'); - }) - afterEach(function () { - console.info('afterEach: *************Usb Unit Test Case*************'); - }) - - afterAll(function () { - var isPipClose = usb.closePipe(gPipe) - console.info('usb unit close gPipe ret : ' + isPipClose); - console.log('*************Usb Unit UsbDevicePipeJsFunctionsTest End*************'); - }) - - function findInitPoint(testParam, j) { - var bfind = false - for (var k = 0; k < testParam.config.interfaces[j].endpoints.length; k++) { - var endpoint = testParam.config.interfaces[j].endpoints[k]; - endpoint.number = 1; - endpoint.type = 1; - endpoint.interfaceid = 1; - if (endpoint.type == EventConstants.USB_ENDPOINT_XFER_BULK) { - bfind = true - if (endpoint.direction == usb.USB_REQUEST_DIR_TO_DEVICE) { - testParam.maxOutSize = endpoint.maxPacketSize; - testParam.outEndpoint = endpoint; - } else if (endpoint.direction == usb.USB_REQUEST_DIR_FROM_DEVICE) { - testParam.maxInSize = endpoint.maxPacketSize; - testParam.inEndpoint = endpoint - } - } - } - if (bfind) { - testParam.interface = testParam.config.interfaces[j] - return bfind - } - return false - } - - function getFlag(testParam, j) { - if (testParam.config.interfaces[j].endpoints.length == 0) { - return false - } - - if (testParam.config.interfaces[j].clazz != 10 || - testParam.config.interfaces[j].subclass != 0 || - testParam.config.interfaces[j].protocol != 2) { - return false - } - return true - } - - function initPoint(testParam) { - for (var j = 0; j < testParam.config.interfaces.length; j++) { - if (getFlag(testParam, j) == true) { - if (findInitPoint(testParam, j) == true) { - break - } - } - } - } - - function getTransferTestParam() { - var testParam = { - config: null, - device: null, - pip: null, - inEndpoint: null, - interface: null, - outEndpoint: null, - usbRequest: null, - sendData: '', - isClaimed: 0, - maxInSize: 1024, - maxOutSize: 1024 - } - - console.info('usb case gDeviceList.length: ' + gDeviceList.length); - for (var i = 0; i < gDeviceList.length; i++) { - testParam.device = gDeviceList[i] - testParam.config = testParam.device.configs[0] - testParam.pip = gPipe - initPoint(testParam) - } - return testParam - } - - /** - * @tc.number : SUB_USB_JS_0630 - * @tc.name : bulkTransfer - * @tc.desc : 批量传输 收数据 - */ - it('SUB_USB_JS_0630', 0, function () { - console.info('usb SUB_USB_JS_0630 begin'); - console.info('usb SUB_USB_JS_0630 portcurrentMode ret : ' + portCurrentMode) - 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) { - 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 = new Uint8Array(testParam.maxInSize); - usb.bulkTransfer(testParam.pip, testParam.inEndpoint, tmpUint8Array, 5000).then(data => { - console.info('usb case readData tmpUint8Array buffer : ' + CheckEmptyUtils.ab2str(tmpUint8Array)); - console.info('usb case readData ret: ' + data); - console.info('usb case SUB_USB_JS_0630 : PASS'); - expect(data >= 0).assertTrue(); - }).catch(error => { - console.info('usb case readData error : ' + JSON.stringify(error)); - expect(false).assertTrue(); - }); - CheckEmptyUtils.sleep(3000); - }) - - /** - * @tc.number : SUB_USB_JS_0640 - * @tc.name : bulkTransfer - * @tc.desc : 批量传输 发数据 - */ - it('SUB_USB_JS_0640', 0, function () { - console.info('usb SUB_USB_JS_0640 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.outEndpoint == null) { - expect(false).assertTrue(); - return - } - - testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true); - expect(testParam.isClaimed).assertEqual(0); - - testParam.sendData = 'send default'; - try { - testParam.sendData = parameter.getSync('test_usb', 'default'); - console.log('usb parameter ' + JSON.stringify(testParam.sendData)); - } catch (e) { - console.log('usb parameter getSync unexpected error: ' + e); - } - - var tmpUint8Array = CheckEmptyUtils.str2ab(testParam.sendData); - usb.bulkTransfer(testParam.pip, testParam.outEndpoint, tmpUint8Array, 5000).then(data => { - console.info('usb case SUB_USB_JS_0640 ret: ' + data); - console.info('usb case SUB_USB_JS_0640 send data: ' + testParam.sendData); - console.info('usb case SUB_USB_JS_0640 : PASS'); - expect(true).assertTrue(); - }).catch(error => { - console.info('usb write error : ' + JSON.stringify(error)); - expect(false).assertTrue(); - }); - CheckEmptyUtils.sleep(3000); - }) - - /** - * @tc.number : SUB_USB_JS_0420 - * @tc.name : claimInterface - * @tc.desc : 获取接口 并释放 - */ - it('SUB_USB_JS_0420', 0, function () { - console.info('usb SUB_USB_JS_0420 begin'); - if (portCurrentMode == 1) { - console.info('usb case get_device port is device') - expect(false).assertFalse(); - return - } - if (gDeviceList.length == 0) { - console.info('usb 01 case get_device_list is null') - expect(gDeviceList.length).assertEqual(-1); - return - } - - if (gDeviceList[0].configs.length == 0) { - console.info('usb 01 case current device.configs.length = 0'); - expect(false).assertTrue(); - return - } - - for (var j = 0; j < gDeviceList[0].configs.length; j++) { - if (gDeviceList[0].configs[j].interfaces.length == 0) { - console.info('usb case current device.configs.interfaces.length = 0'); - } - for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { - //属性预制 - var interfaces = gDeviceList[0].configs[j].interfaces[k]; - interfaces.id = 1; - interfaces.name = ''; - interfaces.alternateSetting = 1; - var isClaim = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[k], true) - console.info('usb case claimInterface function return: ' + isClaim); - expect(isClaim).assertEqual(0); - if (isClaim == 0) { - isClaim = usb.releaseInterface(gPipe, gDeviceList[0].configs[j].interfaces[k]) - console.info('usb case releaseInterface function return: ' + isClaim); - expect(isClaim).assertEqual(0); - gPipe = usb.connectDevice(gDeviceList[0]) - } - } - } - - console.info('usb SUB_USB_JS_0420 : PASS'); - expect(true).assertTrue(); - }) - - function getTransferParam(iCmd, iReqType, iValue, iIndex) { - var tmpUint8Array = new Uint8Array(512); - var requestCmd = iCmd - var requestType = iReqType - var value = iValue; - var index = iIndex; - var controlParam = { - request: requestCmd, - reqType: requestType, - value: value, - index: index, - data: tmpUint8Array - } - return controlParam - } - - /** - * @tc.number : SUB_USB_JS_0740 - * @tc.name : setConfiguration - * @tc.desc : 设置设备接口 - */ - it('SUB_USB_JS_0740', 0, function () { - console.info('usb SUB_USB_JS_0740 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]) - for (var j = 0; j < gDeviceList[0].configs.length; j++) { - var configs = gDeviceList[0].configs[j]; - configs.id = 1; - configs.name = ''; - configs.maxPower = 1; - configs.isRemoteWakeup = true; - configs.isSelfPowered = true; - var ret = usb.setConfiguration(gPipe, gDeviceList[0].configs[j]) - console.info('usb case setConfiguration return : ' + ret); - expect(ret).assertEqual(0); - } - - console.info('usb SUB_USB_JS_0740 : PASS'); - expect(true).assertTrue(); - }) - - /** - * @tc.number : SUB_USB_JS_0750 - * @tc.name : setConfiguration - * @tc.desc : 反向测试 设置设备接口 - */ - it('SUB_USB_JS_0750', 0, function () { - console.info('usb SUB_USB_JS_0750 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 - } - - for (var j = 0; j < gDeviceList[0].configs.length; j++) { - var config = JSON.parse(JSON.stringify(gDeviceList[0].configs[j])); - config.id = 255 - var ret = usb.setConfiguration(gPipe, config) - console.info('usb case setConfiguration return : ' + ret); - expect(ret).assertLess(0); - } - - console.info('usb SUB_USB_JS_0750 : PASS'); - }) - - /** - * @tc.number : SUB_USB_JS_0800 - * @tc.name : setInterface - * @tc.desc : 设置设备接口 - */ - it('SUB_USB_JS_0800', 0, function () { - console.info('usb SUB_USB_JS_0800 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 - } - - for (var j = 0; j < gDeviceList[0].configs.length; j++) { - var isClaim = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true) - expect(isClaim).assertEqual(0) - if (isClaim == 0) { - var ret = usb.setInterface(gPipe, gDeviceList[0].configs[j].interfaces[0]) - expect(ret).assertEqual(0); - console.info('usb case setInterface return : ' + ret); - } - } - - console.info('usb SUB_USB_JS_0800 : PASS'); - expect(true).assertTrue(); - }) - - /** - * @tc.number : SUB_USB_JS_0810 - * @tc.name : setInterface - * @tc.desc : 反向测试 设置设备接口 - */ - it('SUB_USB_JS_0810', 0, function () { - console.info('usb SUB_USB_JS_0810 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 - } - - for (var j = 0; j < gDeviceList[0].configs.length; j++) { - var isClaim = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true) - expect(isClaim).assertEqual(0) - if (isClaim == 0) { - var tmpInterface = JSON.parse(JSON.stringify(gDeviceList[0].configs[j].interfaces[0])); - tmpInterface.id = 234 - var ret = usb.setInterface(gPipe, tmpInterface) - expect(ret).assertLess(0) - console.info('usb case setInterface return : ' + ret) - } - } - - console.info('usb SUB_USB_JS_0810 : PASS'); - expect(true).assertTrue(); - }) - - function callControlTransfer(pip, controlParam, timeout, caseName) { - usb.controlTransfer(pip, controlParam, timeout).then(data => { - console.info('usb controlTransfer ret data : ' + data + ' ' + caseName); - console.info('usb controlTransfer controlParam.data buffer : ' + controlParam.data + ' ' + caseName); - console.info('usb' + caseName + ': PASS'); - expect(true).assertTrue(); - }).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_0540 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 GetDescriptor: cmd 6 reqType 128 value 512 index 0 - */ - it('SUB_USB_JS_0540', 0, function () { - console.info('usb SUB_USB_JS_0540 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 - } - - var timeout = 5000; - var controlParam = getTransferParam(6, (usb.USB_REQUEST_DIR_FROM_DEVICE) - | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), (2 << 8), 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0540 GetDescriptor') - }) - - /** - * @tc.number : SUB_USB_JS_0550 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 GetStatus: cmd 0 reqType 128 value 0 index 0 - */ - it('SUB_USB_JS_0550', 0, function () { - console.info('usb SUB_USB_JS_0550 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 - } - - var timeout = 5000; - var controlParam = getTransferParam(0, (usb.USB_REQUEST_DIR_FROM_DEVICE) - | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0550 GetStatus') - }) - - /** - * @tc.number : SUB_USB_JS_0560 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 GetConfiguration: cmd 8 reqType 128 value 0 index 0 - */ - it('SUB_USB_JS_0560', 0, function () { - console.info('usb SUB_USB_JS_0560 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 - } - - var timeout = 5000; - var controlParam = getTransferParam(8, (usb.USB_REQUEST_DIR_FROM_DEVICE) - | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0560 GetConfiguration') - }) - - /** - * @tc.number : SUB_USB_JS_0570 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 GetInterface: cmd 10 reqType 129 value 0 index 1 - */ - it('SUB_USB_JS_0570', 0, function () { - console.info('usb SUB_USB_JS_0570 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 - } - - var timeout = 5000; - var controlParam = getTransferParam(10, (usb.USB_REQUEST_DIR_FROM_DEVICE) - | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_INTERFACE & 0x1f), 0, 1) - callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0570 GetInterface') - }) - - /** - * @tc.number : SUB_USB_JS_0580 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0 - */ - it('SUB_USB_JS_0580', 0, function () { - console.info('usb SUB_USB_JS_0580 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 - } - - var timeout = 5000; - var controlParam = getTransferParam(1, (usb.USB_REQUEST_DIR_TO_DEVICE) - | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0580 ClearFeature') - }) - - /** - * @tc.number : SUB_USB_JS_0590 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 ClearFeature: cmd 255 reqType 129 value 512 index 0 - */ - it('SUB_USB_JS_0590', 0, function () { - console.info('usb SUB_USB_JS_0590 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 - } - - var timeout = 5000; - var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_FROM_DEVICE) - | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_INTERFACE & 0x1f), (2 << 8), 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0590 ClearFeature') - }) - - /** - * @tc.number : SUB_USB_JS_0600 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 ClearFeature: cmd 255 reqType 34 value 512 index 0 - */ - it('SUB_USB_JS_0600', 0, function () { - console.info('usb SUB_USB_JS_0600 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 - } - - var timeout = 5000; - var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE) - | (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_ENDPOINT & 0x1f), (2 << 8), 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0600 ClearFeature') - }) - - /** - * @tc.number : SUB_USB_JS_0610 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 ClearFeature: cmd 255 reqType 67 value 512 index 0 - */ - it('SUB_USB_JS_0610', 0, function () { - console.info('usb SUB_USB_JS_0610 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 - } - - var timeout = 5000; - var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE) - | (usb.USB_REQUEST_TYPE_VENDOR << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), (2 << 8), 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0610 ClearFeature') - }) - - /** - * @tc.number : SUB_USB_JS_0620 - * @tc.name : controlTransfer - * @tc.desc : 控制传输 ClearFeature: cmd 255 reqType 35 value 0 index 0 - */ - it('SUB_USB_JS_0620', 0, function () { - console.info('usb SUB_USB_JS_0620 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 - } - - var timeout = 5000; - var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE) - | (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0620 ClearFeature') - }) - -}) -} diff --git a/usb/usb_standard/src/main/js/test/UsbFunctionsJsunit.test.js b/usb/usb_standard/src/main/js/test/UsbFunctionsJsunit.test.js index ebeb02e354f1995299f0d8e817f0772f36e27781..35d00a3ce52d2ecad0e74ef406153d3a69740e4f 100644 --- a/usb/usb_standard/src/main/js/test/UsbFunctionsJsunit.test.js +++ b/usb/usb_standard/src/main/js/test/UsbFunctionsJsunit.test.js @@ -50,9 +50,9 @@ describe('UsbFunctionsJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0330 - * @tc.name : getCurrentFunctions - * @tc.desc : 获取当前设备模式 掩码与描述字符转换 + * @tc.number: SUB_USB_JS_0330 + * @tc.name: getCurrentFunctions + * @tc.desc: Positive test: Get current device mode, mask and description character conversion */ it('SUB_USB_JS_0330', 0, function () { console.info('usb SUB_USB_JS_0330 begin'); @@ -65,13 +65,12 @@ describe('UsbFunctionsJsFunctionsTest', function () { console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode); expect(nMaskCode).assertEqual(maskCode); console.info('usb SUB_USB_JS_0330 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0340 - * @tc.name : usbFunctionString - * @tc.desc : 反向测试 获取当前设备模式 掩码与描述字符转换 + * @tc.number: SUB_USB_JS_0340 + * @tc.name: usbFunctionString + * @tc.desc: Negative test: Get current device mode, mask and description character conversion, nMaskcode=0 */ it('SUB_USB_JS_0340', 0, function () { console.info('usb SUB_USB_JS_0340 begin'); @@ -90,17 +89,17 @@ describe('UsbFunctionsJsFunctionsTest', function () { var errStrMaskCode = 'none' var nMaskCode = usb.usbFunctionsFromString(errStrMaskCode) - expect(nMaskCode).assertEqual(usb.NONE); console.info('usb case errStrMaskCode ' + errStrMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - + expect(nMaskCode).assertEqual(usb.NONE); console.info('usb SUB_USB_JS_0340 : PASS'); }) /** - * @tc.number : SUB_USB_JS_1000 - * @tc.name : getCurrentFunctions - * @tc.desc : 反向测试 获取当前设备模式 入参错误(无参接口传参) + * @tc.number: SUB_USB_JS_1000 + * @tc.name: getCurrentFunctions + * @tc.desc: Negative test: Get the current device mode, + * parameters exception(parameter transfer without parameter interface) */ it('SUB_USB_JS_1000', 0, function () { console.info('usb SUB_USB_JS_1000 begin'); diff --git a/usb/usb_standard/src/main/js/test/UsbFunctionsJsunitEx.test.js b/usb/usb_standard/src/main/js/test/UsbFunctionsJsunitEx.test.js index 1faa498671d936e156fddb9f11dedff15e2c0d73..ce0b8bc72b0e0ad0510cd2ab99f70acf57acc81c 100644 --- a/usb/usb_standard/src/main/js/test/UsbFunctionsJsunitEx.test.js +++ b/usb/usb_standard/src/main/js/test/UsbFunctionsJsunitEx.test.js @@ -53,116 +53,116 @@ describe('UsbFunctionsJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0930 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 0 返回 'none' + * @tc.number: SUB_USB_JS_0930 + * @tc.name: usbFunctionsToString + * @tc.desc: Positive test: input 0, return 'none' */ it('SUB_USB_JS_0930', 0, function () { console.info('usb SUB_USB_JS_0930 begin'); var maskCode = usb.NONE console.info('usb case maskCode : ' + usb.NONE); var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('none'); console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); + expect(strMaskCode).assertEqual('none'); console.info('usb SUB_USB_JS_0930 : PASS'); }) /** - * @tc.number : SUB_USB_JS_0940 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 1 返回 'acm' + * @tc.number: SUB_USB_JS_0940 + * @tc.name: usbFunctionsToString + * @tc.desc: Positive test: input 1, return 'acm' */ it('SUB_USB_JS_0940', 0, function () { console.info('usb SUB_USB_JS_0940 begin'); var maskCode = usb.ACM console.info('usb case maskCode : ' + usb.ACM); var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('acm'); console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); + expect(strMaskCode).assertEqual('acm'); console.info('usb SUB_USB_JS_0940 : PASS'); }) /** - * @tc.number : SUB_USB_JS_0950 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 2 返回 'ecm' + * @tc.number: SUB_USB_JS_0950 + * @tc.name: usbFunctionsToString + * @tc.desc: Positive test: input 2, return 'ecm' */ it('SUB_USB_JS_0950', 0, function () { console.info('usb SUB_USB_JS_0950 begin'); var maskCode = usb.ECM console.info('usb case maskCode : ' + maskCode); var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('ecm'); console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); + expect(strMaskCode).assertEqual('ecm'); console.info('usb SUB_USB_JS_0950 : PASS'); }) /** - * @tc.number : SUB_USB_JS_0960 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 3 返回 'acm,ecm' + * @tc.number: SUB_USB_JS_0960 + * @tc.name: usbFunctionsToString + * @tc.desc: Positive test: input 3, return 'acm,ecm' */ it('SUB_USB_JS_0960', 0, function () { console.info('usb SUB_USB_JS_0960 begin'); var maskCode = usb.ACM | usb.ECM console.info('usb case maskCode : ' + maskCode); var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('acm,ecm'); console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); + expect(strMaskCode).assertEqual('acm,ecm'); console.info('usb SUB_USB_JS_0960 : PASS'); }) /** - * @tc.number : SUB_USB_JS_0970 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 4 返回 'hdc' + * @tc.number: SUB_USB_JS_0970 + * @tc.name: usbFunctionsToString + * @tc.desc: Positive test: input 4, return 'hdc' */ it('SUB_USB_JS_0970', 0, function () { console.info('usb SUB_USB_JS_0970 begin'); var maskCode = usb.HDC console.info('usb case maskCode : ' + maskCode); var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('hdc'); console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); + expect(strMaskCode).assertEqual('hdc'); console.info('usb SUB_USB_JS_0970 : PASS'); }) /** - * @tc.number : SUB_USB_JS_0980 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 5 返回 'acm,hdc' + * @tc.number: SUB_USB_JS_0980 + * @tc.name: usbFunctionsToString + * @tc.desc: Positive test: input 5, return 'acm,hdc' */ it('SUB_USB_JS_0980', 0, function () { console.info('usb SUB_USB_JS_0980 begin'); var maskCode = usb.ACM | usb.HDC console.info('usb case maskCode : ' + maskCode); var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('acm,hdc'); console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); + expect(strMaskCode).assertEqual('acm,hdc'); console.info('usb SUB_USB_JS_0980 : PASS'); }) /** - * @tc.number : SUB_USB_JS_0990 - * @tc.name : usbFunctionsToString - * @tc.desc : 正向测试 6 返回 'ecm,hdc' + * @tc.number: SUB_USB_JS_0990 + * @tc.name: usbFunctionsToString + * @tc.desc: Positive test: input 6, return 'ecm,hdc' */ it('SUB_USB_JS_0990', 0, function () { console.info('usb SUB_USB_JS_0990 begin'); var maskCode = usb.ECM | usb.HDC console.info('usb case maskCode : ' + maskCode); var strMaskCode = usb.usbFunctionsToString(maskCode) - expect(strMaskCode).assertEqual('ecm,hdc'); console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); + expect(strMaskCode).assertEqual('ecm,hdc'); console.info('usb SUB_USB_JS_0990 : PASS'); }) /** - * @tc.number : SUB_USB_JS_1160 - * @tc.name : usbFunctionsToString - * @tc.desc : 反向测试 掩码转化成描述字符 参数类型错误 + * @tc.number: SUB_USB_JS_1160 + * @tc.name: usbFunctionsToString + * @tc.desc: Negative test: Mask converted to description character, parameter type error */ - it('SUB_USB_JS_1160', 0, function () { + it('SUB_USB_JS_1160', 0, function () { console.info('usb SUB_USB_JS_1160 begin'); try { var maskCode = usb.usbFunctionsToString("invalid"); @@ -176,11 +176,12 @@ describe('UsbFunctionsJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1360 - * @tc.name : usbFunctionsToString - * @tc.desc : 反向测试 掩码转化成描述字符 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1360 + * @tc.name: usbFunctionsToString + * @tc.desc: Negative test: Mask converted to description character, + * parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1360', 0, function () { + it('SUB_USB_JS_1360', 0, function () { console.info('usb SUB_USB_JS_1360 begin'); try { var maskCode = usb.usbFunctionsToString(); @@ -194,109 +195,109 @@ describe('UsbFunctionsJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0860 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'none' 返回 0 + * @tc.number: SUB_USB_JS_0860 + * @tc.name: usbFunctionsFromString + * @tc.desc: Positive test: input 'none', return 0 */ it('SUB_USB_JS_0860', 0, function () { console.info('usb SUB_USB_JS_0860 begin'); var strMaskCode = 'none' var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(usb.NONE); console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); + expect(nMaskCode).assertEqual(usb.NONE); console.info('usb SUB_USB_JS_0860 : PASS'); }) /** - * @tc.number : SUB_USB_JS_0870 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'acm' 返回 1 + * @tc.number: SUB_USB_JS_0870 + * @tc.name: usbFunctionsFromString + * @tc.desc: Positive test: input 'acm', return 1 */ it('SUB_USB_JS_0870', 0, function () { console.info('usb SUB_USB_JS_0870 begin'); var strMaskCode = 'acm' var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(usb.ACM); console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); + expect(nMaskCode).assertEqual(usb.ACM); console.info('usb SUB_USB_JS_0870 : PASS'); }) /** - * @tc.number : SUB_USB_JS_0880 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'ecm' 返回 2 + * @tc.number: SUB_USB_JS_0880 + * @tc.name: usbFunctionsFromString + * @tc.desc: Positive test: input 'ecm', return 2 */ it('SUB_USB_JS_0880', 0, function () { console.info('usb SUB_USB_JS_0880 begin'); var strMaskCode = 'ecm' var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(usb.ECM); console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); + expect(nMaskCode).assertEqual(usb.ECM); console.info('usb SUB_USB_JS_0880 : PASS'); }) /** - * @tc.number : SUB_USB_JS_0890 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'acm,ecm' 返回 3 + * @tc.number: SUB_USB_JS_0890 + * @tc.name: usbFunctionsFromString + * @tc.desc: Positive test: input 'acm,ecm', return 3 */ it('SUB_USB_JS_0890', 0, function () { console.info('usb SUB_USB_JS_0890 begin'); var strMaskCode = 'acm,ecm' var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(usb.ACM | usb.ECM); console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); + expect(nMaskCode).assertEqual(usb.ACM | usb.ECM); console.info('usb SUB_USB_JS_0890 : PASS'); }) /** - * @tc.number : SUB_USB_JS_0900 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'hdc' 返回 4 + * @tc.number: SUB_USB_JS_0900 + * @tc.name: usbFunctionsFromString + * @tc.desc: Positive test: input 'hdc', return 4 */ it('SUB_USB_JS_0900', 0, function () { console.info('usb SUB_USB_JS_0900 begin'); var strMaskCode = 'hdc' var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(usb.HDC); console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); + expect(nMaskCode).assertEqual(usb.HDC); console.info('usb SUB_USB_JS_0900 : PASS'); }) /** - * @tc.number : SUB_USB_JS_0910 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'acm,hdc' 返回 5 + * @tc.number: SUB_USB_JS_0910 + * @tc.name: usbFunctionsFromString + * @tc.desc: Positive test: input 'acm,hdc', return 5 */ it('SUB_USB_JS_0910', 0, function () { console.info('usb SUB_USB_JS_0910 begin'); var strMaskCode = 'acm,hdc' var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(usb.HDC | usb.ACM); console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); + expect(nMaskCode).assertEqual(usb.HDC | usb.ACM); console.info('usb SUB_USB_JS_0910 : PASS'); }) /** - * @tc.number : SUB_USB_JS_0920 - * @tc.name : usbFunctionsFromString - * @tc.desc : 正向测试 'ecm,hdc' 返回 6 + * @tc.number: SUB_USB_JS_0920 + * @tc.name: usbFunctionsFromString + * @tc.desc: Positive test: input 'ecm,hdc', return 6 */ it('SUB_USB_JS_0920', 0, function () { console.info('usb SUB_USB_JS_0920 begin'); var strMaskCode = 'ecm,hdc' var nMaskCode = usb.usbFunctionsFromString(strMaskCode) - expect(nMaskCode).assertEqual(usb.HDC | usb.ECM); console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); + expect(nMaskCode).assertEqual(usb.HDC | usb.ECM); console.info('usb SUB_USB_JS_0920 : PASS'); }) /** - * @tc.number : SUB_USB_JS_1170 - * @tc.name : usbFunctionsFromString - * @tc.desc : 反向测试 描述字符转换成掩码 参数类型错误 + * @tc.number: SUB_USB_JS_1170 + * @tc.name: usbFunctionsFromString + * @tc.desc: Negative test: Description character converted to mask, parameter type error */ - it('SUB_USB_JS_1170', 0, function () { + it('SUB_USB_JS_1170', 0, function () { console.info('usb SUB_USB_JS_1170 begin'); try { var maskCode = usb.usbFunctionsFromString(invalidCode); @@ -310,11 +311,12 @@ describe('UsbFunctionsJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1370 - * @tc.name : usbFunctionsFromString - * @tc.desc : 反向测试 描述字符转换成掩码 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1370 + * @tc.name: usbFunctionsFromString + * @tc.desc: Negative test: Description character converted to mask, + * parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1370', 0, function () { + it('SUB_USB_JS_1370', 0, function () { console.info('usb SUB_USB_JS_1370 begin'); try { var maskCode = usb.usbFunctionsFromString(); diff --git a/usb/usb_standard/src/main/js/test/UsbPortAndFunctionJsunit.test.js b/usb/usb_standard/src/main/js/test/UsbPortAndFunctionJsunit.test.js index d7a0148efc773e105ee5f0880429063a0042e6f0..b73ed4cecd29ed12d4bda584b7840d1be31a9ed9 100644 --- a/usb/usb_standard/src/main/js/test/UsbPortAndFunctionJsunit.test.js +++ b/usb/usb_standard/src/main/js/test/UsbPortAndFunctionJsunit.test.js @@ -64,9 +64,9 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () { } /** - * @tc.number : SUB_USB_JS_0350 - * @tc.name : functions_test - * @tc.desc : 在设备模式下设置当前的USB功能列表 Set 1 设置为ACM功能 + * @tc.number: SUB_USB_JS_0350 + * @tc.name: functions_test + * @tc.desc: Positive test: Set the current USB function list in device mode, Set 1, Set as ACM function */ it('SUB_USB_JS_0350', 0, function () { CheckEmptyUtils.sleep(3000) @@ -79,9 +79,9 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0360 - * @tc.name : functions_test - * @tc.desc : 在设备模式下设置当前的USB功能列表 Set 2 设置为ECM功能 + * @tc.number: SUB_USB_JS_0360 + * @tc.name: functions_test + * @tc.desc: Positive test: Set the current USB function list in device mode, Set 2, Set as ECM function */ it('SUB_USB_JS_0360', 0, function () { CheckEmptyUtils.sleep(3000) @@ -94,9 +94,9 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0370 - * @tc.name : functions_test - * @tc.desc : 在设备模式下设置当前的USB功能列表 Set 3 设置为ACM、ECM功能 + * @tc.number: SUB_USB_JS_0370 + * @tc.name: functions_test + * @tc.desc: Positive test: Set the current USB function list in device mode, Set 3, Set as ACM、ECM function */ it('SUB_USB_JS_0370', 0, function () { CheckEmptyUtils.sleep(3000) @@ -109,9 +109,9 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0380 - * @tc.name : functions_test - * @tc.desc : 在设备模式下设置当前的USB功能列表 Set 4 设置为HDC功能 + * @tc.number: SUB_USB_JS_0380 + * @tc.name: functions_test + * @tc.desc: Positive test: Set the current USB function list in device mode, Set 4, Set as HDC function */ it('SUB_USB_JS_0380', 0, function () { CheckEmptyUtils.sleep(3000) @@ -124,9 +124,9 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0390 - * @tc.name : functions_test - * @tc.desc : 在设备模式下设置当前的USB功能列表 Set 5 设置为ACM、HDC功能 + * @tc.number: SUB_USB_JS_0390 + * @tc.name: functions_test + * @tc.desc: Positive test: Set the current USB function list in device mode, Set 5, Set as ACM、HDC function */ it('SUB_USB_JS_0390', 0, function () { CheckEmptyUtils.sleep(3000) @@ -139,9 +139,9 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0400 - * @tc.name : functions_test - * @tc.desc : 在设备模式下设置当前的USB功能列表 Set 6 设置为ECM、HDC功能 + * @tc.number: SUB_USB_JS_0400 + * @tc.name: functions_test + * @tc.desc: Positive test: Set the current USB function list in device mode, Set 6, Set as ECM、HDC function */ it('SUB_USB_JS_0400', 0, function () { CheckEmptyUtils.sleep(3000) @@ -154,9 +154,9 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0010 - * @tc.name : setPortRoles - * @tc.desc : 切换为Device set powerRole 2 DataRole 2 + * @tc.number: SUB_USB_JS_0010 + * @tc.name: setPortRoles + * @tc.desc: Positive test: Switch to Device, set powerRole 2 DataRole 2 */ it('SUB_USB_JS_0010', 0, function () { console.info('usb SUB_USB_JS_0010 device 2 2 begin'); @@ -168,25 +168,24 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () { } for (var i = 0; i < usbPortList.length; i++) { - console.info('usb case set data role 2, data role 2'); + console.info('usb 0010 case set data role 2, data role 2'); usb.setPortRoles(usbPortList[i].id, usb.SINK, usb.DEVICE).then(data => { - console.info('usb case setPortRoles return: ' + data); + console.info('usb 0010 case setPortRoles return: ' + data); expect(data).assertTrue(); }).catch(error => { - console.info('usb case setPortRoles error : ' + error); + console.info('usb 0010 case setPortRoles error : ' + error); expect(false).assertTrue(); }); CheckEmptyUtils.sleep(8000) } console.info('usb SUB_USB_JS_0010 device 2 2: PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0020 - * @tc.name : setPortRoles - * @tc.desc : 切换为host set powerRole 1 DataRole 1 + * @tc.number: SUB_USB_JS_0020 + * @tc.name: setPortRoles + * @tc.desc: Positive test: Switch to host, set powerRole 1 DataRole 1 */ it('SUB_USB_JS_0020', 0, function () { console.info('usb SUB_USB_JS_0020 host 1 1 begin'); @@ -198,19 +197,18 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () { } for (var i = 0; i < usbPortList.length; i++) { - console.info('usb case set data role 1, data role 1'); + console.info('usb 0020 case set data role 1, data role 1'); usb.setPortRoles(usbPortList[i].id, usb.SOURCE, usb.HOST).then(data => { + console.info('usb 0020 case setPortRoles return: ' + data); expect(data).assertTrue(); - console.info('usb case setPortRoles return: ' + data); }).catch(error => { - console.info('usb case setPortRoles error : ' + error); + console.info('usb 0020 case setPortRoles error : ' + error); expect(false).assertTrue(); }); CheckEmptyUtils.sleep(8000) } console.info('usb SUB_USB_JS_0020 host 1 1: PASS'); - expect(true).assertTrue(); }) }) } diff --git a/usb/usb_standard/src/main/js/test/UsbPortJsunit.test.js b/usb/usb_standard/src/main/js/test/UsbPortJsunit.test.js index e47a20f8510b1fa9f1c68db050fd18602db66642..bc3217b5ae6c7e386b81b57009369804a2910bf7 100644 --- a/usb/usb_standard/src/main/js/test/UsbPortJsunit.test.js +++ b/usb/usb_standard/src/main/js/test/UsbPortJsunit.test.js @@ -37,9 +37,9 @@ describe('UsbPortJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_JS_0410 - * @tc.name : getPorts - * @tc.desc : 获取USB端口描述信息列表 + * @tc.number: SUB_USB_JS_0410 + * @tc.name: getPorts + * @tc.desc: Positive test: Get USB port description information list */ it('SUB_USB_JS_0410', 0, function () { console.info('usb SUB_USB_JS_0410 begin'); @@ -51,13 +51,12 @@ describe('UsbPortJsFunctionsTest', function () { } expect(usbPortList.length > 0).assertTrue(); console.info('usb SUB_USB_JS_0410 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0220 - * @tc.name : getSupportedModes - * @tc.desc : 获取指定的端口支持的模式列表的组合掩码 + * @tc.number: SUB_USB_JS_0220 + * @tc.name: getSupportedModes + * @tc.desc: Positive test: Get the combination mask of the mode list supported by the specified port */ it('SUB_USB_JS_0220', 0, function () { console.info('usb SUB_USB_JS_0220 begin'); @@ -75,7 +74,6 @@ describe('UsbPortJsFunctionsTest', function () { } console.info('usb SUB_USB_JS_0220 : PASS'); - expect(true).assertTrue(); }) }) diff --git a/usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js b/usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js index e7cc9b164f0e8b2f4e62492f3be01330138e893d..cc01812ea64ce51dc491a49c00326cbc09ccab23 100644 --- a/usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js +++ b/usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js @@ -40,9 +40,9 @@ describe('UsbPortJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0230 - * @tc.name : getSupportedModes - * @tc.desc : 反向测试 改变id 获取指定的端口支持的模式列表的组合掩码 + * @tc.number: SUB_USB_JS_0230 + * @tc.name: getSupportedModes + * @tc.desc: Negative test: Get the combination mask of the mode list supported by the specified port, id error */ it('SUB_USB_JS_0230', 0, function () { console.info('usb SUB_USB_JS_0230 begin'); @@ -60,15 +60,15 @@ describe('UsbPortJsFunctionsTestEx', function () { expect(maskCode).assertEqual(usb.NONE); console.info('usb SUB_USB_JS_0230 : PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_1210 - * @tc.name : getSupportedModes - * @tc.desc : 反向测试 获取指定的端口支持的模式列表的组合掩码 参数类型错误 + * @tc.number: SUB_USB_JS_1210 + * @tc.name: getSupportedModes + * @tc.desc: Negative test: Get the combination mask of the mode list supported by the specified port, + * parameter type error */ - it('SUB_USB_JS_1210', 0, function () { + it('SUB_USB_JS_1210', 0, function () { console.info('usb SUB_USB_JS_1210 begin'); try { var maskCode = usb.getSupportedModes("invalid"); @@ -82,11 +82,12 @@ describe('UsbPortJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1380 - * @tc.name : getSupportedModes - * @tc.desc : 反向测试 获取指定的端口支持的模式列表的组合掩码 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1380 + * @tc.name: getSupportedModes + * @tc.desc: Negative test: Get the combination mask of the mode list supported by the specified port, + * parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1380', 0, function () { + it('SUB_USB_JS_1380', 0, function () { console.info('usb SUB_USB_JS_1380 begin'); try { var maskCode = usb.getSupportedModes(); @@ -100,144 +101,152 @@ describe('UsbPortJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_0030 - * @tc.name : setPortRoles - * @tc.desc : dataRole参数错误 + * @tc.number: SUB_USB_JS_0030 + * @tc.name: setPortRoles + * @tc.desc: Negative test: dataRole error */ it('SUB_USB_JS_0030', 0, function () { var portId = gPort.id; var powerRole = usb.SINK; var dataRole = usb.NONE - 1; usb.setPortRoles(portId, powerRole, dataRole).then(data => { - console.info('usb case setPortRoles return: ' + data); - expect(data).assertTrue(); + console.info('usb 0030 case setPortRoles return: ' + data); + expect(data).assertFalse(); }).catch(error => { - console.info('usb case setPortRoles error : ' + error); + console.info('usb 0030 case setPortRoles error : ' + error); expect(error).assertFalse(); - console.info('usb SUB_USB_JS_0030: PASS'); }) CheckEmptyUtils.sleep(8000) - console.info('usb SUB_USB_JS_0030: PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0040 - * @tc.name : setPortRoles - * @tc.desc : portId,powerRole参数错误 + * @tc.number: SUB_USB_JS_0040 + * @tc.name: setPortRoles + * @tc.desc: Negative test: portId && powerRole error */ it('SUB_USB_JS_0040', 0, function () { var portId = gPort.id; var powerRole = usb.NONE - 1; var dataRole = usb.DEVICE; usb.setPortRoles(portId, powerRole, dataRole).then(data => { - console.info('usb case setPortRoles return: ' + data); - expect(data).assertTrue(); + console.info('usb 0040 case setPortRoles return: ' + data); + expect(data).assertFalse(); }).catch(error => { - console.info('usb case setPortRoles error : ' + error); + console.info('usb 0040 case setPortRoles error : ' + error); expect(error).assertFalse(); - console.info('usb SUB_USB_JS_0040: PASS'); }) CheckEmptyUtils.sleep(8000) console.info('usb SUB_USB_JS_0040: PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0050 - * @tc.name : setPortRoles - * @tc.desc : portId,dataRole参数错误 + * @tc.number: SUB_USB_JS_0050 + * @tc.name: setPortRoles + * @tc.desc: Negative test: portId && dataRole error */ it('SUB_USB_JS_0050', 0, function () { var portId = gPort.id - 3; var powerRole = usb.SINK; var dataRole = usb.NONE - 1; usb.setPortRoles(portId, powerRole, dataRole).then(data => { - console.info('usb case setPortRoles return: ' + data); - expect(data).assertTrue(); + console.info('usb 0050 case setPortRoles return: ' + data); + expect(data).assertFalse(); }).catch(error => { - console.info('usb case setPortRoles error : ' + error); + console.info('usb 0050 case setPortRoles error : ' + error); expect(error).assertFalse(); - console.info('usb SUB_USB_JS_0050: PASS'); }) CheckEmptyUtils.sleep(8000) console.info('usb SUB_USB_JS_0050: PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0060 - * @tc.name : setPortRoles - * @tc.desc : powerRole,dataRole参数错误 + * @tc.number: SUB_USB_JS_0060 + * @tc.name: setPortRoles + * @tc.desc: Negative test: powerRole && dataRole error */ it('SUB_USB_JS_0060', 0, function () { var portId = gPort.id; var powerRole = usb.NONE - 1; var dataRole = usb.NONE - 1; usb.setPortRoles(portId, powerRole, dataRole).then(data => { - console.info('usb case setPortRoles return: ' + data); - expect(data).assertTrue(); + console.info('usb 0060 case setPortRoles return: ' + data); + expect(data).assertFalse(); }).catch(error => { - console.info('usb case setPortRoles error : ' + error); + console.info('usb 0060 case setPortRoles error : ' + error); expect(error).assertFalse(); - console.info('usb SUB_USB_JS_0060: PASS'); }) CheckEmptyUtils.sleep(8000) console.info('usb SUB_USB_JS_0060: PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0070 - * @tc.name : setPortRoles - * @tc.desc : portId,powerRole,dataRole参数错误 + * @tc.number: SUB_USB_JS_0070 + * @tc.name: setPortRoles + * @tc.desc: Negative test: portId && powerRole && dataRole error */ it('SUB_USB_JS_0070', 0, function () { var portId = gPort.id - 1; var dataRole = usb.NONE - 1; var powerRole = usb.NONE - 1; usb.setPortRoles(portId, powerRole, dataRole).then(data => { - console.info('usb case setPortRoles return: ' + data); - expect(data).assertTrue(); + console.info('usb 0070 case setPortRoles return: ' + data); + expect(data).assertFalse(); }).catch(error => { - console.info('usb case setPortRoles error : ' + error); + console.info('usb 0070 case setPortRoles error : ' + error); expect(error).assertFalse(); - console.info('usb SUB_USB_JS_0070: PASS'); }) CheckEmptyUtils.sleep(8000) console.info('usb SUB_USB_JS_0070: PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_0080 - * @tc.name : setPortRoles - * @tc.desc : portId参数错误 + * @tc.number: SUB_USB_JS_0080 + * @tc.name: setPortRoles + * @tc.desc: Negative test: portId error */ it('SUB_USB_JS_0080', 0, function () { var portId = gPort.id - 1; var powerRole = 1; var dataRole = 1; usb.setPortRoles(portId, powerRole, dataRole).then(data => { - console.info('usb case setPortRoles return: ' + data); - expect(data).assertTrue(); + console.info('usb 0080 case setPortRoles return: ' + data); + expect(data).assertFalse(); }).catch(error => { - console.info('usb case setPortRoles error : ' + error); + console.info('usb 0080 case setPortRoles error : ' + error); expect(error).assertFalse(); - console.info('usb SUB_USB_JS_0080: PASS'); }) CheckEmptyUtils.sleep(8000) console.info('usb SUB_USB_JS_0080: PASS'); - expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_JS_1190 - * @tc.name : setPortRoles - * @tc.desc : 反向测试 port功能切换 参数个数错误 + * @tc.number: SUB_USB_JS_1410 + * @tc.name: setPortRoles + * @tc.desc: Negative test: parameter type exception + */ + it('SUB_USB_JS_1410', 0, function () { + console.info('usb SUB_USB_JS_1410 begin'); + var portId = "invalid"; + var powerRole = usb.SINK; + var dataRole = usb.DEVICE; + try { + var maskCode = usb.setPortRoles(portId, powerRole, dataRole); + console.info('usb 1410 case setPortRoles return: ' + maskCode); + expect(false).assertTrue(); + } catch (err) { + console.info('usb 1410 catch err code: ' + err.code + ' message: ' + err.message); + expect(err.code).assertEqual(401); + console.info('usb SUB_USB_JS_1410 : PASS'); + } + }) + + /** + * @tc.number: SUB_USB_JS_1190 + * @tc.name: setPortRoles + * @tc.desc: Negative test: parameter number exception, input a parameter */ - it('SUB_USB_JS_1190', 0, function () { + it('SUB_USB_JS_1190', 0, function () { console.info('usb SUB_USB_JS_1190 begin'); try { var maskCode = usb.setPortRoles("invalid"); @@ -251,11 +260,11 @@ describe('UsbPortJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1390 - * @tc.name : setPortRoles - * @tc.desc : 反向测试 port功能切换 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1390 + * @tc.name: setPortRoles + * @tc.desc: Negative test: parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1390', 0, function () { + it('SUB_USB_JS_1390', 0, function () { console.info('usb SUB_USB_JS_1390 begin'); try { var maskCode = usb.setPortRoles(); @@ -269,11 +278,11 @@ describe('UsbPortJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1200 - * @tc.name : getPorts - * @tc.desc : 反向测试 获取USB端口描述信息列表 入参错误(无参接口传参) + * @tc.number: SUB_USB_JS_1200 + * @tc.name: getPorts + * @tc.desc: Negative test: parameters exception(parameter transfer without parameter interface) */ - it('SUB_USB_JS_1200', 0, function () { + it('SUB_USB_JS_1200', 0, function () { console.info('usb SUB_USB_JS_1200 begin'); try { var maskCode = usb.getPorts("invalid"); @@ -287,11 +296,11 @@ describe('UsbPortJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1180 - * @tc.name : setCurrentFunctions - * @tc.desc : 反向测试 在设备模式下设置当前的USB功能列表 参数类型错误 + * @tc.number: SUB_USB_JS_1180 + * @tc.name: setCurrentFunctions + * @tc.desc: Negative test: parameter type error */ - it('SUB_USB_JS_1180', 0, function () { + it('SUB_USB_JS_1180', 0, function () { console.info('usb SUB_USB_JS_1180 begin'); try { var maskCode = usb.setCurrentFunctions("invalid"); @@ -305,11 +314,11 @@ describe('UsbPortJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_JS_1400 - * @tc.name : setCurrentFunctions - * @tc.desc : 反向测试 在设备模式下设置当前的USB功能列表 参数个数错误,必要参数未传入 + * @tc.number: SUB_USB_JS_1400 + * @tc.name: setCurrentFunctions + * @tc.desc: Negative test: parameter number exception, necessary parameters not input */ - it('SUB_USB_JS_1400', 0, function () { + it('SUB_USB_JS_1400', 0, function () { console.info('usb SUB_USB_JS_1400 begin'); try { var maskCode = usb.setCurrentFunctions();