Package org.usb4java.mocks

Examples of org.usb4java.mocks.PollfdListenerMock


     */
    @Test
    public void testPollFdNotifiers()
    {
        assumeUsbTestsEnabled();
        final PollfdListenerMock listener = new PollfdListenerMock();
        final Context context = new Context();
        LibUsb.init(context);
        LibUsb.setPollfdNotifiers(context, listener, "test");

        FileDescriptor fd = new FileDescriptor();
        LibUsb.triggerPollfdAdded(fd, 53, context.getPointer());
        assertEquals(53, listener.addedEvents);
        assertSame(fd, listener.addedFd);
        assertSame("test", listener.addedUserData);
        assertNull(listener.removedFd);
        assertNull(listener.removedUserData);

        listener.reset();

        fd = new FileDescriptor();
        LibUsb.triggerPollfdRemoved(fd, context.getPointer());
        assertEquals(0, listener.addedEvents);
        assertNull(listener.addedFd);
        assertNull(listener.addedUserData);
        assertSame(fd, listener.removedFd);
        assertSame("test", listener.removedUserData);

        LibUsb.setPollfdNotifiers(context, null, null);
        listener.reset();

        fd = new FileDescriptor();
        LibUsb.triggerPollfdAdded(fd, 53, context.getPointer());
        assertEquals(0, listener.addedEvents);
        assertNull(listener.addedFd);
        assertNull(listener.addedUserData);
        assertNull(listener.removedFd);
        assertNull(listener.removedUserData);

        listener.reset();

        fd = new FileDescriptor();
        LibUsb.triggerPollfdRemoved(fd, context.getPointer());
        assertEquals(0, listener.addedEvents);
        assertNull(listener.addedFd);
View Full Code Here

TOP

Related Classes of org.usb4java.mocks.PollfdListenerMock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.