Package org.usb4java

Source Code of org.usb4java.InterfaceTest

/*
* Copyright (C) 2013 Klaus Reimer <k@ailis.de>
* See LICENSE.md for licensing information.
*/

package org.usb4java;

import static org.usb4java.test.UsbAssume.assumeUsbTestsEnabled;
import static org.usb4java.test.UsbAssume.isUsbTestsEnabled;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.usb4java.Interface;
import org.usb4java.LibUsb;

/**
* Tests the {@link Interface} class.
*
* @author Klaus Reimer (k@ailis.de)
*/
public class InterfaceTest
{
    /** The test subject. */
    private Interface descriptor;

    /**
     * Setup test.
     */
    @Before
    public void setUp()
    {
        if (isUsbTestsEnabled())
        {
            LibUsb.init(null);
            this.descriptor = new Interface();
        }
    }

    /**
     * Tear down test.
     */
    @After
    public void tearDown()
    {
        if (isUsbTestsEnabled())
        {
            LibUsb.exit(null);
        }
    }

    /**
     * Tests uninitialized access to {@link Interface#altsetting()}
     */
    @Test(expected = IllegalStateException.class)
    public void testUninitializedAltsetting()
    {
        assumeUsbTestsEnabled();
        this.descriptor.altsetting();
    }

    /**
     * Tests uninitialized access to {@link Interface#numAltsetting()}
     */
    @Test(expected = IllegalStateException.class)
    public void testUninitializedDescriptorType()
    {
        assumeUsbTestsEnabled();
        this.descriptor.numAltsetting();
    }
}
TOP

Related Classes of org.usb4java.InterfaceTest

TOP
Copyright © 2018 www.massapi.com. 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.