diff --git a/src/test/java/org/usb4java/LibUsbTest.java b/src/test/java/org/usb4java/LibUsbTest.java index 9dba00c..27fa5fc 100644 --- a/src/test/java/org/usb4java/LibUsbTest.java +++ b/src/test/java/org/usb4java/LibUsbTest.java @@ -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.