From b5079c3a7f3821258fc00ca8b90f621ffe7b9880 Mon Sep 17 00:00:00 2001 From: lixiaofeng_154b Date: Fri, 1 Jul 2022 10:23:35 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90xts=5Facts=E3=80=91=E3=80=90master?= =?UTF-8?q?=E3=80=91usb=E6=B5=8B=E8=AF=95=E5=A5=97=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=BA=BFfail,=E7=94=A8=E4=BE=8B=E7=BC=96=E5=8F=B7=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: lixiaofeng_154b Change-Id: Id3e680a471dbc084db476fbb5611b9d42dc2af98 --- .../src/main/js/default/test/ListUsb.test.js | 16 +- .../js/default/test/UsbAutoJsunit.test.js | 158 ++++---- .../js/default/test/UsbCoreJsunit.test.js | 193 +++++++--- .../js/default/test/UsbCoreJsunitEx.test.js | 271 +++++++++----- .../default/test/UsbDevicePipeJsunit.test.js | 236 ++++++++---- .../test/UsbDevicePipeJsunitEx.test.js | 352 ++++++++++++------ .../test/UsbDevicePipeJsunit_A.test.js | 156 ++++---- .../default/test/UsbFunctionsJsunit.test.js | 64 ++-- .../default/test/UsbFunctionsJsunitEx.test.js | 112 +++--- .../js/default/test/UsbPortJsunit.test.js | 40 +- .../js/default/test/UsbPortJsunitEx.test.js | 62 +-- 11 files changed, 1018 insertions(+), 642 deletions(-) diff --git a/usb/usb_standard/src/main/js/default/test/ListUsb.test.js b/usb/usb_standard/src/main/js/default/test/ListUsb.test.js index 85209cdff..5b6a5f44d 100755 --- a/usb/usb_standard/src/main/js/default/test/ListUsb.test.js +++ b/usb/usb_standard/src/main/js/default/test/ListUsb.test.js @@ -15,17 +15,17 @@ /* host test case */ -//require('./UsbCoreJsunit.test.js') -//require('./UsbCoreJsunitEx.test.js') -//require('./UsbDevicePipeJsunit.test.js') -//require('./UsbDevicePipeJsunitEx.test.js') +require('./UsbCoreJsunit.test.js') +require('./UsbCoreJsunitEx.test.js') +require('./UsbDevicePipeJsunit.test.js') +require('./UsbDevicePipeJsunitEx.test.js') /* device test case */ -//require('./UsbFunctionsJsunit.test.js') -//require('./UsbFunctionsJsunitEx.test.js') +require('./UsbFunctionsJsunit.test.js') +require('./UsbFunctionsJsunitEx.test.js') /* device and host test case */ -//require('./UsbPortJsunit.test.js') -//require('./UsbPortJsunitEx.test.js') +require('./UsbPortJsunit.test.js') +require('./UsbPortJsunitEx.test.js') require('./UsbAutoJsunit.test.js') diff --git a/usb/usb_standard/src/main/js/default/test/UsbAutoJsunit.test.js b/usb/usb_standard/src/main/js/default/test/UsbAutoJsunit.test.js index 04f435cca..a1cd7d333 100755 --- a/usb/usb_standard/src/main/js/default/test/UsbAutoJsunit.test.js +++ b/usb/usb_standard/src/main/js/default/test/UsbAutoJsunit.test.js @@ -53,208 +53,208 @@ describe('UsbAutoJsunit', function () { }) /** - * @tc.number : usb_function_to_string_test_01 + * @tc.number : SUB_USB_JS_0930 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 0 返回 'none' */ - it('SUB_USB_usb_function_to_string_test_01', 0, function () { - console.info('usb usb_function_to_string_test_01 begin'); + 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 usb_function_to_string_test_01 : PASS'); + console.info('usb SUB_USB_JS_0930 : PASS'); }) /** - * @tc.number : usb_function_to_string_test_02 + * @tc.number : SUB_USB_JS_0940 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 1 返回 'acm' */ - it('SUB_USB_usb_function_to_string_test_02', 0, function () { - console.info('usb usb_function_to_string_test_02 begin'); + 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 usb_function_to_string_test_02 : PASS'); + console.info('usb SUB_USB_JS_0940 : PASS'); }) /** - * @tc.number : usb_function_to_string_test_03 + * @tc.number : SUB_USB_JS_0950 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 2 返回 'ecm' */ - it('SUB_USB_usb_function_to_string_test_03', 0, function () { - console.info('usb usb_function_to_string_test_02 begin'); + 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 usb_function_to_string_test_02 : PASS'); + console.info('usb SUB_USB_JS_0950 : PASS'); }) /** - * @tc.number : usb_function_to_string_test_04 + * @tc.number : SUB_USB_JS_0960 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 3 返回 'acm,ecm' */ - it('SUB_USB_usb_function_to_string_test_04', 0, function () { - console.info('usb usb_function_to_string_test_02 begin'); + 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 usb_function_to_string_test_02 : PASS'); + console.info('usb SUB_USB_JS_0960 : PASS'); }) /** - * @tc.number : usb_function_to_string_test_05 + * @tc.number : SUB_USB_JS_0970 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 4 返回 'hdc' */ - it('SUB_USB_usb_function_to_string_test_05', 0, function () { - console.info('usb usb_function_to_string_test_05 begin'); + 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 usb_function_to_string_test_05 : PASS'); + console.info('usb SUB_USB_JS_0970 : PASS'); }) /** - * @tc.number : usb_function_to_string_test_06 + * @tc.number : SUB_USB_JS_0980 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 5 返回 'acm,hdc' */ - it('SUB_USB_usb_function_to_string_test_06', 0, function () { - console.info('usb usb_function_to_string_test_06 begin'); + 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('hdc,acm'); console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - console.info('usb usb_function_to_string_test_06 : PASS'); + console.info('usb SUB_USB_JS_0980 : PASS'); }) /** - * @tc.number : usb_function_to_string_test_07 + * @tc.number : SUB_USB_JS_0990 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 6 返回 'ecm,hdc' */ - it('SUB_USB_usb_function_to_string_test_07', 0, function () { - console.info('usb usb_function_to_string_test_07 begin'); + 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('hdc,ecm'); console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - console.info('usb usb_function_to_string_test_07 : PASS'); + console.info('usb SUB_USB_JS_0990 : PASS'); }) /** - * @tc.number : usb_function_from_string_test_01 + * @tc.number : SUB_USB_JS_0860 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'none' 返回 0 */ - it('SUB_USB_usb_function_from_string_test_01', 0, function () { - console.info('usb usb_function_from_string_test_01 begin'); + 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 usb_function_to_string_test_01 : PASS'); + console.info('usb SUB_USB_JS_0860 : PASS'); }) /** - * @tc.number : usb_function_from_string_test_02 + * @tc.number : SUB_USB_JS_0870 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'acm' 返回 1 */ - it('SUB_USB_usb_function_from_string_test_02', 0, function () { - console.info('usb usb_function_from_string_test_02 begin'); + 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 usb_function_from_string_test_02 : PASS'); + console.info('usb SUB_USB_JS_0870 : PASS'); }) /** - * @tc.number : usb_function_from_string_test_03 + * @tc.number : SUB_USB_JS_0880 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'ecm' 返回 2 */ - it('SUB_USB_usb_function_from_string_test_03', 0, function () { - console.info('usb usb_function_from_string_test_03 begin'); + 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 usb_function_from_string_test_03 : PASS'); + console.info('usb SUB_USB_JS_0880 : PASS'); }) /** - * @tc.number : usb_function_from_string_test_04 + * @tc.number : SUB_USB_JS_0890 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'acm,ecm' 返回 3 */ - it('SUB_USB_usb_function_from_string_test_04', 0, function () { - console.info('usb usb_function_from_string_test_04 begin'); + 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 usb_function_from_string_test_04 : PASS'); + console.info('usb SUB_USB_JS_0890 : PASS'); }) /** - * @tc.number : usb_function_from_string_test_05 + * @tc.number : SUB_USB_JS_0900 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'hdc' 返回 4 */ - it('SUB_USB_usb_function_from_string_test_05', 0, function () { - console.info('usb usb_function_from_string_test_05 begin'); + 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 usb_function_from_string_test_04 : PASS'); + console.info('usb SUB_USB_JS_0900 : PASS'); }) /** - * @tc.number : usb_function_from_string_test_06 + * @tc.number : SUB_USB_JS_0910 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'acm,hdc' 返回 5 */ - it('SUB_USB_usb_function_from_string_test_06', 0, function () { - console.info('usb usb_function_from_string_test_06 begin'); + 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 usb_function_from_string_test_06 : PASS'); + console.info('usb SUB_USB_JS_0910 : PASS'); }) /** - * @tc.number : usb_function_from_string_test_07 + * @tc.number : SUB_USB_JS_0920 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'ecm,hdc' 返回 6 */ - it('SUB_USB_usb_function_from_string_test_07', 0, function () { - console.info('usb usb_function_from_string_test_07 begin'); + 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 usb_function_from_string_test_07 : PASS'); + console.info('usb SUB_USB_JS_0920 : PASS'); }) /** - * @tc.number : get_current_functions_test_01 + * @tc.number : SUB_USB_JS_0330 * @tc.name : getCurrentFunctions * @tc.desc : 获取当前设备模式 掩码与描述字符转换 */ - it('SUB_USB_get_current_functions_test_01', 0, function () { - console.info('usb get_current_functions_test_01 begin'); + 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); @@ -263,17 +263,17 @@ describe('UsbAutoJsunit', function () { var nMaskCode = usb.usbFunctionsFromString(strMaskCode) console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode); expect(nMaskCode).assertEqual(maskCode); - console.info('usb get_current_functions_test_01 : PASS'); + console.info('usb SUB_USB_JS_0330 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : get_current_functions_test_02 + * @tc.number : SUB_USB_JS_0340 * @tc.name : usbFunctionString * @tc.desc : 反向测试 获取当前设备模式 掩码与描述字符转换 */ - it('SUB_USB_get_current_functions_test_02', 0, function () { - console.info('usb get_current_functions_test_02 begin'); + 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); @@ -293,37 +293,37 @@ describe('UsbAutoJsunit', function () { console.info('usb case errStrMaskCode ' + errStrMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - console.info('usb get_current_functions_test_02 : PASS'); + console.info('usb SUB_USB_JS_0340 : PASS'); }) /** - * @tc.number : get_ports_test_01 + * @tc.number : SUB_USB_JS_0410 * @tc.name : getPorts * @tc.desc : 获取USB端口描述信息列表 */ - it('SUB_USB_get_ports_test_01', 0, function () { - console.info('usb get_ports_test_01 begin'); + 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 get_ports_test_01 usbPortList is null'); + console.info('usb SUB_USB_JS_0410 usbPortList is null'); expect(false).assertTrue(); return } expect(usbPortList.length > 0).assertTrue(); - console.info('usb get_ports_test_01 : PASS'); + console.info('usb SUB_USB_JS_0410 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : get_supported_modes_test_01 + * @tc.number : SUB_USB_JS_0220 * @tc.name : getSupportedModes * @tc.desc : 获取指定的端口支持的模式列表的组合掩码 */ - it('SUB_USB_get_supported_modes_test_01', 0, function () { - console.info('usb get_supported_modes_test_01 begin'); + 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 get_supported_modes_test_01 usbPortList is null'); + console.info('usb SUB_USB_JS_0220 usbPortList is null'); expect(false).assertTrue(); return } @@ -334,20 +334,20 @@ describe('UsbAutoJsunit', function () { expect(maskCode).assertEqual(usbPortList[i].supportedModes); } - console.info('usb get_supported_modes_test_01 : PASS'); + console.info('usb SUB_USB_JS_0220 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : get_supported_modes_test_02 + * @tc.number : SUB_USB_JS_0230 * @tc.name : getSupportedModes * @tc.desc : 反向测试 改变id 获取指定的端口支持的模式列表的组合掩码 */ - it('SUB_USB_get_supported_modes_test_02', 0, function () { - console.info('usb get_supported_modes_test_02 begin'); + 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 get_supported_modes_test_01 usbPortList is null'); + console.info('usb SUB_USB_JS_0230 usbPortList is null'); expect(false).assertTrue(); return } @@ -358,7 +358,7 @@ describe('UsbAutoJsunit', function () { var maskCode = usb.getSupportedModes(portID) expect(maskCode).assertEqual(0); - console.info('usb get_supported_modes_test_02 : PASS'); + console.info('usb SUB_USB_JS_0230 : PASS'); expect(true).assertTrue(); }) diff --git a/usb/usb_standard/src/main/js/default/test/UsbCoreJsunit.test.js b/usb/usb_standard/src/main/js/default/test/UsbCoreJsunit.test.js index bd0ebb2e9..162dc8087 100755 --- a/usb/usb_standard/src/main/js/default/test/UsbCoreJsunit.test.js +++ b/usb/usb_standard/src/main/js/default/test/UsbCoreJsunit.test.js @@ -21,21 +21,32 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from /* usb core functions test */ describe('UsbCoreJsFunctionsTest', function () { + var gDeviceList; + var gPipe; + var portCurrentMode; + beforeAll(function () { console.log('*************Usb Unit UsbCoreJsFunctionsTest Begin*************'); var Version = usb.getVersion() console.info('begin test getversion :' + Version) // version > 17 host currentMode = 2 device currentMode = 1 var usbPortList = usb.getPorts() + gDeviceList = usb.getDevices(); if (usbPortList.length > 0) { - if (usbPortList[0].status.currentMode == 1) { - usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).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 Begin switch to host*************'); + console.info('usb case gDeviceList.length return: ' + gDeviceList.length); + 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 Begin switch to host*************'); + } + } else { + portCurrentMode = 1 } } }) @@ -49,16 +60,19 @@ describe('UsbCoreJsFunctionsTest', function () { console.log('*************Usb Unit UsbCoreJsFunctionsTest End*************'); }) - var gDeviceList - var gPipe; - /** - * @tc.number : SUB_USB_get_devices_test_01 + * @tc.number : SUB_USB_JS_0480 * @tc.name : getDevices * @tc.desc : 获取设备列表 */ - it('SUB_USB_get_devices_test_01', 0, function () { - console.info('usb get_device_01 begin'); + it('SUB_USB_JS_0480', 0, function () { + console.info('*****SUB_USB_JS_0480 portcurrentMode**** ret : ' + portCurrentMode) + if (portCurrentMode == 1) { + console.info('usb case get_device port is device') + expect(false).assertFalse(); + return + } + console.info('usb SUB_USB_JS_0480 begin'); gDeviceList = usb.getDevices(); if (gDeviceList.length == 0) { console.info('usb case get_devices list is null') @@ -67,17 +81,22 @@ describe('UsbCoreJsFunctionsTest', function () { } expect(gDeviceList.length).assertLarger(0); console.info('usb case getDevices ret length: ' + gDeviceList.length); - console.info('usb get_devices_test_01: PASS'); + console.info('usb SUB_USB_JS_0480: PASS'); }) /** - * @tc.number : SUB_USB_has_right_01 + * @tc.number : SUB_USB_JS_0710 * @tc.name : hasRigt * @tc.desc : 权限查询 连接设备 关闭设备 */ - it('SUB_USB_has_right_01', 0, function () { + it('SUB_USB_JS_0710', 0, function () { console.info('usb has_right_01 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(); @@ -89,18 +108,23 @@ describe('UsbCoreJsFunctionsTest', function () { console.info('usb has_right ret :' + hasRight); } - console.info('usb has_right_01 : PASS'); + console.info('usb SUB_USB_JS_0710 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_request_right_01 + * @tc.number : SUB_USB_JS_0680 * @tc.name : requestRight * @tc.desc : 请求权限 */ - it('SUB_USB_request_right_01', 0, function () { - console.info('usb request_right_01 begin'); + it('SUB_USB_JS_0680', 0, function () { + console.info('usb SUB_USB_JS_0680 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(); @@ -111,7 +135,7 @@ describe('UsbCoreJsFunctionsTest', function () { usb.requestRight(gDeviceList[i].name).then(hasRight => { expect(hasRight).assertTrue(); console.info('usb request_right ret :' + hasRight); - console.info('usb request_right_01 : PASS'); + console.info('usb SUB_USB_JS_0680 : PASS'); }).catch(error => { console.info('usb case device request right failed : ' + error + ' :' + gDeviceList[i].name); expect(false).assertTrue(); @@ -120,12 +144,17 @@ describe('UsbCoreJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_connect_device_01 + * @tc.number : SUB_USB_JS_0090 * @tc.name : connectDevice * @tc.desc : 打开设备 */ - it('SUB_USB_connect_device_01', 0, function () { - console.info('usb connect_device_01 begin'); + it('SUB_USB_JS_0090', 0, function () { + console.info('usb SUB_USB_JS_0090 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(); @@ -145,16 +174,21 @@ describe('UsbCoreJsFunctionsTest', function () { console.info('usb case connectDevice ret: ' + JSON.stringify(gPipe)); expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse(); - console.info('usb connect_device_01 : PASS'); + console.info('usb SUB_USB_JS_0090 : PASS'); }) /** - * @tc.number : SUB_USB_close_pipe_02 + * @tc.number : SUB_USB_JS_0250 * @tc.name : closePipe * @tc.desc : 反向测试 关闭设备 错误 busNum */ - it('SUB_USB_close_pipe_02', 0, function () { - console.info('usb close_pipe_02 begin'); + it('SUB_USB_JS_0250', 0, function () { + console.info('usb SUB_USB_JS_0250 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(); @@ -167,16 +201,21 @@ describe('UsbCoreJsFunctionsTest', function () { console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose == 0).assertFalse(); - console.info('usb close_pipe_02 : PASS'); + console.info('usb SUB_USB_JS_0250 : PASS'); }) /** - * @tc.number : SUB_USB_close_pipe_03 + * @tc.number : SUB_USB_JS_0260 * @tc.name : closePipe * @tc.desc : 反向测试 关闭设备 错误 devAddress */ - it('SUB_USB_close_pipe_03', 0, function () { - console.info('usb close_pipe_03 begin'); + it('SUB_USB_JS_0260', 0, function () { + console.info('usb SUB_USB_JS_0260 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(); @@ -188,16 +227,21 @@ describe('UsbCoreJsFunctionsTest', function () { console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose == 0).assertFalse(); - console.info('usb close_pipe_03 : PASS'); + console.info('usb SUB_USB_JS_0260 : PASS'); }) /** - * @tc.number : SUB_USB_close_pipe_04 + * @tc.number : SUB_USB_JS_0270 * @tc.name : closePipe * @tc.desc : 反向测试 关闭设备 错误 devAddress busNum */ - it('SUB_USB_close_pipe_04', 0, function () { - console.info('usb close_pipe_04 begin'); + it('SUB_USB_JS_0270', 0, function () { + console.info('usb SUB_USB_JS_0270 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(); @@ -210,16 +254,21 @@ describe('UsbCoreJsFunctionsTest', function () { console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose == 0).assertFalse(); - console.info('usb close_pipe_04 : PASS'); + console.info('usb SUB_USB_JS_0270 : PASS'); }) /** - * @tc.number : SUB_USB_close_pipe_01 + * @tc.number : SUB_USB_JS_0240 * @tc.name : closePipe * @tc.desc : 关闭设备 */ - it('SUB_USB_close_pipe_01', 0, function () { - console.info('usb close_pipe_01 begin'); + it('SUB_USB_JS_0240', 0, function () { + console.info('usb SUB_USB_JS_0240 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(); @@ -231,15 +280,21 @@ describe('UsbCoreJsFunctionsTest', function () { console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose).assertEqual(0); - console.info('usb close_pipe_01 : PASS'); + console.info('usb SUB_USB_JS_0240 : PASS'); }) /** - * @tc.number : SUB_USB_get_raw_descriptor_01 + * @tc.number : SUB_USB_JS_0530 * @tc.name : getRawDescriptor * @tc.desc : 获取原始的USB描述符 */ - it('SUB_USB_get_raw_descriptor_01', 0, function () { + it('SUB_USB_JS_0530', 0, function () { + console.info('usb SUB_USB_JS_0530 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(); @@ -254,15 +309,21 @@ describe('UsbCoreJsFunctionsTest', function () { var isPipClose = usb.closePipe(gPipe); expect(isPipClose).assertEqual(0); - console.info('usb SUB_USB_get_raw_descriptor_01 : PASS'); + console.info('usb SUB_USB_JS_0530 : PASS'); }) /** - * @tc.number : SUB_USB_get_file_descriptor_01 + * @tc.number : SUB_USB_JS_0490 * @tc.name : getFileDescriptor * @tc.desc : 获取文件描述符 */ - it('SUB_USB_get_file_descriptor_01', 0, function () { + it('SUB_USB_JS_0490', 0, function () { + console.info('usb SUB_USB_JS_0490 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(); @@ -276,15 +337,21 @@ describe('UsbCoreJsFunctionsTest', function () { var isPipClose = usb.closePipe(gPipe); expect(isPipClose).assertEqual(0); - console.info('usb SUB_USB_get_file_descriptor_01 : PASS'); + console.info('usb SUB_USB_JS_0490 : PASS'); }) /** - * @tc.number : SUB_USB_get_file_descriptor_02 + * @tc.number : SUB_USB_JS_0500 * @tc.name : getFileDescriptor * @tc.desc : 获取文件描述符,反向测试,错误参数busNum=512 */ - it('SUB_USB_get_file_descriptor_02', 0, function () { + it('SUB_USB_JS_0500', 0, function () { + console.info('usb SUB_USB_JS_0500 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(); @@ -298,15 +365,21 @@ describe('UsbCoreJsFunctionsTest', function () { console.info('usb case getFileDescriptor ret: ' + fileDescriptor); var isPipClose = usb.closePipe(gPipe); expect(isPipClose).assertEqual(0); - console.info('usb SUB_USB_get_file_descriptor_02 : PASS'); + console.info('usb SUB_USB_JS_0500 : PASS'); }) /** - * @tc.number : SUB_USB_get_file_descriptor_03 + * @tc.number : SUB_USB_JS_0510 * @tc.name : getFileDescriptor * @tc.desc : 获取文件描述符,反向测试,错误参数devAddress=512 */ - it('SUB_USB_get_file_descriptor_03', 0, function () { + it('SUB_USB_JS_0510', 0, function () { + console.info('usb get_file_descriptor_03 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(); @@ -320,15 +393,21 @@ describe('UsbCoreJsFunctionsTest', function () { console.info('usb case getFileDescriptor ret: ' + fileDescriptor); var isPipClose = usb.closePipe(gPipe); expect(isPipClose).assertEqual(0); - console.info('usb SUB_USB_get_file_descriptor_03 : PASS'); + console.info('usb SUB_USB_JS_0510 : PASS'); }) /** - * @tc.number : SUB_USB_get_file_descriptor_04 + * @tc.number : SUB_USB_JS_0520 * @tc.name : getFileDescriptor * @tc.desc : 获取文件描述符,反向测试,错误参数busNum=512,devAddress=512 */ - it('SUB_USB_get_file_descriptor_04', 0, function () { + it('SUB_USB_JS_0520', 0, function () { + console.info('usb get_file_descriptor_04 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(); @@ -342,7 +421,7 @@ describe('UsbCoreJsFunctionsTest', function () { console.info('usb case getFileDescriptor ret: ' + fileDescriptor); var isPipClose = usb.closePipe(gPipe); expect(isPipClose).assertEqual(0); - console.info('usb SUB_USB_get_file_descriptor_04 : PASS'); + console.info('usb SUB_USB_JS_0520 : PASS'); }) }) diff --git a/usb/usb_standard/src/main/js/default/test/UsbCoreJsunitEx.test.js b/usb/usb_standard/src/main/js/default/test/UsbCoreJsunitEx.test.js index 3e6037f0a..7b13b6429 100755 --- a/usb/usb_standard/src/main/js/default/test/UsbCoreJsunitEx.test.js +++ b/usb/usb_standard/src/main/js/default/test/UsbCoreJsunitEx.test.js @@ -20,24 +20,32 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from /* usb core functions test */ describe('UsbCoreJsFunctionsTestEx', function () { + var gDeviceList + var portCurrentMode + beforeAll(function () { console.log('*************Usb Unit UsbCoreJsFunctionsTestEx Begin*************'); var Version = usb.getVersion() console.info('begin test getversion :' + Version) // version > 17 host currentMode = 2 device currentMode = 1 var usbPortList = usb.getPorts() + gDeviceList = usb.getDevices(); if (usbPortList.length > 0) { - if (usbPortList[0].status.currentMode == 1) { - usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => { - console.info('usb case setPortRolesEx return: ' + data); - }).catch(error => { - console.info('usb case setPortRolesEx error : ' + error); - }); - console.log('*************Usb Unit Begin switch to host*************'); + 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 setPortRolesEx return: ' + data); + }).catch(error => { + console.info('usb case setPortRolesEx error : ' + error); + }); + console.log('*************Usb Unit Begin switch to host*************'); + } + } else { + portCurrentMode = 1 } } - gDeviceList = usb.getDevices(); }) beforeEach(function () { console.info('beforeEach: *************Usb Unit Test CaseEx*************'); @@ -51,12 +59,18 @@ describe('UsbCoreJsFunctionsTestEx', function () { /** - * @tc.number : SUB_USB_connect_device_02 + * @tc.number : SUB_USB_JS_0100 * @tc.name : connectDevice * @tc.desc : 反向测试 错误参数 devAddress 打开设备 */ - it('SUB_USB_connect_device_02', 0, function () { - console.info('usb connect_device_02 begin'); + it('SUB_USB_JS_0100', 0, function () { + console.info('usb SUB_USB_JS_0100 begin'); + console.info('*****SUB_USB_JS_0100 portCurrentMode**** ret : ' + portCurrentMode) + 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(); @@ -66,9 +80,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { if (!isRight) { usb.requestRight(gDeviceList[0].name).then(hasRight => { }).catch(error => { - console.info('usb 02 requestRight error:' + error); + console.info('usb JS_0100 requestRight error:' + error); }); - console.info('usb 02 requestRight end:'); + console.info('usb JS_0100 requestRight end:'); CheckEmptyUtils.sleep(3000) } @@ -84,16 +98,21 @@ describe('UsbCoreJsFunctionsTestEx', function () { ' devAddress ' + device.devAddress); expect(CheckEmptyUtils.isEmpty(usbDevicePipe)).assertTrue(); - console.info('usb connect_device_02 : PASS'); + console.info('usb SUB_USB_JS_0100 : PASS'); }) /** - * @tc.number : SUB_USB_connect_device_03 + * @tc.number : SUB_USB_JS_0110 * @tc.name : connectDevice * @tc.desc : 反向测试 busNum错误参数 打开设备 */ - it('SUB_USB_connect_device_03', 0, function () { - console.info('usb connect_device_03 begin'); + it('SUB_USB_JS_0110', 0, function () { + console.info('usb SUB_USB_JS_0110 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(); @@ -103,9 +122,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { if (!isRight) { usb.requestRight(gDeviceList[0].name).then(hasRight => { }).catch(error => { - console.info('usb 03 requestRight error:' + error); + console.info('usb JS_0110 requestRight error:' + error); }); - console.info('usb 03 requestRight end:'); + console.info('usb JS_0110 requestRight end:'); CheckEmptyUtils.sleep(3000) } @@ -120,16 +139,21 @@ describe('UsbCoreJsFunctionsTestEx', function () { console.info('usb case connectDevice ret: ' + JSON.stringify(usbDevicePipe) + ' busNum ' + device.busNum); expect(CheckEmptyUtils.isEmpty(usbDevicePipe)).assertTrue(); - console.info('usb connect_device_03 : PASS'); + console.info('usb SUB_USB_JS_0110 : PASS'); }) /** - * @tc.number : SUB_USB_connect_device_04 + * @tc.number : SUB_USB_JS_0120 * @tc.name : connectDevice * @tc.desc : 反向测试 serial错误参数 打开设备 */ - it('SUB_USB_connect_device_04', 0, function () { - console.info('usb connect_device_04 begin'); + it('SUB_USB_JS_0120', 0, function () { + console.info('usb SUB_USB_JS_0120 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(); @@ -139,9 +163,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { if (!isRight) { usb.requestRight(gDeviceList[0].name).then(hasRight => { }).catch(error => { - console.info('usb 04 requestRight error:' + error); + console.info('usb JS_0120 requestRight error:' + error); }); - console.info('usb 04 requestRight end:'); + console.info('usb JS_0120 requestRight end:'); CheckEmptyUtils.sleep(3000) } @@ -159,16 +183,21 @@ describe('UsbCoreJsFunctionsTestEx', function () { var isPipClose = usb.closePipe(usbDevicePipe); console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose).assertEqual(0); - console.info('usb connect_device_04 : PASS'); + console.info('usb SUB_USB_JS_0120 : PASS'); }) /** - * @tc.number : SUB_USB_connect_device_05 + * @tc.number : SUB_USB_JS_0130 * @tc.name : connectDevice * @tc.desc : 反向测试 name错误参数 打开设备 */ - it('SUB_USB_connect_device_05', 0, function () { - console.info('usb connect_device_05 begin'); + it('SUB_USB_JS_0130', 0, function () { + console.info('usb SUB_USB_JS_0130 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(); @@ -178,9 +207,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { if (!isRight) { usb.requestRight(gDeviceList[0].name).then(hasRight => { }).catch(error => { - console.info('usb 05 requestRight error:' + error); + console.info('usb JS_0130 requestRight error:' + error); }); - console.info('usb 05 requestRight end:'); + console.info('usb JS_0130 requestRight end:'); CheckEmptyUtils.sleep(3000) } @@ -197,16 +226,21 @@ describe('UsbCoreJsFunctionsTestEx', function () { var isPipClose = usb.closePipe(usbDevicePipe); console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose).assertEqual(0); - console.info('usb connect_device_05 : PASS'); + console.info('usb SUB_USB_JS_0130 : PASS'); }) /** - * @tc.number : SUB_USB_connect_device_06 + * @tc.number : SUB_USB_JS_0140 * @tc.name : connectDevice * @tc.desc : 反向测试 manufacturerName错误参数 打开设备 */ - it('SUB_USB_connect_device_06', 0, function () { + it('SUB_USB_JS_0140', 0, function () { console.info('usb connect_device_06 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(); @@ -216,9 +250,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { if (!isRight) { usb.requestRight(gDeviceList[0].name).then(hasRight => { }).catch(error => { - console.info('usb 06 requestRight error:' + error); + console.info('usb JS_0140 requestRight error:' + error); }); - console.info('usb 06 requestRight end:'); + console.info('usb JS_0140 requestRight end:'); CheckEmptyUtils.sleep(3000) } @@ -236,16 +270,21 @@ describe('UsbCoreJsFunctionsTestEx', function () { var isPipClose = usb.closePipe(usbDevicePipe); console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose).assertEqual(0); - console.info('usb connect_device_06 : PASS'); + console.info('usb SUB_USB_JS_0140 : PASS'); }) /** - * @tc.number : SUB_USB_connect_device_07 + * @tc.number : SUB_USB_JS_0150 * @tc.name : connectDevice * @tc.desc : 反向测试 productName错误参数 打开设备 */ - it('SUB_USB_connect_device_07', 0, function () { - console.info('usb connect_device_07 begin'); + it('SUB_USB_JS_0150', 0, function () { + console.info('usb SUB_USB_JS_0150 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(); @@ -255,9 +294,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { if (!isRight) { usb.requestRight(gDeviceList[0].name).then(hasRight => { }).catch(error => { - console.info('usb 07 requestRight error:' + error); + console.info('usb SUB_USB_JS_0150 requestRight error:' + error); }); - console.info('usb 07 requestRight end:'); + console.info('usb SUB_USB_JS_0150 requestRight end:'); CheckEmptyUtils.sleep(3000) } @@ -275,16 +314,21 @@ describe('UsbCoreJsFunctionsTestEx', function () { var isPipClose = usb.closePipe(usbDevicePipe); console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose).assertEqual(0); - console.info('usb connect_device_07 : PASS'); + console.info('usb SUB_USB_JS_0150 : PASS'); }) /** - * @tc.number : SUB_USB_connect_device_08 + * @tc.number : SUB_USB_JS_0160 * @tc.name : connectDevice * @tc.desc : 反向测试 version错误参数 打开设备 */ - it('SUB_USB_connect_device_08', 0, function () { + it('SUB_USB_JS_0160', 0, function () { console.info('usb connect_device_08 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(); @@ -294,9 +338,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { if (!isRight) { usb.requestRight(gDeviceList[0].name).then(hasRight => { }).catch(error => { - console.info('usb 08 requestRight error:' + error); + console.info('usb SUB_USB_JS_0160 requestRight error:' + error); }); - console.info('usb 08 requestRight end:'); + console.info('usb SUB_USB_JS_0160 requestRight end:'); CheckEmptyUtils.sleep(3000) } @@ -314,16 +358,21 @@ describe('UsbCoreJsFunctionsTestEx', function () { var isPipClose = usb.closePipe(usbDevicePipe); console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose).assertEqual(0); - console.info('usb connect_device_08 : PASS'); + console.info('usb SUB_USB_JS_0160 : PASS'); }) /** - * @tc.number : SUB_USB_connect_device_09 + * @tc.number : SUB_USB_JS_0170 * @tc.name : connectDevice * @tc.desc : 反向测试 vendorId错误参数 打开设备 */ - it('SUB_USB_connect_device_09', 0, function () { + it('SUB_USB_JS_0170', 0, function () { console.info('usb connect_device_09 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(); @@ -333,9 +382,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { if (!isRight) { usb.requestRight(gDeviceList[0].name).then(hasRight => { }).catch(error => { - console.info('usb 09 requestRight error:' + error); + console.info('usb SUB_USB_JS_0170 requestRight error:' + error); }); - console.info('usb 09 requestRight end:'); + console.info('usb SUB_USB_JS_0170 requestRight end:'); CheckEmptyUtils.sleep(3000) } @@ -353,16 +402,21 @@ describe('UsbCoreJsFunctionsTestEx', function () { var isPipClose = usb.closePipe(usbDevicePipe); console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose).assertEqual(0); - console.info('usb connect_device_09 : PASS'); + console.info('usb SUB_USB_JS_0170 : PASS'); }) /** - * @tc.number : SUB_USB_connect_device_10 + * @tc.number : SUB_USB_JS_0180 * @tc.name : connectDevice * @tc.desc : 反向测试 productId错误参数 打开设备 */ - it('SUB_USB_connect_device_10', 0, function () { + it('SUB_USB_JS_0180', 0, function () { console.info('usb connect_device_10 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(); @@ -372,9 +426,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { if (!isRight) { usb.requestRight(gDeviceList[0].name).then(hasRight => { }).catch(error => { - console.info('usb 10 requestRight error:' + error); + console.info('usb SUB_USB_JS_0180 requestRight error:' + error); }); - console.info('usb 10 requestRight end:'); + console.info('usb SUB_USB_JS_0180 requestRight end:'); CheckEmptyUtils.sleep(3000) } @@ -392,16 +446,21 @@ describe('UsbCoreJsFunctionsTestEx', function () { var isPipClose = usb.closePipe(usbDevicePipe); console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose).assertEqual(0); - console.info('usb connect_device_10 : PASS'); + console.info('usb SUB_USB_JS_0180 : PASS'); }) /** - * @tc.number : SUB_USB_connect_device_11 + * @tc.number : SUB_USB_JS_0190 * @tc.name : connectDevice * @tc.desc : 反向测试 clazz错误参数 打开设备 */ - it('SUB_USB_connect_device_11', 0, function () { + it('SUB_USB_JS_0190', 0, function () { console.info('usb connect_device_11 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(); @@ -411,9 +470,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { if (!isRight) { usb.requestRight(gDeviceList[0].name).then(hasRight => { }).catch(error => { - console.info('usb 11 requestRight error:' + error); + console.info('usb SUB_USB_JS_0190 requestRight error:' + error); }); - console.info('usb 11 requestRight end:'); + console.info('usb SUB_USB_JS_0190 requestRight end:'); CheckEmptyUtils.sleep(3000) } @@ -430,16 +489,21 @@ describe('UsbCoreJsFunctionsTestEx', function () { var isPipClose = usb.closePipe(usbDevicePipe); console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose).assertEqual(0); - console.info('usb connect_device_11 : PASS'); + console.info('usb SUB_USB_JS_0190 : PASS'); }) /** - * @tc.number : SUB_USB_connect_device_12 + * @tc.number : SUB_USB_JS_0200 * @tc.name : connectDevice * @tc.desc : 反向测试 subclass错误参数 打开设备 */ - it('SUB_USB_connect_device_12', 0, function () { + it('SUB_USB_JS_0200', 0, function () { console.info('usb connect_device_12 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(); @@ -449,9 +513,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { if (!isRight) { usb.requestRight(gDeviceList[0].name).then(hasRight => { }).catch(error => { - console.info('usb 12 requestRight error:' + error); + console.info('usb SUB_USB_JS_0200 requestRight error:' + error); }); - console.info('usb 12 requestRight end:'); + console.info('usb SUB_USB_JS_0200 requestRight end:'); CheckEmptyUtils.sleep(3000) } @@ -468,16 +532,21 @@ describe('UsbCoreJsFunctionsTestEx', function () { var isPipClose = usb.closePipe(usbDevicePipe); console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose).assertEqual(0); - console.info('usb connect_device_12 : PASS'); + console.info('usb SUB_USB_JS_0200 : PASS'); }) /** - * @tc.number : SUB_USB_connect_device_13 + * @tc.number : SUB_USB_JS_0210 * @tc.name : connectDevice * @tc.desc : 反向测试 protocol错误参数 打开设备 */ - it('SUB_USB_connect_device_13', 0, function () { + it('SUB_USB_JS_0210', 0, function () { console.info('usb connect_device_13 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(); @@ -487,9 +556,9 @@ describe('UsbCoreJsFunctionsTestEx', function () { if (!isRight) { usb.requestRight(gDeviceList[0].name).then(hasRight => { }).catch(error => { - console.info('usb 13 requestRight error:' + error); + console.info('usb SUB_USB_JS_0210 requestRight error:' + error); }); - console.info('usb 13 requestRight end:'); + console.info('usb SUB_USB_JS_0210 requestRight end:'); CheckEmptyUtils.sleep(3000) } @@ -506,16 +575,21 @@ describe('UsbCoreJsFunctionsTestEx', function () { var isPipClose = usb.closePipe(usbDevicePipe); console.info('usb case closePipe ret: ' + isPipClose); expect(isPipClose).assertEqual(0); - console.info('usb connect_device_13 : PASS'); + console.info('usb SUB_USB_JS_0210 : PASS'); }) /** - * @tc.number : SUB_USB_has_right_02 + * @tc.number : SUB_USB_JS_0720 * @tc.name : hasRight * @tc.desc : 反向测试 给错误设备名字 */ - it('SUB_USB_has_right_02', 0, function () { - console.info('usb has_right_02 begin'); + it('SUB_USB_JS_0720', 0, function () { + console.info('usb SUB_USB_JS_0720 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(); @@ -530,17 +604,22 @@ describe('UsbCoreJsFunctionsTestEx', function () { expect(hasRight == false).assertTrue(); } - console.info('usb has_right_02 : PASS'); + console.info('usb SUB_USB_JS_0720 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_has_right_03 + * @tc.number : SUB_USB_JS_0730 * @tc.name : hasRight * @tc.desc : 反向测试 给设备名字为字母 */ - it('SUB_USB_has_right_03', 0, function () { - console.info('usb has_right_03 begin'); + it('SUB_USB_JS_0730', 0, function () { + console.info('usb SUB_USB_JS_0730 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(); @@ -555,17 +634,22 @@ describe('UsbCoreJsFunctionsTestEx', function () { expect(hasRight == false).assertTrue(); } - console.info('usb has_right_03 : PASS'); + console.info('usb SUB_USB_JS_0730 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_request_right_02 + * @tc.number : SUB_USB_JS_0690 * @tc.name : requestRight * @tc.desc : 反向测试 错误设备名字 请求权限 */ - it('SUB_USB_request_right_02', 0, function () { - console.info('usb request_right_02 begin'); + it('SUB_USB_JS_0690', 0, function () { + console.info('usb SUB_USB_JS_0690 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(); @@ -578,21 +662,26 @@ describe('UsbCoreJsFunctionsTestEx', function () { usb.requestRight(diviceName).then(hasRight => { console.info('usb request_right ret :' + hasRight); expect(hasRight).assertFalse(); - console.info('usb request_right_02 : PASS'); + console.info('usb SUB_USB_JS_0690 : PASS'); }).catch(error => { expect(error).assertFalse(); - console.info('usb request_right_02 error: ' + error); + console.info('usb SUB_USB_JS_0690 error: ' + error); }); } }) /** - * @tc.number : SUB_USB_request_right_03 + * @tc.number : SUB_USB_JS_0700 * @tc.name : requestRight * @tc.desc : 反向测试 设备名字为数字 请求权限 */ - it('SUB_USB_request_right_03', 0, function () { - console.info('usb request_right_03 begin'); + it('SUB_USB_JS_0700', 0, function () { + console.info('usb SUB_USB_JS_0700 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(); @@ -605,10 +694,10 @@ describe('UsbCoreJsFunctionsTestEx', function () { usb.requestRight(diviceName).then(hasRight => { console.info('usb request_right ret :' + hasRight); expect(hasRight).assertFalse(); - console.info('usb request_right_03 : PASS'); + console.info('usb SUB_USB_JS_0700 : PASS'); }).catch(error => { expect(error).assertFalse(); - console.info('usb request_right_03 error: ' + error); + console.info('usb SUB_USB_JS_0700 error: ' + error); }); } }) diff --git a/usb/usb_standard/src/main/js/default/test/UsbDevicePipeJsunit.test.js b/usb/usb_standard/src/main/js/default/test/UsbDevicePipeJsunit.test.js index a2fc702fb..0ff53d603 100755 --- a/usb/usb_standard/src/main/js/default/test/UsbDevicePipeJsunit.test.js +++ b/usb/usb_standard/src/main/js/default/test/UsbDevicePipeJsunit.test.js @@ -21,8 +21,10 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from /* usb device pipe test */ describe('UsbDevicePipeJsFunctionsTest', function () { + var gDeviceList var gPipe + var portCurrentMode beforeAll(function () { console.log('*************Usb Unit UsbDevicePipeJsFunctionsTest Begin*************'); @@ -30,18 +32,23 @@ describe('UsbDevicePipeJsFunctionsTest', function () { 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 (usbPortList[0].status.currentMode == 1) { - usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => { - console.info('usb case setPortRoles return: ' + data); - }).catch(error => { - console.info('usb case setPortRoles error : ' + error); - }); - console.log('*************Usb Unit switch to host Begin*************'); + 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); + }); + console.log('*************Usb Unit switch to host Begin*************'); + } + } else { + portCurrentMode = 1 } } - gDeviceList = usb.getDevices(); gPipe = usb.connectDevice(gDeviceList[0]) console.info('usb unit connectDevice gPipe ret : ' + JSON.stringify(gPipe)); }) @@ -131,12 +138,18 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } /** - * @tc.number : SUB_USB_bulk_transfer_test_01 + * @tc.number : SUB_USB_JS_0630 * @tc.name : bulkTransfer * @tc.desc : 批量传输 收数据 */ - it('SUB_USB_bulk_transfer_test_01', 0, function () { - console.info('usb bulk_transfer_test_01 begin'); + 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(); @@ -151,7 +164,7 @@ 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 bulk_transfer_test_01 : PASS'); + console.info('usb case SUB_USB_JS_0630 : PASS'); expect(data >= 0).assertTrue(); }).catch(error => { console.info('usb case readData error : ' + JSON.stringify(error)); @@ -160,12 +173,17 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_bulk_transfer_test_02 + * @tc.number : SUB_USB_JS_0640 * @tc.name : bulkTransfer * @tc.desc : 批量传输 发数据 */ - it('SUB_USB_bulk_transfer_test_02', 0, function () { - console.info('usb bulk_transfer_test_02 begin'); + 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(); @@ -185,9 +203,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var tmpUint8Array = CheckEmptyUtils.str2ab(testParam.sendData); usb.bulkTransfer(testParam.pip, testParam.outEndpoint, tmpUint8Array, 5000).then(data => { - console.info('usb case bulk_transfer_test_02 ret: ' + data); - console.info('usb case bulk_transfer_test_02 send data: ' + testParam.sendData); - console.info('usb case bulk_transfer_test_02 : PASS'); + 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)); @@ -197,12 +215,17 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_claim_interface_test_01 + * @tc.number : SUB_USB_JS_0420 * @tc.name : claimInterface * @tc.desc : 获取接口 并释放 */ - it('SUB_USB_claim_interface_test_01', 0, function () { - console.info('usb claim_interface_test_01 begin'); + 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); @@ -232,7 +255,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } } - console.info('usb claim_interface_test_01 : PASS'); + console.info('usb SUB_USB_JS_0420 : PASS'); expect(true).assertTrue(); }) @@ -253,12 +276,17 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } /** - * @tc.number : SUB_USB_set_configuration_test_01 + * @tc.number : SUB_USB_JS_0740 * @tc.name : setConfiguration * @tc.desc : 设置设备接口 */ - it('SUB_USB_set_configuration_test_01', 0, function () { - console.info('usb set_configuration_test_01 begin'); + 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(); @@ -272,17 +300,22 @@ describe('UsbDevicePipeJsFunctionsTest', function () { expect(ret).assertEqual(0); } - console.info('usb set_configuration_test_01 : PASS'); + console.info('usb SUB_USB_JS_0740 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_configuration_test_02 + * @tc.number : SUB_USB_JS_0750 * @tc.name : setConfiguration * @tc.desc : 反向测试 设置设备接口 */ - it('SUB_USB_set_configuration_test_02', 0, function () { - console.info('usb set_configuration_test_02 begin'); + 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(); @@ -297,16 +330,21 @@ describe('UsbDevicePipeJsFunctionsTest', function () { expect(ret).assertLess(0); } - console.info('usb set_configuration_test_02 : PASS'); + console.info('usb SUB_USB_JS_0750 : PASS'); }) /** - * @tc.number : SUB_USB_set_interface_test_01 + * @tc.number : SUB_USB_JS_0800 * @tc.name : setInterface * @tc.desc : 设置设备接口 */ - it('SUB_USB_set_interface_test_01', 0, function () { - console.info('usb set_interface_test_01 begin'); + 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(); @@ -323,17 +361,22 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } } - console.info('usb set_interface_test_01 : PASS'); + console.info('usb SUB_USB_JS_0800 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_interface_test_02 + * @tc.number : SUB_USB_JS_0810 * @tc.name : setInterface * @tc.desc : 反向测试 设置设备接口 */ - it('SUB_USB_set_interface_test_02', 0, function () { - console.info('usb set_interface_test_02 begin'); + 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() @@ -352,7 +395,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } } - console.info('usb set_interface_test_02 : PASS'); + console.info('usb SUB_USB_JS_0810 : PASS'); expect(true).assertTrue(); }) @@ -370,12 +413,17 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } /** - * @tc.number : SUB_USB_control_transfer_test_01 + * @tc.number : SUB_USB_JS_0540 * @tc.name : controlTransfer * @tc.desc : 控制传输 GetDescriptor: cmd 6 reqType 128 value 512 index 0 */ - it('SUB_USB_control_transfer_test_01', 0, function () { - console.info('usb control_transfer_test_01 begin'); + 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(); @@ -385,16 +433,21 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(6, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7) | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), (2 << 8), 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_01 GetDescriptor') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0540 GetDescriptor') }) /** - * @tc.number : SUB_USB_control_transfer_test_02 + * @tc.number : SUB_USB_JS_0550 * @tc.name : controlTransfer * @tc.desc : 控制传输 GetStatus: cmd 0 reqType 128 value 0 index 0 */ - it('SUB_USB_control_transfer_test_02', 0, function () { - console.info('usb control_transfer_test_02 begin'); + 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(); @@ -404,16 +457,21 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(0, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7) | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_02 GetStatus') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0550 GetStatus') }) /** - * @tc.number : SUB_USB_control_transfer_test_03 + * @tc.number : SUB_USB_JS_0560 * @tc.name : controlTransfer * @tc.desc : 控制传输 GetConfiguration: cmd 8 reqType 128 value 0 index 0 */ - it('SUB_USB_control_transfer_test_03', 0, function () { - console.info('usb control_transfer_test_03 begin'); + 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(); @@ -423,16 +481,21 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(8, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7) | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_03 GetConfiguration') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0560 GetConfiguration') }) /** - * @tc.number : SUB_USB_control_transfer_test_04 + * @tc.number : SUB_USB_JS_0570 * @tc.name : controlTransfer * @tc.desc : 控制传输 GetInterface: cmd 10 reqType 129 value 0 index 1 */ - it('SUB_USB_control_transfer_test_04', 0, function () { - console.info('usb control_transfer_test_04 begin'); + 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(); @@ -442,16 +505,21 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(10, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7) | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_INTERFACE & 0x1f), 0, 1) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_04 GetInterface') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0570 GetInterface') }) /** - * @tc.number : SUB_USB_control_transfer_test_05 + * @tc.number : SUB_USB_JS_0580 * @tc.name : controlTransfer * @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0 */ - it('SUB_USB_control_transfer_test_05', 0, function () { - console.info('usb control_transfer_test_05 begin'); + 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(); @@ -461,16 +529,21 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(1, (usb.USB_REQUEST_DIR_TO_DEVICE << 7) | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_05 ClearFeature') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0580 ClearFeature') }) /** - * @tc.number : SUB_USB_control_transfer_test_06 + * @tc.number : SUB_USB_JS_0590 * @tc.name : controlTransfer * @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0 */ - it('SUB_USB_control_transfer_test_06', 0, function () { - console.info('usb control_transfer_test_06 begin'); + 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(); @@ -480,16 +553,21 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7) | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_INTERFACE & 0x1f), (2 << 8), 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_06 ClearFeature') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0590 ClearFeature') }) /** - * @tc.number : SUB_USB_control_transfer_test_07 + * @tc.number : SUB_USB_JS_0600 * @tc.name : controlTransfer * @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0 */ - it('SUB_USB_control_transfer_test_07', 0, function () { - console.info('usb control_transfer_test_07 begin'); + 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(); @@ -499,16 +577,21 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE << 7) | (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_ENDPOINT & 0x1f), (2 << 8), 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_07 ClearFeature') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0600 ClearFeature') }) /** - * @tc.number : SUB_USB_control_transfer_test_08 + * @tc.number : SUB_USB_JS_0610 * @tc.name : controlTransfer * @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0 */ - it('SUB_USB_control_transfer_test_08', 0, function () { - console.info('usb control_transfer_test_08 begin'); + 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(); @@ -518,16 +601,21 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE << 7) | (usb.USB_REQUEST_TYPE_VENDOR << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), (2 << 8), 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_08 ClearFeature') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0610 ClearFeature') }) /** - * @tc.number : SUB_USB_control_transfer_test_09 + * @tc.number : SUB_USB_JS_0620 * @tc.name : controlTransfer * @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0 */ - it('SUB_USB_control_transfer_test_09', 0, function () { - console.info('usb control_transfer_test_09 begin'); + 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(); @@ -537,7 +625,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE << 7) | (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_09 ClearFeature') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0620 ClearFeature') }) }) diff --git a/usb/usb_standard/src/main/js/default/test/UsbDevicePipeJsunitEx.test.js b/usb/usb_standard/src/main/js/default/test/UsbDevicePipeJsunitEx.test.js index 5985802dd..5ef929532 100755 --- a/usb/usb_standard/src/main/js/default/test/UsbDevicePipeJsunitEx.test.js +++ b/usb/usb_standard/src/main/js/default/test/UsbDevicePipeJsunitEx.test.js @@ -20,8 +20,10 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from /* usb device pipe test */ describe('UsbDevicePipeJsFunctionsTestEx', function () { + var gDeviceList var gPipe + var portCurrentMode beforeAll(function () { console.log('*************Usb Unit UsbDevicePipeJsFunctionsTestEx Begin*************'); @@ -30,20 +32,25 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { // version > 17 host currentMode = 2 device currentMode = 1 var usbPortList = usb.getPorts() + gDeviceList = usb.getDevices(); if (usbPortList.length > 0) { - if (usbPortList[0].status.currentMode == 1) { - usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => { - console.info('usb case setPortRoles return: ' + data); - }).catch(error => { - console.info('usb case setPortRoles error : ' + error); - }); - - console.log('*************Usb Unit switch to host Ex Begin*************'); - CheckEmptyUtils.sleep(3000) + 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); + }); + + console.log('*************Usb Unit switch to host Ex Begin*************'); + CheckEmptyUtils.sleep(3000) + } + } else { + portCurrentMode = 1 } } - gDeviceList = usb.getDevices(); gPipe = usb.connectDevice(gDeviceList[0]) console.info('usb unit connectDevice gPipe ret : ' + JSON.stringify(gPipe)); }) @@ -133,12 +140,17 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } /** - * @tc.number : SUB_USB_bulk_transfer_test_03 + * @tc.number : SUB_USB_JS_0650 * @tc.name : bulkTransfer * @tc.desc : 反向测试 批量传输 发数据 修改 outEndpoint.address = 123 */ - it('SUB_USB_bulk_transfer_test_03', 0, function () { - console.info('usb bulk_transfer_test_03 begin'); + it('SUB_USB_JS_0650', 0, function () { + console.info('usb SUB_USB_JS_0650 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(); @@ -153,23 +165,28 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { var TmpTestParam = testParam TmpTestParam.outEndpoint.address = 123 usb.bulkTransfer(TmpTestParam.pip, TmpTestParam.outEndpoint, tmpUint8Array, 5000).then(data => { - console.info('usb case bulk_transfer_test_03 ret: ' + data); - console.info('usb case bulk_transfer_test_03 : PASS'); + console.info('usb case SUB_USB_JS_0650 ret: ' + data); + console.info('usb case SUB_USB_JS_0650 : PASS'); expect(data).assertEqual(-1); }).catch(error => { console.info('usb 03 write error : ' + JSON.stringify(error)); expect(false).assertFalse(); - console.info('usb case bulk_transfer_test_03 : PASS'); + console.info('usb case SUB_USB_JS_0650 : PASS'); }); }) /** - * @tc.number : SUB_USB_bulk_transfer_test_04 + * @tc.number : SUB_USB_JS_0660 * @tc.name : bulkTransfer * @tc.desc : 反向测试 批量传输 发数据 修改 outEndpoint.number = 123 */ - it('SUB_USB_bulk_transfer_test_04', 0, function () { - console.info('usb bulk_transfer_test_04 begin'); + it('SUB_USB_JS_0660', 0, function () { + console.info('usb SUB_USB_JS_0660 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(); @@ -184,23 +201,28 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { var TmpTestParam = testParam TmpTestParam.outEndpoint.number = 123 usb.bulkTransfer(TmpTestParam.pip, TmpTestParam.outEndpoint, tmpUint8Array, 5000).then(data => { - console.info('usb case bulk_transfer_test_04 ret: ' + data); - console.info('usb case bulk_transfer_test_04 : PASS'); + console.info('usb case SUB_USB_JS_0660 ret: ' + data); + console.info('usb case SUB_USB_JS_0660 : PASS'); expect(data).assertEqual(-1); }).catch(error => { console.info('usb 04 write error : ' + JSON.stringify(error)); expect(false).assertFalse(); - console.info('usb case bulk_transfer_test_04 : PASS'); + console.info('usb case SUB_USB_JS_0660 : PASS'); }); }) /** - * @tc.number : SUB_USB_bulk_transfer_test_05 + * @tc.number : SUB_USB_JS_0670 * @tc.name : bulkTransfer * @tc.desc : 反向测试 批量传输 发数据 修改 outEndpoint.type = 123 */ - it('SUB_USB_bulk_transfer_test_05', 0, function () { - console.info('usb bulk_transfer_test_05 begin'); + it('SUB_USB_JS_0670', 0, function () { + console.info('usb SUB_USB_JS_0670 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(); @@ -215,23 +237,28 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { var TmpTestParam = testParam TmpTestParam.outEndpoint.type = 123 usb.bulkTransfer(TmpTestParam.pip, TmpTestParam.outEndpoint, tmpUint8Array, 5000).then(data => { - console.info('usb case bulk_transfer_test_05 ret: ' + data); - console.info('usb case bulk_transfer_test_05 : PASS'); + console.info('usb case SUB_USB_JS_0670 ret: ' + data); + console.info('usb case SUB_USB_JS_0670 : PASS'); expect(data).assertEqual(-1); }).catch(error => { console.info('usb 05 write error : ' + JSON.stringify(error)); expect(false).assertFalse(); - console.info('usb case bulk_transfer_test_05 : PASS'); + console.info('usb case SUB_USB_JS_0670 : PASS'); }); }) /** - * @tc.number : SUB_USB_claim_interface_test_02 + * @tc.number : SUB_USB_JS_0430 * @tc.name : claimInterface * @tc.desc : 反向测试 USBInterface传入异常id 获取接口 失败 */ - it('SUB_USB_claim_interface_test_02', 0, function () { - console.info('usb claim_interface_test_02 begin'); + it('SUB_USB_JS_0430', 0, function () { + console.info('usb SUB_USB_JS_0430 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(); @@ -239,14 +266,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } if (gDeviceList[0].configs.length == 0) { - console.info('usb case 02 current device.configs.length = 0'); + console.info('usb case SUB_USB_JS_0430 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 02 current device.configs.interfaces.length = 0'); + 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] @@ -257,17 +284,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } } - console.info('usb claim_interface_test_02 : PASS'); + console.info('usb SUB_USB_JS_0430 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_claim_interface_test_03 + * @tc.number : SUB_USB_JS_0440 * @tc.name : claimInterface * @tc.desc : 反向测试 USBInterface传入异常protocol 获取接口 失败 */ - it('SUB_USB_claim_interface_test_03', 0, function () { - console.info('usb claim_interface_test_03 begin'); + it('SUB_USB_JS_0440', 0, function () { + console.info('usb SUB_USB_JS_0440 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(); @@ -275,14 +307,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } if (gDeviceList[0].configs.length == 0) { - console.info('usb case 03 current device.configs.length = 0'); + console.info('usb case SUB_USB_JS_0440 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 03 current device.configs.interfaces.length = 0'); + console.info('usb case SUB_USB_JS_0440 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] @@ -293,17 +325,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } } - console.info('usb claim_interface_test_03 : PASS'); + console.info('usb SUB_USB_JS_0440 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_claim_interface_test_04 + * @tc.number : SUB_USB_JS_0450 * @tc.name : claimInterface * @tc.desc : 反向测试 USBInterface传入异常clazz 获取接口 失败 */ - it('SUB_USB_claim_interface_test_04', 0, function () { - console.info('usb claim_interface_test_04 begin'); + it('SUB_USB_JS_0450', 0, function () { + console.info('usb SUB_USB_JS_0450 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(); @@ -311,14 +348,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } if (gDeviceList[0].configs.length == 0) { - console.info('usb case 04 current device.configs.length = 0'); + console.info('usb case SUB_USB_JS_0450 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 04 current device.configs.interfaces.length = 0'); + console.info('usb case SUB_USB_JS_0450 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] @@ -329,17 +366,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } } - console.info('usb claim_interface_test_04 : PASS'); + console.info('usb SUB_USB_JS_0450 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_claim_interface_test_05 + * @tc.number : SUB_USB_JS_0460 * @tc.name : claimInterface * @tc.desc : 反向测试 USBInterface传入异常name 获取接口 失败 */ - it('SUB_USB_claim_interface_test_05', 0, function () { - console.info('usb claim_interface_test_05 begin'); + it('SUB_USB_JS_0460', 0, function () { + console.info('usb SUB_USB_JS_0460 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(); @@ -347,14 +389,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } if (gDeviceList[0].configs.length == 0) { - console.info('usb case 05 current device.configs.length = 0'); + console.info('usb case SUB_USB_JS_0460 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 05 current device.configs.interfaces.length = 0'); + console.info('usb case SUB_USB_JS_0460 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] @@ -365,17 +407,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } } - console.info('usb claim_interface_test_05 : PASS'); + console.info('usb SUB_USB_JS_0460 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_claim_interface_test_06 + * @tc.number : SUB_USB_JS_0470 * @tc.name : claimInterface * @tc.desc : 反向测试 USBInterface传入异常subClass 获取接口 失败 */ - it('SUB_USB_claim_interface_test_06', 0, function () { - console.info('usb claim_interface_test_06 begin'); + it('SUB_USB_JS_0470', 0, function () { + console.info('usb SUB_USB_JS_0470 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(); @@ -383,14 +430,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } if (gDeviceList[0].configs.length == 0) { - console.info('usb case 06 current device.configs.length = 0'); + console.info('usb case SUB_USB_JS_0470 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 06 current device.configs.interfaces.length = 0'); + console.info('usb case SUB_USB_JS_0470 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] @@ -401,17 +448,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } } - console.info('usb claim_interface_test_06 : PASS'); + console.info('usb SUB_USB_JS_0470 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_release_interface_test_01 + * @tc.number : SUB_USB_JS_0280 * @tc.name : releaseInterface * @tc.desc : 反向测试 获取接口 release传入Interface的错误ID 并释放 */ - it('SUB_USB_release_interface_test_01', 0, function () { - console.info('usb release_interface_test_01 begin'); + it('SUB_USB_JS_0280', 0, function () { + console.info('usb SUB_USB_JS_0280 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(); @@ -419,14 +471,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } if (gDeviceList[0].configs.length == 0) { - console.info('usb 01 case current device.configs.length = 0'); + console.info('usb SUB_USB_JS_0280 case current device.configs.length = 0'); expect(false).assertTrue(); return } gPipe = usb.connectDevice(gDeviceList[0]) for (var j = 0; j < gDeviceList[0].configs.length; j++) { if (gDeviceList[0].configs[j].interfaces.length == 0) { - console.info('usb 01 case current device.configs.interfaces.length = 0'); + console.info('usb SUB_USB_JS_0280 case 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] @@ -437,17 +489,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } } - console.info('usb release_interface_test_01 : PASS'); + console.info('usb SUB_USB_JS_0280 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_release_interface_test_02 + * @tc.number : SUB_USB_JS_0290 * @tc.name : releaseInterface * @tc.desc : 反向测试 获取接口 release传入Interface的错误name 并释放 */ - it('SUB_USB_release_interface_test_02', 0, function () { - console.info('usb release_interface_test_02 begin'); + it('SUB_USB_JS_0290', 0, function () { + console.info('usb SUB_USB_JS_0290 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(); @@ -455,14 +512,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } if (gDeviceList[0].configs.length == 0) { - console.info('usb 02 case current device.configs.length = 0'); + console.info('usb SUB_USB_JS_0290 case current device.configs.length = 0'); expect(false).assertTrue(); return } gPipe = usb.connectDevice(gDeviceList[0]) for (var j = 0; j < gDeviceList[0].configs.length; j++) { if (gDeviceList[0].configs[j].interfaces.length == 0) { - console.info('usb 02 case current device.configs.interfaces.length = 0'); + console.info('usb SUB_USB_JS_0290 case 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] @@ -473,17 +530,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } } - console.info('usb release_interface_test_02 : PASS'); + console.info('usb SUB_USB_JS_0290 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_release_interface_test_03 + * @tc.number : SUB_USB_JS_0300 * @tc.name : releaseInterface * @tc.desc : 反向测试 获取接口 release传入Interface的错误clazz 并释放 */ - it('SUB_USB_release_interface_test_03', 0, function () { - console.info('usb release_interface_test_03 begin'); + it('SUB_USB_JS_0300', 0, function () { + console.info('usb SUB_USB_JS_0300 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(); @@ -491,14 +553,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } if (gDeviceList[0].configs.length == 0) { - console.info('usb 03 case current device.configs.length = 0'); + console.info('usb SUB_USB_JS_0300 case current device.configs.length = 0'); expect(false).assertTrue(); return } gPipe = usb.connectDevice(gDeviceList[0]) for (var j = 0; j < gDeviceList[0].configs.length; j++) { if (gDeviceList[0].configs[j].interfaces.length == 0) { - console.info('usb 03 case current device.configs.interfaces.length = 0'); + console.info('usb SUB_USB_JS_0300 case 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] @@ -509,17 +571,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } } - console.info('usb release_interface_test_03 : PASS'); + console.info('usb SUB_USB_JS_0300 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_release_interface_test_04 + * @tc.number : SUB_USB_JS_0310 * @tc.name : releaseInterface * @tc.desc : 反向测试 获取接口 release传入Interface的错误protocol 并释放 */ - it('SUB_USB_release_interface_test_04', 0, function () { - console.info('usb release_interface_test_04 begin'); + it('SUB_USB_JS_0310', 0, function () { + console.info('usb SUB_USB_JS_0310 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(); @@ -527,14 +594,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } if (gDeviceList[0].configs.length == 0) { - console.info('usb 04 case current device.configs.length = 0'); + console.info('usb SUB_USB_JS_0310 case current device.configs.length = 0'); expect(false).assertTrue(); return } gPipe = usb.connectDevice(gDeviceList[0]) for (var j = 0; j < gDeviceList[0].configs.length; j++) { if (gDeviceList[0].configs[j].interfaces.length == 0) { - console.info('usb 04 case current device.configs.interfaces.length = 0'); + console.info('usb SUB_USB_JS_0310 case 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] @@ -545,17 +612,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } } - console.info('usb release_interface_test_04 : PASS'); + console.info('usb SUB_USB_JS_0310 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_release_interface_test_05 + * @tc.number : SUB_USB_JS_0320 * @tc.name : releaseInterface * @tc.desc : 反向测试 获取接口 release传入Interface的错误subClass 并释放 */ - it('SUB_USB_release_interface_test_05', 0, function () { - console.info('usb release_interface_test_05 begin'); + it('SUB_USB_JS_0320', 0, function () { + console.info('usb SUB_USB_JS_0320 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(); @@ -563,14 +635,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } if (gDeviceList[0].configs.length == 0) { - console.info('usb 05 case current device.configs.length = 0'); + console.info('usb SUB_USB_JS_0320 case current device.configs.length = 0'); expect(false).assertTrue(); return } gPipe = usb.connectDevice(gDeviceList[0]) for (var j = 0; j < gDeviceList[0].configs.length; j++) { if (gDeviceList[0].configs[j].interfaces.length == 0) { - console.info('usb 05 case current device.configs.interfaces.length = 0'); + console.info('usb SUB_USB_JS_0320 case 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] @@ -581,17 +653,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } } - console.info('usb release_interface_test_05 : PASS'); + console.info('usb SUB_USB_JS_0320 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_interface_test_03 + * @tc.number : SUB_USB_JS_0820 * @tc.name : setInterface * @tc.desc : 反向测试 Interface的protocol 设置设备接口 */ - it('SUB_USB_set_interface_test_03', 0, function () { - console.info('usb set_interface_test_03 begin'); + it('SUB_USB_JS_0820', 0, function () { + console.info('usb SUB_USB_JS_0820 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() @@ -608,17 +685,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { console.info('usb case setInterface return : ' + ret) } - console.info('usb set_interface_test_03 : PASS'); + console.info('usb SUB_USB_JS_0820 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_interface_test_04 + * @tc.number : SUB_USB_JS_0830 * @tc.name : setInterface * @tc.desc : 反向测试 Interface的clazz 设置设备接口 */ - it('SUB_USB_set_interface_test_04', 0, function () { - console.info('usb set_interface_test_04 begin'); + it('SUB_USB_JS_0830', 0, function () { + console.info('usb SUB_USB_JS_0830 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() @@ -636,17 +718,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } - console.info('usb set_interface_test_04 : PASS'); + console.info('usb SUB_USB_JS_0830 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_interface_test_05 + * @tc.number : SUB_USB_JS_0840 * @tc.name : setInterface * @tc.desc : 反向测试 Interface的subClass 设置设备接口 */ - it('SUB_USB_set_interface_test_05', 0, function () { - console.info('usb set_interface_test_05 begin'); + it('SUB_USB_JS_0840', 0, function () { + console.info('usb SUB_USB_JS_0840 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() @@ -664,17 +751,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { } - console.info('usb set_interface_test_05 : PASS'); + console.info('usb SUB_USB_JS_0840 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_interface_test_06 + * @tc.number : SUB_USB_JS_0850 * @tc.name : setInterface * @tc.desc : 反向测试 Interface的name 设置设备接口 */ - it('SUB_USB_set_interface_test_06', 0, function () { - console.info('usb set_interface_test_05 begin'); + it('SUB_USB_JS_0850', 0, function () { + console.info('usb SUB_USB_JS_0840 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() @@ -691,17 +783,22 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { console.info('usb case setInterface return : ' + ret) } - console.info('usb set_interface_test_06 : PASS'); + console.info('usb SUB_USB_JS_0850 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_configuration_test_03 + * @tc.number : SUB_USB_JS_0760 * @tc.name : setConfiguration * @tc.desc : 反向测试 USBConfig的name 赋值错误 设置设备接口 */ - it('SUB_USB_set_configuration_test_03', 0, function () { - console.info('usb set_configuration_test_03 begin'); + it('SUB_USB_JS_0760', 0, function () { + console.info('usb SUB_USB_JS_0760 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(); @@ -716,16 +813,21 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { expect(ret).assertEqual(0); } - console.info('usb set_configuration_test_03 : PASS'); + console.info('usb SUB_USB_JS_0760 : PASS'); }) /** - * @tc.number : SUB_USB_set_configuration_test_04 + * @tc.number : SUB_USB_JS_0770 * @tc.name : setConfiguration * @tc.desc : 反向测试 USBConfig的name 赋值错误 设置设备接口 */ - it('SUB_USB_set_configuration_test_04', 0, function () { - console.info('usb set_configuration_test_04 begin'); + it('SUB_USB_JS_0770', 0, function () { + console.info('usb SUB_USB_JS_0770 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(); @@ -741,16 +843,21 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { expect(ret).assertLess(0); } - console.info('usb set_configuration_test_04 : PASS'); + console.info('usb SUB_USB_JS_0770 : PASS'); }) /** - * @tc.number : SUB_USB_set_configuration_test_05 + * @tc.number : SUB_USB_JS_0780 * @tc.name : setConfiguration * @tc.desc : 反向测试 USBConfig的attributes 赋值错误 设置设备接口 */ - it('SUB_USB_set_configuration_test_05', 0, function () { - console.info('usb set_configuration_test_05 begin'); + it('SUB_USB_JS_0780', 0, function () { + console.info('usb SUB_USB_JS_0780 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(); @@ -765,16 +872,21 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { expect(ret).assertLess(0); } - console.info('usb set_configuration_test_05 : PASS'); + console.info('usb SUB_USB_JS_0780 : PASS'); }) /** - * @tc.number : SUB_USB_set_configuration_test_06 + * @tc.number : SUB_USB_JS_0790 * @tc.name : setConfiguration * @tc.desc : 反向测试 USBConfig的name interval(1-16) 赋值错误 设置设备接口 */ - it('SUB_USB_set_configuration_test_06', 0, function () { - console.info('usb set_configuration_test_06 begin'); + 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') + expect(false).assertFalse(); + return + } if (gDeviceList.length == 0) { console.info('usb case get_device_list is null') expect(false).assertTrue(); @@ -790,7 +902,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () { expect(ret).assertLess(0); } - console.info('usb set_configuration_test_06 : PASS'); + console.info('usb SUB_USB_JS_0790 : PASS'); }) }) diff --git a/usb/usb_standard/src/main/js/default/test/UsbDevicePipeJsunit_A.test.js b/usb/usb_standard/src/main/js/default/test/UsbDevicePipeJsunit_A.test.js index dafcda180..b51ab1a48 100755 --- a/usb/usb_standard/src/main/js/default/test/UsbDevicePipeJsunit_A.test.js +++ b/usb/usb_standard/src/main/js/default/test/UsbDevicePipeJsunit_A.test.js @@ -23,6 +23,7 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from describe('UsbDevicePipeJsFunctionsTest', function () { var gDeviceList var gPipe + var portCurrentMode beforeAll(function () { console.log('*************Usb Unit UsbDevicePipeJsFunctionsTest Begin*************'); @@ -30,15 +31,22 @@ describe('UsbDevicePipeJsFunctionsTest', function () { 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 (usbPortList[0].status.currentMode == 1) { - usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => { - console.info('usb case setPortRoles return: ' + data); - }).catch(error => { - console.info('usb case setPortRoles error : ' + error); - }); - console.log('*************Usb Unit switch to host Begin*************'); + 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); + }); + console.log('*************Usb Unit switch to host Begin*************'); + } + } else { + portCurrentMode = 1 } + } gDeviceList = usb.getDevices(); @@ -136,12 +144,12 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } /** - * @tc.number : SUB_USB_bulk_transfer_test_01 + * @tc.number : SUB_USB_JS_0630 * @tc.name : bulkTransfer * @tc.desc : 批量传输 收数据 */ - it('SUB_USB_bulk_transfer_test_01', 0, function () { - console.info('usb bulk_transfer_test_01 begin'); + it('SUB_USB_JS_0630', 0, function () { + console.info('usb SUB_USB_JS_0630 begin'); var testParam = getTransferTestParam() if (testParam.interface == null || testParam.inEndpoint == null) { expect(false).assertTrue(); @@ -156,7 +164,7 @@ 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 bulk_transfer_test_01 : PASS'); + console.info('usb case SUB_USB_JS_0630 : PASS'); expect(data >= 0).assertTrue(); }).catch(error => { console.info('usb case readData error : ' + JSON.stringify(error)); @@ -165,12 +173,12 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_bulk_transfer_test_02 + * @tc.number : SUB_USB_JS_0640 * @tc.name : bulkTransfer * @tc.desc : 批量传输 发数据 */ - it('SUB_USB_bulk_transfer_test_02', 0, function () { - console.info('usb bulk_transfer_test_02 begin'); + it('SUB_USB_JS_0640', 0, function () { + console.info('usb SUB_USB_JS_0640 begin'); var testParam = getTransferTestParam() if (testParam.interface == null || testParam.outEndpoint == null) { expect(false).assertTrue(); @@ -190,9 +198,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var tmpUint8Array = CheckEmptyUtils.str2ab(testParam.sendData); usb.bulkTransfer(testParam.pip, testParam.outEndpoint, tmpUint8Array, 5000).then(data => { - console.info('usb case bulk_transfer_test_02 ret: ' + data); - console.info('usb case bulk_transfer_test_02 send data: ' + testParam.sendData); - console.info('usb case bulk_transfer_test_02 : PASS'); + 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)); @@ -202,12 +210,12 @@ describe('UsbDevicePipeJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_claim_interface_test_01 + * @tc.number : SUB_USB_JS_0420 * @tc.name : claimInterface * @tc.desc : 获取接口 并释放 */ - it('SUB_USB_claim_interface_test_01', 0, function () { - console.info('usb claim_interface_test_01 begin'); + it('SUB_USB_JS_0420', 0, function () { + console.info('usb SUB_USB_JS_0420 begin'); if (gDeviceList.length == 0) { console.info('usb 01 case get_device_list is null') expect(gDeviceList.length).assertEqual(-1); @@ -242,7 +250,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } } - console.info('usb claim_interface_test_01 : PASS'); + console.info('usb SUB_USB_JS_0420 : PASS'); expect(true).assertTrue(); }) @@ -263,12 +271,12 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } /** - * @tc.number : SUB_USB_set_configuration_test_01 + * @tc.number : SUB_USB_JS_0740 * @tc.name : setConfiguration * @tc.desc : 设置设备接口 */ - it('SUB_USB_set_configuration_test_01', 0, function () { - console.info('usb set_configuration_test_01 begin'); + it('SUB_USB_JS_0740', 0, function () { + console.info('usb SUB_USB_JS_0740 begin'); if (gDeviceList.length == 0) { console.info('usb case get_device_list is null') expect(false).assertTrue(); @@ -281,24 +289,24 @@ describe('UsbDevicePipeJsFunctionsTest', function () { configs.id = 1; configs.name = ''; configs.maxPower = 1; - configs.isRemoteWakeUp = true; + 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 set_configuration_test_01 : PASS'); + console.info('usb SUB_USB_JS_0740 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_configuration_test_02 + * @tc.number : SUB_USB_JS_0750 * @tc.name : setConfiguration * @tc.desc : 反向测试 设置设备接口 */ - it('SUB_USB_set_configuration_test_02', 0, function () { - console.info('usb set_configuration_test_02 begin'); + it('SUB_USB_JS_0750', 0, function () { + console.info('usb SUB_USB_JS_0750 begin'); if (gDeviceList.length == 0) { console.info('usb case get_device_list is null') expect(false).assertTrue(); @@ -313,16 +321,16 @@ describe('UsbDevicePipeJsFunctionsTest', function () { expect(ret).assertLess(0); } - console.info('usb set_configuration_test_02 : PASS'); + console.info('usb SUB_USB_JS_0750 : PASS'); }) /** - * @tc.number : SUB_USB_set_interface_test_01 + * @tc.number : SUB_USB_JS_0800 * @tc.name : setInterface * @tc.desc : 设置设备接口 */ - it('SUB_USB_set_interface_test_01', 0, function () { - console.info('usb set_interface_test_01 begin'); + it('SUB_USB_JS_0800', 0, function () { + console.info('usb SUB_USB_JS_0800 begin'); if (gDeviceList.length == 0) { console.info('usb case get_device_list is null') expect(false).assertTrue(); @@ -339,17 +347,17 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } } - console.info('usb set_interface_test_01 : PASS'); + console.info('usb SUB_USB_JS_0800 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_interface_test_02 + * @tc.number : SUB_USB_JS_0810 * @tc.name : setInterface * @tc.desc : 反向测试 设置设备接口 */ - it('SUB_USB_set_interface_test_02', 0, function () { - console.info('usb set_interface_test_02 begin'); + it('SUB_USB_JS_0810', 0, function () { + console.info('usb SUB_USB_JS_0810 begin'); if (gDeviceList.length == 0) { console.info('usb case get_device_list is null') expect(false).assertTrue() @@ -368,7 +376,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } } - console.info('usb set_interface_test_02 : PASS'); + console.info('usb SUB_USB_JS_0810 : PASS'); expect(true).assertTrue(); }) @@ -386,12 +394,12 @@ describe('UsbDevicePipeJsFunctionsTest', function () { } /** - * @tc.number : SUB_USB_control_transfer_test_01 + * @tc.number : SUB_USB_JS_0540 * @tc.name : controlTransfer * @tc.desc : 控制传输 GetDescriptor: cmd 6 reqType 128 value 512 index 0 */ - it('SUB_USB_control_transfer_test_01', 0, function () { - console.info('usb control_transfer_test_01 begin'); + it('SUB_USB_JS_0540', 0, function () { + console.info('usb SUB_USB_JS_0540 begin'); var testParam = getTransferTestParam() if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) { expect(false).assertTrue(); @@ -401,16 +409,16 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(6, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7) | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), (2 << 8), 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_01 GetDescriptor') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0540 GetDescriptor') }) /** - * @tc.number : SUB_USB_control_transfer_test_02 + * @tc.number : SUB_USB_JS_0550 * @tc.name : controlTransfer * @tc.desc : 控制传输 GetStatus: cmd 0 reqType 128 value 0 index 0 */ - it('SUB_USB_control_transfer_test_02', 0, function () { - console.info('usb control_transfer_test_02 begin'); + it('SUB_USB_JS_0550', 0, function () { + console.info('usb SUB_USB_JS_0550 begin'); var testParam = getTransferTestParam() if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) { expect(false).assertTrue(); @@ -420,16 +428,16 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(0, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7) | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_02 GetStatus') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0550 GetStatus') }) /** - * @tc.number : SUB_USB_control_transfer_test_03 + * @tc.number : SUB_USB_JS_0560 * @tc.name : controlTransfer * @tc.desc : 控制传输 GetConfiguration: cmd 8 reqType 128 value 0 index 0 */ - it('SUB_USB_control_transfer_test_03', 0, function () { - console.info('usb control_transfer_test_03 begin'); + it('SUB_USB_JS_0560', 0, function () { + console.info('usb SUB_USB_JS_0560 begin'); var testParam = getTransferTestParam() if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) { expect(false).assertTrue(); @@ -439,16 +447,16 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(8, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7) | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_03 GetConfiguration') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0560 GetConfiguration') }) /** - * @tc.number : SUB_USB_control_transfer_test_04 + * @tc.number : SUB_USB_JS_0570 * @tc.name : controlTransfer * @tc.desc : 控制传输 GetInterface: cmd 10 reqType 129 value 0 index 1 */ - it('SUB_USB_control_transfer_test_04', 0, function () { - console.info('usb control_transfer_test_04 begin'); + it('SUB_USB_JS_0570', 0, function () { + console.info('usb SUB_USB_JS_0570 begin'); var testParam = getTransferTestParam() if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) { expect(false).assertTrue(); @@ -458,16 +466,16 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(10, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7) | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_INTERFACE & 0x1f), 0, 1) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_04 GetInterface') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0570 GetInterface') }) /** - * @tc.number : SUB_USB_control_transfer_test_05 + * @tc.number : SUB_USB_JS_0580 * @tc.name : controlTransfer * @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0 */ - it('SUB_USB_control_transfer_test_05', 0, function () { - console.info('usb control_transfer_test_05 begin'); + it('SUB_USB_JS_0580', 0, function () { + console.info('usb SUB_USB_JS_0580 begin'); var testParam = getTransferTestParam() if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) { expect(false).assertTrue(); @@ -477,16 +485,16 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(1, (usb.USB_REQUEST_DIR_TO_DEVICE << 7) | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_05 ClearFeature') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0580 ClearFeature') }) /** - * @tc.number : SUB_USB_control_transfer_test_06 + * @tc.number : SUB_USB_JS_0590 * @tc.name : controlTransfer * @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0 */ - it('SUB_USB_control_transfer_test_06', 0, function () { - console.info('usb control_transfer_test_06 begin'); + it('SUB_USB_JS_0590', 0, function () { + console.info('usb SUB_USB_JS_0590 begin'); var testParam = getTransferTestParam() if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) { expect(false).assertTrue(); @@ -496,16 +504,16 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_FROM_DEVICE << 7) | (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_INTERFACE & 0x1f), (2 << 8), 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_06 ClearFeature') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0590 ClearFeature') }) /** - * @tc.number : SUB_USB_control_transfer_test_07 + * @tc.number : SUB_USB_JS_0600 * @tc.name : controlTransfer * @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0 */ - it('SUB_USB_control_transfer_test_07', 0, function () { - console.info('usb control_transfer_test_07 begin'); + it('SUB_USB_JS_0600', 0, function () { + console.info('usb SUB_USB_JS_0600 begin'); var testParam = getTransferTestParam() if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) { expect(false).assertTrue(); @@ -515,16 +523,16 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE << 7) | (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_ENDPOINT & 0x1f), (2 << 8), 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_07 ClearFeature') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0600 ClearFeature') }) /** - * @tc.number : SUB_USB_control_transfer_test_08 + * @tc.number : SUB_USB_JS_0610 * @tc.name : controlTransfer * @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0 */ - it('SUB_USB_control_transfer_test_08', 0, function () { - console.info('usb control_transfer_test_08 begin'); + it('SUB_USB_JS_0610', 0, function () { + console.info('usb SUB_USB_JS_0610 begin'); var testParam = getTransferTestParam() if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) { expect(false).assertTrue(); @@ -534,16 +542,16 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE << 7) | (usb.USB_REQUEST_TYPE_VENDOR << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), (2 << 8), 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_08 ClearFeature') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0610 ClearFeature') }) /** - * @tc.number : SUB_USB_control_transfer_test_09 + * @tc.number : SUB_USB_JS_0620 * @tc.name : controlTransfer * @tc.desc : 控制传输 ClearFeature: cmd 1 reqType 0 value 0 index 0 */ - it('SUB_USB_control_transfer_test_09', 0, function () { - console.info('usb control_transfer_test_09 begin'); + it('SUB_USB_JS_0620', 0, function () { + console.info('usb SUB_USB_JS_0620 begin'); var testParam = getTransferTestParam() if (testParam.inEndpoint == null || testParam.interface == null || testParam.outEndpoint == null) { expect(false).assertTrue(); @@ -553,7 +561,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { var timeout = 5000; var controlParam = getTransferParam(255, (usb.USB_REQUEST_DIR_TO_DEVICE << 7) | (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0) - callControlTransfer(testParam.pip, controlParam, timeout, 'control_transfer_test_09 ClearFeature') + callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0620 ClearFeature') }) }) diff --git a/usb/usb_standard/src/main/js/default/test/UsbFunctionsJsunit.test.js b/usb/usb_standard/src/main/js/default/test/UsbFunctionsJsunit.test.js index 99f888fe8..541a009ec 100755 --- a/usb/usb_standard/src/main/js/default/test/UsbFunctionsJsunit.test.js +++ b/usb/usb_standard/src/main/js/default/test/UsbFunctionsJsunit.test.js @@ -48,12 +48,12 @@ describe('UsbFunctionsJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_get_current_functions_test_01 + * @tc.number : SUB_USB_JS_0330 * @tc.name : getCurrentFunctions * @tc.desc : 获取当前设备模式 掩码与描述字符转换 */ - it('SUB_USB_get_current_functions_test_01', 0, function () { - console.info('usb get_current_functions_test_01 begin'); + 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); @@ -62,17 +62,17 @@ describe('UsbFunctionsJsFunctionsTest', function () { var nMaskCode = usb.usbFunctionsFromString(strMaskCode) console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode); expect(nMaskCode).assertEqual(maskCode); - console.info('usb get_current_functions_test_01 : PASS'); + console.info('usb SUB_USB_JS_0330 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_get_current_functions_test_02 + * @tc.number : SUB_USB_JS_0340 * @tc.name : usbFunctionString * @tc.desc : 反向测试 获取当前设备模式 掩码与描述字符转换 */ - it('SUB_USB_get_current_functions_test_02', 0, function () { - console.info('usb get_current_functions_test_02 begin'); + 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); @@ -92,7 +92,7 @@ describe('UsbFunctionsJsFunctionsTest', function () { console.info('usb case errStrMaskCode ' + errStrMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - console.info('usb get_current_functions_test_02 : PASS'); + console.info('usb SUB_USB_JS_0340 : PASS'); }) function callSetCurFunction(caseName, iValue) { @@ -110,93 +110,93 @@ describe('UsbFunctionsJsFunctionsTest', function () { } /** - * @tc.number : SUB_USB_set_current_functions_test_02 + * @tc.number : SUB_USB_JS_0350 * @tc.name : functions_test * @tc.desc : 在设备模式下设置当前的USB功能列表 Set 1 设置为ACM功能 */ - it('SUB_USB_set_current_functions_test_02', 0, function () { + it('SUB_USB_JS_0350', 0, function () { CheckEmptyUtils.sleep(3000) - console.info('usb set_current_functions_test_02 set ACM begin'); + console.info('usb SUB_USB_JS_0350 set ACM begin'); var maskCode = usb.getCurrentFunctions(); console.info('usb case getCurrentFunctions return: ' + maskCode); var funcString = usb.usbFunctionsToString(maskCode); console.info('usb case funcString:' + funcString); - callSetCurFunction('set_current_functions_test_02 ACM 1', usb.ACM) + callSetCurFunction('SUB_USB_JS_0350 ACM 1', usb.ACM) }) /** - * @tc.number : SUB_USB_set_current_functions_test_03 + * @tc.number : SUB_USB_JS_0360 * @tc.name : functions_test * @tc.desc : 在设备模式下设置当前的USB功能列表 Set 2 设置为ECM功能 */ - it('SUB_USB_set_current_functions_test_03', 0, function () { + it('SUB_USB_JS_0360', 0, function () { CheckEmptyUtils.sleep(3000) - console.info('usb set_current_functions_test_03 set ECM begin'); + console.info('usb SUB_USB_JS_0360 set ECM begin'); var maskCode = usb.getCurrentFunctions(); console.info('usb case getCurrentFunctions return: ' + maskCode); var funcString = usb.usbFunctionsToString(maskCode); console.info('usb case funcString:' + funcString); - callSetCurFunction('set_current_functions_test_03 ECM 2', usb.ECM) + callSetCurFunction('SUB_USB_JS_0360 ECM 2', usb.ECM) }) /** - * @tc.number : SUB_USB_set_current_functions_test_04 + * @tc.number : SUB_USB_JS_0370 * @tc.name : functions_test * @tc.desc : 在设备模式下设置当前的USB功能列表 Set 3 设置为ACM、ECM功能 */ - it('SUB_USB_set_current_functions_test_04', 0, function () { + it('SUB_USB_JS_0370', 0, function () { CheckEmptyUtils.sleep(3000) - console.info('usb set_current_functions_test_04 set ACM ECM begin'); + console.info('usb SUB_USB_JS_0370 set ACM ECM begin'); var maskCode = usb.getCurrentFunctions(); console.info('usb case getCurrentFunctions return: ' + maskCode); var funcString = usb.usbFunctionsToString(maskCode); console.info('usb case funcString:' + funcString); - callSetCurFunction('set_current_functions_test_04 ACM ECM 3', (usb.ACM | usb.ECM)) + callSetCurFunction('SUB_USB_JS_0370 ACM ECM 3', (usb.ACM | usb.ECM)) }) /** - * @tc.number : SUB_USB_set_current_functions_test_05 + * @tc.number : SUB_USB_JS_0380 * @tc.name : functions_test * @tc.desc : 在设备模式下设置当前的USB功能列表 Set 4 设置为HDC功能 */ - it('SUB_USB_set_current_functions_test_05', 0, function () { + it('SUB_USB_JS_0380', 0, function () { CheckEmptyUtils.sleep(3000) - console.info('usb set_current_functions_test_05 set HDC begin'); + console.info('usb SUB_USB_JS_0380 set HDC begin'); var maskCode = usb.getCurrentFunctions(); console.info('usb case getCurrentFunctions return: ' + maskCode); var funcString = usb.usbFunctionsToString(maskCode); console.info('usb case funcString:' + funcString); - callSetCurFunction('set_current_functions_test_05 HDC 4', usb.HDC) + callSetCurFunction('SUB_USB_JS_0380 HDC 4', usb.HDC) }) /** - * @tc.number : SUB_USB_set_current_functions_test_06 + * @tc.number : SUB_USB_JS_0390 * @tc.name : functions_test * @tc.desc : 在设备模式下设置当前的USB功能列表 Set 5 设置为ACM、HDC功能 */ - it('SUB_USB_set_current_functions_test_06', 0, function () { + it('SUB_USB_JS_0390', 0, function () { CheckEmptyUtils.sleep(3000) - console.info('usb set_current_functions_test_06 set ACM HDC begin'); + console.info('usb SUB_USB_JS_0390 set ACM HDC begin'); var maskCode = usb.getCurrentFunctions(); console.info('usb case getCurrentFunctions return: ' + maskCode); var funcString = usb.usbFunctionsToString(maskCode); console.info('usb case funcString:' + funcString); - callSetCurFunction('set_current_functions_test_06 ACM HDC 5', (usb.HDC | usb.ACM)) + callSetCurFunction('SUB_USB_JS_0390 ACM HDC 5', (usb.HDC | usb.ACM)) }) /** - * @tc.number : SUB_USB_set_current_functions_test_07 + * @tc.number : SUB_USB_JS_0400 * @tc.name : functions_test * @tc.desc : 在设备模式下设置当前的USB功能列表 Set 6 设置为ECM、HDC功能 */ - it('SUB_USB_set_current_functions_test_07', 0, function () { + it('SUB_USB_JS_0400', 0, function () { CheckEmptyUtils.sleep(3000) - console.info('usb set_current_functions_test_07 set ECM HDC begin'); + console.info('usb SUB_USB_JS_0400 set ECM HDC begin'); var maskCode = usb.getCurrentFunctions(); console.info('usb case getCurrentFunctions return: ' + maskCode); var funcString = usb.usbFunctionsToString(maskCode); console.info('usb case funcString:' + funcString); - callSetCurFunction('set_current_functions_test_07 ECM HDC 6', (usb.HDC | usb.ECM)) + callSetCurFunction('SUB_USB_JS_0400 ECM HDC 6', (usb.HDC | usb.ECM)) }) }) diff --git a/usb/usb_standard/src/main/js/default/test/UsbFunctionsJsunitEx.test.js b/usb/usb_standard/src/main/js/default/test/UsbFunctionsJsunitEx.test.js index b102116bf..3e416ca53 100755 --- a/usb/usb_standard/src/main/js/default/test/UsbFunctionsJsunitEx.test.js +++ b/usb/usb_standard/src/main/js/default/test/UsbFunctionsJsunitEx.test.js @@ -50,206 +50,206 @@ describe('UsbFunctionsJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_usb_function_to_string_test_01 + * @tc.number : SUB_USB_JS_0930 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 0 返回 'none' */ - it('SUB_USB_usb_function_to_string_test_01', 0, function () { - console.info('usb usb_function_to_string_test_01 begin'); + 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); - console.info('usb usb_function_to_string_test_01 : PASS'); + console.info('usb SUB_USB_JS_0930 : PASS'); }) /** - * @tc.number : SUB_USB_usb_function_to_string_test_02 + * @tc.number : SUB_USB_JS_0940 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 1 返回 'acm' */ - it('SUB_USB_usb_function_to_string_test_02', 0, function () { - console.info('usb usb_function_to_string_test_02 begin'); + 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); - console.info('usb usb_function_to_string_test_02 : PASS'); + console.info('usb SUB_USB_JS_0940 : PASS'); }) /** - * @tc.number : SUB_USB_usb_function_to_string_test_03 + * @tc.number : SUB_USB_JS_0950 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 2 返回 'ecm' */ - it('SUB_USB_usb_function_to_string_test_03', 0, function () { - console.info('usb usb_function_to_string_test_02 begin'); + 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); - console.info('usb usb_function_to_string_test_02 : PASS'); + console.info('usb SUB_USB_JS_0950 : PASS'); }) /** - * @tc.number : SUB_USB_usb_function_to_string_test_04 + * @tc.number : SUB_USB_JS_0960 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 3 返回 'acm,ecm' */ - it('SUB_USB_usb_function_to_string_test_04', 0, function () { - console.info('usb usb_function_to_string_test_02 begin'); + 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); - console.info('usb usb_function_to_string_test_02 : PASS'); + console.info('usb SUB_USB_JS_0960 : PASS'); }) /** - * @tc.number : SUB_USB_usb_function_to_string_test_05 + * @tc.number : SUB_USB_JS_0970 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 4 返回 'hdc' */ - it('SUB_USB_usb_function_to_string_test_05', 0, function () { - console.info('usb usb_function_to_string_test_05 begin'); + 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); - console.info('usb usb_function_to_string_test_05 : PASS'); + console.info('usb SUB_USB_JS_0970 : PASS'); }) /** - * @tc.number : SUB_USB_usb_function_to_string_test_06 + * @tc.number : SUB_USB_JS_0980 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 5 返回 'acm,hdc' */ - it('SUB_USB_usb_function_to_string_test_06', 0, function () { - console.info('usb usb_function_to_string_test_06 begin'); + 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('hdc,acm'); console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - console.info('usb usb_function_to_string_test_06 : PASS'); + console.info('usb SUB_USB_JS_0980 : PASS'); }) /** - * @tc.number : SUB_USB_usb_function_to_string_test_07 + * @tc.number : SUB_USB_JS_0990 * @tc.name : usbFunctionsToString * @tc.desc : 正向测试 6 返回 'ecm,hdc' */ - it('SUB_USB_usb_function_to_string_test_07', 0, function () { - console.info('usb usb_function_to_string_test_07 begin'); + 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('hdc,ecm'); console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - console.info('usb usb_function_to_string_test_07 : PASS'); + console.info('usb SUB_USB_JS_0990 : PASS'); }) /** - * @tc.number : SUB_USB_usb_function_from_string_test_01 + * @tc.number : SUB_USB_JS_0860 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'none' 返回 0 */ - it('SUB_USB_usb_function_from_string_test_01', 0, function () { - console.info('usb usb_function_from_string_test_01 begin'); + 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); - console.info('usb usb_function_to_string_test_01 : PASS'); + console.info('usb SUB_USB_JS_0860 : PASS'); }) /** - * @tc.number : SUB_USB_usb_function_from_string_test_02 + * @tc.number : SUB_USB_JS_0870 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'acm' 返回 1 */ - it('SUB_USB_usb_function_from_string_test_02', 0, function () { - console.info('usb usb_function_from_string_test_02 begin'); + 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); - console.info('usb usb_function_from_string_test_02 : PASS'); + console.info('usb SUB_USB_JS_0870 : PASS'); }) /** - * @tc.number : SUB_USB_usb_function_from_string_test_03 + * @tc.number : SUB_USB_JS_0880 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'ecm' 返回 2 */ - it('SUB_USB_usb_function_from_string_test_03', 0, function () { - console.info('usb usb_function_from_string_test_03 begin'); + 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); - console.info('usb usb_function_from_string_test_03 : PASS'); + console.info('usb SUB_USB_JS_0880 : PASS'); }) /** - * @tc.number : SUB_USB_usb_function_from_string_test_04 + * @tc.number : SUB_USB_JS_0890 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'acm,ecm' 返回 3 */ - it('SUB_USB_usb_function_from_string_test_04', 0, function () { - console.info('usb usb_function_from_string_test_04 begin'); + 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); - console.info('usb usb_function_from_string_test_04 : PASS'); + console.info('usb SUB_USB_JS_0890 : PASS'); }) /** - * @tc.number : SUB_USB_usb_function_from_string_test_05 + * @tc.number : SUB_USB_JS_0900 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'hdc' 返回 4 */ - it('SUB_USB_usb_function_from_string_test_05', 0, function () { - console.info('usb usb_function_from_string_test_05 begin'); + 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); - console.info('usb usb_function_from_string_test_04 : PASS'); + console.info('usb SUB_USB_JS_0900 : PASS'); }) /** - * @tc.number : SUB_USB_usb_function_from_string_test_06 + * @tc.number : SUB_USB_JS_0910 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'acm,hdc' 返回 5 */ - it('SUB_USB_usb_function_from_string_test_06', 0, function () { - console.info('usb usb_function_from_string_test_06 begin'); + 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); - console.info('usb usb_function_from_string_test_06 : PASS'); + console.info('usb SUB_USB_JS_0910 : PASS'); }) /** - * @tc.number : SUB_USB_usb_function_from_string_test_07 + * @tc.number : SUB_USB_JS_0920 * @tc.name : usbFunctionsFromString * @tc.desc : 正向测试 'ecm,hdc' 返回 6 */ - it('SUB_USB_usb_function_from_string_test_07', 0, function () { - console.info('usb usb_function_from_string_test_07 begin'); + 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); - console.info('usb usb_function_from_string_test_07 : PASS'); + console.info('usb SUB_USB_JS_0920 : PASS'); }) }) diff --git a/usb/usb_standard/src/main/js/default/test/UsbPortJsunit.test.js b/usb/usb_standard/src/main/js/default/test/UsbPortJsunit.test.js index d0e0021b8..a80e07bf8 100755 --- a/usb/usb_standard/src/main/js/default/test/UsbPortJsunit.test.js +++ b/usb/usb_standard/src/main/js/default/test/UsbPortJsunit.test.js @@ -36,33 +36,33 @@ describe('UsbPortJsFunctionsTest', function () { }) /** - * @tc.number : SUB_USB_get_ports_test_01 + * @tc.number : SUB_USB_JS_0410 * @tc.name : getPorts * @tc.desc : 获取USB端口描述信息列表 */ - it('SUB_USB_get_ports_test_01', 0, function () { - console.info('usb get_ports_test_01 begin'); + 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 get_ports_test_01 usbPortList is null'); + console.info('usb SUB_USB_JS_0410 usbPortList is null'); expect(false).assertTrue(); return } expect(usbPortList.length > 0).assertTrue(); - console.info('usb get_ports_test_01 : PASS'); + console.info('usb SUB_USB_JS_0410 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_get_supported_modes_test_01 + * @tc.number : SUB_USB_JS_0220 * @tc.name : getSupportedModes * @tc.desc : 获取指定的端口支持的模式列表的组合掩码 */ - it('SUB_USB_get_supported_modes_test_01', 0, function () { - console.info('usb get_supported_modes_test_01 begin'); + 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 get_supported_modes_test_01 usbPortList is null'); + console.info('usb SUB_USB_JS_0220 usbPortList is null'); expect(false).assertTrue(); return } @@ -73,20 +73,20 @@ describe('UsbPortJsFunctionsTest', function () { expect(maskCode).assertEqual(usbPortList[i].supportedModes); } - console.info('usb get_supported_modes_test_01 : PASS'); + console.info('usb SUB_USB_JS_0220 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_port_roles_test_01 + * @tc.number : SUB_USB_JS_0010 * @tc.name : setPortRoles * @tc.desc : 切换为Device set powerRole 2 DataRole 2 */ - it('SUB_USB_set_port_roles_test_01', 0, function () { - console.info('usb set_port_roles_test_01 device 2 2 begin'); + it('SUB_USB_JS_0010', 0, function () { + console.info('usb SUB_USB_JS_0010 device 2 2 begin'); var usbPortList = usb.getPorts() if (usbPortList.length == 0) { - console.info('usb set_port_roles_test_01 device 2 2 usbPortList is null'); + console.info('usb SUB_USB_JS_0010 device 2 2 usbPortList is null'); expect(false).assertTrue(); return } @@ -102,20 +102,20 @@ describe('UsbPortJsFunctionsTest', function () { }); } - console.info('usb set_port_roles_test_01 device 2 2: PASS'); + console.info('usb SUB_USB_JS_0010 device 2 2: PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_port_roles_test_02 + * @tc.number : SUB_USB_JS_0020 * @tc.name : setPortRoles * @tc.desc : 切换为host set powerRole 1 DataRole 1 */ - it('SUB_USB_set_port_roles_test_02', 0, function () { - console.info('usb set_port_roles_test_02 host 1 1 begin'); + it('SUB_USB_JS_0020', 0, function () { + console.info('usb SUB_USB_JS_0020 host 1 1 begin'); var usbPortList = usb.getPorts() if (usbPortList.length == 0) { - console.info('usb set_port_roles_test_02 host 1 1 usbPortList is null'); + console.info('usb SUB_USB_JS_0020 host 1 1 usbPortList is null'); expect(false).assertTrue(); return } @@ -132,7 +132,7 @@ describe('UsbPortJsFunctionsTest', function () { }); } - console.info('usb set_port_roles_test_02 host 1 1: PASS'); + console.info('usb SUB_USB_JS_0020 host 1 1: PASS'); expect(true).assertTrue(); }) diff --git a/usb/usb_standard/src/main/js/default/test/UsbPortJsunitEx.test.js b/usb/usb_standard/src/main/js/default/test/UsbPortJsunitEx.test.js index ae1976920..d37d45e80 100755 --- a/usb/usb_standard/src/main/js/default/test/UsbPortJsunitEx.test.js +++ b/usb/usb_standard/src/main/js/default/test/UsbPortJsunitEx.test.js @@ -39,15 +39,15 @@ describe('UsbPortJsFunctionsTestEx', function () { }) /** - * @tc.number : SUB_USB_get_supported_modes_test_02 + * @tc.number : SUB_USB_JS_0230 * @tc.name : getSupportedModes * @tc.desc : 反向测试 改变id 获取指定的端口支持的模式列表的组合掩码 */ - it('SUB_USB_get_supported_modes_test_02', 0, function () { - console.info('usb get_supported_modes_test_02 begin'); + 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 get_supported_modes_test_01 usbPortList is null'); + console.info('usb SUB_USB_JS_0230 usbPortList is null'); expect(false).assertTrue(); return } @@ -58,16 +58,16 @@ describe('UsbPortJsFunctionsTestEx', function () { var maskCode = usb.getSupportedModes(portID) expect(maskCode).assertEqual(usb.NONE); - console.info('usb get_supported_modes_test_02 : PASS'); + console.info('usb SUB_USB_JS_0230 : PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_port_roles_test_03 + * @tc.number : SUB_USB_JS_0030 * @tc.name : setPortRoles * @tc.desc : dataRole参数错误 */ - it('SUB_USB_set_port_roles_test_03', 0, function () { + it('SUB_USB_JS_0030', 0, function () { var portId = gPort.id; var powerRole = usb.SINK; var dataRole = usb.NONE - 1; @@ -78,19 +78,19 @@ describe('UsbPortJsFunctionsTestEx', function () { }).catch(error => { console.info('usb case setPortRoles error : ' + error); expect(error).assertFalse(); - console.info('usb set_port_roles_test_03: PASS'); + console.info('usb SUB_USB_JS_0030: PASS'); }) - console.info('usb set_port_roles_test_03: PASS'); + console.info('usb SUB_USB_JS_0030: PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_port_roles_test_04 + * @tc.number : SUB_USB_JS_0040 * @tc.name : setPortRoles * @tc.desc : portId,powerRole参数错误 */ - it('SUB_USB_set_port_roles_test_04', 0, function () { + it('SUB_USB_JS_0040', 0, function () { var portId = gPort.id; var powerRole = usb.NONE - 1; var dataRole = usb.DEVICE; @@ -101,19 +101,19 @@ describe('UsbPortJsFunctionsTestEx', function () { }).catch(error => { console.info('usb case setPortRoles error : ' + error); expect(error).assertFalse(); - console.info('usb set_port_roles_test_04: PASS'); + console.info('usb SUB_USB_JS_0040: PASS'); }) - console.info('usb set_port_roles_test_04: PASS'); + console.info('usb SUB_USB_JS_0040: PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_port_roles_test_05 + * @tc.number : SUB_USB_JS_0050 * @tc.name : setPortRoles * @tc.desc : portId,dataRole参数错误 */ - it('SUB_USB_set_port_roles_test_05', 0, function () { + it('SUB_USB_JS_0050', 0, function () { var portId = gPort.id - 3; var powerRole = usb.SINK; var dataRole = usb.NONE - 1; @@ -124,19 +124,19 @@ describe('UsbPortJsFunctionsTestEx', function () { }).catch(error => { console.info('usb case setPortRoles error : ' + error); expect(error).assertFalse(); - console.info('usb set_port_roles_test_05: PASS'); + console.info('usb SUB_USB_JS_0050: PASS'); }) - console.info('usb set_port_roles_test_05: PASS'); + console.info('usb SUB_USB_JS_0050: PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_port_roles_test_06 + * @tc.number : SUB_USB_JS_0060 * @tc.name : setPortRoles * @tc.desc : powerRole,dataRole参数错误 */ - it('SUB_USB_set_port_roles_test_06', 0, function () { + it('SUB_USB_JS_0060', 0, function () { var portId = gPort.id; var powerRole = usb.NONE - 1; var dataRole = usb.NONE - 1; @@ -147,43 +147,43 @@ describe('UsbPortJsFunctionsTestEx', function () { }).catch(error => { console.info('usb case setPortRoles error : ' + error); expect(error).assertFalse(); - console.info('usb set_port_roles_test_06: PASS'); + console.info('usb SUB_USB_JS_0060: PASS'); }) - console.info('usb set_port_roles_test_06: PASS'); + console.info('usb SUB_USB_JS_0060: PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_port_roles_test_07 + * @tc.number : SUB_USB_JS_0070 * @tc.name : setPortRoles * @tc.desc : portId,portId,dataRole参数错误 */ - it('SUB_USB_set_port_roles_test_07', 0, function () { + it('SUB_USB_JS_0070', 0, function () { var portId = gPort.id - 1; var dataRole = usb.NONE - 1; var powerRole = usb.NONE - 1; CheckEmptyUtils.sleep(2000) usb.setPortRoles(portId, powerRole, dataRole).then(data => { - console.info('usb case setPortRoles 07 return: ' + data); + console.info('usb case setPortRoles return: ' + data); expect(data).assertTrue(); }).catch(error => { - console.info('usb case setPortRoles 07 error : ' + error); + console.info('usb case setPortRoles error : ' + error); expect(error).assertFalse(); - console.info('usb set_port_roles_test_07: PASS'); + console.info('usb SUB_USB_JS_0070: PASS'); }) - console.info('usb set_port_roles_test_07: PASS'); + console.info('usb SUB_USB_JS_0070: PASS'); expect(true).assertTrue(); }) /** - * @tc.number : SUB_USB_set_port_roles_test_08 + * @tc.number : SUB_USB_JS_0080 * @tc.name : setPortRoles * @tc.desc : portId参数错误 */ - it('SUB_USB_set_port_roles_test_08', 0, function () { + it('SUB_USB_JS_0080', 0, function () { var portId = gPort.id - 1; var powerRole = 1; var dataRole = 1; @@ -194,10 +194,10 @@ describe('UsbPortJsFunctionsTestEx', function () { }).catch(error => { console.info('usb case setPortRoles error : ' + error); expect(error).assertFalse(); - console.info('usb set_port_roles_test_08: PASS'); + console.info('usb SUB_USB_JS_0080: PASS'); }) - console.info('usb set_port_roles_test_08: PASS'); + console.info('usb SUB_USB_JS_0080: PASS'); expect(true).assertTrue(); }) -- GitLab