mirror of https://github.com/rusefi/usb4java.git
Add more unit tests for GetDeviceList
This commit is contained in:
parent
b24618df0f
commit
b762fb3f01
|
@ -308,6 +308,47 @@ public class LibUsbTest
|
|||
LibUsb.setOption(context, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link LibUsb#getDeviceList(Context, DeviceList)} method.
|
||||
*/
|
||||
@Test
|
||||
public void testGetDeviceList()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
final Context context = new Context();
|
||||
final DeviceList deviceList = new DeviceList();
|
||||
LibUsb.init(context);
|
||||
try
|
||||
{
|
||||
assertTrue(LibUsb.getDeviceList(context, deviceList) >= 0);
|
||||
LibUsb.freeDeviceList(deviceList, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LibUsb.exit(context);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link LibUsb#getDeviceList(Context, DeviceList)} method with the default context.
|
||||
*/
|
||||
@Test
|
||||
public void testGetDeviceListFromDefaultContext()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
final DeviceList deviceList = new DeviceList();
|
||||
LibUsb.init(null);
|
||||
try
|
||||
{
|
||||
assertTrue(LibUsb.getDeviceList(null, deviceList) >= 0);
|
||||
LibUsb.freeDeviceList(deviceList, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link LibUsb#getDeviceList(Context, DeviceList)} method with uninitialized USB context.
|
||||
*/
|
||||
|
@ -319,6 +360,16 @@ public class LibUsbTest
|
|||
LibUsb.getDeviceList(context, new DeviceList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link LibUsb#getDeviceList(Context, DeviceList)} method with uninitialized default USB context.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testGetDeviceListWithUninitializedDefaultContext()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getDeviceList(null, new DeviceList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link LibUsb#freeDeviceList(DeviceList, boolean)} method with
|
||||
* uninitialized list.
|
||||
|
|
Loading…
Reference in New Issue