Package de.fuhagen.sttp.test

Source Code of de.fuhagen.sttp.test.FlatToggleButtonTest

/**
*
*/
package de.fuhagen.sttp.test;

import static org.junit.Assert.assertTrue;

import javax.swing.Action;

import org.junit.Test;

import de.fuhagen.sttp.demo.DemoAction;
import de.fuhagen.sttp.gui.FlatToggleButton;

/**
* @author thomas
*
*/
public class FlatToggleButtonTest {

    /**
     * Test method for {@link de.fuhagen.sttp.gui.FlatToggleButton#FlatToggleButton(javax.swing.AbstractAction, javax.swing.AbstractAction, int, int)}.
     */
    @Test
    public void testFlatToggleButton() {
        Action on = new DemoAction("on");
        Action off = new DemoAction("off");
        FlatToggleButton button = new FlatToggleButton(on, off, 20, 80);

        assertTrue("width", button.getWidth() == 20);
        assertTrue("width", button.getHeight() == 80);
        assertTrue("action", button.getAction() == on);
    }

    /**
     * Test method for {@link de.fuhagen.sttp.gui.FlatToggleButton#getOnAction()}.
     */
    @Test
    public void testGetOnAction() {
        Action on = new DemoAction("on");
        Action off = new DemoAction("off");
        FlatToggleButton button = new FlatToggleButton(on, off, 20, 80);

        assertTrue("on action", button.getOnAction() == on);
    }

    /**
     * Test method for {@link de.fuhagen.sttp.gui.FlatToggleButton#getOffAction()}.
     */
    @Test
    public void testGetOffAction() {
        Action on = new DemoAction("on");
        Action off = new DemoAction("off");
        FlatToggleButton button = new FlatToggleButton(on, off, 20, 80);

        assertTrue("off action", button.getOffAction() == off);
    }

    /**
     * Test method for {@link de.fuhagen.sttp.gui.FlatToggleButton#isOn()}.
     */
    @Test
    public void testIsOn() {
        Action on = new DemoAction("on");
        Action off = new DemoAction("off");
        FlatToggleButton button = new FlatToggleButton(on, off, 20, 80);

        assertTrue("is on", !button.isOn());
    }

    /**
     * Test method for {@link de.fuhagen.sttp.gui.FlatToggleButton#setState(boolean)}.
     */
    @Test
    public void testSetOn() {
        Action on = new DemoAction("on");
        Action off = new DemoAction("off");
        FlatToggleButton button = new FlatToggleButton(on, off, 20, 80);

        button.setState(true);
        assertTrue("is on", button.isOn());

        button.setState(false);
        assertTrue("is off", !button.isOn());
    }

}
TOP

Related Classes of de.fuhagen.sttp.test.FlatToggleButtonTest

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.