Update/merge tests with new master branch.
Reformat/clean-up so to be closer to upstream style.
This commit is contained in:
parent
5b2b987820
commit
608121bbe6
1
TODO.txt
1
TODO.txt
@ -1,2 +1 @@
|
||||
* Implement hotplug support.
|
||||
* Implement asynchronous communication in low-level API.
|
||||
@ -31,19 +31,18 @@ public class BosDescriptorTest
|
||||
LibUsb.init(null);
|
||||
this.descriptor = new BosDescriptor();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tear down test.
|
||||
*/
|
||||
@After
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link BosDescriptor#bLength()}
|
||||
* Tests uninitialized access to {@link BosDescriptor#bLength()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedLength()
|
||||
@ -53,8 +52,7 @@ public class BosDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link BosDescriptor#bDescriptorType()}
|
||||
* Tests uninitialized access to {@link BosDescriptor#bDescriptorType()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedDescriptorType()
|
||||
@ -64,8 +62,7 @@ public class BosDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link BosDescriptor#wTotalLength()}
|
||||
* Tests uninitialized access to {@link BosDescriptor#wTotalLength()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedTotalLength()
|
||||
@ -75,8 +72,7 @@ public class BosDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link BosDescriptor#bNumDeviceCaps()}
|
||||
* Tests uninitialized access to {@link BosDescriptor#bNumDeviceCaps()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedNumDeviceCaps()
|
||||
@ -86,8 +82,7 @@ public class BosDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link BosDescriptor#devCapability()}
|
||||
* Tests uninitialized access to {@link BosDescriptor#devCapability()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedDevCapability()
|
||||
|
||||
@ -31,11 +31,11 @@ public class BosDevCapabilityDescriptorTest
|
||||
LibUsb.init(null);
|
||||
this.descriptor = new BosDevCapabilityDescriptor();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tear down test.
|
||||
*/
|
||||
@After
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
|
||||
@ -31,19 +31,18 @@ public class ConfigDescriptorTest
|
||||
LibUsb.init(null);
|
||||
this.descriptor = new ConfigDescriptor();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tear down test.
|
||||
*/
|
||||
@After
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link ConfigDescriptor#bLength()}
|
||||
* Tests uninitialized access to {@link ConfigDescriptor#bLength()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedLength()
|
||||
@ -53,8 +52,7 @@ public class ConfigDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link ConfigDescriptor#bDescriptorType()}
|
||||
* Tests uninitialized access to {@link ConfigDescriptor#bDescriptorType()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedDescriptorType()
|
||||
@ -64,8 +62,7 @@ public class ConfigDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link ConfigDescriptor#wTotalLength()}
|
||||
* Tests uninitialized access to {@link ConfigDescriptor#wTotalLength()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedTotalLength()
|
||||
@ -75,8 +72,7 @@ public class ConfigDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link ConfigDescriptor#bNumInterfaces()}
|
||||
* Tests uninitialized access to {@link ConfigDescriptor#bNumInterfaces()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedNumInterfaces()
|
||||
@ -97,8 +93,7 @@ public class ConfigDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link ConfigDescriptor#iConfiguration()}
|
||||
* Tests uninitialized access to {@link ConfigDescriptor#iConfiguration()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedConfiguration()
|
||||
@ -108,8 +103,7 @@ public class ConfigDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link ConfigDescriptor#bmAttributes()}
|
||||
* Tests uninitialized access to {@link ConfigDescriptor#bmAttributes()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedDescriptorAttributes()
|
||||
@ -119,8 +113,7 @@ public class ConfigDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link ConfigDescriptor#bMaxPower()}
|
||||
* Tests uninitialized access to {@link ConfigDescriptor#bMaxPower()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedDescriptorMaxPower()
|
||||
@ -130,8 +123,7 @@ public class ConfigDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link ConfigDescriptor#iface()}
|
||||
* Tests uninitialized access to {@link ConfigDescriptor#iface()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedDescriptorIface()
|
||||
@ -141,8 +133,7 @@ public class ConfigDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link ConfigDescriptor#extra()}
|
||||
* Tests uninitialized access to {@link ConfigDescriptor#extra()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedDescriptorExtra()
|
||||
@ -152,8 +143,7 @@ public class ConfigDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link ConfigDescriptor#extraLength()}
|
||||
* Tests uninitialized access to {@link ConfigDescriptor#extraLength()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedDescriptorExtraLength()
|
||||
|
||||
@ -31,19 +31,18 @@ public class ContainerIdDescriptorTest
|
||||
LibUsb.init(null);
|
||||
this.descriptor = new ContainerIdDescriptor();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tear down test.
|
||||
*/
|
||||
@After
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link ContainerIdDescriptor#bLength()}
|
||||
* Tests uninitialized access to {@link ContainerIdDescriptor#bLength()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedLength()
|
||||
@ -75,8 +74,7 @@ public class ContainerIdDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link ContainerIdDescriptor#bReserved()}
|
||||
* Tests uninitialized access to {@link ContainerIdDescriptor#bReserved()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedReserved()
|
||||
@ -86,8 +84,7 @@ public class ContainerIdDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link ContainerIdDescriptor#containerId()}
|
||||
* Tests uninitialized access to {@link ContainerIdDescriptor#containerId()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedContainerId()
|
||||
|
||||
@ -31,19 +31,18 @@ public class DeviceDescriptorTest
|
||||
LibUsb.init(null);
|
||||
this.descriptor = new DeviceDescriptor();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tear down test.
|
||||
*/
|
||||
@After
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link DeviceDescriptor#bLength()}
|
||||
* Tests uninitialized access to {@link DeviceDescriptor#bLength()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedLength()
|
||||
@ -53,8 +52,7 @@ public class DeviceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link DeviceDescriptor#bDescriptorType()}
|
||||
* Tests uninitialized access to {@link DeviceDescriptor#bDescriptorType()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedDescriptorType()
|
||||
@ -64,8 +62,7 @@ public class DeviceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link DeviceDescriptor#bcdUSB()}
|
||||
* Tests uninitialized access to {@link DeviceDescriptor#bcdUSB()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedBcdUSB()
|
||||
@ -75,8 +72,7 @@ public class DeviceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link DeviceDescriptor#bDeviceClass()}
|
||||
* Tests uninitialized access to {@link DeviceDescriptor#bDeviceClass()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedDeviceClass()
|
||||
@ -86,8 +82,7 @@ public class DeviceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link DeviceDescriptor#bDeviceSubClass()}
|
||||
* Tests uninitialized access to {@link DeviceDescriptor#bDeviceSubClass()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedDeviceSubClass()
|
||||
@ -97,8 +92,7 @@ public class DeviceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link DeviceDescriptor#bDeviceProtocol()}
|
||||
* Tests uninitialized access to {@link DeviceDescriptor#bDeviceProtocol()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedDeviceProtocol()
|
||||
@ -108,8 +102,7 @@ public class DeviceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link DeviceDescriptor#bMaxPacketSize0()}
|
||||
* Tests uninitialized access to {@link DeviceDescriptor#bMaxPacketSize0()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedMaxPacketSize0()
|
||||
@ -119,8 +112,7 @@ public class DeviceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link DeviceDescriptor#idVendor()}
|
||||
* Tests uninitialized access to {@link DeviceDescriptor#idVendor()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedVendor()
|
||||
@ -130,8 +122,7 @@ public class DeviceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link DeviceDescriptor#idProduct()}
|
||||
* Tests uninitialized access to {@link DeviceDescriptor#idProduct()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedProduct()
|
||||
@ -141,8 +132,7 @@ public class DeviceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link DeviceDescriptor#bcdDevice()}
|
||||
* Tests uninitialized access to {@link DeviceDescriptor#bcdDevice()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedBcdDevice()
|
||||
@ -152,8 +142,7 @@ public class DeviceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link DeviceDescriptor#iManufacturer()}
|
||||
* Tests uninitialized access to {@link DeviceDescriptor#iManufacturer()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedManufacturer()
|
||||
@ -163,8 +152,7 @@ public class DeviceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link DeviceDescriptor#iProduct()}
|
||||
* Tests uninitialized access to {@link DeviceDescriptor#iProduct()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedIProduct()
|
||||
@ -174,8 +162,7 @@ public class DeviceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link DeviceDescriptor#iSerialNumber()}
|
||||
* Tests uninitialized access to {@link DeviceDescriptor#iSerialNumber()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedSerialNumber()
|
||||
|
||||
@ -31,19 +31,18 @@ public class EndpointDescriptorTest
|
||||
LibUsb.init(null);
|
||||
this.descriptor = new EndpointDescriptor();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tear down test.
|
||||
*/
|
||||
@After
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link EndpointDescriptor#bLength()}
|
||||
* Tests uninitialized access to {@link EndpointDescriptor#bLength()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedLength()
|
||||
@ -62,7 +61,7 @@ public class EndpointDescriptorTest
|
||||
assumeUsbTestsEnabled();
|
||||
this.descriptor.bDescriptorType();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link EndpointDescriptor#bEndpointAddress()}
|
||||
@ -73,10 +72,9 @@ public class EndpointDescriptorTest
|
||||
assumeUsbTestsEnabled();
|
||||
this.descriptor.bEndpointAddress();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link EndpointDescriptor#bmAttributes()}
|
||||
* Tests uninitialized access to {@link EndpointDescriptor#bmAttributes()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedAttributes()
|
||||
@ -86,8 +84,7 @@ public class EndpointDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link EndpointDescriptor#wMaxPacketSize()}
|
||||
* Tests uninitialized access to {@link EndpointDescriptor#wMaxPacketSize()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedMaxPacketSize()
|
||||
@ -97,8 +94,7 @@ public class EndpointDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link EndpointDescriptor#bInterval()}
|
||||
* Tests uninitialized access to {@link EndpointDescriptor#bInterval()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedInterval()
|
||||
@ -106,10 +102,9 @@ public class EndpointDescriptorTest
|
||||
assumeUsbTestsEnabled();
|
||||
this.descriptor.bInterval();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link EndpointDescriptor#bRefresh()}
|
||||
* Tests uninitialized access to {@link EndpointDescriptor#bRefresh()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedRefresh()
|
||||
@ -117,10 +112,9 @@ public class EndpointDescriptorTest
|
||||
assumeUsbTestsEnabled();
|
||||
this.descriptor.bRefresh();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link EndpointDescriptor#bSynchAddress()}
|
||||
* Tests uninitialized access to {@link EndpointDescriptor#bSynchAddress()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedSynchAddress()
|
||||
@ -128,10 +122,9 @@ public class EndpointDescriptorTest
|
||||
assumeUsbTestsEnabled();
|
||||
this.descriptor.bSynchAddress();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link EndpointDescriptor#extra()}
|
||||
* Tests uninitialized access to {@link EndpointDescriptor#extra()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedExtra()
|
||||
@ -141,8 +134,7 @@ public class EndpointDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link EndpointDescriptor#extraLength()}
|
||||
* Tests uninitialized access to {@link EndpointDescriptor#extraLength()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedExtraLength()
|
||||
|
||||
@ -31,19 +31,18 @@ public class InterfaceDescriptorTest
|
||||
LibUsb.init(null);
|
||||
this.descriptor = new InterfaceDescriptor();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tear down test.
|
||||
*/
|
||||
@After
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link InterfaceDescriptor#bLength()}
|
||||
* Tests uninitialized access to {@link InterfaceDescriptor#bLength()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedLength()
|
||||
@ -86,8 +85,7 @@ public class InterfaceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link InterfaceDescriptor#bNumEndpoints()}
|
||||
* Tests uninitialized access to {@link InterfaceDescriptor#bNumEndpoints()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedNumEndpoints()
|
||||
@ -130,8 +128,7 @@ public class InterfaceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link InterfaceDescriptor#iInterface()}
|
||||
* Tests uninitialized access to {@link InterfaceDescriptor#iInterface()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedInterface()
|
||||
@ -141,8 +138,7 @@ public class InterfaceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link InterfaceDescriptor#endpoint()}
|
||||
* Tests uninitialized access to {@link InterfaceDescriptor#endpoint()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedEndpoint()
|
||||
@ -152,8 +148,7 @@ public class InterfaceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link InterfaceDescriptor#extra()}
|
||||
* Tests uninitialized access to {@link InterfaceDescriptor#extra()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedExtra()
|
||||
@ -163,8 +158,7 @@ public class InterfaceDescriptorTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link InterfaceDescriptor#extraLength()}
|
||||
* Tests uninitialized access to {@link InterfaceDescriptor#extraLength()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedExtraLength()
|
||||
|
||||
@ -31,19 +31,18 @@ public class InterfaceTest
|
||||
LibUsb.init(null);
|
||||
this.descriptor = new Interface();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tear down test.
|
||||
*/
|
||||
@After
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link Interface#altsetting()}
|
||||
* Tests uninitialized access to {@link Interface#altsetting()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedAltsetting()
|
||||
@ -53,8 +52,7 @@ public class InterfaceTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link Interface#numAltsetting()}
|
||||
* Tests uninitialized access to {@link Interface#numAltsetting()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedDescriptorType()
|
||||
|
||||
@ -19,6 +19,8 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import de.ailis.usb4java.utils.BufferUtils;
|
||||
|
||||
/**
|
||||
* Tests the device-scope methods of the {@link LibUsb} class which need a open
|
||||
* USB context and a device to run the tests on.
|
||||
@ -51,21 +53,20 @@ public class LibUSBDeviceTest
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
context = new Context();
|
||||
LibUsb.init(context);
|
||||
this.context = new Context();
|
||||
LibUsb.init(this.context);
|
||||
try
|
||||
{
|
||||
device = findTestDevice();
|
||||
if (device == null)
|
||||
this.device = this.findTestDevice();
|
||||
if (this.device == null)
|
||||
{
|
||||
throw new IllegalStateException("Need at least one USB device "
|
||||
+
|
||||
"with at least one endpoint to execute this test");
|
||||
+ "with at least one endpoint to execute this test");
|
||||
}
|
||||
}
|
||||
catch (Throwable e)
|
||||
catch (final Throwable e)
|
||||
{
|
||||
device = null;
|
||||
this.device = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -76,41 +77,41 @@ public class LibUSBDeviceTest
|
||||
*/
|
||||
private Device findTestDevice()
|
||||
{
|
||||
DeviceList list = new DeviceList();
|
||||
if (LibUsb.getDeviceList(context, list) <= 0)
|
||||
final DeviceList list = new DeviceList();
|
||||
if (LibUsb.getDeviceList(this.context, list) <= 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
for (Device device: list)
|
||||
for (final Device device : list)
|
||||
{
|
||||
DeviceDescriptor descriptor = new DeviceDescriptor();
|
||||
final DeviceDescriptor descriptor = new DeviceDescriptor();
|
||||
if (LibUsb.getDeviceDescriptor(device, descriptor) != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
vendorId = descriptor.idVendor();
|
||||
productId = descriptor.idProduct();
|
||||
ConfigDescriptor config = new ConfigDescriptor();
|
||||
this.vendorId = descriptor.idVendor();
|
||||
this.productId = descriptor.idProduct();
|
||||
final ConfigDescriptor config = new ConfigDescriptor();
|
||||
if (LibUsb.getActiveConfigDescriptor(device, config) < 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
try
|
||||
{
|
||||
configValue = config.bConfigurationValue();
|
||||
this.configValue = config.bConfigurationValue();
|
||||
for (int j = 0; j < config.bNumInterfaces(); j++)
|
||||
{
|
||||
Interface iface = config.iface()[j];
|
||||
final Interface iface = config.iface()[j];
|
||||
for (int k = 0; k < iface.numAltsetting(); k++)
|
||||
{
|
||||
InterfaceDescriptor ifaceDescriptor =
|
||||
iface.altsetting()[k];
|
||||
final InterfaceDescriptor ifaceDescriptor = iface
|
||||
.altsetting()[k];
|
||||
if (ifaceDescriptor.bNumEndpoints() > 1)
|
||||
{
|
||||
endpoint = ifaceDescriptor.endpoint()[0].
|
||||
bEndpointAddress();
|
||||
this.endpoint = ifaceDescriptor.endpoint()[0]
|
||||
.bEndpointAddress();
|
||||
return LibUsb.refDevice(device);
|
||||
}
|
||||
}
|
||||
@ -135,13 +136,13 @@ public class LibUSBDeviceTest
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
if (device != null)
|
||||
if (this.device != null)
|
||||
{
|
||||
LibUsb.unrefDevice(device);
|
||||
LibUsb.unrefDevice(this.device);
|
||||
}
|
||||
if (context != null)
|
||||
if (this.context != null)
|
||||
{
|
||||
LibUsb.exit(context);
|
||||
LibUsb.exit(this.context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,8 +153,8 @@ public class LibUSBDeviceTest
|
||||
public void testGetBusNumber()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
assertTrue(LibUsb.getBusNumber(device) >= 0);
|
||||
assumeNotNull(this.device);
|
||||
assertTrue(LibUsb.getBusNumber(this.device) >= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -163,126 +164,69 @@ public class LibUSBDeviceTest
|
||||
public void testGetPortNumber()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
assertTrue(LibUsb.getPortNumber(device) >= 0);
|
||||
assumeNotNull(this.device);
|
||||
assertTrue(LibUsb.getPortNumber(this.device) >= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* Tests the {@link LibUsb#getPortNumbers(Device, byte[])} method.
|
||||
=======
|
||||
* Tests the {@link LibUsb#getPortPath(Context, Device, ByteBuffer)} method.
|
||||
>>>>>>> origin/asyncio
|
||||
* Tests the {@link LibUsb#getPortNumbers(Device, ByteBuffer)} method.
|
||||
*/
|
||||
@Test
|
||||
public void testGetPortNumbers()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
<<<<<<< HEAD
|
||||
assumeNotNull(this.device);
|
||||
byte[] path = new byte[8];
|
||||
int result = LibUsb.getPortNumbers(this.device, path);
|
||||
=======
|
||||
assumeNotNull(device);
|
||||
ByteBuffer path = ByteBuffer.allocateDirect(8);
|
||||
int result = LibUsb.getPortPath(context, device, path);
|
||||
>>>>>>> origin/asyncio
|
||||
final ByteBuffer path = BufferUtils.allocateByteBuffer(8);
|
||||
final int result = LibUsb.getPortNumbers(this.device, path);
|
||||
assertTrue(result > 0);
|
||||
assertTrue(result <= path.capacity());
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* Tests the {@link LibUsb#getPortNumbers(Device, byte[])} method with
|
||||
=======
|
||||
* Tests the {@link LibUsb#getPortPath(Context, Device, ByteBuffer)} method with
|
||||
>>>>>>> origin/asyncio
|
||||
* Tests the {@link LibUsb#getPortNumbers(Device, ByteBuffer)} method with
|
||||
* 0-sized path buffer.
|
||||
*/
|
||||
@Test
|
||||
public void testGetPortNumbersWithTooSmallBuffer()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
<<<<<<< HEAD
|
||||
assumeNotNull(this.device);
|
||||
byte[] path = new byte[0];
|
||||
int result = LibUsb.getPortNumbers(this.device, path);
|
||||
=======
|
||||
assumeNotNull(device);
|
||||
ByteBuffer path = ByteBuffer.allocateDirect(0);
|
||||
int result = LibUsb.getPortPath(context, device, path);
|
||||
>>>>>>> origin/asyncio
|
||||
final ByteBuffer path = BufferUtils.allocateByteBuffer(0);
|
||||
final int result = LibUsb.getPortNumbers(this.device, path);
|
||||
assertEquals(LibUsb.ERROR_OVERFLOW, result);
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* Tests the {@link LibUsb#getPortNumbers(Device, byte[])} method
|
||||
=======
|
||||
* Tests the {@link LibUsb#getPortPath(Context, Device, ByteBuffer)} method
|
||||
>>>>>>> origin/asyncio
|
||||
* Tests the {@link LibUsb#getPortNumbers(Device, ByteBuffer)} method
|
||||
* without a device.
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testGetPortNumbersWithoutDevice()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
<<<<<<< HEAD
|
||||
LibUsb.getPortNumbers(null, new byte[8]);
|
||||
LibUsb.getPortNumbers(null, BufferUtils.allocateByteBuffer(8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the {@link LibUsb#getPortNumbers(Device, byte[])} method
|
||||
=======
|
||||
LibUsb.getPortPath(context, null, ByteBuffer.allocateDirect(8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the {@link LibUsb#getPortPath(Context, Device, ByteBuffer)} method
|
||||
>>>>>>> origin/asyncio
|
||||
* Tests the {@link LibUsb#getPortNumbers(Device, ByteBuffer)} method
|
||||
* without a buffer.
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testGetPortNumbersWithoutBuffer()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
<<<<<<< HEAD
|
||||
LibUsb.getPortNumbers(this.device, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link LibUsb#getPortNumbers(Device, byte[])} method with
|
||||
=======
|
||||
LibUsb.getPortPath(context, device, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link LibUsb#getPortPath(Context, Device, ByteBuffer)} method with
|
||||
* uninitialized USB context.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testGetPortPathWithUninitializedContext()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
final Context context = new Context();
|
||||
LibUsb.getPortPath(context, device, ByteBuffer.allocateDirect(16));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link LibUsb#getPortPath(Context, Device, ByteBuffer)} method with
|
||||
>>>>>>> origin/asyncio
|
||||
* Tests {@link LibUsb#getPortNumbers(Device, ByteBuffer)} method with
|
||||
* uninitialized device.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testGetPortNumbersWithUninitializedDevice()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
<<<<<<< HEAD
|
||||
LibUsb.getPortNumbers(new Device(), new byte[16]);
|
||||
=======
|
||||
LibUsb.getPortPath(context, new Device(), ByteBuffer.allocateDirect(16));
|
||||
>>>>>>> origin/asyncio
|
||||
LibUsb.getPortNumbers(new Device(), BufferUtils.allocateByteBuffer(16));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -292,17 +236,17 @@ public class LibUSBDeviceTest
|
||||
public void testGetParent()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
DeviceList list = new DeviceList();
|
||||
LibUsb.getDeviceList(context, list);
|
||||
assumeNotNull(this.device);
|
||||
final DeviceList list = new DeviceList();
|
||||
LibUsb.getDeviceList(this.context, list);
|
||||
try
|
||||
{
|
||||
Device parent = LibUsb.getParent(device);
|
||||
final Device parent = LibUsb.getParent(this.device);
|
||||
|
||||
// We cannot test anything else here. Parent can be null if our
|
||||
// test device is a root device. We just make sure that it can't
|
||||
// be the device itself.
|
||||
assertNotEquals(parent, device);
|
||||
assertNotEquals(parent, this.device);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -327,8 +271,8 @@ public class LibUSBDeviceTest
|
||||
public void testGetDeviceAddress()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
assertTrue(LibUsb.getDeviceAddress(device) >= 0);
|
||||
assumeNotNull(this.device);
|
||||
assertTrue(LibUsb.getDeviceAddress(this.device) >= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -349,9 +293,10 @@ public class LibUSBDeviceTest
|
||||
public void testGetDeviceSpeed()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
int speed = LibUsb.getDeviceSpeed(device);
|
||||
assertTrue((speed >= LibUsb.SPEED_UNKNOWN) && (speed <= LibUsb.SPEED_SUPER));
|
||||
assumeNotNull(this.device);
|
||||
final int speed = LibUsb.getDeviceSpeed(this.device);
|
||||
assertTrue((speed >= LibUsb.SPEED_UNKNOWN)
|
||||
&& (speed <= LibUsb.SPEED_SUPER));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -371,9 +316,9 @@ public class LibUSBDeviceTest
|
||||
public void testGetMaxPacketSizeWithInvalidEndpoint()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
assumeNotNull(this.device);
|
||||
assertEquals(LibUsb.ERROR_NOT_FOUND,
|
||||
LibUsb.getMaxPacketSize(device, (byte) 0));
|
||||
LibUsb.getMaxPacketSize(this.device, (byte) 0));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -383,8 +328,8 @@ public class LibUSBDeviceTest
|
||||
public void testGetMaxPacketSize()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
assertTrue(LibUsb.getMaxPacketSize(device, endpoint) > 0);
|
||||
assumeNotNull(this.device);
|
||||
assertTrue(LibUsb.getMaxPacketSize(this.device, this.endpoint) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -405,9 +350,9 @@ public class LibUSBDeviceTest
|
||||
public void testGetMaxIsoPacketSizeWithInvalidEndpoint()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
assumeNotNull(this.device);
|
||||
assertEquals(LibUsb.ERROR_NOT_FOUND,
|
||||
LibUsb.getMaxIsoPacketSize(device, (byte) 0));
|
||||
LibUsb.getMaxIsoPacketSize(this.device, (byte) 0));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -417,8 +362,8 @@ public class LibUSBDeviceTest
|
||||
public void testGetMaxIsoPacketSize()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
assertTrue(LibUsb.getMaxIsoPacketSize(device, endpoint) > 0);
|
||||
assumeNotNull(this.device);
|
||||
assertTrue(LibUsb.getMaxIsoPacketSize(this.device, this.endpoint) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -440,8 +385,8 @@ public class LibUSBDeviceTest
|
||||
public void testRefUnRefDevice()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
Device device = LibUsb.refDevice(this.device);
|
||||
assumeNotNull(this.device);
|
||||
final Device device = LibUsb.refDevice(this.device);
|
||||
try
|
||||
{
|
||||
assertEquals(this.device, device);
|
||||
@ -483,10 +428,11 @@ public class LibUSBDeviceTest
|
||||
public void testOpenAndClose()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
DeviceHandle handle = new DeviceHandle();
|
||||
int result = LibUsb.open(device, handle);
|
||||
assertTrue((result == LibUsb.SUCCESS) || (result == LibUsb.ERROR_ACCESS));
|
||||
assumeNotNull(this.device);
|
||||
final DeviceHandle handle = new DeviceHandle();
|
||||
final int result = LibUsb.open(this.device, handle);
|
||||
assertTrue((result == LibUsb.SUCCESS)
|
||||
|| (result == LibUsb.ERROR_ACCESS));
|
||||
if (result == LibUsb.SUCCESS)
|
||||
{
|
||||
LibUsb.close(handle);
|
||||
@ -496,7 +442,7 @@ public class LibUSBDeviceTest
|
||||
LibUsb.close(handle);
|
||||
fail("Double-close should throw IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException e)
|
||||
catch (final IllegalStateException e)
|
||||
{
|
||||
// Expected behavior
|
||||
}
|
||||
@ -511,7 +457,7 @@ public class LibUSBDeviceTest
|
||||
public void testOpenWithoutDevice()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
DeviceHandle handle = new DeviceHandle();
|
||||
final DeviceHandle handle = new DeviceHandle();
|
||||
LibUsb.open(null, handle);
|
||||
}
|
||||
|
||||
@ -523,7 +469,7 @@ public class LibUSBDeviceTest
|
||||
public void testOpenWithoutHandle()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.open(device, null);
|
||||
LibUsb.open(this.device, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -537,7 +483,8 @@ public class LibUSBDeviceTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the {@link LibUsb#openDeviceWithVidPid(Context, int, int)} method.
|
||||
* Tests the {@link LibUsb#openDeviceWithVidPid(Context, short, short)}
|
||||
* method.
|
||||
* We can't test anything here because the device most likely can't be
|
||||
* opened anyway. We just make sure it does not crash.
|
||||
*/
|
||||
@ -545,8 +492,8 @@ public class LibUSBDeviceTest
|
||||
public void testOpenDeviceWithVidPid()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
DeviceHandle handle = LibUsb.openDeviceWithVidPid(context,
|
||||
vendorId, productId);
|
||||
final DeviceHandle handle = LibUsb.openDeviceWithVidPid(this.context,
|
||||
this.vendorId, this.productId);
|
||||
if (handle != null)
|
||||
{
|
||||
LibUsb.close(handle);
|
||||
@ -572,7 +519,7 @@ public class LibUSBDeviceTest
|
||||
public void testGetConfigurationWithoutHandle()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getConfiguration(null, IntBuffer.allocate(1));
|
||||
LibUsb.getConfiguration(null, BufferUtils.allocateIntBuffer());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -705,7 +652,7 @@ public class LibUSBDeviceTest
|
||||
public void testGetDeviceDescriptorWithoutDescriptor()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getDeviceDescriptor(device, null);
|
||||
LibUsb.getDeviceDescriptor(this.device, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -720,9 +667,9 @@ public class LibUSBDeviceTest
|
||||
public void testGetDeviceDescriptor()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
DeviceDescriptor desc = new DeviceDescriptor();
|
||||
LibUsb.getDeviceDescriptor(device, desc);
|
||||
assumeNotNull(this.device);
|
||||
final DeviceDescriptor desc = new DeviceDescriptor();
|
||||
LibUsb.getDeviceDescriptor(this.device, desc);
|
||||
desc.bcdDevice();
|
||||
desc.bcdUSB();
|
||||
assertEquals(LibUsb.DT_DEVICE, desc.bDescriptorType());
|
||||
@ -755,7 +702,7 @@ public class LibUSBDeviceTest
|
||||
public void testGetActiveConfigDescriptorWithoutDescriptor()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getActiveConfigDescriptor(device, null);
|
||||
LibUsb.getActiveConfigDescriptor(this.device, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -776,9 +723,9 @@ public class LibUSBDeviceTest
|
||||
assertEquals(desc.bNumInterfaces(), desc.iface().length);
|
||||
assertTrue(desc.wTotalLength() >= desc.bLength());
|
||||
|
||||
for (Interface iface: desc.iface())
|
||||
for (final Interface iface : desc.iface())
|
||||
{
|
||||
validateInterface(iface);
|
||||
this.validateInterface(iface);
|
||||
}
|
||||
}
|
||||
|
||||
@ -791,9 +738,9 @@ public class LibUSBDeviceTest
|
||||
private void validateInterface(final Interface iface)
|
||||
{
|
||||
assertEquals(iface.numAltsetting(), iface.altsetting().length);
|
||||
for (InterfaceDescriptor desc: iface.altsetting())
|
||||
for (final InterfaceDescriptor desc : iface.altsetting())
|
||||
{
|
||||
validateInterfaceDescriptor(desc);
|
||||
this.validateInterfaceDescriptor(desc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -816,9 +763,9 @@ public class LibUSBDeviceTest
|
||||
assertEquals(desc.extraLength(), desc.extra().limit());
|
||||
desc.iInterface();
|
||||
|
||||
for (EndpointDescriptor endDesc: desc.endpoint())
|
||||
for (final EndpointDescriptor endDesc : desc.endpoint())
|
||||
{
|
||||
validateEndpointDescriptor(endDesc);
|
||||
this.validateEndpointDescriptor(endDesc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -850,12 +797,12 @@ public class LibUSBDeviceTest
|
||||
public void testGetActiveConfigDescriptor()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
ConfigDescriptor desc = new ConfigDescriptor();
|
||||
LibUsb.getActiveConfigDescriptor(device, desc);
|
||||
assumeNotNull(this.device);
|
||||
final ConfigDescriptor desc = new ConfigDescriptor();
|
||||
LibUsb.getActiveConfigDescriptor(this.device, desc);
|
||||
try
|
||||
{
|
||||
validateConfigDescriptor(desc);
|
||||
this.validateConfigDescriptor(desc);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -884,23 +831,24 @@ public class LibUSBDeviceTest
|
||||
public void testGetConfigDescriptorWithoutDescriptor()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getConfigDescriptor(device, (byte) 0, null);
|
||||
LibUsb.getConfigDescriptor(this.device, (byte) 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#getConfigDescriptor(Device, byte, ConfigDescriptor)} method.
|
||||
* {@link LibUsb#getConfigDescriptor(Device, byte, ConfigDescriptor)}
|
||||
* method.
|
||||
*/
|
||||
@Test
|
||||
public void testGetConfigDescriptor()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
ConfigDescriptor desc = new ConfigDescriptor();
|
||||
LibUsb.getConfigDescriptor(device, (byte) 0, desc);
|
||||
assumeNotNull(this.device);
|
||||
final ConfigDescriptor desc = new ConfigDescriptor();
|
||||
LibUsb.getConfigDescriptor(this.device, (byte) 0, desc);
|
||||
try
|
||||
{
|
||||
validateConfigDescriptor(desc);
|
||||
this.validateConfigDescriptor(desc);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -917,7 +865,8 @@ public class LibUSBDeviceTest
|
||||
public void testGetConfigDescriptorByValueWithoutDevice()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getConfigDescriptorByValue(null, (byte) 0, new ConfigDescriptor());
|
||||
LibUsb.getConfigDescriptorByValue(null, (byte) 0,
|
||||
new ConfigDescriptor());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -929,7 +878,7 @@ public class LibUSBDeviceTest
|
||||
public void testGetConfigDescriptorByValueWithoutDescriptor()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getConfigDescriptorByValue(device, (byte) 0, null);
|
||||
LibUsb.getConfigDescriptorByValue(this.device, (byte) 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -941,12 +890,12 @@ public class LibUSBDeviceTest
|
||||
public void testGetConfigDescriptorByValue()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
assumeNotNull(device);
|
||||
ConfigDescriptor desc = new ConfigDescriptor();
|
||||
LibUsb.getConfigDescriptorByValue(device, configValue, desc);
|
||||
assumeNotNull(this.device);
|
||||
final ConfigDescriptor desc = new ConfigDescriptor();
|
||||
LibUsb.getConfigDescriptorByValue(this.device, this.configValue, desc);
|
||||
try
|
||||
{
|
||||
validateConfigDescriptor(desc);
|
||||
this.validateConfigDescriptor(desc);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -957,7 +906,7 @@ public class LibUSBDeviceTest
|
||||
LibUsb.freeConfigDescriptor(desc);
|
||||
fail("Double-free should throw IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException e)
|
||||
catch (final IllegalStateException e)
|
||||
{
|
||||
// Expected behavior
|
||||
}
|
||||
@ -1008,7 +957,8 @@ public class LibUSBDeviceTest
|
||||
public void testGetDescriptorWithoutHandle()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getDescriptor(null, (byte) 0, (byte) 0, ByteBuffer.allocate(18));
|
||||
LibUsb.getDescriptor(null, (byte) 0, (byte) 0,
|
||||
BufferUtils.allocateByteBuffer(18));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1032,7 +982,8 @@ public class LibUSBDeviceTest
|
||||
public void testGetStringDescriptorWithoutHandle()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getStringDescriptor(null, (byte) 0, (short) 0, ByteBuffer.allocate(18));
|
||||
LibUsb.getStringDescriptor(null, (byte) 0, (short) 0,
|
||||
BufferUtils.allocateByteBuffer(18));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1044,7 +995,8 @@ public class LibUSBDeviceTest
|
||||
public void testGetStringDescriptorWithoutBuffer()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getStringDescriptor(new DeviceHandle(), (byte) 0, (short) 0, null);
|
||||
LibUsb.getStringDescriptor(new DeviceHandle(), (byte) 0, (short) 0,
|
||||
null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1056,7 +1008,8 @@ public class LibUSBDeviceTest
|
||||
public void testControlTransferWithoutHandle()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.controlTransfer(null, (byte) 0, (byte) 0, (short) 0, (short) 0, ByteBuffer.allocate(0), 0);
|
||||
LibUsb.controlTransfer(null, (byte) 0, (byte) 0, (short) 0, (short) 0,
|
||||
BufferUtils.allocateByteBuffer(0), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1068,7 +1021,8 @@ public class LibUSBDeviceTest
|
||||
public void testControlTransferWithoutBuffer()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.controlTransfer(new DeviceHandle(), (byte) 0, (byte) 0, (short) 0, (short) 0, null, 0);
|
||||
LibUsb.controlTransfer(new DeviceHandle(), (byte) 0, (byte) 0,
|
||||
(short) 0, (short) 0, null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1080,8 +1034,8 @@ public class LibUSBDeviceTest
|
||||
public void testControlTransferWithIndirectBuffer()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.controlTransfer(new DeviceHandle(), (byte) 0, (byte) 0, (short) 0, (short) 0,
|
||||
ByteBuffer.allocate(0), 0);
|
||||
LibUsb.controlTransfer(new DeviceHandle(), (byte) 0, (byte) 0,
|
||||
(short) 0, (short) 0, ByteBuffer.allocate(0), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1093,8 +1047,8 @@ public class LibUSBDeviceTest
|
||||
public void testBulkTransferWithoutHandle()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.bulkTransfer(null, (byte) 0, ByteBuffer.allocate(0),
|
||||
IntBuffer.allocate(1), 0);
|
||||
LibUsb.bulkTransfer(null, (byte) 0, BufferUtils.allocateByteBuffer(0),
|
||||
BufferUtils.allocateIntBuffer(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1107,7 +1061,7 @@ public class LibUSBDeviceTest
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.bulkTransfer(new DeviceHandle(), (byte) 0, null,
|
||||
IntBuffer.allocate(1), 0);
|
||||
BufferUtils.allocateIntBuffer(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1119,8 +1073,8 @@ public class LibUSBDeviceTest
|
||||
public void testBulkTransferWithIndirectDataBuffer()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.bulkTransfer(new DeviceHandle(), (byte) 0, ByteBuffer.allocate(0),
|
||||
IntBuffer.allocate(1), 0);
|
||||
LibUsb.bulkTransfer(new DeviceHandle(), (byte) 0,
|
||||
ByteBuffer.allocate(0), BufferUtils.allocateIntBuffer(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1132,8 +1086,8 @@ public class LibUSBDeviceTest
|
||||
public void testBulkTransferWithoutTransferredBuffer()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.bulkTransfer(new DeviceHandle(), (byte) 0, ByteBuffer.allocate(0),
|
||||
null, 0);
|
||||
LibUsb.bulkTransfer(new DeviceHandle(), (byte) 0,
|
||||
BufferUtils.allocateByteBuffer(0), null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1145,8 +1099,9 @@ public class LibUSBDeviceTest
|
||||
public void testInterruptTransferWithoutHandle()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.interruptTransfer(null, (byte) 0, ByteBuffer.allocate(0),
|
||||
IntBuffer.allocate(1), 0);
|
||||
LibUsb.interruptTransfer(null, (byte) 0,
|
||||
BufferUtils.allocateByteBuffer(0), BufferUtils.allocateIntBuffer(),
|
||||
0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1159,7 +1114,7 @@ public class LibUSBDeviceTest
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.interruptTransfer(new DeviceHandle(), (byte) 0, null,
|
||||
IntBuffer.allocate(1), 0);
|
||||
BufferUtils.allocateIntBuffer(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1171,8 +1126,8 @@ public class LibUSBDeviceTest
|
||||
public void testInterruptTransferWithIndirectDataBuffer()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.interruptTransfer(new DeviceHandle(), (byte) 0, ByteBuffer.allocate(0),
|
||||
IntBuffer.allocate(1), 0);
|
||||
LibUsb.interruptTransfer(new DeviceHandle(), (byte) 0,
|
||||
ByteBuffer.allocate(0), BufferUtils.allocateIntBuffer(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1184,8 +1139,8 @@ public class LibUSBDeviceTest
|
||||
public void testInterruptTransferWithoutTransferredBuffer()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.interruptTransfer(new DeviceHandle(), (byte) 0, ByteBuffer.allocate(0),
|
||||
null, 0);
|
||||
LibUsb.interruptTransfer(new DeviceHandle(), (byte) 0,
|
||||
BufferUtils.allocateByteBuffer(0), null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1196,8 +1151,8 @@ public class LibUSBDeviceTest
|
||||
public void testGetAndFreeDeviceList()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
DeviceList list = new DeviceList();
|
||||
assertTrue(LibUsb.getDeviceList(context, list) >= 0);
|
||||
final DeviceList list = new DeviceList();
|
||||
assertTrue(LibUsb.getDeviceList(this.context, list) >= 0);
|
||||
LibUsb.freeDeviceList(list, true);
|
||||
|
||||
try
|
||||
@ -1205,7 +1160,7 @@ public class LibUSBDeviceTest
|
||||
LibUsb.freeDeviceList(list, true);
|
||||
fail("Double-free should throw IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException e)
|
||||
catch (final IllegalStateException e)
|
||||
{
|
||||
// Expected behavior
|
||||
}
|
||||
@ -1220,7 +1175,7 @@ public class LibUSBDeviceTest
|
||||
public void testGetAndFreeDeviceListWithDefaultContext()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
DeviceList list = new DeviceList();
|
||||
final DeviceList list = new DeviceList();
|
||||
assertEquals(0, LibUsb.init(null));
|
||||
try
|
||||
{
|
||||
@ -1232,7 +1187,7 @@ public class LibUSBDeviceTest
|
||||
LibUsb.freeDeviceList(list, true);
|
||||
fail("Double-free should throw IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException e)
|
||||
catch (final IllegalStateException e)
|
||||
{
|
||||
// Expected behavior
|
||||
}
|
||||
|
||||
@ -32,14 +32,14 @@ public class LibUSBGlobalTest
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
context = new Context();
|
||||
this.context = new Context();
|
||||
try
|
||||
{
|
||||
LibUsb.init(context);
|
||||
LibUsb.init(this.context);
|
||||
}
|
||||
catch (Throwable e)
|
||||
catch (final Throwable e)
|
||||
{
|
||||
context = null;
|
||||
this.context = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,9 +49,9 @@ public class LibUSBGlobalTest
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
if (context != null)
|
||||
if (this.context != null)
|
||||
{
|
||||
LibUsb.exit(context);
|
||||
LibUsb.exit(this.context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,11 +62,11 @@ public class LibUSBGlobalTest
|
||||
public void testSetDebug()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.setDebug(context, LibUsb.LOG_LEVEL_DEBUG);
|
||||
LibUsb.setDebug(context, LibUsb.LOG_LEVEL_INFO);
|
||||
LibUsb.setDebug(context, LibUsb.LOG_LEVEL_WARNING);
|
||||
LibUsb.setDebug(context, LibUsb.LOG_LEVEL_ERROR);
|
||||
LibUsb.setDebug(context, LibUsb.LOG_LEVEL_NONE);
|
||||
LibUsb.setDebug(this.context, LibUsb.LOG_LEVEL_DEBUG);
|
||||
LibUsb.setDebug(this.context, LibUsb.LOG_LEVEL_INFO);
|
||||
LibUsb.setDebug(this.context, LibUsb.LOG_LEVEL_WARNING);
|
||||
LibUsb.setDebug(this.context, LibUsb.LOG_LEVEL_ERROR);
|
||||
LibUsb.setDebug(this.context, LibUsb.LOG_LEVEL_NONE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,13 +77,13 @@ public class LibUSBGlobalTest
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
final DeviceList list = new DeviceList();
|
||||
final int result = LibUsb.getDeviceList(context, list);
|
||||
final int result = LibUsb.getDeviceList(this.context, list);
|
||||
assertTrue(
|
||||
"At least one USB device must be present for the simple unit tests",
|
||||
result > 0);
|
||||
assertEquals(result, list.getSize());
|
||||
int i = 0;
|
||||
for (Device device: list)
|
||||
for (final Device device : list)
|
||||
{
|
||||
assertNotNull(device);
|
||||
assertEquals(device, list.get(i));
|
||||
@ -101,7 +101,7 @@ public class LibUSBGlobalTest
|
||||
public void testGetDeviceListWithoutList()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getDeviceList(context, null);
|
||||
LibUsb.getDeviceList(this.context, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -194,7 +194,7 @@ public class LibUSBTest
|
||||
LibUsb.exit(null);
|
||||
fail("Double-exit should throw IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException e)
|
||||
catch (final IllegalStateException e)
|
||||
{
|
||||
// Expected behavior
|
||||
}
|
||||
@ -208,7 +208,7 @@ public class LibUSBTest
|
||||
public void testInitDeinitWithContext()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
Context context = new Context();
|
||||
final Context context = new Context();
|
||||
assertEquals(LibUsb.SUCCESS, LibUsb.init(context));
|
||||
LibUsb.exit(context);
|
||||
|
||||
@ -217,7 +217,7 @@ public class LibUSBTest
|
||||
LibUsb.exit(context);
|
||||
fail("Double-exit should throw IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException e)
|
||||
catch (final IllegalStateException e)
|
||||
{
|
||||
// Expected behavior
|
||||
}
|
||||
@ -440,7 +440,8 @@ public class LibUSBTest
|
||||
public void testGetConfigurationWithUninitializedHandle()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getConfiguration(new DeviceHandle(), IntBuffer.allocate(1));
|
||||
LibUsb.getConfiguration(new DeviceHandle(),
|
||||
BufferUtils.allocateIntBuffer());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -609,7 +610,8 @@ public class LibUSBTest
|
||||
public void testGetConfigDescriptorWithUninitializedDevice()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getConfigDescriptor(new Device(), (byte) 0, new ConfigDescriptor());
|
||||
LibUsb.getConfigDescriptor(new Device(), (byte) 0,
|
||||
new ConfigDescriptor());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -638,7 +640,6 @@ public class LibUSBTest
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
<<<<<<< HEAD
|
||||
* {@link LibUsb#getSsEndpointCompanionDescriptor(Context, EndpointDescriptor, SsEndpointCompanionDescriptor)}
|
||||
* method with uninitialized endpoint.
|
||||
*/
|
||||
@ -646,7 +647,7 @@ public class LibUSBTest
|
||||
public void testGetSsEndpointCompanionDescriptorWithUninitializedEndpoint()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getSsEndpointCompanionDescriptor(null, new EndpointDescriptor(),
|
||||
LibUsb.getSsEndpointCompanionDescriptor(null, new EndpointDescriptor(),
|
||||
new SsEndpointCompanionDescriptor());
|
||||
}
|
||||
|
||||
@ -671,7 +672,8 @@ public class LibUSBTest
|
||||
public void testFreeSsEndpointCompanionDescriptorWithUninitializedDescriptor()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.freeSsEndpointCompanionDescriptor(new SsEndpointCompanionDescriptor());
|
||||
LibUsb
|
||||
.freeSsEndpointCompanionDescriptor(new SsEndpointCompanionDescriptor());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -685,10 +687,9 @@ public class LibUSBTest
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.freeSsEndpointCompanionDescriptor(null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#getBosDescriptor(DeviceHandle, BosDescriptor)}
|
||||
* Tests the {@link LibUsb#getBosDescriptor(DeviceHandle, BosDescriptor)}
|
||||
* method with uninitialized handled.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
@ -699,8 +700,7 @@ public class LibUSBTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#getBosDescriptor(DeviceHandle, BosDescriptor)}
|
||||
* Tests the {@link LibUsb#getBosDescriptor(DeviceHandle, BosDescriptor)}
|
||||
* method without handle.
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@ -711,9 +711,8 @@ public class LibUSBTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#freeBosDescriptor(BosDescriptor)}
|
||||
* method with uninitialized descriptor.
|
||||
* Tests the {@link LibUsb#freeBosDescriptor(BosDescriptor)} method with
|
||||
* uninitialized descriptor.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testFreeBosDescriptorWithUninitializedDescriptor()
|
||||
@ -723,9 +722,8 @@ public class LibUSBTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#freeBosDescriptor(BosDescriptor)}
|
||||
* method with null parameter. Must do nothing.
|
||||
* Tests the {@link LibUsb#freeBosDescriptor(BosDescriptor)} method with
|
||||
* null parameter. Must do nothing.
|
||||
*/
|
||||
@Test
|
||||
public void testFreeBosDescriptorWithNull()
|
||||
@ -733,26 +731,23 @@ public class LibUSBTest
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.freeBosDescriptor(null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#getUsb20ExtensionDescriptor(Context,
|
||||
* BosDevCapabilityDescriptor, Usb20ExtensionDescriptor)}
|
||||
* {@link LibUsb#getUsb20ExtensionDescriptor(Context, BosDevCapabilityDescriptor, Usb20ExtensionDescriptor)}
|
||||
* method with uninitialized device capability descriptor.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testGetUsb20ExtensionDescriptorWithUninitializedEndpoint()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getUsb20ExtensionDescriptor(null,
|
||||
new BosDevCapabilityDescriptor(),
|
||||
new Usb20ExtensionDescriptor());
|
||||
LibUsb.getUsb20ExtensionDescriptor(null,
|
||||
new BosDevCapabilityDescriptor(), new Usb20ExtensionDescriptor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#getUsb20ExtensionDescriptor(Context,
|
||||
* BosDevCapabilityDescriptor, Usb20ExtensionDescriptor)}
|
||||
* {@link LibUsb#getUsb20ExtensionDescriptor(Context, BosDevCapabilityDescriptor, Usb20ExtensionDescriptor)}
|
||||
* method without descriptors.
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@ -785,26 +780,24 @@ public class LibUSBTest
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.freeUsb20ExtensionDescriptor(null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#getSsUsbDeviceCapabilityDescriptor(Context,
|
||||
* BosDevCapabilityDescriptor, SsUsbDeviceCapabilityDescriptor)}
|
||||
* {@link LibUsb#getSsUsbDeviceCapabilityDescriptor(Context, BosDevCapabilityDescriptor, SsUsbDeviceCapabilityDescriptor)}
|
||||
* method with uninitialized device capability descriptor.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testGetSsUsbDeviceCapabilityDescriptorWithUninitializedEndpoint()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getSsUsbDeviceCapabilityDescriptor(null,
|
||||
new BosDevCapabilityDescriptor(),
|
||||
LibUsb.getSsUsbDeviceCapabilityDescriptor(null,
|
||||
new BosDevCapabilityDescriptor(),
|
||||
new SsUsbDeviceCapabilityDescriptor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#getSsUsbDeviceCapabilityDescriptor(Context,
|
||||
* BosDevCapabilityDescriptor, SsUsbDeviceCapabilityDescriptor)}
|
||||
* {@link LibUsb#getSsUsbDeviceCapabilityDescriptor(Context, BosDevCapabilityDescriptor, SsUsbDeviceCapabilityDescriptor)}
|
||||
* method without descriptors.
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@ -823,7 +816,8 @@ public class LibUSBTest
|
||||
public void testFreeSsUsbDeviceCapabilityDescriptorWithUninitializedDescriptor()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.freeSsUsbDeviceCapabilityDescriptor(new SsUsbDeviceCapabilityDescriptor());
|
||||
LibUsb
|
||||
.freeSsUsbDeviceCapabilityDescriptor(new SsUsbDeviceCapabilityDescriptor());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -837,26 +831,23 @@ public class LibUSBTest
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.freeSsUsbDeviceCapabilityDescriptor(null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#getContainerIdDescriptor(Context,
|
||||
* BosDevCapabilityDescriptor, ContainerIdDescriptor)}
|
||||
* {@link LibUsb#getContainerIdDescriptor(Context, BosDevCapabilityDescriptor, ContainerIdDescriptor)}
|
||||
* method with uninitialized device capability descriptor.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testGetContainerIdDescriptorWithUninitializedEndpoint()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.getContainerIdDescriptor(null,
|
||||
new BosDevCapabilityDescriptor(),
|
||||
LibUsb.getContainerIdDescriptor(null, new BosDevCapabilityDescriptor(),
|
||||
new ContainerIdDescriptor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#getContainerIdDescriptor(Context,
|
||||
* BosDevCapabilityDescriptor, ContainerIdDescriptor)}
|
||||
* {@link LibUsb#getContainerIdDescriptor(Context, BosDevCapabilityDescriptor, ContainerIdDescriptor)}
|
||||
* method without descriptors.
|
||||
*/
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@ -867,8 +858,7 @@ public class LibUSBTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#freeContainerIdDescriptor(ContainerIdDescriptor)}
|
||||
* Tests the {@link LibUsb#freeContainerIdDescriptor(ContainerIdDescriptor)}
|
||||
* method with uninitialized descriptor.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
@ -879,8 +869,7 @@ public class LibUSBTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#freeContainerIdDescriptor(ContainerIdDescriptor)}
|
||||
* Tests the {@link LibUsb#freeContainerIdDescriptor(ContainerIdDescriptor)}
|
||||
* method with null parameter. Must do nothing.
|
||||
*/
|
||||
@Test
|
||||
@ -892,10 +881,7 @@ public class LibUSBTest
|
||||
|
||||
/**
|
||||
* Tests the
|
||||
* {@link LibUsb#getDescriptor(DeviceHandle, int, int, ByteBuffer)} method
|
||||
=======
|
||||
* {@link LibUsb#getDescriptor(DeviceHandle, byte, byte, ByteBuffer)} method
|
||||
>>>>>>> origin/asyncio
|
||||
* with uninitialized device handle.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
@ -928,8 +914,8 @@ public class LibUSBTest
|
||||
public void testControlTransferWithUninitializedHandle()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.controlTransfer(new DeviceHandle(), (byte) 0, (byte) 0, (short) 0, (short) 0,
|
||||
ByteBuffer.allocateDirect(1), 0);
|
||||
LibUsb.controlTransfer(new DeviceHandle(), (byte) 0, (byte) 0,
|
||||
(short) 0, (short) 0, ByteBuffer.allocateDirect(1), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -942,7 +928,7 @@ public class LibUSBTest
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.bulkTransfer(new DeviceHandle(), (byte) 0,
|
||||
ByteBuffer.allocateDirect(1), IntBuffer.allocate(1), 0);
|
||||
ByteBuffer.allocateDirect(1), BufferUtils.allocateIntBuffer(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -955,7 +941,7 @@ public class LibUSBTest
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
LibUsb.interruptTransfer(new DeviceHandle(), (byte) 0,
|
||||
ByteBuffer.allocateDirect(1), IntBuffer.allocate(1), 0);
|
||||
ByteBuffer.allocateDirect(1), BufferUtils.allocateIntBuffer(), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1086,7 +1072,8 @@ public class LibUSBTest
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
final Context context = new Context();
|
||||
LibUsb.handleEventsTimeoutCompleted(context, 53, BufferUtils.allocateIntBuffer());
|
||||
LibUsb.handleEventsTimeoutCompleted(context, 53,
|
||||
BufferUtils.allocateIntBuffer());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1150,7 +1137,7 @@ public class LibUSBTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link LibUsb#getNextTimeout(Context, IntBuffer)} with
|
||||
* Tests {@link LibUsb#getNextTimeout(Context, LongBuffer)} with
|
||||
* uninitialized USB context.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
@ -1158,12 +1145,12 @@ public class LibUSBTest
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
final Context context = new Context();
|
||||
LibUsb.getNextTimeout(context, LongBuffer.allocate(1));
|
||||
LibUsb.getNextTimeout(context, BufferUtils.allocateLongBuffer());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests {@link LibUsb#setPollfdNotifiers(Context)} with uninitialized USB
|
||||
* context.
|
||||
* Tests {@link LibUsb#setPollfdNotifiers(Context, long)} with uninitialized
|
||||
* USB context.
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testSetPollfdNotifiersWithUninitializedContext()
|
||||
@ -1194,8 +1181,8 @@ public class LibUSBTest
|
||||
public void testPollFdNotifiers()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
PollfdListenerMock listener = new PollfdListenerMock();
|
||||
Context context = new Context();
|
||||
final PollfdListenerMock listener = new PollfdListenerMock();
|
||||
final Context context = new Context();
|
||||
LibUsb.init(context);
|
||||
LibUsb.setPollfdNotifiers(context, listener, "test");
|
||||
|
||||
|
||||
@ -31,11 +31,11 @@ public class SsEndpointCompanionDescriptorTest
|
||||
LibUsb.init(null);
|
||||
this.descriptor = new SsEndpointCompanionDescriptor();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tear down test.
|
||||
*/
|
||||
@After
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
|
||||
@ -31,11 +31,11 @@ public class SsUsbDeviceCapabilityDescriptorTest
|
||||
LibUsb.init(null);
|
||||
this.descriptor = new SsUsbDeviceCapabilityDescriptor();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tear down test.
|
||||
*/
|
||||
@After
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
|
||||
@ -35,14 +35,14 @@ public class TransferTest
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
context = new Context();
|
||||
this.context = new Context();
|
||||
try
|
||||
{
|
||||
LibUsb.init(context);
|
||||
LibUsb.init(this.context);
|
||||
}
|
||||
catch (Throwable e)
|
||||
catch (final Throwable e)
|
||||
{
|
||||
context = null;
|
||||
this.context = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,9 +52,9 @@ public class TransferTest
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
if (context != null)
|
||||
if (this.context != null)
|
||||
{
|
||||
LibUsb.exit(context);
|
||||
LibUsb.exit(this.context);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ public class TransferTest
|
||||
public void testAllocAndFree()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
Transfer transfer = LibUsb.allocTransfer(0);
|
||||
final Transfer transfer = LibUsb.allocTransfer(0);
|
||||
assertNotNull(transfer);
|
||||
LibUsb.freeTransfer(transfer);
|
||||
|
||||
@ -74,7 +74,7 @@ public class TransferTest
|
||||
LibUsb.freeTransfer(transfer);
|
||||
fail("Double-free should throw IllegalStateException");
|
||||
}
|
||||
catch (IllegalStateException e)
|
||||
catch (final IllegalStateException e)
|
||||
{
|
||||
// Expected behavior
|
||||
}
|
||||
@ -88,16 +88,16 @@ public class TransferTest
|
||||
* @param pointer
|
||||
* The pointer to set.
|
||||
*/
|
||||
private void setPointer(DeviceHandle handle, long pointer)
|
||||
private void setPointer(final DeviceHandle handle, final long pointer)
|
||||
{
|
||||
try
|
||||
{
|
||||
Field field =
|
||||
DeviceHandle.class.getDeclaredField("deviceHandlePointer");
|
||||
final Field field = DeviceHandle.class
|
||||
.getDeclaredField("deviceHandlePointer");
|
||||
field.setAccessible(true);
|
||||
field.set(handle, pointer);
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (final Exception e)
|
||||
{
|
||||
throw new RuntimeException(e.toString(), e);
|
||||
}
|
||||
@ -111,11 +111,11 @@ public class TransferTest
|
||||
public void testDevHandle()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
Transfer transfer = LibUsb.allocTransfer(0);
|
||||
DeviceHandle handle = new DeviceHandle();
|
||||
setPointer(handle, 1);
|
||||
DeviceHandle handle2 = new DeviceHandle();
|
||||
setPointer(handle2, 2);
|
||||
final Transfer transfer = LibUsb.allocTransfer(0);
|
||||
final DeviceHandle handle = new DeviceHandle();
|
||||
this.setPointer(handle, 1);
|
||||
final DeviceHandle handle2 = new DeviceHandle();
|
||||
this.setPointer(handle2, 2);
|
||||
assertNull(transfer.devHandle());
|
||||
transfer.setDevHandle(handle);
|
||||
assertNotNull(transfer.devHandle());
|
||||
@ -135,7 +135,7 @@ public class TransferTest
|
||||
public void testFlags()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
Transfer transfer = LibUsb.allocTransfer(0);
|
||||
final Transfer transfer = LibUsb.allocTransfer(0);
|
||||
assertEquals(0, transfer.flags());
|
||||
transfer.setFlags((byte) 1);
|
||||
assertEquals(1, transfer.flags());
|
||||
@ -152,7 +152,7 @@ public class TransferTest
|
||||
public void testEndpoint()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
Transfer transfer = LibUsb.allocTransfer(0);
|
||||
final Transfer transfer = LibUsb.allocTransfer(0);
|
||||
assertEquals(0, transfer.endpoint());
|
||||
transfer.setEndpoint((byte) 1);
|
||||
assertEquals(1, transfer.endpoint());
|
||||
@ -169,7 +169,7 @@ public class TransferTest
|
||||
public void testType()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
Transfer transfer = LibUsb.allocTransfer(0);
|
||||
final Transfer transfer = LibUsb.allocTransfer(0);
|
||||
assertEquals(0, transfer.type());
|
||||
transfer.setType((byte) 1);
|
||||
assertEquals(1, transfer.type());
|
||||
@ -186,7 +186,7 @@ public class TransferTest
|
||||
public void testTimeout()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
Transfer transfer = LibUsb.allocTransfer(0);
|
||||
final Transfer transfer = LibUsb.allocTransfer(0);
|
||||
assertEquals(0, transfer.timeout());
|
||||
transfer.setTimeout(1);
|
||||
assertEquals(1, transfer.timeout());
|
||||
@ -202,7 +202,7 @@ public class TransferTest
|
||||
public void testGetStatus()
|
||||
{
|
||||
assumeUsbTestsEnabled();
|
||||
Transfer transfer = LibUsb.allocTransfer(0);
|
||||
final Transfer transfer = LibUsb.allocTransfer(0);
|
||||
assertEquals(0, transfer.status());
|
||||
LibUsb.freeTransfer(transfer);
|
||||
}
|
||||
|
||||
@ -31,19 +31,18 @@ public class Usb20ExtensionDescriptorTest
|
||||
LibUsb.init(null);
|
||||
this.descriptor = new Usb20ExtensionDescriptor();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tear down test.
|
||||
*/
|
||||
@After
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link Usb20ExtensionDescriptor#bLength()}
|
||||
* Tests uninitialized access to {@link Usb20ExtensionDescriptor#bLength()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedLength()
|
||||
|
||||
@ -31,19 +31,18 @@ public class VersionTest
|
||||
LibUsb.init(null);
|
||||
this.version = new Version();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tear down test.
|
||||
*/
|
||||
@After
|
||||
@After
|
||||
public void tearDown()
|
||||
{
|
||||
LibUsb.exit(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link Version#major()}
|
||||
* Tests uninitialized access to {@link Version#major()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedMajor()
|
||||
@ -53,8 +52,7 @@ public class VersionTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link Version#minor()}
|
||||
* Tests uninitialized access to {@link Version#minor()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedMinor()
|
||||
@ -64,8 +62,7 @@ public class VersionTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link Version#micro()}
|
||||
* Tests uninitialized access to {@link Version#micro()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedMicro()
|
||||
@ -75,8 +72,7 @@ public class VersionTest
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests uninitialized access to
|
||||
* {@link Version#rc()}
|
||||
* Tests uninitialized access to {@link Version#rc()}
|
||||
*/
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testUninitializedRc()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user