diff --git a/usb/usb_standard/src/main/js/test/List.test.js b/usb/usb_standard/src/main/js/test/List.test.js index d045a52092f7ac43a5cfc7ae5647acb41fd7c071..28b4633750765412d8134c02ddc48d428774e402 100644 --- a/usb/usb_standard/src/main/js/test/List.test.js +++ b/usb/usb_standard/src/main/js/test/List.test.js @@ -12,24 +12,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import UsbPortAndFunctionsJsFunctionsTest from './UsbPortAndFunctionJsunit.test.js' -import UsbPortJsFunctionsTest from './UsbPortJsunit.test.js' -import UsbPortJsFunctionsTestEx from './UsbPortJsunitEx.test.js' -import UsbFunctionsJsFunctionsTestEx from './UsbFunctionsJsunitEx.test.js' -import UsbFunctionsJsFunctionsTest from './UsbFunctionsJsunit.test.js' + import UsbDevicePipeJsFunctionsTest from './UsbDevicePipeJsunit.test.js' import UsbDevicePipeJsFunctionsTestEx from './UsbDevicePipeJsunitEx.test.js' import UsbCoreJsFunctionsTest from './UsbCoreJsunit.test.js' import UsbCoreJsFunctionsTestEx from './UsbCoreJsunitEx.test.js' + /* host test case */ export default function testsuite() { UsbCoreJsFunctionsTest() UsbCoreJsFunctionsTestEx() UsbDevicePipeJsFunctionsTest() UsbDevicePipeJsFunctionsTestEx() -UsbFunctionsJsFunctionsTest() -UsbFunctionsJsFunctionsTestEx() -// UsbPortAndFunctionsJsFunctionsTest() -UsbPortJsFunctionsTest() -UsbPortJsFunctionsTestEx() } diff --git a/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js b/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js index fba3900b6d81350b37a393d521c6d572c88b9e34..800013933d0ec07ffefb9c7737cd90eb87220652 100644 --- a/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js +++ b/usb/usb_standard/src/main/js/test/UsbDevicePipeJsunit.test.js @@ -231,7 +231,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { /** * @tc.number: SUB_USB_JS_0641 * @tc.name: bulkTransfer - * @tc.desc: Undefined + * @tc.desc: Undefined option arguments, use default options. */ it('SUB_USB_JS_0641', 0, function () { console.info('usb SUB_USB_JS_0641 begin'); @@ -273,7 +273,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { /** * @tc.number: SUB_USB_JS_0642 * @tc.name: bulkTransfer - * @tc.desc: Null + * @tc.desc: Null option arguments, use default options. */ it('SUB_USB_JS_0642', 0, function () { console.info('usb SUB_USB_JS_0642 begin'); @@ -315,7 +315,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { /** * @tc.number: SUB_USB_JS_0643 * @tc.name: bulkTransfer - * @tc.desc: + * @tc.desc: Ignore option arguments, use default options. */ it('SUB_USB_JS_0643', 0, function () { console.info('usb SUB_USB_JS_0643 begin'); @@ -406,7 +406,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { /** * @tc.number: SUB_USB_JS_1520 * @tc.name: claimInterface - * @tc.desc: Negative test: Get interface, parameter force type error + * @tc.desc: Negative test: Get interface, parameter force type error, use default options */ it('SUB_USB_JS_1520', 0, function () { console.info('usb SUB_USB_JS_1520 begin'); @@ -468,7 +468,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { //Attribute Prefabrication var interfaces = gDeviceList[0].configs[j].interfaces[k]; - var isClaim = usbManager.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[k], undefined) + var isClaim = usbManager.claimInterface(gPipe, interfaces, undefined) console.info('usb case 0421 claimInterface function return: ' + isClaim); expect(isClaim).assertEqual(0); if (isClaim == 0) { @@ -486,7 +486,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { * @tc.number: SUB_USB_JS_0422 * @tc.name: claimInterface * @tc.desc: Test the claimInterface() interface. - * Undefined option arguments, use default options. + * Null option arguments, use default options. */ it('SUB_USB_JS_0422', 0, function () { console.info('usb SUB_USB_JS_0422 begin'); @@ -514,7 +514,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { //Attribute Prefabrication var interfaces = gDeviceList[0].configs[j].interfaces[k]; - var isClaim = usbManager.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[k], null) + var isClaim = usbManager.claimInterface(gPipe, interfaces, null) console.info('usb case 0422 claimInterface function return: ' + isClaim); expect(isClaim).assertEqual(0); if (isClaim == 0) { @@ -532,7 +532,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { * @tc.number: SUB_USB_JS_0423 * @tc.name: claimInterface * @tc.desc: Test the claimInterface() interface. - * Undefined option arguments, use default options. + * Ignore option arguments, use default options. */ it('SUB_USB_JS_0423', 0, function () { console.info('usb SUB_USB_JS_0423 begin'); @@ -560,7 +560,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { //Attribute Prefabrication var interfaces = gDeviceList[0].configs[j].interfaces[k]; - var isClaim = usbManager.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[k]) + var isClaim = usbManager.claimInterface(gPipe, interfaces) console.info('usb case 0423 claimInterface function return: ' + isClaim); expect(isClaim).assertEqual(0); if (isClaim == 0) { @@ -837,7 +837,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { * @tc.number: SUB_USB_JS_0553 * @tc.name: controlTransfer * @tc.desc: Test the bulkTransfer interface - * Ignore option arguments. + * Ignore option arguments, use default options. */ it('SUB_USB_JS_0553', 0, function () { console.info('usb SUB_USB_JS_0553 begin'); @@ -1183,7 +1183,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { /** * @tc.number: SUB_USB_JS_1570 * @tc.name: controlTransfer - * @tc.desc: Negative test: control transfer, parameter timeout type error + * @tc.desc: Negative test: control transfer, parameter timeout type error, use default options. */ it('SUB_USB_JS_1570', 0, function () { console.info('usb SUB_USB_JS_1570 begin'); diff --git a/usb/usb_standard/src/main/js/test/UsbFunctionsJsunit.test.js b/usb/usb_standard/src/main/js/test/UsbFunctionsJsunit.test.js deleted file mode 100644 index 7b33e05320ee6e00a962102150758405eb71aec6..0000000000000000000000000000000000000000 --- a/usb/usb_standard/src/main/js/test/UsbFunctionsJsunit.test.js +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import usbManager from '@ohos.usbManager'; -import CheckEmptyUtils from './CheckEmptyUtils.js'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' - -/* usb core functions test */ -export default function UsbFunctionsJsFunctionsTest() { -describe('UsbFunctionsJsFunctionsTest', function () { - - beforeAll(function () { - console.log('*************Usb Unit UsbFunctionsJsFunctionsTest Begin*************'); - var Version = usbManager.getVersion() - console.info('begin test getversion :' + Version) - // version > 17 host currentMode = 2 device currentMode = 1 - var usbPortList = usbManager.getPorts() - if (usbPortList.length > 0) { - if (usbPortList[0].status.currentMode == 2) { - usbManager.setPortRoles(usbPortList[0].id, usbManager.SINK, usbManager.DEVICE).then(data => { - console.info('usb case setPortRoles return: ' + data); - }).catch(error => { - console.info('usb case setPortRoles error : ' + error); - }); - CheckEmptyUtils.sleep(8000) - console.log('*************Usb Unit switch to device Begin*************'); - } - } - }) - beforeEach(function () { - console.info('beforeEach: *************Usb Unit Test Case*************'); - }) - afterEach(function () { - console.info('afterEach: *************Usb Unit Test Case*************'); - }) - afterAll(function () { - console.log('*************Usb Unit UsbFunctionsJsFunctionsTest End*************'); - }) - - /** - * @tc.number: SUB_USB_JS_0330 - * @tc.name: getCurrentFunctions - * @tc.desc: Positive test: Get current device mode, mask and description character conversion - * @tc.desc: 【C-ALL-HARDWARE-0500】端口必须可连接到具有标准A型或C型的主机模式的USB端口 - */ - it('SUB_USB_JS_0330', 0, function () { - console.info('usb SUB_USB_JS_0330 begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - - var strMaskCode = usbManager.usbFunctionsToString(maskCode) - console.info('usb case usbFunctionsToString return str: ' + strMaskCode); - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(maskCode); - console.info('usb SUB_USB_JS_0330 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0340 - * @tc.name: usbFunctionString - * @tc.desc: Negative test: Get current device mode, mask and description character conversion, nMaskcode=0 - */ - it('SUB_USB_JS_0340', 0, function () { - console.info('usb SUB_USB_JS_0340 begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - - var strMaskCode = usbManager.usbFunctionsToString(maskCode) - console.info('usb case usbFunctionsToString return str: ' + strMaskCode); - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode); - - var errmaskCode = 0 - var strMaskCode = usbManager.usbFunctionsToString(errmaskCode) - - console.info('usb case ' + errmaskCode + ' usbFunctionsToString return str: ' + strMaskCode); - - var errStrMaskCode = 'none' - var nMaskCode = usbManager.usbFunctionsFromString(errStrMaskCode) - console.info('usb case errStrMaskCode ' + errStrMaskCode + - ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.NONE); - console.info('usb SUB_USB_JS_0340 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1000 - * @tc.name: getCurrentFunctions - * @tc.desc: Negative test: Get the current device mode, - * parameters exception(parameter transfer without parameter interface) - */ - it('SUB_USB_JS_1000', 0, function () { - console.info('usb SUB_USB_JS_1000 begin'); - try { - var maskCode = usbManager.getCurrentFunctions("invalid"); - console.info('usb 1000 case getCurrentFunctions return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1000 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1000 : PASS'); - } - }) -}) -} diff --git a/usb/usb_standard/src/main/js/test/UsbFunctionsJsunitEx.test.js b/usb/usb_standard/src/main/js/test/UsbFunctionsJsunitEx.test.js deleted file mode 100644 index 7795528a40bffa702c79bae5ff8e6bc7c0f65f15..0000000000000000000000000000000000000000 --- a/usb/usb_standard/src/main/js/test/UsbFunctionsJsunitEx.test.js +++ /dev/null @@ -1,564 +0,0 @@ -/* - * Copyright (C) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the 'License'); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an 'AS IS' BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import usbManager from '@ohos.usbManager'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' - -/* usb core functions test */ -export default function UsbFunctionsJsFunctionsTestEx() { -describe('UsbFunctionsJsFunctionsTestEx', function () { - - var invalidCode = 0; - - beforeAll(function () { - console.log('*************Usb Unit UsbFunctionsJsFunctionsTestEx Begin*************'); - var Version = usbManager.getVersion() - console.info('begin test getversion :' + Version) - // 17 version host currentMode = 2 device currentMode = 1 - var usbPortList = usbManager.getPorts() - if (usbPortList.length > 0) { - if (usbPortList[0].status.currentMode == 2) { - usbManager.setPortRoles(usbPortList[0].id, usbManager.SINK, usbManager.DEVICE).then(data => { - console.info('usb case setPortRoles return: ' + data); - }).catch(error => { - console.info('usb case setPortRoles error : ' + error); - }); - CheckEmptyUtils.sleep(8000) - console.log('*************Usb Unit switch to device Begin*************'); - } - } - }) - beforeEach(function () { - console.info('beforeEach: *************Usb Unit Test Case*************'); - }) - - afterEach(function () { - console.info('afterEach: *************Usb Unit Test Case*************'); - }) - - afterAll(function () { - console.log('*************Usb Unit UsbFunctionsJsFunctionsTest End*************'); - }) - - /** - * @tc.number: SUB_USB_JS_0930 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 0, return 'none' - */ - it('SUB_USB_JS_0930', 0, function () { - console.info('usb SUB_USB_JS_0930 begin'); - var maskCode = usbManager.NONE - console.info('usb case maskCode : ' + usbManager.NONE); - var strMaskCode = usbManager.usbFunctionsToString(maskCode) - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('none'); - console.info('usb SUB_USB_JS_0930 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0940 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 1, return 'acm' - */ - it('SUB_USB_JS_0940', 0, function () { - console.info('usb SUB_USB_JS_0940 begin'); - var maskCode = usbManager.ACM - console.info('usb case maskCode : ' + usbManager.ACM); - var strMaskCode = usbManager.usbFunctionsToString(maskCode) - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('acm'); - console.info('usb SUB_USB_JS_0940 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0950 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 2, return 'ecm' - */ - it('SUB_USB_JS_0950', 0, function () { - console.info('usb SUB_USB_JS_0950 begin'); - var maskCode = usbManager.ECM - console.info('usb case maskCode : ' + maskCode); - var strMaskCode = usbManager.usbFunctionsToString(maskCode) - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('ecm'); - console.info('usb SUB_USB_JS_0950 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0960 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 3, return 'acm,ecm' - */ - it('SUB_USB_JS_0960', 0, function () { - console.info('usb SUB_USB_JS_0960 begin'); - var maskCode = usbManager.ACM | usbManager.ECM - console.info('usb case maskCode : ' + maskCode); - var strMaskCode = usbManager.usbFunctionsToString(maskCode) - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('acm,ecm'); - console.info('usb SUB_USB_JS_0960 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0970 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 4, return 'hdc' - */ - it('SUB_USB_JS_0970', 0, function () { - console.info('usb SUB_USB_JS_0970 begin'); - var maskCode = usbManager.HDC - console.info('usb case maskCode : ' + maskCode); - var strMaskCode = usbManager.usbFunctionsToString(maskCode) - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('hdc'); - console.info('usb SUB_USB_JS_0970 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0980 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 5, return 'acm,hdc' - */ - it('SUB_USB_JS_0980', 0, function () { - console.info('usb SUB_USB_JS_0980 begin'); - var maskCode = usbManager.ACM | usbManager.HDC - console.info('usb case maskCode : ' + maskCode); - var strMaskCode = usbManager.usbFunctionsToString(maskCode) - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('acm,hdc'); - console.info('usb SUB_USB_JS_0980 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0990 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 6, return 'ecm,hdc' - */ - it('SUB_USB_JS_0990', 0, function () { - console.info('usb SUB_USB_JS_0990 begin'); - var maskCode = usbManager.ECM | usbManager.HDC - console.info('usb case maskCode : ' + maskCode); - var strMaskCode = usbManager.usbFunctionsToString(maskCode) - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('ecm,hdc'); - console.info('usb SUB_USB_JS_0990 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1770 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 8, return 'mtp' - */ - it('SUB_USB_JS_1770', 0, function () { - console.info('usb SUB_USB_JS_1770 begin'); - var maskCode = usbManager.MTP; - console.info('usb case maskCode : ' + maskCode); - var strMaskCode = usbManager.usbFunctionsToString(maskCode); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('mtp'); - console.info('usb SUB_USB_JS_1770 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1780 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 12, return 'hdc,mtp' - */ - it('SUB_USB_JS_1780', 0, function () { - console.info('usb SUB_USB_JS_1780 begin'); - var maskCode = usbManager.MTP | usbManager.HDC; - console.info('usb case maskCode : ' + maskCode); - var strMaskCode = usbManager.usbFunctionsToString(maskCode); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('hdc,mtp'); - console.info('usb SUB_USB_JS_1780 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1790 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 16, return 'ptp' - */ - it('SUB_USB_JS_1790', 0, function () { - console.info('usb SUB_USB_JS_1790 begin'); - var maskCode = usbManager.PTP; - console.info('usb case maskCode : ' + maskCode); - var strMaskCode = usbManager.usbFunctionsToString(maskCode); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('ptp'); - console.info('usb SUB_USB_JS_1790 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1800 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 20, return 'hdc,ptp' - */ - it('SUB_USB_JS_1800', 0, function () { - console.info('usb SUB_USB_JS_1800 begin'); - var maskCode = usbManager.PTP | usbManager.HDC; - console.info('usb case maskCode : ' + maskCode); - var strMaskCode = usbManager.usbFunctionsToString(maskCode); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('hdc,ptp'); - console.info('usb SUB_USB_JS_1800 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1810 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 32, return 'rndis' - */ - it('SUB_USB_JS_1810', 0, function () { - console.info('usb SUB_USB_JS_1810 begin'); - var maskCode = usbManager.RNDIS; - console.info('usb case maskCode : ' + maskCode); - var strMaskCode = usbManager.usbFunctionsToString(maskCode); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('rndis'); - console.info('usb SUB_USB_JS_1810 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1820 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 36, return 'hdc,rndis' - */ - it('SUB_USB_JS_1820', 0, function () { - console.info('usb SUB_USB_JS_1820 begin'); - var maskCode = usbManager.RNDIS | usbManager.HDC; - console.info('usb case maskCode : ' + maskCode); - var strMaskCode = usbManager.usbFunctionsToString(maskCode); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('hdc,rndis'); - console.info('usb SUB_USB_JS_1820 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1830 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 512, return 'storage' - */ - it('SUB_USB_JS_1830', 0, function () { - console.info('usb SUB_USB_JS_1830 begin'); - var maskCode = usbManager.STORAGE; - console.info('usb case maskCode : ' + maskCode); - var strMaskCode = usbManager.usbFunctionsToString(maskCode); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('storage'); - console.info('usb SUB_USB_JS_1830 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1840 - * @tc.name: usbFunctionsToString - * @tc.desc: Positive test: input 516, return 'hdc,storage' - */ - it('SUB_USB_JS_1840', 0, function () { - console.info('usb SUB_USB_JS_1840 begin'); - var maskCode = usbManager.STORAGE | usbManager.HDC; - console.info('usb case maskCode : ' + maskCode); - var strMaskCode = usbManager.usbFunctionsToString(maskCode); - console.info('usb case maskCode ' + maskCode + ' usbFunctionsToString return int: ' + strMaskCode); - expect(strMaskCode).assertEqual('hdc,storage'); - console.info('usb SUB_USB_JS_1840 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1160 - * @tc.name: usbFunctionsToString - * @tc.desc: Negative test: Mask converted to description character, parameter type error - */ - it('SUB_USB_JS_1160', 0, function () { - console.info('usb SUB_USB_JS_1160 begin'); - try { - var maskCode = usbManager.usbFunctionsToString("invalid"); - console.info('usb 1160 case usbFunctionsToString return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1160 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1160 : PASS'); - } - }) - - /** - * @tc.number: SUB_USB_JS_1360 - * @tc.name: usbFunctionsToString - * @tc.desc: Negative test: Mask converted to description character, - * parameter number exception, necessary parameters not input - */ - it('SUB_USB_JS_1360', 0, function () { - console.info('usb SUB_USB_JS_1360 begin'); - try { - var maskCode = usbManager.usbFunctionsToString(); - console.info('usb 1360 case usbFunctionsToString return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1360 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1360 : PASS'); - } - }) - - /** - * @tc.number: SUB_USB_JS_0860 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'none', return 0 - */ - it('SUB_USB_JS_0860', 0, function () { - console.info('usb SUB_USB_JS_0860 begin'); - var strMaskCode = 'none' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.NONE); - console.info('usb SUB_USB_JS_0860 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0870 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'acm', return 1 - */ - it('SUB_USB_JS_0870', 0, function () { - console.info('usb SUB_USB_JS_0870 begin'); - var strMaskCode = 'acm' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.ACM); - console.info('usb SUB_USB_JS_0870 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0880 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'ecm', return 2 - */ - it('SUB_USB_JS_0880', 0, function () { - console.info('usb SUB_USB_JS_0880 begin'); - var strMaskCode = 'ecm' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.ECM); - console.info('usb SUB_USB_JS_0880 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0890 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'acm,ecm', return 3 - */ - it('SUB_USB_JS_0890', 0, function () { - console.info('usb SUB_USB_JS_0890 begin'); - var strMaskCode = 'acm,ecm' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.ACM | usbManager.ECM); - console.info('usb SUB_USB_JS_0890 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0900 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'hdc', return 4 - */ - it('SUB_USB_JS_0900', 0, function () { - console.info('usb SUB_USB_JS_0900 begin'); - var strMaskCode = 'hdc' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.HDC); - console.info('usb SUB_USB_JS_0900 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0910 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'acm,hdc', return 5 - */ - it('SUB_USB_JS_0910', 0, function () { - console.info('usb SUB_USB_JS_0910 begin'); - var strMaskCode = 'acm,hdc' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.HDC | usbManager.ACM); - console.info('usb SUB_USB_JS_0910 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0920 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'ecm,hdc', return 6 - */ - it('SUB_USB_JS_0920', 0, function () { - console.info('usb SUB_USB_JS_0920 begin'); - var strMaskCode = 'ecm,hdc' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.HDC | usbManager.ECM); - console.info('usb SUB_USB_JS_0920 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1220 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'mtp', return 8 - */ - it('SUB_USB_JS_1220', 0, function () { - console.info('usb SUB_USB_JS_1220 begin'); - var strMaskCode = 'mtp' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.MTP); - console.info('usb SUB_USB_JS_1220 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1700 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'hdc,mtp', return 12 - */ - it('SUB_USB_JS_1700', 0, function () { - console.info('usb SUB_USB_JS_1700 begin'); - var strMaskCode = 'hdc,mtp' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.MTP | usbManager.HDC); - console.info('usb SUB_USB_JS_1700 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1710 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'ptp', return 16 - */ - it('SUB_USB_JS_1710', 0, function () { - console.info('usb SUB_USB_JS_1710 begin'); - var strMaskCode = 'ptp' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.PTP); - console.info('usb SUB_USB_JS_1710 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1720 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'hdc,ptp', return 20 - */ - it('SUB_USB_JS_1720', 0, function () { - console.info('usb SUB_USB_JS_1720 begin'); - var strMaskCode = 'hdc,ptp' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.PTP | usbManager.HDC); - console.info('usb SUB_USB_JS_1720 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1730 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'rndis', return 32 - */ - it('SUB_USB_JS_1730', 0, function () { - console.info('usb SUB_USB_JS_1730 begin'); - var strMaskCode = 'rndis' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.RNDIS); - console.info('usb SUB_USB_JS_1730 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1740 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'hdc,rndis', return 36 - */ - it('SUB_USB_JS_1740', 0, function () { - console.info('usb SUB_USB_JS_1740 begin'); - var strMaskCode = 'hdc,rndis' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.RNDIS | usbManager.HDC); - console.info('usb SUB_USB_JS_1740 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1750 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'storage', return 512 - */ - it('SUB_USB_JS_1750', 0, function () { - console.info('usb SUB_USB_JS_1750 begin'); - var strMaskCode = 'storage' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.STORAGE); - console.info('usb SUB_USB_JS_1750 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1760 - * @tc.name: usbFunctionsFromString - * @tc.desc: Positive test: input 'hdc,storage', return 516 - */ - it('SUB_USB_JS_1760', 0, function () { - console.info('usb SUB_USB_JS_1760 begin'); - var strMaskCode = 'hdc,storage' - var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode) - console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode); - expect(nMaskCode).assertEqual(usbManager.STORAGE | usbManager.HDC); - console.info('usb SUB_USB_JS_1760 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1170 - * @tc.name: usbFunctionsFromString - * @tc.desc: Negative test: Description character converted to mask, parameter type error - */ - it('SUB_USB_JS_1170', 0, function () { - console.info('usb SUB_USB_JS_1170 begin'); - try { - var maskCode = usbManager.usbFunctionsFromString(invalidCode); - console.info('usb 1170 case usbFunctionsFromString return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1170 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1170 : PASS'); - } - }) - - /** - * @tc.number: SUB_USB_JS_1370 - * @tc.name: usbFunctionsFromString - * @tc.desc: Negative test: Description character converted to mask, - * parameter number exception, necessary parameters not input - */ - it('SUB_USB_JS_1370', 0, function () { - console.info('usb SUB_USB_JS_1370 begin'); - try { - var maskCode = usbManager.usbFunctionsFromString(); - console.info('usb 1370 case usbFunctionsFromString return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1370 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1370 : PASS'); - } - }) -}) -} diff --git a/usb/usb_standard/src/main/js/test/UsbPortAndFunctionJsunit.test.js b/usb/usb_standard/src/main/js/test/UsbPortAndFunctionJsunit.test.js deleted file mode 100644 index 323ddc84ff81f7b15bc6340bccc0e79b4ea01aa7..0000000000000000000000000000000000000000 --- a/usb/usb_standard/src/main/js/test/UsbPortAndFunctionJsunit.test.js +++ /dev/null @@ -1,334 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import usbManager from '@ohos.usbManager'; -import CheckEmptyUtils from './CheckEmptyUtils.js'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' - -/* usb core functions test */ -export default function UsbPortAndFunctionsJsFunctionsTest() { -describe('UsbPortAndFunctionsJsFunctionsTest', function () { - - beforeAll(function () { - console.log('*************Usb Unit UsbPortAndFunctionsJsFunctionsTest Begin*************'); - var Version = usbManager.getVersion() - console.info('begin test getversion :' + Version) - // version > 17 host currentMode = 2 device currentMode = 1 - var usbPortList = usbManager.getPorts() - if (usbPortList.length > 0) { - if (usbPortList[0].status.currentMode == 2) { - usbManager.setPortRoles(usbPortList[0].id, usbManager.SINK, usbManager.DEVICE).then(data => { - console.info('usb case setPortRoles return: ' + data); - }).catch(error => { - console.info('usb case setPortRoles error : ' + error); - }); - CheckEmptyUtils.sleep(8000) - console.log('*************Usb Unit switch to device Begin*************'); - } - } - }) - beforeEach(function () { - console.info('beforeEach: *************Usb Unit Test Case*************'); - }) - afterEach(function () { - console.info('afterEach: *************Usb Unit Test Case*************'); - }) - afterAll(function () { - console.log('*************Usb Unit UsbPortAndFunctionsJsFunctionsTest End*************'); - }) - - function callSetCurFunction(caseName, iValue) { - console.info('usb case param case name:' + caseName); - console.info('usb case param iValue:' + iValue); - usbManager.setCurrentFunctions(iValue).then(data => { - console.info('usb case SetCurFunction ret:' + data); - expect(data).assertTrue(); - console.info('usb case ' + caseName + ': PASS'); - }).catch(error => { - console.info('usb case ' + caseName + ' error : ' + error); - expect(false).assertTrue(); - }); - CheckEmptyUtils.sleep(6000); - } - - /** - * @tc.number: SUB_USB_JS_0350 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 1, Set as ACM function - */ - it('SUB_USB_JS_0350', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_0350 set ACM begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_0350 ACM 1', usbManager.ACM); - }) - - /** - * @tc.number: SUB_USB_JS_0360 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 2, Set as ECM function - */ - it('SUB_USB_JS_0360', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_0360 set ECM begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_0360 ECM 2', usbManager.ECM); - }) - - /** - * @tc.number: SUB_USB_JS_0370 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 3, Set as ACM、ECM function - */ - it('SUB_USB_JS_0370', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_0370 set ACM ECM begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_0370 ACM ECM 3', (usbManager.ACM | usbManager.ECM)); - }) - - /** - * @tc.number: SUB_USB_JS_0380 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 4, Set as HDC function - */ - it('SUB_USB_JS_0380', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_0380 set HDC begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_0380 HDC 4', usbManager.HDC); - }) - - /** - * @tc.number: SUB_USB_JS_0390 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 5, Set as ACM、HDC function - */ - it('SUB_USB_JS_0390', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_0390 set ACM HDC begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_0390 ACM HDC 5', (usbManager.HDC | usbManager.ACM)); - }) - - /** - * @tc.number: SUB_USB_JS_0400 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 6, Set as ECM、HDC function - */ - it('SUB_USB_JS_0400', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_0400 set ECM HDC begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_0400 ECM HDC 6', (usbManager.HDC | usbManager.ECM)); - }) - - /** - * @tc.number: SUB_USB_JS_1620 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 8, Set as MTP function - */ - it('SUB_USB_JS_1620', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_1620 set MTP begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_1620 MTP 8', (usbManager.MTP)); - }) - - /** - * @tc.number: SUB_USB_JS_1630 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 12, Set as MTP、HDC function - */ - it('SUB_USB_JS_1630', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_1630 set MTP HDC begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_1630 MTP HDC 12', (usbManager.MTP | usbManager.HDC)); - }) - - /** - * @tc.number: SUB_USB_JS_1640 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 16, Set as PTP function - */ - it('SUB_USB_JS_1640', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_1640 set PTP begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_1640 PTP 16', (usbManager.PTP)); - }) - - /** - * @tc.number: SUB_USB_JS_1650 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 20, Set as PTP、HDC function - */ - it('SUB_USB_JS_1650', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_1650 set PTP HDC begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_1650 PTP HDC 20', (usbManager.PTP | usbManager.HDC)); - }) - - /** - * @tc.number: SUB_USB_JS_1660 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 32, Set as RNDIS function - */ - it('SUB_USB_JS_1660', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_1660 set RNDIS begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_1660 RNDIS 32', (usbManager.RNDIS)); - }) - - /** - * @tc.number: SUB_USB_JS_1670 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 36, Set as RNDIS、HDC function - */ - it('SUB_USB_JS_1670', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_1670 set RNDIS HDC begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_1670 RNDIS HDC 36', (usbManager.RNDIS | usbManager.HDC)); - }) - - /** - * @tc.number: SUB_USB_JS_1680 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 512, Set as STORAGE function - */ - it('SUB_USB_JS_1680', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_1680 set STORAGE begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_1680 STORAGE 512', (usbManager.STORAGE)); - }) - - /** - * @tc.number: SUB_USB_JS_1690 - * @tc.name: functions_test - * @tc.desc: Positive test: Set the current USB function list in device mode, Set 516, Set as STORAGE、HDC function - */ - it('SUB_USB_JS_1690', 0, function () { - CheckEmptyUtils.sleep(3000); - console.info('usb SUB_USB_JS_1690 set STORAGE HDC begin'); - var maskCode = usbManager.getCurrentFunctions(); - console.info('usb case getCurrentFunctions return: ' + maskCode); - var funcString = usbManager.usbFunctionsToString(maskCode); - console.info('usb case funcString:' + funcString); - callSetCurFunction('SUB_USB_JS_1690 STORAGE HDC 516', (usbManager.STORAGE | usbManager.HDC)); - }) - - /** - * @tc.number: SUB_USB_JS_0010 - * @tc.name: setPortRoles - * @tc.desc: Positive test: Switch to Device, set powerRole 2 DataRole 2 - */ - it('SUB_USB_JS_0010', 0, function () { - console.info('usb SUB_USB_JS_0010 device 2 2 begin'); - var usbPortList = usbManager.getPorts() - if (usbPortList.length == 0) { - console.info('usb SUB_USB_JS_0010 device 2 2 usbPortList is null'); - expect(false).assertTrue(); - return - } - - for (var i = 0; i < usbPortList.length; i++) { - console.info('usb 0010 case set data role 2, data role 2'); - usbManager.setPortRoles(usbPortList[i].id, usbManager.SINK, usbManager.DEVICE).then(data => { - console.info('usb 0010 case setPortRoles return: ' + data); - expect(data).assertTrue(); - }).catch(error => { - console.info('usb 0010 case setPortRoles error : ' + error); - expect(false).assertTrue(); - }); - CheckEmptyUtils.sleep(8000) - } - - console.info('usb SUB_USB_JS_0010 device 2 2: PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0020 - * @tc.name: setPortRoles - * @tc.desc: Positive test: Switch to host, set powerRole 1 DataRole 1 - */ - it('SUB_USB_JS_0020', 0, function () { - console.info('usb SUB_USB_JS_0020 host 1 1 begin'); - var usbPortList = usbManager.getPorts() - if (usbPortList.length == 0) { - console.info('usb SUB_USB_JS_0020 host 1 1 usbPortList is null'); - expect(false).assertTrue(); - return - } - - for (var i = 0; i < usbPortList.length; i++) { - console.info('usb 0020 case set data role 1, data role 1'); - usbManager.setPortRoles(usbPortList[i].id, usbManager.SOURCE, usbManager.HOST).then(data => { - console.info('usb 0020 case setPortRoles return: ' + data); - expect(data).assertTrue(); - }).catch(error => { - console.info('usb 0020 case setPortRoles error : ' + error); - expect(false).assertTrue(); - }); - CheckEmptyUtils.sleep(8000) - } - - console.info('usb SUB_USB_JS_0020 host 1 1: PASS'); - }) -}) -} diff --git a/usb/usb_standard/src/main/js/test/UsbPortJsunit.test.js b/usb/usb_standard/src/main/js/test/UsbPortJsunit.test.js deleted file mode 100644 index e8647dcee26dd6bbdd5a324809a363edb93695ea..0000000000000000000000000000000000000000 --- a/usb/usb_standard/src/main/js/test/UsbPortJsunit.test.js +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import usbManager from '@ohos.usbManager'; -import CheckEmptyUtils from './CheckEmptyUtils.js'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' - -/* usb core functions test */ -export default function UsbPortJsFunctionsTest() { -describe('UsbPortJsFunctionsTest', function () { - - beforeAll(function () { - console.log('*************Usb Unit UsbPortJsFunctionsTest Begin*************'); - var Version = usbManager.getVersion() - console.info('begin test getversion :' + Version) - }) - beforeEach(function () { - console.info('beforeEach: *************Usb Unit Test Case*************'); - }) - afterEach(function () { - console.info('afterEach: *************Usb Unit Test Case*************'); - }) - afterAll(function () { - console.log('*************Usb Unit UsbPortJsFunctionsTest End*************'); - }) - - /** - * @tc.number: SUB_USB_JS_0410 - * @tc.name: getPorts - * @tc.desc: Positive test: Get USB port description information list - */ - it('SUB_USB_JS_0410', 0, function () { - console.info('usb SUB_USB_JS_0410 begin'); - var usbPortList = usbManager.getPorts() - if (usbPortList.length == 0) { - console.info('usb SUB_USB_JS_0410 usbPortList is null'); - expect(false).assertTrue(); - return - } - expect(usbPortList.length > 0).assertTrue(); - console.info('usb SUB_USB_JS_0410 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0220 - * @tc.name: getSupportedModes - * @tc.desc: Positive test: Get the combination mask of the mode list supported by the specified port - */ - it('SUB_USB_JS_0220', 0, function () { - console.info('usb SUB_USB_JS_0220 begin'); - var usbPortList = usbManager.getPorts() - if (usbPortList.length == 0) { - console.info('usb SUB_USB_JS_0220 usbPortList is null'); - expect(false).assertTrue(); - return - } - - expect(usbPortList.length > 0).assertTrue(); - for (var i = 0; i < usbPortList.length; i++) { - var maskCode = usbManager.getSupportedModes(usbPortList[i].id) - expect(maskCode).assertEqual(usbPortList[i].supportedModes); - } - - console.info('usb SUB_USB_JS_0220 : PASS'); - }) - -}) -} diff --git a/usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js b/usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js deleted file mode 100644 index fffdf220660a5bed9b40dbea1cb6ae0fb474cc93..0000000000000000000000000000000000000000 --- a/usb/usb_standard/src/main/js/test/UsbPortJsunitEx.test.js +++ /dev/null @@ -1,396 +0,0 @@ -/* - * Copyright (c) 2021-2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import usbManager from '@ohos.usbManager'; -import CheckEmptyUtils from './CheckEmptyUtils.js'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' - -/* usb core functions test */ -export default function UsbPortJsFunctionsTestEx() { -describe('UsbPortJsFunctionsTestEx', function () { - - var gPort; - beforeAll(function () { - console.log('*************Usb Unit UsbPortJsFunctionsTestEx Begin*************'); - var Version = usbManager.getVersion() - console.info('begin test getversion :' + Version) - }) - beforeEach(function () { - console.info('beforeEach: *************Usb Unit Test Case*************'); - }) - - afterEach(function () { - console.info('afterEach: *************Usb Unit Test Case*************'); - }) - - afterAll(function () { - console.log('*************Usb Unit UsbPortJsFunctionsTest End*************'); - }) - - /** - * @tc.number: SUB_USB_JS_0230 - * @tc.name: getSupportedModes - * @tc.desc: Negative test: Get the combination mask of the mode list supported by the specified port, id error - */ - it('SUB_USB_JS_0230', 0, function () { - console.info('usb SUB_USB_JS_0230 begin'); - var usbPortList = usbManager.getPorts() - if (usbPortList.length == 0) { - console.info('usb SUB_USB_JS_0230 usbPortList is null'); - expect(false).assertTrue(); - return - } - - expect(usbPortList.length > 0).assertTrue(); - gPort = usbPortList[0] - var portID = usbPortList[0].id + 10 - var maskCode = usbManager.getSupportedModes(portID) - expect(maskCode).assertEqual(usbManager.NONE); - - console.info('usb SUB_USB_JS_0230 : PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1210 - * @tc.name: getSupportedModes - * @tc.desc: Negative test: Get the combination mask of the mode list supported by the specified port, - * parameter type error - */ - it('SUB_USB_JS_1210', 0, function () { - console.info('usb SUB_USB_JS_1210 begin'); - try { - var maskCode = usbManager.getSupportedModes("invalid"); - console.info('usb 1210 case getSupportedModes return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1210 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1210 : PASS'); - } - }) - - /** - * @tc.number: SUB_USB_JS_1380 - * @tc.name: getSupportedModes - * @tc.desc: Negative test: Get the combination mask of the mode list supported by the specified port, - * parameter number exception, necessary parameters not input - */ - it('SUB_USB_JS_1380', 0, function () { - console.info('usb SUB_USB_JS_1380 begin'); - try { - var maskCode = usbManager.getSupportedModes(); - console.info('usb 1380 case getSupportedModes return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1380 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1380 : PASS'); - } - }) - - /** - * @tc.number: SUB_USB_JS_0030 - * @tc.name: setPortRoles - * @tc.desc: Negative test: dataRole error - */ - it('SUB_USB_JS_0030', 0, function () { - var portId = gPort.id; - var powerRole = usbManager.SINK; - var dataRole = usbManager.NONE - 1; - usbManager.setPortRoles(portId, powerRole, dataRole).then(data => { - console.info('usb 0030 case setPortRoles return: ' + data); - expect(data).assertFalse(); - }).catch(error => { - console.info('usb 0030 case setPortRoles error : ' + error); - expect(error).assertFalse(); - }) - CheckEmptyUtils.sleep(4000) - console.info('usb SUB_USB_JS_0030: PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0040 - * @tc.name: setPortRoles - * @tc.desc: Negative test: portId && powerRole error - */ - it('SUB_USB_JS_0040', 0, function () { - var portId = gPort.id; - var powerRole = usbManager.NONE - 1; - var dataRole = usbManager.DEVICE; - usbManager.setPortRoles(portId, powerRole, dataRole).then(data => { - console.info('usb 0040 case setPortRoles return: ' + data); - expect(data).assertFalse(); - }).catch(error => { - console.info('usb 0040 case setPortRoles error : ' + error); - expect(error).assertFalse(); - }) - CheckEmptyUtils.sleep(4000) - console.info('usb SUB_USB_JS_0040: PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0050 - * @tc.name: setPortRoles - * @tc.desc: Negative test: portId && dataRole error - */ - it('SUB_USB_JS_0050', 0, function () { - var portId = gPort.id - 3; - var powerRole = usbManager.SINK; - var dataRole = usbManager.NONE - 1; - usbManager.setPortRoles(portId, powerRole, dataRole).then(data => { - console.info('usb 0050 case setPortRoles return: ' + data); - expect(data).assertFalse(); - }).catch(error => { - console.info('usb 0050 case setPortRoles error : ' + error); - expect(error).assertFalse(); - }) - CheckEmptyUtils.sleep(4000) - console.info('usb SUB_USB_JS_0050: PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0060 - * @tc.name: setPortRoles - * @tc.desc: Negative test: powerRole && dataRole error - */ - it('SUB_USB_JS_0060', 0, function () { - var portId = gPort.id; - var powerRole = usbManager.NONE - 1; - var dataRole = usbManager.NONE - 1; - usbManager.setPortRoles(portId, powerRole, dataRole).then(data => { - console.info('usb 0060 case setPortRoles return: ' + data); - expect(data).assertFalse(); - }).catch(error => { - console.info('usb 0060 case setPortRoles error : ' + error); - expect(error).assertFalse(); - }) - CheckEmptyUtils.sleep(4000) - console.info('usb SUB_USB_JS_0060: PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0070 - * @tc.name: setPortRoles - * @tc.desc: Negative test: portId && powerRole && dataRole error - */ - it('SUB_USB_JS_0070', 0, function () { - var portId = gPort.id - 1; - var dataRole = usbManager.NONE - 1; - var powerRole = usbManager.NONE - 1; - usbManager.setPortRoles(portId, powerRole, dataRole).then(data => { - console.info('usb 0070 case setPortRoles return: ' + data); - expect(data).assertFalse(); - }).catch(error => { - console.info('usb 0070 case setPortRoles error : ' + error); - expect(error).assertFalse(); - }) - CheckEmptyUtils.sleep(4000) - console.info('usb SUB_USB_JS_0070: PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_0080 - * @tc.name: setPortRoles - * @tc.desc: Negative test: portId error - */ - it('SUB_USB_JS_0080', 0, function () { - var portId = gPort.id - 1; - var powerRole = 1; - var dataRole = 1; - usbManager.setPortRoles(portId, powerRole, dataRole).then(data => { - console.info('usb 0080 case setPortRoles return: ' + data); - expect(data).assertFalse(); - }).catch(error => { - console.info('usb 0080 case setPortRoles error : ' + error); - expect(error).assertFalse(); - }) - CheckEmptyUtils.sleep(4000) - console.info('usb SUB_USB_JS_0080: PASS'); - }) - - /** - * @tc.number: SUB_USB_JS_1410 - * @tc.name: setPortRoles - * @tc.desc: Negative test: parameter portId type exception - */ - it('SUB_USB_JS_1410', 0, function () { - console.info('usb SUB_USB_JS_1410 begin'); - var portId = "invalid"; - var powerRole = usbManager.SINK; - var dataRole = usbManager.DEVICE; - try { - var maskCode = usbManager.setPortRoles(portId, powerRole, dataRole); - console.info('usb 1410 case setPortRoles return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1410 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1410 : PASS'); - } - }) - - /** - * @tc.number: SUB_USB_JS_1190 - * @tc.name: setPortRoles - * @tc.desc: Negative test: parameter number exception, input a parameter - */ - it('SUB_USB_JS_1190', 0, function () { - console.info('usb SUB_USB_JS_1190 begin'); - try { - var maskCode = usbManager.setPortRoles("invalid"); - console.info('usb 1190 case setPortRoles return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1190 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1190 : PASS'); - } - }) - - /** - * @tc.number: SUB_USB_JS_1390 - * @tc.name: setPortRoles - * @tc.desc: Negative test: parameter number exception, necessary parameters not input - */ - it('SUB_USB_JS_1390', 0, function () { - console.info('usb SUB_USB_JS_1390 begin'); - try { - var maskCode = usbManager.setPortRoles(); - console.info('usb 1390 case setPortRoles return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1390 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1390 : PASS'); - } - }) - - /** - * @tc.number: SUB_USB_JS_1590 - * @tc.name: setPortRoles - * @tc.desc: Negative test: parameter number exception, parameter powerRole type exception - */ - it('SUB_USB_JS_1590', 0, function () { - console.info('usb SUB_USB_JS_1590 begin'); - var portId = gPort.id; - var powerRole = "invalid"; - var dataRole = usbManager.DEVICE; - try { - var maskCode = usbManager.setPortRoles(portId, powerRole, dataRole); - console.info('usb 1590 case setPortRoles return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1590 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1590 : PASS'); - } - }) - - /** - * @tc.number: SUB_USB_JS_1600 - * @tc.name: setPortRoles - * @tc.desc: Negative test: parameter number exception, parameter dataRole type exception - */ - it('SUB_USB_JS_1600', 0, function () { - console.info('usb SUB_USB_JS_1600 begin'); - var portId = gPort.id; - var powerRole = usbManager.SINK; - var dataRole = "invalid"; - try { - var maskCode = usbManager.setPortRoles(portId, powerRole, dataRole); - console.info('usb 1600 case setPortRoles return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1600 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1600 : PASS'); - } - }) - - /** - * @tc.number: SUB_USB_JS_1610 - * @tc.name: setPortRoles - * @tc.desc: Negative test: parameter number exception, input two parameter - */ - it('SUB_USB_JS_1610', 0, function () { - console.info('usb SUB_USB_JS_1610 begin'); - var portId = gPort.id; - var powerRole = usbManager.SINK; - try { - var maskCode = usbManager.setPortRoles(portId, powerRole); - console.info('usb 1610 case setPortRoles return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1610 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1610 : PASS'); - } - }) - - /** - * @tc.number: SUB_USB_JS_1200 - * @tc.name: getPorts - * @tc.desc: Negative test: parameters exception(parameter transfer without parameter interface) - */ - it('SUB_USB_JS_1200', 0, function () { - console.info('usb SUB_USB_JS_1200 begin'); - try { - var maskCode = usbManager.getPorts("invalid"); - console.info('usb 1200 case getPorts return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1200 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1200 : PASS'); - } - }) - - /** - * @tc.number: SUB_USB_JS_1180 - * @tc.name: setCurrentFunctions - * @tc.desc: Negative test: parameter type error - */ - it('SUB_USB_JS_1180', 0, function () { - console.info('usb SUB_USB_JS_1180 begin'); - try { - var maskCode = usbManager.setCurrentFunctions("invalid"); - console.info('usb 1180 case setCurrentFunctions return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1180 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1180 : PASS'); - } - }) - - /** - * @tc.number: SUB_USB_JS_1400 - * @tc.name: setCurrentFunctions - * @tc.desc: Negative test: parameter number exception, necessary parameters not input - */ - it('SUB_USB_JS_1400', 0, function () { - console.info('usb SUB_USB_JS_1400 begin'); - try { - var maskCode = usbManager.setCurrentFunctions(); - console.info('usb 1400 case setCurrentFunctions return: ' + maskCode); - expect(false).assertTrue(); - } catch (err) { - console.info('usb 1400 catch err code: ' + err.code + ' message: ' + err.message); - expect(err.code).assertEqual(401); - console.info('usb SUB_USB_JS_1400 : PASS'); - } - }) -}) -}