提交 e54412ed 编写于 作者: L lixiaofeng_154b

整改usb_js接口用例,移除systemApi用例

Signed-off-by: Nlixiaofeng_154b <lixiaofeng54@huawei.com>
Change-Id: If898f70a6d346c5e1473e4a57b1d879b1ac5a7f4
上级 154bcac7
...@@ -12,24 +12,16 @@ ...@@ -12,24 +12,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * 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 UsbDevicePipeJsFunctionsTest from './UsbDevicePipeJsunit.test.js'
import UsbDevicePipeJsFunctionsTestEx from './UsbDevicePipeJsunitEx.test.js' import UsbDevicePipeJsFunctionsTestEx from './UsbDevicePipeJsunitEx.test.js'
import UsbCoreJsFunctionsTest from './UsbCoreJsunit.test.js' import UsbCoreJsFunctionsTest from './UsbCoreJsunit.test.js'
import UsbCoreJsFunctionsTestEx from './UsbCoreJsunitEx.test.js' import UsbCoreJsFunctionsTestEx from './UsbCoreJsunitEx.test.js'
/* host test case */ /* host test case */
export default function testsuite() { export default function testsuite() {
UsbCoreJsFunctionsTest() UsbCoreJsFunctionsTest()
UsbCoreJsFunctionsTestEx() UsbCoreJsFunctionsTestEx()
UsbDevicePipeJsFunctionsTest() UsbDevicePipeJsFunctionsTest()
UsbDevicePipeJsFunctionsTestEx() UsbDevicePipeJsFunctionsTestEx()
UsbFunctionsJsFunctionsTest()
UsbFunctionsJsFunctionsTestEx()
// UsbPortAndFunctionsJsFunctionsTest()
UsbPortJsFunctionsTest()
UsbPortJsFunctionsTestEx()
} }
...@@ -231,7 +231,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -231,7 +231,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
/** /**
* @tc.number: SUB_USB_JS_0641 * @tc.number: SUB_USB_JS_0641
* @tc.name: bulkTransfer * @tc.name: bulkTransfer
* @tc.desc: Undefined * @tc.desc: Undefined option arguments, use default options.
*/ */
it('SUB_USB_JS_0641', 0, function () { it('SUB_USB_JS_0641', 0, function () {
console.info('usb SUB_USB_JS_0641 begin'); console.info('usb SUB_USB_JS_0641 begin');
...@@ -273,7 +273,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -273,7 +273,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
/** /**
* @tc.number: SUB_USB_JS_0642 * @tc.number: SUB_USB_JS_0642
* @tc.name: bulkTransfer * @tc.name: bulkTransfer
* @tc.desc: Null * @tc.desc: Null option arguments, use default options.
*/ */
it('SUB_USB_JS_0642', 0, function () { it('SUB_USB_JS_0642', 0, function () {
console.info('usb SUB_USB_JS_0642 begin'); console.info('usb SUB_USB_JS_0642 begin');
...@@ -315,7 +315,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -315,7 +315,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
/** /**
* @tc.number: SUB_USB_JS_0643 * @tc.number: SUB_USB_JS_0643
* @tc.name: bulkTransfer * @tc.name: bulkTransfer
* @tc.desc: * @tc.desc: Ignore option arguments, use default options.
*/ */
it('SUB_USB_JS_0643', 0, function () { it('SUB_USB_JS_0643', 0, function () {
console.info('usb SUB_USB_JS_0643 begin'); console.info('usb SUB_USB_JS_0643 begin');
...@@ -406,7 +406,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -406,7 +406,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
/** /**
* @tc.number: SUB_USB_JS_1520 * @tc.number: SUB_USB_JS_1520
* @tc.name: claimInterface * @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 () { it('SUB_USB_JS_1520', 0, function () {
console.info('usb SUB_USB_JS_1520 begin'); console.info('usb SUB_USB_JS_1520 begin');
...@@ -468,7 +468,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -468,7 +468,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
//Attribute Prefabrication //Attribute Prefabrication
var interfaces = gDeviceList[0].configs[j].interfaces[k]; 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); console.info('usb case 0421 claimInterface function return: ' + isClaim);
expect(isClaim).assertEqual(0); expect(isClaim).assertEqual(0);
if (isClaim == 0) { if (isClaim == 0) {
...@@ -486,7 +486,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -486,7 +486,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
* @tc.number: SUB_USB_JS_0422 * @tc.number: SUB_USB_JS_0422
* @tc.name: claimInterface * @tc.name: claimInterface
* @tc.desc: Test the claimInterface() interface. * @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 () { it('SUB_USB_JS_0422', 0, function () {
console.info('usb SUB_USB_JS_0422 begin'); console.info('usb SUB_USB_JS_0422 begin');
...@@ -514,7 +514,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -514,7 +514,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
//Attribute Prefabrication //Attribute Prefabrication
var interfaces = gDeviceList[0].configs[j].interfaces[k]; 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); console.info('usb case 0422 claimInterface function return: ' + isClaim);
expect(isClaim).assertEqual(0); expect(isClaim).assertEqual(0);
if (isClaim == 0) { if (isClaim == 0) {
...@@ -532,7 +532,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -532,7 +532,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
* @tc.number: SUB_USB_JS_0423 * @tc.number: SUB_USB_JS_0423
* @tc.name: claimInterface * @tc.name: claimInterface
* @tc.desc: Test the claimInterface() interface. * @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 () { it('SUB_USB_JS_0423', 0, function () {
console.info('usb SUB_USB_JS_0423 begin'); console.info('usb SUB_USB_JS_0423 begin');
...@@ -560,7 +560,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -560,7 +560,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) { for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
//Attribute Prefabrication //Attribute Prefabrication
var interfaces = gDeviceList[0].configs[j].interfaces[k]; 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); console.info('usb case 0423 claimInterface function return: ' + isClaim);
expect(isClaim).assertEqual(0); expect(isClaim).assertEqual(0);
if (isClaim == 0) { if (isClaim == 0) {
...@@ -837,7 +837,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -837,7 +837,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
* @tc.number: SUB_USB_JS_0553 * @tc.number: SUB_USB_JS_0553
* @tc.name: controlTransfer * @tc.name: controlTransfer
* @tc.desc: Test the bulkTransfer interface * @tc.desc: Test the bulkTransfer interface
* Ignore option arguments. * Ignore option arguments, use default options.
*/ */
it('SUB_USB_JS_0553', 0, function () { it('SUB_USB_JS_0553', 0, function () {
console.info('usb SUB_USB_JS_0553 begin'); console.info('usb SUB_USB_JS_0553 begin');
...@@ -1183,7 +1183,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () { ...@@ -1183,7 +1183,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
/** /**
* @tc.number: SUB_USB_JS_1570 * @tc.number: SUB_USB_JS_1570
* @tc.name: controlTransfer * @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 () { it('SUB_USB_JS_1570', 0, function () {
console.info('usb SUB_USB_JS_1570 begin'); console.info('usb SUB_USB_JS_1570 begin');
......
/*
* 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');
}
})
})
}
/*
* 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');
})
})
}
/*
* 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');
})
})
}
/*
* 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');
}
})
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册