提交 8582b46e 编写于 作者: L lixiaofeng_154b

修改d.ts文件

Signed-off-by: Nlixiaofeng_154b <lixiaofeng54@huawei.com>
Change-Id: I1f1f619092ee56a98c52e71d6a5f9827cc679612
上级 bf2e4f97
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import usb from '@ohos.usb';
import usbManager from '@ohos.usbManager';
import CheckEmptyUtils from './CheckEmptyUtils.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
......@@ -28,20 +28,20 @@ describe('UsbCoreJsFunctionsTest', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbCoreJsFunctionsTest Begin*************');
var Version = usb.getVersion()
var Version = usbManager.getVersion()
console.info('begin test getversion :' + Version)
// version > 17 host currentMode = 2 device currentMode = 1
var usbPortList = usb.getPorts()
var usbPortList = usbManager.getPorts()
if (usbPortList == undefined) {
portCurrentMode = 1;
return
}
gDeviceList = usb.getDevices();
gDeviceList = usbManager.getDevices();
if (usbPortList.length > 0) {
console.info('usb case gDeviceList.length return: ' + gDeviceList.length);
if (gDeviceList.length > 0) {
if (usbPortList[0].status.currentMode == 1) {
usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => {
usbManager.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => {
portCurrentMode = 2
console.info('usb case setPortRoles return: ' + data);
}).catch(error => {
......@@ -79,7 +79,7 @@ describe('UsbCoreJsFunctionsTest', function () {
expect(false).assertFalse();
return
}
gDeviceList = usb.getDevices();
gDeviceList = usbManager.getDevices();
if (gDeviceList.length == 0) {
console.info('usb case get_devices list is null')
expect(false).assertTrue();
......@@ -109,7 +109,7 @@ describe('UsbCoreJsFunctionsTest', function () {
}
for (var i = 0; i < gDeviceList.length; i++) {
var hasRight = usb.hasRight(gDeviceList[i].name)
var hasRight = usbManager.hasRight(gDeviceList[i].name)
console.info('usb has_right ret :' + hasRight);
}
......@@ -136,7 +136,7 @@ describe('UsbCoreJsFunctionsTest', function () {
}
for (var i = 0; i < gDeviceList.length; i++) {
usb.requestRight(gDeviceList[i].name).then(hasRight => {
usbManager.requestRight(gDeviceList[i].name).then(hasRight => {
console.info('usb request_right ret :' + hasRight);
expect(hasRight).assertTrue();
console.info('usb SUB_USB_JS_0680 : PASS');
......@@ -165,16 +165,16 @@ describe('UsbCoreJsFunctionsTest', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
console.info('usb 1080 requestRight hasRight:' + hasRight);
}).catch(error => {
console.info('usb 1080 requestRight error:' + error);
});
CheckEmptyUtils.sleep(5000);
}
var remRight = usb.removeRight(gDeviceList[0].name);
var remRight = usbManager.removeRight(gDeviceList[0].name);
console.info('usb remove_right ret :' + remRight);
expect(remRight).assertTrue();
console.info('usb SUB_USB_JS_1080 : PASS');
......@@ -197,9 +197,9 @@ describe('UsbCoreJsFunctionsTest', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
console.info('usb 0090 requestRight hasRight:' + hasRight);
}).catch(error => {
console.info('usb 0090 requestRight error:' + error);
......@@ -207,7 +207,7 @@ describe('UsbCoreJsFunctionsTest', function () {
CheckEmptyUtils.sleep(5000)
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
console.info('usb case connectDevice ret: ' + JSON.stringify(gPipe));
expect(CheckEmptyUtils.isEmpty(gPipe)).assertFalse();
......@@ -234,7 +234,7 @@ describe('UsbCoreJsFunctionsTest', function () {
var tmpPipe = JSON.parse(JSON.stringify(gPipe));
tmpPipe.busNum = -23
var isPipClose = usb.closePipe(tmpPipe);
var isPipClose = usbManager.closePipe(tmpPipe);
console.info('usb case closePipe ret: ' + isPipClose);
expect(isPipClose == 0).assertFalse();
......@@ -260,7 +260,7 @@ describe('UsbCoreJsFunctionsTest', function () {
}
var tmpPipe = JSON.parse(JSON.stringify(gPipe));
tmpPipe.devAddress = -23
var isPipClose = usb.closePipe(tmpPipe);
var isPipClose = usbManager.closePipe(tmpPipe);
console.info('usb case closePipe ret: ' + isPipClose);
expect(isPipClose == 0).assertFalse();
......@@ -287,7 +287,7 @@ describe('UsbCoreJsFunctionsTest', function () {
var tmpPipe = JSON.parse(JSON.stringify(gPipe));
tmpPipe.devAddress = -23
tmpPipe.busNum = -23
var isPipClose = usb.closePipe(tmpPipe);
var isPipClose = usbManager.closePipe(tmpPipe);
console.info('usb case closePipe ret: ' + isPipClose);
expect(isPipClose == 0).assertFalse();
......@@ -313,7 +313,7 @@ describe('UsbCoreJsFunctionsTest', function () {
}
console.info('usb case closePipe param: ' + JSON.stringify(gPipe));
var isPipClose = usb.closePipe(gPipe);
var isPipClose = usbManager.closePipe(gPipe);
console.info('usb case closePipe ret: ' + isPipClose);
expect(isPipClose).assertEqual(0);
......@@ -338,12 +338,12 @@ describe('UsbCoreJsFunctionsTest', function () {
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
console.info('usb case getRawDescriptor param: ' + JSON.stringify(gPipe));
var descriptor = usb.getRawDescriptor(gPipe);
var descriptor = usbManager.getRawDescriptor(gPipe);
console.info('usb case getRawDescriptor ret: ' + descriptor);
expect(descriptor.length).assertLarger(0);
var isPipClose = usb.closePipe(gPipe);
var isPipClose = usbManager.closePipe(gPipe);
expect(isPipClose).assertEqual(0);
console.info('usb SUB_USB_JS_0530 : PASS');
......@@ -366,12 +366,12 @@ describe('UsbCoreJsFunctionsTest', function () {
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
console.info('usb case getFileDescriptor param: ' + JSON.stringify(gPipe));
var fileDescriptor = usb.getFileDescriptor(gPipe);
var fileDescriptor = usbManager.getFileDescriptor(gPipe);
console.info('usb case getFileDescriptor ret: ' + fileDescriptor);
expect(fileDescriptor >= 0).assertTrue();
var isPipClose = usb.closePipe(gPipe);
var isPipClose = usbManager.closePipe(gPipe);
expect(isPipClose).assertEqual(0);
console.info('usb SUB_USB_JS_0490 : PASS');
......@@ -394,13 +394,13 @@ describe('UsbCoreJsFunctionsTest', function () {
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
var tempPipe = {busNum : 255, devAddress : 255}
console.info('usb case getFileDescriptor param: ' + JSON.stringify(gPipe));
var fileDescriptor = usb.getFileDescriptor(tempPipe);
var fileDescriptor = usbManager.getFileDescriptor(tempPipe);
expect(fileDescriptor < 0).assertTrue();
console.info('usb case getFileDescriptor ret: ' + fileDescriptor);
var isPipClose = usb.closePipe(gPipe);
var isPipClose = usbManager.closePipe(gPipe);
expect(isPipClose).assertEqual(0);
console.info('usb SUB_USB_JS_0500 : PASS');
})
......@@ -422,13 +422,13 @@ describe('UsbCoreJsFunctionsTest', function () {
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
var tempPipe = {busNum : 255, devAddress : gPipe.devAddress}
console.info('usb case getFileDescriptor param: ' + JSON.stringify(gPipe));
var fileDescriptor = usb.getFileDescriptor(tempPipe);
var fileDescriptor = usbManager.getFileDescriptor(tempPipe);
expect(fileDescriptor < 0).assertTrue();
console.info('usb case getFileDescriptor ret: ' + fileDescriptor);
var isPipClose = usb.closePipe(gPipe);
var isPipClose = usbManager.closePipe(gPipe);
expect(isPipClose).assertEqual(0);
console.info('usb SUB_USB_JS_0510 : PASS');
})
......@@ -450,13 +450,13 @@ describe('UsbCoreJsFunctionsTest', function () {
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
var tempPipe = {busNum : gPipe.busNum, devAddress : 255}
console.info('usb case getFileDescriptor param: ' + JSON.stringify(gPipe));
var fileDescriptor = usb.getFileDescriptor(tempPipe);
var fileDescriptor = usbManager.getFileDescriptor(tempPipe);
expect(fileDescriptor < 0).assertTrue();
console.info('usb case getFileDescriptor ret: ' + fileDescriptor);
var isPipClose = usb.closePipe(gPipe);
var isPipClose = usbManager.closePipe(gPipe);
expect(isPipClose).assertEqual(0);
console.info('usb SUB_USB_JS_0520 : PASS');
})
......@@ -478,9 +478,9 @@ describe('UsbCoreJsFunctionsTest', function () {
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
try {
var maskCode = usb.getFileDescriptor("invalid");
var maskCode = usbManager.getFileDescriptor("invalid");
console.info('usb 1070 case getFileDescriptor return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -507,9 +507,9 @@ describe('UsbCoreJsFunctionsTest', function () {
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
try {
var maskCode = usb.getFileDescriptor();
var maskCode = usbManager.getFileDescriptor();
console.info('usb 1230 case getFileDescriptor return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import usb from '@ohos.usb';
import usbManager from '@ohos.usbManager';
import CheckEmptyUtils from './CheckEmptyUtils.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
......@@ -28,19 +28,19 @@ describe('UsbCoreJsFunctionsTestEx', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbCoreJsFunctionsTestEx Begin*************');
var Version = usb.getVersion()
var Version = usbManager.getVersion()
console.info('begin test getversion :' + Version)
// version > 17 host currentMode = 2 device currentMode = 1
var usbPortList = usb.getPorts()
var usbPortList = usbManager.getPorts()
if (usbPortList == undefined) {
portCurrentMode = 1;
return
}
gDeviceList = usb.getDevices();
gDeviceList = usbManager.getDevices();
if (usbPortList.length > 0) {
if (gDeviceList.length > 0) {
if (usbPortList[0].status.currentMode == 1) {
usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => {
usbManager.setPortRoles(usbPortList[0].id, usbManager.SOURCE, usbManager.HOST).then(data => {
portCurrentMode = 2
console.info('usb case setPortRolesEx return: ' + data);
}).catch(error => {
......@@ -83,9 +83,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
}).catch(error => {
console.info('usb JS_0100 requestRight error:' + error);
});
......@@ -96,7 +96,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
var device = JSON.parse(JSON.stringify(gDeviceList[0]));
device.devAddress = 2 + 10000
try {
var usbDevicePipe = usb.connectDevice(device)
var usbDevicePipe = usbManager.connectDevice(device)
} catch (err) {
expect(true).assertTrue();
console.info('usb connectDevice fail:' + err);
......@@ -125,9 +125,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
}).catch(error => {
console.info('usb JS_0110 requestRight error:' + error);
});
......@@ -138,7 +138,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
var device = JSON.parse(JSON.stringify(gDeviceList[0]));
device.busNum = 2 + 1000
try {
var usbDevicePipe = usb.connectDevice(device)
var usbDevicePipe = usbManager.connectDevice(device)
} catch (err) {
expect(true).assertTrue();
console.info('usb connectDevice fail:' + err);
......@@ -166,9 +166,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
}).catch(error => {
console.info('usb JS_0120 requestRight error:' + error);
});
......@@ -179,7 +179,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
var device = JSON.parse(JSON.stringify(gDeviceList[0]));
device.serial = 'asdfsd'
try {
var usbDevicePipe = usb.connectDevice(device)
var usbDevicePipe = usbManager.connectDevice(device)
} catch (err) {
expect(true).assertTrue();
console.info('usb connectDevice fail:' + err);
......@@ -187,7 +187,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
console.info('usb case connectDevice ret: ' + JSON.stringify(usbDevicePipe) +
' serial ' + device.serial);
expect(CheckEmptyUtils.isEmpty(usbDevicePipe)).assertFalse();
var isPipClose = usb.closePipe(usbDevicePipe);
var isPipClose = usbManager.closePipe(usbDevicePipe);
console.info('usb case closePipe ret: ' + isPipClose);
expect(isPipClose).assertEqual(0);
console.info('usb SUB_USB_JS_0120 : PASS');
......@@ -210,9 +210,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
}).catch(error => {
console.info('usb JS_0130 requestRight error:' + error);
});
......@@ -223,7 +223,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
var device = JSON.parse(JSON.stringify(gDeviceList[0]));
device.name = 2 + 10000
try {
var usbDevicePipe = usb.connectDevice(device)
var usbDevicePipe = usbManager.connectDevice(device)
} catch (err) {
expect(true).assertTrue();
console.info('usb connectDevice fail:' + err);
......@@ -250,9 +250,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
}).catch(error => {
console.info('usb JS_0140 requestRight error:' + error);
});
......@@ -263,7 +263,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
var device = JSON.parse(JSON.stringify(gDeviceList[0]));
device.manufacturerName = 2 + 10000
try {
var usbDevicePipe = usb.connectDevice(device)
var usbDevicePipe = usbManager.connectDevice(device)
} catch (err) {
expect(true).assertTrue();
console.info('usb connectDevice fail:' + err);
......@@ -291,9 +291,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
}).catch(error => {
console.info('usb SUB_USB_JS_0150 requestRight error:' + error);
});
......@@ -304,7 +304,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
var device = JSON.parse(JSON.stringify(gDeviceList[0]));
device.productName = 'sdfsdfe'
try {
var usbDevicePipe = usb.connectDevice(device)
var usbDevicePipe = usbManager.connectDevice(device)
} catch (err) {
expect(true).assertTrue();
console.info('usb connectDevice fail:' + err);
......@@ -312,7 +312,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
console.info('usb case connectDevice ret: ' + JSON.stringify(usbDevicePipe) +
' productName ' + device.productName);
expect(CheckEmptyUtils.isEmpty(usbDevicePipe)).assertFalse();
var isPipClose = usb.closePipe(usbDevicePipe);
var isPipClose = usbManager.closePipe(usbDevicePipe);
console.info('usb case closePipe ret: ' + isPipClose);
expect(isPipClose).assertEqual(0);
console.info('usb SUB_USB_JS_0150 : PASS');
......@@ -335,9 +335,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
}).catch(error => {
console.info('usb SUB_USB_JS_0160 requestRight error:' + error);
});
......@@ -348,7 +348,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
var device = JSON.parse(JSON.stringify(gDeviceList[0]));
device.version = 'gwefsdf'
try {
var usbDevicePipe = usb.connectDevice(device)
var usbDevicePipe = usbManager.connectDevice(device)
} catch (err) {
expect(true).assertTrue();
console.info('usb connectDevice fail:' + err);
......@@ -356,7 +356,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
console.info('usb case connectDevice ret: ' + JSON.stringify(usbDevicePipe) +
' version ' + device.version);
expect(CheckEmptyUtils.isEmpty(usbDevicePipe)).assertFalse();
var isPipClose = usb.closePipe(usbDevicePipe);
var isPipClose = usbManager.closePipe(usbDevicePipe);
console.info('usb case closePipe ret: ' + isPipClose);
expect(isPipClose).assertEqual(0);
console.info('usb SUB_USB_JS_0160 : PASS');
......@@ -379,9 +379,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
}).catch(error => {
console.info('usb SUB_USB_JS_0170 requestRight error:' + error);
});
......@@ -392,7 +392,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
var device = JSON.parse(JSON.stringify(gDeviceList[0]));
device.vendorId = 2 + 10000
try {
var usbDevicePipe = usb.connectDevice(device)
var usbDevicePipe = usbManager.connectDevice(device)
} catch (err) {
expect(true).assertTrue();
console.info('usb connectDevice fail:' + err);
......@@ -400,7 +400,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
console.info('usb case connectDevice ret: ' + JSON.stringify(usbDevicePipe) +
' vendorId ' + device.vendorId);
expect(CheckEmptyUtils.isEmpty(usbDevicePipe)).assertFalse();
var isPipClose = usb.closePipe(usbDevicePipe);
var isPipClose = usbManager.closePipe(usbDevicePipe);
console.info('usb case closePipe ret: ' + isPipClose);
expect(isPipClose).assertEqual(0);
console.info('usb SUB_USB_JS_0170 : PASS');
......@@ -423,9 +423,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
}).catch(error => {
console.info('usb SUB_USB_JS_0180 requestRight error:' + error);
});
......@@ -436,7 +436,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
var device = JSON.parse(JSON.stringify(gDeviceList[0]));
device.productId = 2 + 10000
try {
var usbDevicePipe = usb.connectDevice(device)
var usbDevicePipe = usbManager.connectDevice(device)
} catch (err) {
expect(true).assertTrue();
console.info('usb connectDevice fail:' + err);
......@@ -444,7 +444,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
console.info('usb case connectDevice ret: ' + JSON.stringify(usbDevicePipe) +
' productId ' + device.productId);
expect(CheckEmptyUtils.isEmpty(usbDevicePipe)).assertFalse();
var isPipClose = usb.closePipe(usbDevicePipe);
var isPipClose = usbManager.closePipe(usbDevicePipe);
console.info('usb case closePipe ret: ' + isPipClose);
expect(isPipClose).assertEqual(0);
console.info('usb SUB_USB_JS_0180 : PASS');
......@@ -467,9 +467,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
}).catch(error => {
console.info('usb SUB_USB_JS_0190 requestRight error:' + error);
});
......@@ -480,14 +480,14 @@ describe('UsbCoreJsFunctionsTestEx', function () {
var device = JSON.parse(JSON.stringify(gDeviceList[0]));
device.clazz = 2 + 10000
try {
var usbDevicePipe = usb.connectDevice(device)
var usbDevicePipe = usbManager.connectDevice(device)
} catch (err) {
expect(true).assertTrue();
console.info('usb connectDevice fail:' + err);
}
console.info('usb case connectDevice ret: ' + JSON.stringify(usbDevicePipe) + ' clazz ' + device.clazz);
expect(CheckEmptyUtils.isEmpty(usbDevicePipe)).assertFalse();
var isPipClose = usb.closePipe(usbDevicePipe);
var isPipClose = usbManager.closePipe(usbDevicePipe);
console.info('usb case closePipe ret: ' + isPipClose);
expect(isPipClose).assertEqual(0);
console.info('usb SUB_USB_JS_0190 : PASS');
......@@ -510,9 +510,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
console.info('usb SUB_USB_JS_0200 requestRight hasRight: ' + hasRight);
}).catch(error => {
console.info('usb SUB_USB_JS_0200 requestRight error:' + error);
......@@ -524,14 +524,14 @@ describe('UsbCoreJsFunctionsTestEx', function () {
var device = JSON.parse(JSON.stringify(gDeviceList[0]));
device.subClass = 2 + 10000
try {
var usbDevicePipe = usb.connectDevice(device)
var usbDevicePipe = usbManager.connectDevice(device)
} catch (err) {
expect(true).assertTrue();
console.info('usb connectDevice fail:' + err);
}
console.info('usb case connectDevice ret: ' + JSON.stringify(usbDevicePipe) + ' subClass ' + device.subClass);
expect(CheckEmptyUtils.isEmpty(usbDevicePipe)).assertFalse();
var isPipClose = usb.closePipe(usbDevicePipe);
var isPipClose = usbManager.closePipe(usbDevicePipe);
console.info('usb case closePipe ret: ' + isPipClose);
expect(isPipClose).assertEqual(0);
console.info('usb SUB_USB_JS_0200 : PASS');
......@@ -554,9 +554,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
}).catch(error => {
console.info('usb SUB_USB_JS_0210 requestRight error:' + error);
});
......@@ -567,14 +567,14 @@ describe('UsbCoreJsFunctionsTestEx', function () {
var device = JSON.parse(JSON.stringify(gDeviceList[0]));
device.protocol = 2 + 10000
try {
var usbDevicePipe = usb.connectDevice(device)
var usbDevicePipe = usbManager.connectDevice(device)
} catch (err) {
expect(true).assertTrue();
console.info('usb connectDevice fail:' + err);
}
console.info('usb case connectDevice ret: ' + JSON.stringify(usbDevicePipe) + ' protocol ' + device.protocol);
expect(CheckEmptyUtils.isEmpty(usbDevicePipe)).assertFalse();
var isPipClose = usb.closePipe(usbDevicePipe);
var isPipClose = usbManager.closePipe(usbDevicePipe);
console.info('usb case closePipe ret: ' + isPipClose);
expect(isPipClose).assertEqual(0);
console.info('usb SUB_USB_JS_0210 : PASS');
......@@ -597,9 +597,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
console.info('usb 1040 requestRight hasRight:' + hasRight);
}).catch(error => {
console.info('usb 1040 requestRight error:' + error);
......@@ -607,7 +607,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
CheckEmptyUtils.sleep(5000)
}
try {
var maskCode = usb.connectDevice("invalid");
var maskCode = usbManager.connectDevice("invalid");
console.info('usb 1040 case connectDevice return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -634,9 +634,9 @@ describe('UsbCoreJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
var isRight = usb.hasRight(gDeviceList[0].name);
var isRight = usbManager.hasRight(gDeviceList[0].name);
if (!isRight) {
usb.requestRight(gDeviceList[0].name).then(hasRight => {
usbManager.requestRight(gDeviceList[0].name).then(hasRight => {
console.info('usb 1240 requestRight hasRight:' + hasRight);
}).catch(error => {
console.info('usb 1240 requestRight error:' + error);
......@@ -644,7 +644,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
CheckEmptyUtils.sleep(5000)
}
try {
var maskCode = usb.connectDevice();
var maskCode = usbManager.connectDevice();
console.info('usb 1240 case connectDevice return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -675,7 +675,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
for (var i = 0; i < gDeviceList.length; i++) {
var deviceName = gDeviceList[i].name
deviceName = deviceName + '$#'
var hasRight = usb.hasRight(deviceName)
var hasRight = usbManager.hasRight(deviceName)
console.info('usb has_right ret :' + hasRight);
expect(hasRight).assertTrue();
}
......@@ -703,7 +703,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
for (var i = 0; i < gDeviceList.length; i++) {
var deviceName = gDeviceList[i].name
deviceName = deviceName + 'abcdg'
var hasRight = usb.hasRight(deviceName)
var hasRight = usbManager.hasRight(deviceName)
console.info('usb hasRight ret :' + hasRight);
expect(hasRight).assertTrue();
}
......@@ -728,7 +728,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.hasRight(invalidCode);
var maskCode = usbManager.hasRight(invalidCode);
console.info('usb 1020 case hasRight return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -756,7 +756,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.hasRight();
var maskCode = usbManager.hasRight();
console.info('usb 1250 case hasRight return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -787,7 +787,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
for (var i = 0; i < gDeviceList.length; i++) {
var diviceName = gDeviceList[i].name
diviceName = diviceName + '@#'
usb.requestRight(diviceName).then(hasRight => {
usbManager.requestRight(diviceName).then(hasRight => {
console.info('usb request_right ret :' + hasRight);
expect(hasRight).assertFalse();
console.info('usb SUB_USB_JS_0690 : PASS');
......@@ -820,7 +820,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
for (var i = 0; i < gDeviceList.length; i++) {
var diviceName = gDeviceList[i].name
diviceName = diviceName + '123'
usb.requestRight(diviceName).then(hasRight => {
usbManager.requestRight(diviceName).then(hasRight => {
console.info('usb request_right ret :' + hasRight);
expect(hasRight).assertFalse();
console.info('usb SUB_USB_JS_0700 : PASS');
......@@ -850,7 +850,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.requestRight(invalidCode);
var maskCode = usbManager.requestRight(invalidCode);
console.info('usb 1030 case requestRight return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -879,7 +879,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.requestRight();
var maskCode = usbManager.requestRight();
console.info('usb 1260 case requestRight return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -903,7 +903,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.getDevices("invalid");
var maskCode = usbManager.getDevices("invalid");
console.info('usb 1010 case getDevices return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -931,7 +931,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.closePipe("invalid");
var maskCode = usbManager.closePipe("invalid");
console.info('usb 1050 case closePipe return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -959,7 +959,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.closePipe();
var maskCode = usbManager.closePipe();
console.info('usb 1270 case closePipe return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -987,7 +987,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.getRawDescriptor("invalid");
var maskCode = usbManager.getRawDescriptor("invalid");
console.info('usb 1060 case getRawDescriptor return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -1016,7 +1016,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.getRawDescriptor();
var maskCode = usbManager.getRawDescriptor();
console.info('usb 1280 case getRawDescriptor return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -1044,7 +1044,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.removeRight(invalidCode);
var maskCode = usbManager.removeRight(invalidCode);
console.info('usb 1090 case removeRight return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -1073,7 +1073,7 @@ describe('UsbCoreJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.removeRight();
var maskCode = usbManager.removeRight();
console.info('usb 1290 case removeRight return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import usb from '@ohos.usb';
import usbManager from '@ohos.usbManager';
import CheckEmptyUtils from './CheckEmptyUtils.js';
import EventConstants from './EventConstants.js';
import parameter from '@ohos.systemparameter';
......@@ -29,19 +29,19 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbDevicePipeJsFunctionsTest Begin*************');
var Version = usb.getVersion()
var Version = usbManager.getVersion()
console.info('usb unit begin test getversion :' + Version)
// version > 17 host currentMode = 2 device currentMode = 1
var usbPortList = usb.getPorts()
var usbPortList = usbManager.getPorts()
if (usbPortList == undefined) {
portCurrentMode = 1;
return
}
gDeviceList = usb.getDevices();
gDeviceList = usbManager.getDevices();
if (usbPortList.length > 0) {
if (gDeviceList.length > 0) {
if (usbPortList[0].status.currentMode == 1) {
usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => {
usbManager.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => {
portCurrentMode = 2
console.info('usb case setPortRoles return: ' + data);
}).catch(error => {
......@@ -55,11 +55,11 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
}
gDeviceList = usb.getDevices();
gDeviceList = usbManager.getDevices();
gDeviceList[0].name;
gDeviceList[0].version;
gDeviceList[0].configs;
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
console.info('usb unit connectDevice gPipe ret : ' + JSON.stringify(gPipe));
})
......@@ -71,7 +71,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
})
afterAll(function () {
var isPipClose = usb.closePipe(gPipe)
var isPipClose = usbManager.closePipe(gPipe)
console.info('usb unit close gPipe ret : ' + isPipClose);
console.log('*************Usb Unit UsbDevicePipeJsFunctionsTest End*************');
})
......@@ -85,10 +85,10 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
endpoint.interfaceid = 1;
if (endpoint.type == EventConstants.USB_ENDPOINT_XFER_BULK) {
bfind = true
if (endpoint.direction == usb.USB_REQUEST_DIR_TO_DEVICE) {
if (endpoint.direction == usbManager.USB_REQUEST_DIR_TO_DEVICE) {
testParam.maxOutSize = endpoint.maxPacketSize;
testParam.outEndpoint = endpoint;
} else if (endpoint.direction == usb.USB_REQUEST_DIR_FROM_DEVICE) {
} else if (endpoint.direction == usbManager.USB_REQUEST_DIR_FROM_DEVICE) {
testParam.maxInSize = endpoint.maxPacketSize;
testParam.inEndpoint = endpoint
}
......@@ -169,12 +169,12 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
return
}
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
testParam.isClaimed = usbManager.claimInterface(testParam.pip, testParam.interface, true);
expect(testParam.isClaimed).assertEqual(0);
console.info('usb case readData begin');
var tmpUint8Array = new Uint8Array(testParam.maxInSize);
usb.bulkTransfer(testParam.pip, testParam.inEndpoint, tmpUint8Array, 5000).then(data => {
usbManager.bulkTransfer(testParam.pip, testParam.inEndpoint, tmpUint8Array, 5000).then(data => {
console.info('usb case readData tmpUint8Array buffer : ' + CheckEmptyUtils.ab2str(tmpUint8Array));
console.info('usb case readData ret: ' + data);
expect(data >= 0).assertTrue();
......@@ -204,7 +204,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
return
}
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
testParam.isClaimed = usbManager.claimInterface(testParam.pip, testParam.interface, true);
expect(testParam.isClaimed).assertEqual(0);
testParam.sendData = 'send default';
......@@ -216,7 +216,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var tmpUint8Array = CheckEmptyUtils.str2ab(testParam.sendData);
usb.bulkTransfer(testParam.pip, testParam.outEndpoint, tmpUint8Array, 5000).then(data => {
usbManager.bulkTransfer(testParam.pip, testParam.outEndpoint, tmpUint8Array, 5000).then(data => {
console.info('usb case SUB_USB_JS_0640 ret: ' + data);
console.info('usb case SUB_USB_JS_0640 send data: ' + testParam.sendData);
expect(data > 0).assertTrue();
......@@ -262,14 +262,14 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
interfaces.id = 1;
interfaces.name = '';
interfaces.alternateSetting = 0;
var isClaim = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[k], true)
var isClaim = usbManager.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[k], true)
console.info('usb case claimInterface function return: ' + isClaim);
expect(isClaim).assertEqual(0);
if (isClaim == 0) {
isClaim = usb.releaseInterface(gPipe, gDeviceList[0].configs[j].interfaces[k])
isClaim = usbManager.releaseInterface(gPipe, gDeviceList[0].configs[j].interfaces[k])
console.info('usb case releaseInterface function return: ' + isClaim);
expect(isClaim).assertEqual(0);
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
}
}
}
......@@ -313,7 +313,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
var configs = gDeviceList[0].configs[j];
configs.id = 1;
......@@ -321,7 +321,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
configs.maxPower = 1;
configs.isRemoteWakeup = true;
configs.isSelfPowered = true;
var ret = usb.setConfiguration(gPipe, gDeviceList[0].configs[j])
var ret = usbManager.setConfiguration(gPipe, gDeviceList[0].configs[j])
console.info('usb case setConfiguration return : ' + ret);
expect(ret).assertEqual(0);
}
......@@ -350,7 +350,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
var config = JSON.parse(JSON.stringify(gDeviceList[0].configs[j]));
config.id = 255
var ret = usb.setConfiguration(gPipe, config)
var ret = usbManager.setConfiguration(gPipe, config)
console.info('usb case setConfiguration return : ' + ret);
expect(ret).assertLess(0);
}
......@@ -377,10 +377,10 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
var isClaim = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true)
var isClaim = usbManager.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true)
expect(isClaim).assertEqual(0)
if (isClaim == 0) {
var ret = usb.setInterface(gPipe, gDeviceList[0].configs[j].interfaces[0])
var ret = usbManager.setInterface(gPipe, gDeviceList[0].configs[j].interfaces[0])
console.info('usb case setInterface return : ' + ret);
expect(ret).assertEqual(0);
}
......@@ -408,12 +408,12 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
var isClaim = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true)
var isClaim = usbManager.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true)
expect(isClaim).assertEqual(0)
if (isClaim == 0) {
var tmpInterface = JSON.parse(JSON.stringify(gDeviceList[0].configs[j].interfaces[0]));
tmpInterface.id = 234
var ret = usb.setInterface(gPipe, tmpInterface)
var ret = usbManager.setInterface(gPipe, tmpInterface)
console.info('usb case setInterface return : ' + ret)
expect(ret).assertLess(0)
}
......@@ -423,7 +423,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
})
function callControlTransfer(pip, controlParam, timeout, caseName) {
usb.controlTransfer(pip, controlParam, timeout).then(data => {
usbManager.controlTransfer(pip, controlParam, timeout).then(data => {
console.info('usb controlTransfer ret data : ' + data + ' ' + caseName);
console.info('usb controlTransfer controlParam.data buffer : ' + controlParam.data + ' ' + caseName);
expect(data >= 0).assertTrue();
......@@ -455,8 +455,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(6, usb.USB_REQUEST_TARGET_DEVICE, (usb.USB_REQUEST_DIR_FROM_DEVICE)
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), (2 << 8), 0)
var controlParam = getTransferParam(6, usbManager.USB_REQUEST_TARGET_DEVICE,
(usbManager.USB_REQUEST_DIR_FROM_DEVICE) | (usbManager.USB_REQUEST_TYPE_STANDARD << 5)
| (usbManager.USB_REQUEST_TARGET_DEVICE & 0x1f), (2 << 8), 0);
callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0540 GetDescriptor')
})
......@@ -479,8 +480,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(0, usb.USB_REQUEST_TARGET_DEVICE, (usb.USB_REQUEST_DIR_FROM_DEVICE)
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0)
var controlParam = getTransferParam(0, usbManager.USB_REQUEST_TARGET_DEVICE,
(usbManager.USB_REQUEST_DIR_FROM_DEVICE) | (usbManager.USB_REQUEST_TYPE_STANDARD << 5)
| (usbManager.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0);
callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0550 GetStatus')
})
......@@ -503,8 +505,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(8, usb.USB_REQUEST_TARGET_DEVICE, (usb.USB_REQUEST_DIR_FROM_DEVICE)
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0)
var controlParam = getTransferParam(8, usbManager.USB_REQUEST_TARGET_DEVICE,
(usbManager.USB_REQUEST_DIR_FROM_DEVICE) | (usbManager.USB_REQUEST_TYPE_STANDARD << 5)
| (usbManager.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0);
callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0560 GetConfiguration')
})
......@@ -527,8 +530,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(10, usb.USB_REQUEST_TARGET_INTERFACE, (usb.USB_REQUEST_DIR_FROM_DEVICE)
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_INTERFACE & 0x1f), 0, 1)
var controlParam = getTransferParam(10, usbManager.USB_REQUEST_TARGET_INTERFACE,
(usbManager.USB_REQUEST_DIR_FROM_DEVICE) | (usbManager.USB_REQUEST_TYPE_STANDARD << 5)
| (usbManager.USB_REQUEST_TARGET_INTERFACE & 0x1f), 0, 1);
callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0570 GetInterface')
})
......@@ -551,8 +555,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(1, usb.USB_REQUEST_TARGET_DEVICE, (usb.USB_REQUEST_DIR_TO_DEVICE)
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0)
var controlParam = getTransferParam(1, usbManager.USB_REQUEST_TARGET_DEVICE,
(usbManager.USB_REQUEST_DIR_TO_DEVICE) | (usbManager.USB_REQUEST_TYPE_STANDARD << 5)
| (usbManager.USB_REQUEST_TARGET_DEVICE & 0x1f), 0, 0);
callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0580 ClearFeature')
})
......@@ -575,8 +580,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(255, usb.USB_REQUEST_TARGET_INTERFACE, (usb.USB_REQUEST_DIR_FROM_DEVICE)
| (usb.USB_REQUEST_TYPE_STANDARD << 5) | (usb.USB_REQUEST_TARGET_INTERFACE & 0x1f), (2 << 8), 0)
var controlParam = getTransferParam(255, usbManager.USB_REQUEST_TARGET_INTERFACE,
(usbManager.USB_REQUEST_DIR_FROM_DEVICE) | (usbManager.USB_REQUEST_TYPE_STANDARD << 5)
| (usbManager.USB_REQUEST_TARGET_INTERFACE & 0x1f), (2 << 8), 0);
callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0590 ClearFeature')
})
......@@ -599,8 +605,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(255, usb.USB_REQUEST_TARGET_ENDPOINT, (usb.USB_REQUEST_DIR_TO_DEVICE)
| (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_ENDPOINT & 0x1f), (2 << 8), 0)
var controlParam = getTransferParam(255, usbManager.USB_REQUEST_TARGET_ENDPOINT,
(usbManager.USB_REQUEST_DIR_TO_DEVICE) | (usbManager.USB_REQUEST_TYPE_CLASS << 5)
| (usbManager.USB_REQUEST_TARGET_ENDPOINT & 0x1f), (2 << 8), 0);
callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0600 ClearFeature')
})
......@@ -623,8 +630,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(255, usb.USB_REQUEST_TARGET_OTHER, (usb.USB_REQUEST_DIR_TO_DEVICE)
| (usb.USB_REQUEST_TYPE_VENDOR << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), (2 << 8), 0)
var controlParam = getTransferParam(255, usbManager.USB_REQUEST_TARGET_OTHER,
(usbManager.USB_REQUEST_DIR_TO_DEVICE) | (usbManager.USB_REQUEST_TYPE_VENDOR << 5)
| (usbManager.USB_REQUEST_TARGET_OTHER & 0x1f), (2 << 8), 0);
callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0610 ClearFeature')
})
......@@ -647,13 +655,14 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var timeout = 5000;
var controlParam = getTransferParam(255, usb.USB_REQUEST_TARGET_OTHER, (usb.USB_REQUEST_DIR_TO_DEVICE)
| (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0)
var controlParam = getTransferParam(255, usbManager.USB_REQUEST_TARGET_OTHER,
(usbManager.USB_REQUEST_DIR_TO_DEVICE) | (usbManager.USB_REQUEST_TYPE_CLASS << 5)
| (usbManager.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0);
callControlTransfer(testParam.pip, controlParam, timeout, 'SUB_USB_JS_0620 ClearFeature')
})
function callControlTransferEx(pip, controlParam, timeout, caseName) {
usb.controlTransfer(pip, controlParam, timeout).then(data => {
usbManager.controlTransfer(pip, controlParam, timeout).then(data => {
console.info('usb controlTransfer ret data : ' + data + ' ' + caseName);
expect(false).assertTrue();
console.info('usb' + caseName + ': FAILED');
......@@ -683,7 +692,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
return
}
try {
usb.controlTransfer("invalid").then(data => {
usbManager.controlTransfer("invalid").then(data => {
console.info('usb 1140 case controlTransfer ret data : ' + data);
expect(false).assertTrue();
}).catch(error => {
......@@ -715,7 +724,7 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
return
}
try {
usb.controlTransfer().then(data => {
usbManager.controlTransfer().then(data => {
console.info('usb 1300 case controlTransfer ret data : ' + data);
expect(false).assertTrue();
}).catch(error => {
......@@ -748,8 +757,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
}
var testParamPip = "invalid";
var timeout = 5000;
var controlParam = getTransferParam(255, usb.USB_REQUEST_TARGET_OTHER, (usb.USB_REQUEST_DIR_TO_DEVICE)
| (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0);
var controlParam = getTransferParam(255, usbManager.USB_REQUEST_TARGET_OTHER,
(usbManager.USB_REQUEST_DIR_TO_DEVICE) | (usbManager.USB_REQUEST_TYPE_CLASS << 5)
| (usbManager.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0);
try {
callControlTransferEx(testParamPip, controlParam, timeout, 'SUB_USB_JS_1440 ClearFeature');
} catch (err) {
......@@ -806,8 +816,9 @@ describe('UsbDevicePipeJsFunctionsTest', function () {
return
}
var timeout = "invalid";
var controlParam = getTransferParam(255, usb.USB_REQUEST_TARGET_OTHER, (usb.USB_REQUEST_DIR_TO_DEVICE)
| (usb.USB_REQUEST_TYPE_CLASS << 5) | (usb.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0);
var controlParam = getTransferParam(255, usbManager.USB_REQUEST_TARGET_OTHER,
(usbManager.USB_REQUEST_DIR_TO_DEVICE) | (usbManager.USB_REQUEST_TYPE_CLASS << 5)
| (usbManager.USB_REQUEST_TARGET_OTHER & 0x1f), 0, 0);
try {
callControlTransferEx(testParam.pip, controlParam, timeout, 'SUB_USB_JS_1570 ClearFeature');
} catch (err) {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import usb from '@ohos.usb';
import usbManager from '@ohos.usbManager';
import CheckEmptyUtils from './CheckEmptyUtils.js';
import EventConstants from './EventConstants.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
......@@ -28,20 +28,20 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbDevicePipeJsFunctionsTestEx Begin*************');
var Version = usb.getVersion()
var Version = usbManager.getVersion()
console.info('usb unit begin test getversion :' + Version)
// version > 17 host currentMode = 2 device currentMode = 1
var usbPortList = usb.getPorts()
var usbPortList = usbManager.getPorts()
if (usbPortList == undefined) {
portCurrentMode = 1;
return
}
gDeviceList = usb.getDevices();
gDeviceList = usbManager.getDevices();
if (usbPortList.length > 0) {
if (gDeviceList.length > 0) {
if (usbPortList[0].status.currentMode == 1) {
usb.setPortRoles(usbPortList[0].id, usb.SOURCE, usb.HOST).then(data => {
usbManager.setPortRoles(usbPortList[0].id, usbManager.SOURCE, usbManager.HOST).then(data => {
portCurrentMode = 2
console.info('usb case setPortRoles return: ' + data);
}).catch(error => {
......@@ -56,7 +56,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
}
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
console.info('usb unit connectDevice gPipe ret : ' + JSON.stringify(gPipe));
})
beforeEach(function () {
......@@ -66,7 +66,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
console.info('afterEach: *************Usb Unit Test Ex Case*************');
})
afterAll(function () {
var isPipClose = usb.closePipe(gPipe)
var isPipClose = usbManager.closePipe(gPipe)
console.info('usb unit close gPipe ret : ' + isPipClose);
console.log('*************Usb Unit UsbDevicePipeJsFunctionsTestEx End*************');
})
......@@ -78,10 +78,10 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
if (endpoint.type == EventConstants.USB_ENDPOINT_XFER_BULK) {
bfind = true
if (endpoint.direction == usb.USB_REQUEST_DIR_TO_DEVICE) {
if (endpoint.direction == usbManager.USB_REQUEST_DIR_TO_DEVICE) {
testParam.outEndpoint = endpoint;
testParam.maxOutSize = endpoint.maxPacketSize;
} else if (endpoint.direction == usb.USB_REQUEST_DIR_FROM_DEVICE) {
} else if (endpoint.direction == usbManager.USB_REQUEST_DIR_FROM_DEVICE) {
testParam.inEndpoint = endpoint
testParam.maxInSize = endpoint.maxPacketSize;
}
......@@ -162,14 +162,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
testParam.isClaimed = usbManager.claimInterface(testParam.pip, testParam.interface, true);
expect(testParam.isClaimed).assertEqual(0);
testParam.sendData = 'send time 13213213 wzy 03';
var tmpUint8Array = CheckEmptyUtils.str2ab(testParam.sendData);
var TmpTestParam = testParam
TmpTestParam.outEndpoint.address = 123
usb.bulkTransfer(TmpTestParam.pip, TmpTestParam.outEndpoint, tmpUint8Array, 5000).then(data => {
usbManager.bulkTransfer(TmpTestParam.pip, TmpTestParam.outEndpoint, tmpUint8Array, 5000).then(data => {
console.info('usb case SUB_USB_JS_0650 ret: ' + data);
expect(data).assertEqual(-1);
console.info('usb case SUB_USB_JS_0650 : PASS');
......@@ -199,14 +199,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
testParam.isClaimed = usbManager.claimInterface(testParam.pip, testParam.interface, true);
expect(testParam.isClaimed).assertEqual(0);
testParam.sendData = 'send time 13213213 wzy 04';
var tmpUint8Array = CheckEmptyUtils.str2ab(testParam.sendData);
var TmpTestParam = testParam
TmpTestParam.outEndpoint.number = 123
usb.bulkTransfer(TmpTestParam.pip, TmpTestParam.outEndpoint, tmpUint8Array, 5000).then(data => {
usbManager.bulkTransfer(TmpTestParam.pip, TmpTestParam.outEndpoint, tmpUint8Array, 5000).then(data => {
console.info('usb case SUB_USB_JS_0660 ret: ' + data);
expect(data).assertEqual(-1);
console.info('usb case SUB_USB_JS_0660 : PASS');
......@@ -236,14 +236,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
testParam.isClaimed = usbManager.claimInterface(testParam.pip, testParam.interface, true);
expect(testParam.isClaimed).assertEqual(0);
testParam.sendData = 'send time 13213213 wzy 05';
var tmpUint8Array = CheckEmptyUtils.str2ab(testParam.sendData);
var TmpTestParam = testParam
TmpTestParam.outEndpoint.type = 123
usb.bulkTransfer(TmpTestParam.pip, TmpTestParam.outEndpoint, tmpUint8Array, 5000).then(data => {
usbManager.bulkTransfer(TmpTestParam.pip, TmpTestParam.outEndpoint, tmpUint8Array, 5000).then(data => {
console.info('usb case SUB_USB_JS_0670 ret: ' + data);
expect(data).assertEqual(-1);
console.info('usb case SUB_USB_JS_0670 : PASS');
......@@ -273,11 +273,11 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
testParam.isClaimed = usbManager.claimInterface(testParam.pip, testParam.interface, true);
expect(testParam.isClaimed).assertEqual(0);
try {
usb.bulkTransfer(testParam.pip).then(data => {
usbManager.bulkTransfer(testParam.pip).then(data => {
console.info('usb case SUB_USB_JS_1100 ret: ' + data);
expect(false).assertTrue();
console.info('usb case SUB_USB_JS_1100 : FAILED');
......@@ -311,11 +311,11 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
testParam.isClaimed = usbManager.claimInterface(testParam.pip, testParam.interface, true);
expect(testParam.isClaimed).assertEqual(0);
try {
usb.bulkTransfer(testParam.pip, testParam.outEndpoint).then(data => {
usbManager.bulkTransfer(testParam.pip, testParam.outEndpoint).then(data => {
console.info('usb case SUB_USB_JS_1480 ret: ' + data);
expect(false).assertTrue();
console.info('usb case SUB_USB_JS_1480 : FAILED');
......@@ -350,7 +350,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
}
try {
usb.bulkTransfer().then(data => {
usbManager.bulkTransfer().then(data => {
console.info('usb case SUB_USB_JS_1310 ret: ' + data);
expect(false).assertTrue();
console.info('usb case SUB_USB_JS_1310 : FAILED');
......@@ -385,7 +385,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
testParam.isClaimed = usbManager.claimInterface(testParam.pip, testParam.interface, true);
expect(testParam.isClaimed).assertEqual(0);
console.info('usb case readData begin');
......@@ -393,7 +393,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
tmpTestParam.pip = "invalid";
var tmpUint8Array = new Uint8Array(testParam.maxInSize);
try {
usb.bulkTransfer(tmpTestParam.pip, tmpTestParam.inEndpoint, tmpUint8Array, 5000).then(data => {
usbManager.bulkTransfer(tmpTestParam.pip, tmpTestParam.inEndpoint, tmpUint8Array, 5000).then(data => {
console.info('usb case SUB_USB_JS_1420 ret: ' + data);
expect(false).assertTrue();
console.info('usb case SUB_USB_JS_1420 : FAILED');
......@@ -428,7 +428,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
testParam.isClaimed = usbManager.claimInterface(testParam.pip, testParam.interface, true);
expect(testParam.isClaimed).assertEqual(0);
console.info('usb case readData begin');
......@@ -436,7 +436,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
tmpTestParam.inEndpoint = "invalid";
var tmpUint8Array = new Uint8Array(testParam.maxInSize);
try {
usb.bulkTransfer(tmpTestParam.pip, tmpTestParam.inEndpoint, tmpUint8Array, 5000).then(data => {
usbManager.bulkTransfer(tmpTestParam.pip, tmpTestParam.inEndpoint, tmpUint8Array, 5000).then(data => {
console.info('usb case SUB_USB_JS_1490 ret: ' + data);
expect(false).assertTrue();
console.info('usb case SUB_USB_JS_1490 : FAILED');
......@@ -471,13 +471,13 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
testParam.isClaimed = usbManager.claimInterface(testParam.pip, testParam.interface, true);
expect(testParam.isClaimed).assertEqual(0);
console.info('usb case readData begin');
var tmpUint8Array = "invalid";
try {
usb.bulkTransfer(testParam.pip, testParam.inEndpoint, tmpUint8Array, 5000).then(data => {
usbManager.bulkTransfer(testParam.pip, testParam.inEndpoint, tmpUint8Array, 5000).then(data => {
console.info('usb case SUB_USB_JS_1500 ret: ' + data);
expect(false).assertTrue();
console.info('usb case SUB_USB_JS_1500 : FAILED');
......@@ -512,14 +512,14 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
testParam.isClaimed = usb.claimInterface(testParam.pip, testParam.interface, true);
testParam.isClaimed = usbManager.claimInterface(testParam.pip, testParam.interface, true);
expect(testParam.isClaimed).assertEqual(0);
console.info('usb case readData begin');
var tmpTimeOut = "invalid";
var tmpUint8Array = new Uint8Array(testParam.maxInSize);
try {
usb.bulkTransfer(testParam.pip, testParam.inEndpoint, tmpUint8Array, tmpTimeOut).then(data => {
usbManager.bulkTransfer(testParam.pip, testParam.inEndpoint, tmpUint8Array, tmpTimeOut).then(data => {
console.info('usb case SUB_USB_JS_1530 ret: ' + data);
expect(false).assertTrue();
console.info('usb case SUB_USB_JS_1530 : FAILED');
......@@ -566,7 +566,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var TmpInterface = gDeviceList[0].configs[j].interfaces[k];
TmpInterface.id = 123;
var isClaim = usb.claimInterface(gPipe, TmpInterface, true);
var isClaim = usbManager.claimInterface(gPipe, TmpInterface, true);
console.info('usb case claimInterface function return: ' + isClaim);
expect(isClaim).assertLess(0);
}
......@@ -606,7 +606,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var TmpInterface = gDeviceList[0].configs[j].interfaces[k]
TmpInterface.protocol = 120
var isClaim = usb.claimInterface(gPipe, TmpInterface, true)
var isClaim = usbManager.claimInterface(gPipe, TmpInterface, true)
console.info('usb case claimInterface function return: ' + isClaim);
expect(isClaim).assertLess(0);
}
......@@ -646,7 +646,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var TmpInterface = gDeviceList[0].configs[j].interfaces[k]
TmpInterface.clazz = 784
var isClaim = usb.claimInterface(gPipe, TmpInterface, true)
var isClaim = usbManager.claimInterface(gPipe, TmpInterface, true)
console.info('usb case claimInterface function return: ' + isClaim);
expect(isClaim).assertLess(0);
}
......@@ -686,7 +686,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var TmpInterface = gDeviceList[0].configs[j].interfaces[k]
TmpInterface.name = '123sdf'
var isClaim = usb.claimInterface(gPipe, TmpInterface, true)
var isClaim = usbManager.claimInterface(gPipe, TmpInterface, true)
console.info('usb case claimInterface function return: ' + isClaim);
expect(isClaim).assertLess(0);
}
......@@ -726,7 +726,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var TmpInterface = gDeviceList[0].configs[j].interfaces[k]
TmpInterface.subClass = 1210
var isClaim = usb.claimInterface(gPipe, TmpInterface, true)
var isClaim = usbManager.claimInterface(gPipe, TmpInterface, true)
console.info('usb case claimInterface function return: ' + isClaim);
expect(isClaim).assertLess(0);
}
......@@ -758,7 +758,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.claimInterface("invalid");
var maskCode = usbManager.claimInterface("invalid");
console.info('usb 1110 case claimInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -791,7 +791,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.claimInterface();
var maskCode = usbManager.claimInterface();
console.info('usb 1320 case claimInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -828,7 +828,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
}
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var TmpInterface = gDeviceList[0].configs[j].interfaces[k];
var maskCode = usb.claimInterface(testParamPip, TmpInterface, true);
var maskCode = usbManager.claimInterface(testParamPip, TmpInterface, true);
console.info('usb 1430 case claimInterface return: ' + maskCode);
expect(false).assertTrue();
}
......@@ -860,7 +860,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
var TmpInterface = "invalid";
try {
var maskCode = usb.claimInterface(gPipe, TmpInterface);
var maskCode = usbManager.claimInterface(gPipe, TmpInterface);
console.info('usb 1510 case claimInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -895,7 +895,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
}
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var TmpInterface = gDeviceList[0].configs[j].interfaces[k];
var maskCode = usb.claimInterface(gPipe, TmpInterface, "invalid");
var maskCode = usbManager.claimInterface(gPipe, TmpInterface, "invalid");
console.info('usb 1520 case claimInterface return: ' + maskCode);
expect(false).assertTrue();
}
......@@ -930,7 +930,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
if (gDeviceList[0].configs[j].interfaces.length == 0) {
console.info('usb SUB_USB_JS_0280 case current device.configs.interfaces.length = 0');
......@@ -938,7 +938,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var tmpInterface = gDeviceList[0].configs[j].interfaces[k]
tmpInterface.id = 134
var isClaim = usb.releaseInterface(gPipe, tmpInterface)
var isClaim = usbManager.releaseInterface(gPipe, tmpInterface)
console.info('usb case releaseInterface function return: ' + isClaim);
expect(isClaim).assertLess(0);
}
......@@ -970,7 +970,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
if (gDeviceList[0].configs[j].interfaces.length == 0) {
console.info('usb SUB_USB_JS_0290 case current device.configs.interfaces.length = 0');
......@@ -978,7 +978,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var tmpInterface = gDeviceList[0].configs[j].interfaces[k]
tmpInterface.name = '134wer'
var isClaim = usb.releaseInterface(gPipe, tmpInterface)
var isClaim = usbManager.releaseInterface(gPipe, tmpInterface)
console.info('usb case releaseInterface function return: ' + isClaim);
expect(isClaim).assertLess(0);
}
......@@ -1010,7 +1010,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
if (gDeviceList[0].configs[j].interfaces.length == 0) {
console.info('usb SUB_USB_JS_0300 case current device.configs.interfaces.length = 0');
......@@ -1018,7 +1018,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var tmpInterface = gDeviceList[0].configs[j].interfaces[k]
tmpInterface.clazz = 78
var isClaim = usb.releaseInterface(gPipe, tmpInterface)
var isClaim = usbManager.releaseInterface(gPipe, tmpInterface)
console.info('usb case releaseInterface function return: ' + isClaim);
expect(isClaim).assertLess(0);
}
......@@ -1050,7 +1050,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
if (gDeviceList[0].configs[j].interfaces.length == 0) {
console.info('usb SUB_USB_JS_0310 case current device.configs.interfaces.length = 0');
......@@ -1058,7 +1058,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var tmpInterface = gDeviceList[0].configs[j].interfaces[k]
tmpInterface.protocol = 124
var isClaim = usb.releaseInterface(gPipe, tmpInterface)
var isClaim = usbManager.releaseInterface(gPipe, tmpInterface)
console.info('usb case releaseInterface function return: ' + isClaim);
expect(isClaim).assertLess(0);
}
......@@ -1090,7 +1090,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
if (gDeviceList[0].configs[j].interfaces.length == 0) {
console.info('usb SUB_USB_JS_0320 case current device.configs.interfaces.length = 0');
......@@ -1098,7 +1098,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var tmpInterface = gDeviceList[0].configs[j].interfaces[k]
tmpInterface.subClass = 784
var isClaim = usb.releaseInterface(gPipe, tmpInterface)
var isClaim = usbManager.releaseInterface(gPipe, tmpInterface)
console.info('usb case releaseInterface function return: ' + isClaim);
expect(isClaim).assertLess(0);
}
......@@ -1129,9 +1129,9 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
try {
var maskCode = usb.releaseInterface("invalid");
var maskCode = usbManager.releaseInterface("invalid");
console.info('usb 1150 case releaseInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -1164,7 +1164,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.releaseInterface();
var maskCode = usbManager.releaseInterface();
console.info('usb 1330 case releaseInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -1196,7 +1196,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
}
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var TmpInterface = gDeviceList[0].configs[j].interfaces[k];
var maskCode = usb.releaseInterface(testParamPip, TmpInterface);
var maskCode = usbManager.releaseInterface(testParamPip, TmpInterface);
console.info('usb 1450 case releaseInterface return: ' + maskCode);
expect(false).assertTrue();
}
......@@ -1223,7 +1223,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
var TmpInterface = "invalid";
try {
var maskCode = usb.releaseInterface(gPipe, TmpInterface);
var maskCode = usbManager.releaseInterface(gPipe, TmpInterface);
console.info('usb 1580 case releaseInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -1250,13 +1250,13 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect(false).assertTrue()
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
var isClaimed = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true);
var isClaimed = usbManager.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true);
var tmpInterface = gDeviceList[0].configs[j].interfaces[0]
tmpInterface.protocol = 482
var ret = usb.setInterface(gPipe, tmpInterface)
var ret = usbManager.setInterface(gPipe, tmpInterface)
console.info('usb case setInterface return : ' + ret)
expect(ret).assertLess(0);
}
......@@ -1281,13 +1281,13 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect(false).assertTrue()
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
var isClaim = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true)
var isClaim = usbManager.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true)
var tmpInterface = gDeviceList[0].configs[j].interfaces[0]
tmpInterface.clazz = 482
var ret = usb.setInterface(gPipe, tmpInterface)
var ret = usbManager.setInterface(gPipe, tmpInterface)
console.info('usb case setInterface return : ' + ret)
expect(ret).assertLess(0);
}
......@@ -1312,13 +1312,13 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect(false).assertTrue()
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
var isClaim = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true)
var isClaim = usbManager.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true)
var tmpInterface = gDeviceList[0].configs[j].interfaces[0]
tmpInterface.subClass = 482
var ret = usb.setInterface(gPipe, tmpInterface)
var ret = usbManager.setInterface(gPipe, tmpInterface)
console.info('usb case setInterface return : ' + ret)
expect(ret).assertLess(0);
......@@ -1344,13 +1344,13 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect(false).assertTrue()
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
var isClaim = usb.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true)
var isClaim = usbManager.claimInterface(gPipe, gDeviceList[0].configs[j].interfaces[0], true)
var tmpInterface = gDeviceList[0].configs[j].interfaces[0]
tmpInterface.name = 'wer32'
var ret = usb.setInterface(gPipe, tmpInterface)
var ret = usbManager.setInterface(gPipe, tmpInterface)
console.info('usb case setInterface return : ' + ret)
expect(ret).assertLess(0);
}
......@@ -1377,7 +1377,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.setInterface("invalid");
var maskCode = usbManager.setInterface("invalid");
console.info('usb 1130 case setInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -1405,7 +1405,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.setInterface();
var maskCode = usbManager.setInterface();
console.info('usb 1340 case setInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -1442,7 +1442,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
}
for (var k = 0; k < gDeviceList[0].configs[j].interfaces.length; k++) {
var TmpInterface = gDeviceList[0].configs[j].interfaces[k];
var maskCode = usb.setInterface(testParamPip, TmpInterface);
var maskCode = usbManager.setInterface(testParamPip, TmpInterface);
console.info('usb 1460 case setInterface return: ' + maskCode);
expect(false).assertTrue();
}
......@@ -1474,7 +1474,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
var TmpInterface = "invalid";
try {
var maskCode = usb.setInterface(gPipe, TmpInterface);
var maskCode = usbManager.setInterface(gPipe, TmpInterface);
console.info('usb 1550 case setInterface return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -1501,11 +1501,11 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
expect(false).assertTrue();
return
}
gPipe = usb.connectDevice(gDeviceList[0])
gPipe = usbManager.connectDevice(gDeviceList[0])
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
var config = gDeviceList[0].configs[j]
config.name = 'asdfsd'
var ret = usb.setConfiguration(gPipe, config)
var ret = usbManager.setConfiguration(gPipe, config)
console.info('usb case setConfiguration return : ' + ret);
expect(ret).assertEqual(0);
}
......@@ -1535,7 +1535,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
var config = gDeviceList[0].configs[j]
config.name = 'asdfsd'
config.id = 154
var ret = usb.setConfiguration(gPipe, config)
var ret = usbManager.setConfiguration(gPipe, config)
console.info('usb case setConfiguration return : ' + ret);
expect(ret).assertLess(0);
}
......@@ -1564,7 +1564,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
var config = gDeviceList[0].configs[j]
config.attributes = 154
var ret = usb.setConfiguration(gPipe, config)
var ret = usbManager.setConfiguration(gPipe, config)
console.info('usb case setConfiguration return : ' + ret);
expect(ret).assertLess(0);
}
......@@ -1594,7 +1594,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
var config = gDeviceList[0].configs[j]
config.name = 'asdfsd'
config.interfaces[0].endpoints[0].interval = 0
var ret = usb.setConfiguration(gPipe, config)
var ret = usbManager.setConfiguration(gPipe, config)
console.info('usb case setConfiguration return : ' + ret);
expect(ret).assertLess(0);
}
......@@ -1620,7 +1620,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.setConfiguration("invalid");
var maskCode = usbManager.setConfiguration("invalid");
console.info('usb 1120 case setConfiguration return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -1648,7 +1648,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
return
}
try {
var maskCode = usb.setConfiguration();
var maskCode = usbManager.setConfiguration();
console.info('usb 1350 case setConfiguration return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -1681,7 +1681,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
try {
for (var j = 0; j < gDeviceList[0].configs.length; j++) {
var TmpConfig = gDeviceList[0].configs[j];
var maskCode = usb.setConfiguration(testParamPip, TmpConfig);
var maskCode = usbManager.setConfiguration(testParamPip, TmpConfig);
console.info('usb 1470 case setConfiguration return: ' + maskCode);
expect(false).assertTrue();
}
......@@ -1713,7 +1713,7 @@ describe('UsbDevicePipeJsFunctionsTestEx', function () {
var TmpConfig = "invalid";
try {
var maskCode = usb.setConfiguration(gPipe, TmpConfig);
var maskCode = usbManager.setConfiguration(gPipe, TmpConfig);
console.info('usb 1540 case setConfiguration return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import usb from '@ohos.usb';
import usbManager from '@ohos.usbManager';
import CheckEmptyUtils from './CheckEmptyUtils.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
......@@ -23,13 +23,13 @@ describe('UsbFunctionsJsFunctionsTest', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbFunctionsJsFunctionsTest Begin*************');
var Version = usb.getVersion()
var Version = usbManager.getVersion()
console.info('begin test getversion :' + Version)
// version > 17 host currentMode = 2 device currentMode = 1
var usbPortList = usb.getPorts()
var usbPortList = usbManager.getPorts()
if (usbPortList.length > 0) {
if (usbPortList[0].status.currentMode == 2) {
usb.setPortRoles(usbPortList[0].id, usb.SINK, usb.DEVICE).then(data => {
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);
......@@ -57,12 +57,12 @@ describe('UsbFunctionsJsFunctionsTest', function () {
*/
it('SUB_USB_JS_0330', 0, function () {
console.info('usb SUB_USB_JS_0330 begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
var strMaskCode = usbManager.usbFunctionsToString(maskCode)
console.info('usb case usbFunctionsToString return str: ' + strMaskCode);
var nMaskCode = usb.usbFunctionsFromString(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');
......@@ -75,24 +75,24 @@ describe('UsbFunctionsJsFunctionsTest', function () {
*/
it('SUB_USB_JS_0340', 0, function () {
console.info('usb SUB_USB_JS_0340 begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(maskCode)
var strMaskCode = usbManager.usbFunctionsToString(maskCode)
console.info('usb case usbFunctionsToString return str: ' + strMaskCode);
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode usbFunctionsFromString return int: ' + nMaskCode);
var errmaskCode = 0
var strMaskCode = usb.usbFunctionsToString(errmaskCode)
var strMaskCode = usbManager.usbFunctionsToString(errmaskCode)
console.info('usb case ' + errmaskCode + ' usbFunctionsToString return str: ' + strMaskCode);
var errStrMaskCode = 'none'
var nMaskCode = usb.usbFunctionsFromString(errStrMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(errStrMaskCode)
console.info('usb case errStrMaskCode ' + errStrMaskCode +
' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.NONE);
expect(nMaskCode).assertEqual(usbManager.NONE);
console.info('usb SUB_USB_JS_0340 : PASS');
})
......@@ -105,7 +105,7 @@ describe('UsbFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_1000', 0, function () {
console.info('usb SUB_USB_JS_1000 begin');
try {
var maskCode = usb.getCurrentFunctions("invalid");
var maskCode = usbManager.getCurrentFunctions("invalid");
console.info('usb 1000 case getCurrentFunctions return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import usb from '@ohos.usb';
import usbManager from '@ohos.usbManager';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
/* usb core functions test */
......@@ -24,13 +24,13 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbFunctionsJsFunctionsTestEx Begin*************');
var Version = usb.getVersion()
var Version = usbManager.getVersion()
console.info('begin test getversion :' + Version)
// 17 version host currentMode = 2 device currentMode = 1
var usbPortList = usb.getPorts()
var usbPortList = usbManager.getPorts()
if (usbPortList.length > 0) {
if (usbPortList[0].status.currentMode == 2) {
usb.setPortRoles(usbPortList[0].id, usb.SINK, usb.DEVICE).then(data => {
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);
......@@ -59,9 +59,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_0930', 0, function () {
console.info('usb SUB_USB_JS_0930 begin');
var maskCode = usb.NONE
console.info('usb case maskCode : ' + usb.NONE);
var strMaskCode = usb.usbFunctionsToString(maskCode)
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');
......@@ -74,9 +74,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_0940', 0, function () {
console.info('usb SUB_USB_JS_0940 begin');
var maskCode = usb.ACM
console.info('usb case maskCode : ' + usb.ACM);
var strMaskCode = usb.usbFunctionsToString(maskCode)
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');
......@@ -89,9 +89,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_0950', 0, function () {
console.info('usb SUB_USB_JS_0950 begin');
var maskCode = usb.ECM
var maskCode = usbManager.ECM
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(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');
......@@ -104,9 +104,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_0960', 0, function () {
console.info('usb SUB_USB_JS_0960 begin');
var maskCode = usb.ACM | usb.ECM
var maskCode = usbManager.ACM | usbManager.ECM
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(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');
......@@ -119,9 +119,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_0970', 0, function () {
console.info('usb SUB_USB_JS_0970 begin');
var maskCode = usb.HDC
var maskCode = usbManager.HDC
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(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');
......@@ -134,9 +134,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_0980', 0, function () {
console.info('usb SUB_USB_JS_0980 begin');
var maskCode = usb.ACM | usb.HDC
var maskCode = usbManager.ACM | usbManager.HDC
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(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');
......@@ -149,9 +149,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_0990', 0, function () {
console.info('usb SUB_USB_JS_0990 begin');
var maskCode = usb.ECM | usb.HDC
var maskCode = usbManager.ECM | usbManager.HDC
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(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');
......@@ -164,9 +164,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_1770', 0, function () {
console.info('usb SUB_USB_JS_1770 begin');
var maskCode = usb.MTP;
var maskCode = usbManager.MTP;
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(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');
......@@ -179,9 +179,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_1780', 0, function () {
console.info('usb SUB_USB_JS_1780 begin');
var maskCode = usb.MTP | usb.HDC;
var maskCode = usbManager.MTP | usbManager.HDC;
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(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');
......@@ -194,9 +194,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_1790', 0, function () {
console.info('usb SUB_USB_JS_1790 begin');
var maskCode = usb.PTP;
var maskCode = usbManager.PTP;
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(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');
......@@ -209,9 +209,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_1800', 0, function () {
console.info('usb SUB_USB_JS_1800 begin');
var maskCode = usb.PTP | usb.HDC;
var maskCode = usbManager.PTP | usbManager.HDC;
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(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');
......@@ -224,9 +224,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_1810', 0, function () {
console.info('usb SUB_USB_JS_1810 begin');
var maskCode = usb.RNDIS;
var maskCode = usbManager.RNDIS;
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(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');
......@@ -239,9 +239,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_1820', 0, function () {
console.info('usb SUB_USB_JS_1820 begin');
var maskCode = usb.RNDIS | usb.HDC;
var maskCode = usbManager.RNDIS | usbManager.HDC;
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(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');
......@@ -254,9 +254,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_1830', 0, function () {
console.info('usb SUB_USB_JS_1830 begin');
var maskCode = usb.STORAGE;
var maskCode = usbManager.STORAGE;
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(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');
......@@ -269,9 +269,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_1840', 0, function () {
console.info('usb SUB_USB_JS_1840 begin');
var maskCode = usb.STORAGE | usb.HDC;
var maskCode = usbManager.STORAGE | usbManager.HDC;
console.info('usb case maskCode : ' + maskCode);
var strMaskCode = usb.usbFunctionsToString(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');
......@@ -285,7 +285,7 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_1160', 0, function () {
console.info('usb SUB_USB_JS_1160 begin');
try {
var maskCode = usb.usbFunctionsToString("invalid");
var maskCode = usbManager.usbFunctionsToString("invalid");
console.info('usb 1160 case usbFunctionsToString return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -304,7 +304,7 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_1360', 0, function () {
console.info('usb SUB_USB_JS_1360 begin');
try {
var maskCode = usb.usbFunctionsToString();
var maskCode = usbManager.usbFunctionsToString();
console.info('usb 1360 case usbFunctionsToString return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -322,9 +322,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_0860', 0, function () {
console.info('usb SUB_USB_JS_0860 begin');
var strMaskCode = 'none'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.NONE);
expect(nMaskCode).assertEqual(usbManager.NONE);
console.info('usb SUB_USB_JS_0860 : PASS');
})
......@@ -336,9 +336,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_0870', 0, function () {
console.info('usb SUB_USB_JS_0870 begin');
var strMaskCode = 'acm'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.ACM);
expect(nMaskCode).assertEqual(usbManager.ACM);
console.info('usb SUB_USB_JS_0870 : PASS');
})
......@@ -350,9 +350,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_0880', 0, function () {
console.info('usb SUB_USB_JS_0880 begin');
var strMaskCode = 'ecm'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.ECM);
expect(nMaskCode).assertEqual(usbManager.ECM);
console.info('usb SUB_USB_JS_0880 : PASS');
})
......@@ -364,9 +364,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_0890', 0, function () {
console.info('usb SUB_USB_JS_0890 begin');
var strMaskCode = 'acm,ecm'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.ACM | usb.ECM);
expect(nMaskCode).assertEqual(usbManager.ACM | usbManager.ECM);
console.info('usb SUB_USB_JS_0890 : PASS');
})
......@@ -378,9 +378,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_0900', 0, function () {
console.info('usb SUB_USB_JS_0900 begin');
var strMaskCode = 'hdc'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.HDC);
expect(nMaskCode).assertEqual(usbManager.HDC);
console.info('usb SUB_USB_JS_0900 : PASS');
})
......@@ -392,9 +392,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_0910', 0, function () {
console.info('usb SUB_USB_JS_0910 begin');
var strMaskCode = 'acm,hdc'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.HDC | usb.ACM);
expect(nMaskCode).assertEqual(usbManager.HDC | usbManager.ACM);
console.info('usb SUB_USB_JS_0910 : PASS');
})
......@@ -406,9 +406,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_0920', 0, function () {
console.info('usb SUB_USB_JS_0920 begin');
var strMaskCode = 'ecm,hdc'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.HDC | usb.ECM);
expect(nMaskCode).assertEqual(usbManager.HDC | usbManager.ECM);
console.info('usb SUB_USB_JS_0920 : PASS');
})
......@@ -420,9 +420,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_1220', 0, function () {
console.info('usb SUB_USB_JS_1220 begin');
var strMaskCode = 'mtp'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.MTP);
expect(nMaskCode).assertEqual(usbManager.MTP);
console.info('usb SUB_USB_JS_1220 : PASS');
})
......@@ -434,9 +434,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_1700', 0, function () {
console.info('usb SUB_USB_JS_1700 begin');
var strMaskCode = 'hdc,mtp'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.MTP | usb.HDC);
expect(nMaskCode).assertEqual(usbManager.MTP | usbManager.HDC);
console.info('usb SUB_USB_JS_1700 : PASS');
})
......@@ -448,9 +448,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_1710', 0, function () {
console.info('usb SUB_USB_JS_1710 begin');
var strMaskCode = 'ptp'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.PTP);
expect(nMaskCode).assertEqual(usbManager.PTP);
console.info('usb SUB_USB_JS_1710 : PASS');
})
......@@ -462,9 +462,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_1720', 0, function () {
console.info('usb SUB_USB_JS_1720 begin');
var strMaskCode = 'hdc,ptp'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.PTP | usb.HDC);
expect(nMaskCode).assertEqual(usbManager.PTP | usbManager.HDC);
console.info('usb SUB_USB_JS_1720 : PASS');
})
......@@ -476,9 +476,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_1730', 0, function () {
console.info('usb SUB_USB_JS_1730 begin');
var strMaskCode = 'rndis'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.RNDIS);
expect(nMaskCode).assertEqual(usbManager.RNDIS);
console.info('usb SUB_USB_JS_1730 : PASS');
})
......@@ -490,9 +490,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_1740', 0, function () {
console.info('usb SUB_USB_JS_1740 begin');
var strMaskCode = 'hdc,rndis'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.RNDIS | usb.HDC);
expect(nMaskCode).assertEqual(usbManager.RNDIS | usbManager.HDC);
console.info('usb SUB_USB_JS_1740 : PASS');
})
......@@ -504,9 +504,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_1750', 0, function () {
console.info('usb SUB_USB_JS_1750 begin');
var strMaskCode = 'storage'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.STORAGE);
expect(nMaskCode).assertEqual(usbManager.STORAGE);
console.info('usb SUB_USB_JS_1750 : PASS');
})
......@@ -518,9 +518,9 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_1760', 0, function () {
console.info('usb SUB_USB_JS_1760 begin');
var strMaskCode = 'hdc,storage'
var nMaskCode = usb.usbFunctionsFromString(strMaskCode)
var nMaskCode = usbManager.usbFunctionsFromString(strMaskCode)
console.info('usb case strMaskCode ' + strMaskCode + ' usbFunctionsFromString return int: ' + nMaskCode);
expect(nMaskCode).assertEqual(usb.STORAGE | usb.HDC);
expect(nMaskCode).assertEqual(usbManager.STORAGE | usbManager.HDC);
console.info('usb SUB_USB_JS_1760 : PASS');
})
......@@ -532,7 +532,7 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_1170', 0, function () {
console.info('usb SUB_USB_JS_1170 begin');
try {
var maskCode = usb.usbFunctionsFromString(invalidCode);
var maskCode = usbManager.usbFunctionsFromString(invalidCode);
console.info('usb 1170 case usbFunctionsFromString return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -551,7 +551,7 @@ describe('UsbFunctionsJsFunctionsTestEx', function () {
it('SUB_USB_JS_1370', 0, function () {
console.info('usb SUB_USB_JS_1370 begin');
try {
var maskCode = usb.usbFunctionsFromString();
var maskCode = usbManager.usbFunctionsFromString();
console.info('usb 1370 case usbFunctionsFromString return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import usb from '@ohos.usb';
import usbManager from '@ohos.usbManager';
import CheckEmptyUtils from './CheckEmptyUtils.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
......@@ -23,13 +23,13 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbPortAndFunctionsJsFunctionsTest Begin*************');
var Version = usb.getVersion()
var Version = usbManager.getVersion()
console.info('begin test getversion :' + Version)
// version > 17 host currentMode = 2 device currentMode = 1
var usbPortList = usb.getPorts()
var usbPortList = usbManager.getPorts()
if (usbPortList.length > 0) {
if (usbPortList[0].status.currentMode == 2) {
usb.setPortRoles(usbPortList[0].id, usb.SINK, usb.DEVICE).then(data => {
usb.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);
......@@ -52,7 +52,7 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
function callSetCurFunction(caseName, iValue) {
console.info('usb case param case name:' + caseName);
console.info('usb case param iValue:' + iValue);
usb.setCurrentFunctions(iValue).then(data => {
usbManager.setCurrentFunctions(iValue).then(data => {
console.info('usb case SetCurFunction ret:' + data);
expect(data).assertTrue();
console.info('usb case ' + caseName + ': PASS');
......@@ -71,11 +71,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_0350', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_0350 set ACM begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_0350 ACM 1', usb.ACM);
callSetCurFunction('SUB_USB_JS_0350 ACM 1', usbManager.ACM);
})
/**
......@@ -86,11 +86,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_0360', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_0360 set ECM begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_0360 ECM 2', usb.ECM);
callSetCurFunction('SUB_USB_JS_0360 ECM 2', usbManager.ECM);
})
/**
......@@ -101,11 +101,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_0370', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_0370 set ACM ECM begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_0370 ACM ECM 3', (usb.ACM | usb.ECM));
callSetCurFunction('SUB_USB_JS_0370 ACM ECM 3', (usbManager.ACM | usbManager.ECM));
})
/**
......@@ -116,11 +116,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_0380', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_0380 set HDC begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_0380 HDC 4', usb.HDC);
callSetCurFunction('SUB_USB_JS_0380 HDC 4', usbManager.HDC);
})
/**
......@@ -131,11 +131,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_0390', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_0390 set ACM HDC begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_0390 ACM HDC 5', (usb.HDC | usb.ACM));
callSetCurFunction('SUB_USB_JS_0390 ACM HDC 5', (usbManager.HDC | usbManager.ACM));
})
/**
......@@ -146,11 +146,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_0400', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_0400 set ECM HDC begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_0400 ECM HDC 6', (usb.HDC | usb.ECM));
callSetCurFunction('SUB_USB_JS_0400 ECM HDC 6', (usbManager.HDC | usbManager.ECM));
})
/**
......@@ -161,11 +161,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_1620', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_1620 set MTP begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_1620 MTP 8', (usb.MTP));
callSetCurFunction('SUB_USB_JS_1620 MTP 8', (usbManager.MTP));
})
/**
......@@ -176,11 +176,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_1630', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_1630 set MTP HDC begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_1630 MTP HDC 12', (usb.MTP | usb.HDC));
callSetCurFunction('SUB_USB_JS_1630 MTP HDC 12', (usbManager.MTP | usbManager.HDC));
})
/**
......@@ -191,11 +191,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_1640', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_1640 set PTP begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_1640 PTP 16', (usb.PTP));
callSetCurFunction('SUB_USB_JS_1640 PTP 16', (usbManager.PTP));
})
/**
......@@ -206,11 +206,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_1650', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_1650 set PTP HDC begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_1650 PTP HDC 20', (usb.PTP | usb.HDC));
callSetCurFunction('SUB_USB_JS_1650 PTP HDC 20', (usbManager.PTP | usbManager.HDC));
})
/**
......@@ -221,11 +221,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_1660', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_1660 set RNDIS begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_1660 RNDIS 32', (usb.RNDIS));
callSetCurFunction('SUB_USB_JS_1660 RNDIS 32', (usbManager.RNDIS));
})
/**
......@@ -236,11 +236,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_1670', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_1670 set RNDIS HDC begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_1670 RNDIS HDC 36', (usb.RNDIS | usb.HDC));
callSetCurFunction('SUB_USB_JS_1670 RNDIS HDC 36', (usbManager.RNDIS | usbManager.HDC));
})
/**
......@@ -251,11 +251,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_1680', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_1680 set STORAGE begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_1680 STORAGE 512', (usb.STORAGE));
callSetCurFunction('SUB_USB_JS_1680 STORAGE 512', (usbManager.STORAGE));
})
/**
......@@ -266,11 +266,11 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
it('SUB_USB_JS_1690', 0, function () {
CheckEmptyUtils.sleep(3000);
console.info('usb SUB_USB_JS_1690 set STORAGE HDC begin');
var maskCode = usb.getCurrentFunctions();
var maskCode = usbManager.getCurrentFunctions();
console.info('usb case getCurrentFunctions return: ' + maskCode);
var funcString = usb.usbFunctionsToString(maskCode);
var funcString = usbManager.usbFunctionsToString(maskCode);
console.info('usb case funcString:' + funcString);
callSetCurFunction('SUB_USB_JS_1690 STORAGE HDC 516', (usb.STORAGE | usb.HDC));
callSetCurFunction('SUB_USB_JS_1690 STORAGE HDC 516', (usbManager.STORAGE | usbManager.HDC));
})
/**
......@@ -280,7 +280,7 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
*/
it('SUB_USB_JS_0010', 0, function () {
console.info('usb SUB_USB_JS_0010 device 2 2 begin');
var usbPortList = usb.getPorts()
var usbPortList = usbManager.getPorts()
if (usbPortList.length == 0) {
console.info('usb SUB_USB_JS_0010 device 2 2 usbPortList is null');
expect(false).assertTrue();
......@@ -289,7 +289,7 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
for (var i = 0; i < usbPortList.length; i++) {
console.info('usb 0010 case set data role 2, data role 2');
usb.setPortRoles(usbPortList[i].id, usb.SINK, usb.DEVICE).then(data => {
usbManager.setPortRoles(usbPortList[i].id, usbManager.SINK, usbManager.DEVICE).then(data => {
console.info('usb 0010 case setPortRoles return: ' + data);
expect(data).assertTrue();
}).catch(error => {
......@@ -309,7 +309,7 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
*/
it('SUB_USB_JS_0020', 0, function () {
console.info('usb SUB_USB_JS_0020 host 1 1 begin');
var usbPortList = usb.getPorts()
var usbPortList = usbManager.getPorts()
if (usbPortList.length == 0) {
console.info('usb SUB_USB_JS_0020 host 1 1 usbPortList is null');
expect(false).assertTrue();
......@@ -318,7 +318,7 @@ describe('UsbPortAndFunctionsJsFunctionsTest', function () {
for (var i = 0; i < usbPortList.length; i++) {
console.info('usb 0020 case set data role 1, data role 1');
usb.setPortRoles(usbPortList[i].id, usb.SOURCE, usb.HOST).then(data => {
usbManager.setPortRoles(usbPortList[i].id, usbManager.SOURCE, usbManager.HOST).then(data => {
console.info('usb 0020 case setPortRoles return: ' + data);
expect(data).assertTrue();
}).catch(error => {
......
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import usb from '@ohos.usb';
import usbManager from '@ohos.usbManager';
import CheckEmptyUtils from './CheckEmptyUtils.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
......@@ -23,7 +23,7 @@ describe('UsbPortJsFunctionsTest', function () {
beforeAll(function () {
console.log('*************Usb Unit UsbPortJsFunctionsTest Begin*************');
var Version = usb.getVersion()
var Version = usbManager.getVersion()
console.info('begin test getversion :' + Version)
})
beforeEach(function () {
......@@ -43,7 +43,7 @@ describe('UsbPortJsFunctionsTest', function () {
*/
it('SUB_USB_JS_0410', 0, function () {
console.info('usb SUB_USB_JS_0410 begin');
var usbPortList = usb.getPorts()
var usbPortList = usbManager.getPorts()
if (usbPortList.length == 0) {
console.info('usb SUB_USB_JS_0410 usbPortList is null');
expect(false).assertTrue();
......@@ -60,7 +60,7 @@ describe('UsbPortJsFunctionsTest', function () {
*/
it('SUB_USB_JS_0220', 0, function () {
console.info('usb SUB_USB_JS_0220 begin');
var usbPortList = usb.getPorts()
var usbPortList = usbManager.getPorts()
if (usbPortList.length == 0) {
console.info('usb SUB_USB_JS_0220 usbPortList is null');
expect(false).assertTrue();
......@@ -69,7 +69,7 @@ describe('UsbPortJsFunctionsTest', function () {
expect(usbPortList.length > 0).assertTrue();
for (var i = 0; i < usbPortList.length; i++) {
var maskCode = usb.getSupportedModes(usbPortList[i].id)
var maskCode = usbManager.getSupportedModes(usbPortList[i].id)
expect(maskCode).assertEqual(usbPortList[i].supportedModes);
}
......
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import usb from '@ohos.usb';
import usbManager from '@ohos.usbManager';
import CheckEmptyUtils from './CheckEmptyUtils.js';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
......@@ -24,7 +24,7 @@ describe('UsbPortJsFunctionsTestEx', function () {
var gPort;
beforeAll(function () {
console.log('*************Usb Unit UsbPortJsFunctionsTestEx Begin*************');
var Version = usb.getVersion()
var Version = usbManager.getVersion()
console.info('begin test getversion :' + Version)
})
beforeEach(function () {
......@@ -46,7 +46,7 @@ describe('UsbPortJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_0230', 0, function () {
console.info('usb SUB_USB_JS_0230 begin');
var usbPortList = usb.getPorts()
var usbPortList = usbManager.getPorts()
if (usbPortList.length == 0) {
console.info('usb SUB_USB_JS_0230 usbPortList is null');
expect(false).assertTrue();
......@@ -56,8 +56,8 @@ describe('UsbPortJsFunctionsTestEx', function () {
expect(usbPortList.length > 0).assertTrue();
gPort = usbPortList[0]
var portID = usbPortList[0].id + 10
var maskCode = usb.getSupportedModes(portID)
expect(maskCode).assertEqual(usb.NONE);
var maskCode = usbManager.getSupportedModes(portID)
expect(maskCode).assertEqual(usbManager.NONE);
console.info('usb SUB_USB_JS_0230 : PASS');
})
......@@ -71,7 +71,7 @@ describe('UsbPortJsFunctionsTestEx', function () {
it('SUB_USB_JS_1210', 0, function () {
console.info('usb SUB_USB_JS_1210 begin');
try {
var maskCode = usb.getSupportedModes("invalid");
var maskCode = usbManager.getSupportedModes("invalid");
console.info('usb 1210 case getSupportedModes return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -90,7 +90,7 @@ describe('UsbPortJsFunctionsTestEx', function () {
it('SUB_USB_JS_1380', 0, function () {
console.info('usb SUB_USB_JS_1380 begin');
try {
var maskCode = usb.getSupportedModes();
var maskCode = usbManager.getSupportedModes();
console.info('usb 1380 case getSupportedModes return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -107,9 +107,9 @@ describe('UsbPortJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_0030', 0, function () {
var portId = gPort.id;
var powerRole = usb.SINK;
var dataRole = usb.NONE - 1;
usb.setPortRoles(portId, powerRole, dataRole).then(data => {
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 => {
......@@ -127,9 +127,9 @@ describe('UsbPortJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_0040', 0, function () {
var portId = gPort.id;
var powerRole = usb.NONE - 1;
var dataRole = usb.DEVICE;
usb.setPortRoles(portId, powerRole, dataRole).then(data => {
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 => {
......@@ -147,9 +147,9 @@ describe('UsbPortJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_0050', 0, function () {
var portId = gPort.id - 3;
var powerRole = usb.SINK;
var dataRole = usb.NONE - 1;
usb.setPortRoles(portId, powerRole, dataRole).then(data => {
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 => {
......@@ -167,9 +167,9 @@ describe('UsbPortJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_0060', 0, function () {
var portId = gPort.id;
var powerRole = usb.NONE - 1;
var dataRole = usb.NONE - 1;
usb.setPortRoles(portId, powerRole, dataRole).then(data => {
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 => {
......@@ -187,9 +187,9 @@ describe('UsbPortJsFunctionsTestEx', function () {
*/
it('SUB_USB_JS_0070', 0, function () {
var portId = gPort.id - 1;
var dataRole = usb.NONE - 1;
var powerRole = usb.NONE - 1;
usb.setPortRoles(portId, powerRole, dataRole).then(data => {
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 => {
......@@ -209,7 +209,7 @@ describe('UsbPortJsFunctionsTestEx', function () {
var portId = gPort.id - 1;
var powerRole = 1;
var dataRole = 1;
usb.setPortRoles(portId, powerRole, dataRole).then(data => {
usbManager.setPortRoles(portId, powerRole, dataRole).then(data => {
console.info('usb 0080 case setPortRoles return: ' + data);
expect(data).assertFalse();
}).catch(error => {
......@@ -228,10 +228,10 @@ describe('UsbPortJsFunctionsTestEx', function () {
it('SUB_USB_JS_1410', 0, function () {
console.info('usb SUB_USB_JS_1410 begin');
var portId = "invalid";
var powerRole = usb.SINK;
var dataRole = usb.DEVICE;
var powerRole = usbManager.SINK;
var dataRole = usbManager.DEVICE;
try {
var maskCode = usb.setPortRoles(portId, powerRole, dataRole);
var maskCode = usbManager.setPortRoles(portId, powerRole, dataRole);
console.info('usb 1410 case setPortRoles return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -249,7 +249,7 @@ describe('UsbPortJsFunctionsTestEx', function () {
it('SUB_USB_JS_1190', 0, function () {
console.info('usb SUB_USB_JS_1190 begin');
try {
var maskCode = usb.setPortRoles("invalid");
var maskCode = usbManager.setPortRoles("invalid");
console.info('usb 1190 case setPortRoles return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -267,7 +267,7 @@ describe('UsbPortJsFunctionsTestEx', function () {
it('SUB_USB_JS_1390', 0, function () {
console.info('usb SUB_USB_JS_1390 begin');
try {
var maskCode = usb.setPortRoles();
var maskCode = usbManager.setPortRoles();
console.info('usb 1390 case setPortRoles return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -286,9 +286,9 @@ describe('UsbPortJsFunctionsTestEx', function () {
console.info('usb SUB_USB_JS_1590 begin');
var portId = gPort.id;
var powerRole = "invalid";
var dataRole = usb.DEVICE;
var dataRole = usbManager.DEVICE;
try {
var maskCode = usb.setPortRoles(portId, powerRole, dataRole);
var maskCode = usbManager.setPortRoles(portId, powerRole, dataRole);
console.info('usb 1590 case setPortRoles return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -306,10 +306,10 @@ describe('UsbPortJsFunctionsTestEx', function () {
it('SUB_USB_JS_1600', 0, function () {
console.info('usb SUB_USB_JS_1600 begin');
var portId = gPort.id;
var powerRole = usb.SINK;
var powerRole = usbManager.SINK;
var dataRole = "invalid";
try {
var maskCode = usb.setPortRoles(portId, powerRole, dataRole);
var maskCode = usbManager.setPortRoles(portId, powerRole, dataRole);
console.info('usb 1600 case setPortRoles return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -327,9 +327,9 @@ describe('UsbPortJsFunctionsTestEx', function () {
it('SUB_USB_JS_1610', 0, function () {
console.info('usb SUB_USB_JS_1610 begin');
var portId = gPort.id;
var powerRole = usb.SINK;
var powerRole = usbManager.SINK;
try {
var maskCode = usb.setPortRoles(portId, powerRole);
var maskCode = usbManager.setPortRoles(portId, powerRole);
console.info('usb 1610 case setPortRoles return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -347,7 +347,7 @@ describe('UsbPortJsFunctionsTestEx', function () {
it('SUB_USB_JS_1200', 0, function () {
console.info('usb SUB_USB_JS_1200 begin');
try {
var maskCode = usb.getPorts("invalid");
var maskCode = usbManager.getPorts("invalid");
console.info('usb 1200 case getPorts return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -365,7 +365,7 @@ describe('UsbPortJsFunctionsTestEx', function () {
it('SUB_USB_JS_1180', 0, function () {
console.info('usb SUB_USB_JS_1180 begin');
try {
var maskCode = usb.setCurrentFunctions("invalid");
var maskCode = usbManager.setCurrentFunctions("invalid");
console.info('usb 1180 case setCurrentFunctions return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......@@ -383,7 +383,7 @@ describe('UsbPortJsFunctionsTestEx', function () {
it('SUB_USB_JS_1400', 0, function () {
console.info('usb SUB_USB_JS_1400 begin');
try {
var maskCode = usb.setCurrentFunctions();
var maskCode = usbManager.setCurrentFunctions();
console.info('usb 1400 case setCurrentFunctions return: ' + maskCode);
expect(false).assertTrue();
} catch (err) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册