Search in sources :

Example 16 with MouseEventData

use of junit.extensions.jfcunit.eventdata.MouseEventData in project JMRI by JMRI.

the class IconEditorWindowTest method testSensorEditor.

public void testSensorEditor() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        // can't Assume in TestCase
        return;
    }
    _editor.addSensorEditor();
    Editor.JFrameItem iconEditorFrame = _editor.getIconFrame("Sensor");
    IconAdder iconEditor = iconEditorFrame.getEditor();
    Assert.assertNotNull(iconEditor);
    iconEditor._sysNametext.setText("IS0");
    iconEditor.addToTable();
    SensorIcon icon = _editor.putSensor();
    Assert.assertNotNull(icon);
    Sensor sensor = icon.getSensor();
    Assert.assertNotNull(sensor);
    int x = 50;
    int y = 20;
    jmri.util.ThreadingUtil.runOnGUI(() -> {
        icon.setLocation(x, y);
        _panel.repaint();
    });
    java.awt.Point location = new java.awt.Point(x + icon.getSize().width / 2, y + icon.getSize().height / 2);
    Assert.assertEquals("initial state", Sensor.UNKNOWN, sensor.getState());
    getHelper().enterClickAndLeave(new MouseEventData(this, // component
    _panel, // number clicks
    1, // modifiers
    EventDataConstants.DEFAULT_MOUSE_MODIFIERS, // isPopUpTrigger
    false, // sleeptime
    10, // position
    EventDataConstants.CUSTOM, location));
    Assert.assertEquals("state after one click", Sensor.INACTIVE, sensor.getState());
    // Click icon change state to inactive
    getHelper().enterClickAndLeave(new MouseEventData(this, icon));
    Assert.assertEquals("state after two clicks", Sensor.ACTIVE, sensor.getState());
    TestHelper.disposeWindow(iconEditorFrame, this);
}
Also used : MouseEventData(junit.extensions.jfcunit.eventdata.MouseEventData) PanelEditor(jmri.jmrit.display.panelEditor.PanelEditor) Sensor(jmri.Sensor)

Example 17 with MouseEventData

use of junit.extensions.jfcunit.eventdata.MouseEventData in project JMRI by JMRI.

the class IconEditorWindowTest method testLightEditor.

public void testLightEditor() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        // can't Assume in TestCase
        return;
    }
    Editor.JFrameItem iconEditorFrame = _editor.getIconFrame("Light");
    IconAdder iconEditor = iconEditorFrame.getEditor();
    Assert.assertNotNull(iconEditor);
    iconEditor._sysNametext.setText("IL0");
    iconEditor.addToTable();
    LightIcon icon = _editor.addLight();
    Assert.assertNotNull(icon);
    Light light = icon.getLight();
    Assert.assertNotNull(light);
    int x = 30;
    int y = 10;
    icon.setLocation(x, y);
    _panel.repaint();
    java.awt.Point location = new java.awt.Point(x + icon.getSize().width / 2, y + icon.getSize().height / 2);
    Assert.assertEquals("initial state", Light.OFF, light.getState());
    getHelper().enterClickAndLeave(new MouseEventData(this, // component
    _panel, // number clicks
    1, // modifiers
    EventDataConstants.DEFAULT_MOUSE_MODIFIERS, // isPopUpTrigger
    false, // sleeptime
    10, // position
    EventDataConstants.CUSTOM, location));
    Assert.assertEquals("state after one click", Light.ON, light.getState());
    // Click icon change state to inactive
    getHelper().enterClickAndLeave(new MouseEventData(this, icon));
    Assert.assertEquals("state after two clicks", Light.OFF, light.getState());
    TestHelper.disposeWindow(iconEditorFrame, this);
}
Also used : Light(jmri.Light) MouseEventData(junit.extensions.jfcunit.eventdata.MouseEventData) PanelEditor(jmri.jmrit.display.panelEditor.PanelEditor)

Example 18 with MouseEventData

use of junit.extensions.jfcunit.eventdata.MouseEventData in project JMRI by JMRI.

the class IconEditorWindowTest method testSignalHeadEditor.

public void testSignalHeadEditor() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        // can't Assume in TestCase
        return;
    }
    Editor.JFrameItem iconEditorFrame = _editor.getIconFrame("SignalHead");
    IconAdder iconEditor = iconEditorFrame.getEditor();
    Assert.assertNotNull(iconEditor);
    SignalHead signalHead = new jmri.implementation.VirtualSignalHead("IH0");
    InstanceManager.getDefault(jmri.SignalHeadManager.class).register(signalHead);
    iconEditor.setSelection(signalHead);
    SignalHeadIcon icon = _editor.putSignalHead();
    Assert.assertNotNull(icon);
    SignalHead sh = icon.getSignalHead();
    Assert.assertEquals("SignalHead==sh", signalHead, sh);
    int x = 30;
    int y = 10;
    icon.setLocation(x, y);
    _panel.repaint();
    java.awt.Point location = new java.awt.Point(x + icon.getSize().width / 2, y + icon.getSize().height / 2);
    int[] states = signalHead.getValidStates();
    Assert.assertEquals("initial state", states[0], signalHead.getState());
    getHelper().enterClickAndLeave(new MouseEventData(this, // component
    _panel, // number clicks
    1, // modifiers
    EventDataConstants.DEFAULT_MOUSE_MODIFIERS, // isPopUpTrigger
    false, // sleeptime
    10, // position
    EventDataConstants.CUSTOM, location));
    for (int i = 1; i < states.length; i++) {
        Assert.assertEquals("state after " + i + " click", states[i], signalHead.getState());
        getHelper().enterClickAndLeave(new MouseEventData(this, icon));
    }
    TestHelper.disposeWindow(iconEditorFrame, this);
}
Also used : SignalHead(jmri.SignalHead) MouseEventData(junit.extensions.jfcunit.eventdata.MouseEventData) PanelEditor(jmri.jmrit.display.panelEditor.PanelEditor)

Example 19 with MouseEventData

use of junit.extensions.jfcunit.eventdata.MouseEventData in project JMRI by JMRI.

the class IconEditorWindowTest method testRightTOEditor.

public void testRightTOEditor() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        // can't Assume in TestCase
        return;
    }
    Editor.JFrameItem iconEditorFrame = _editor.getIconFrame("RightTurnout");
    IconAdder iconEditor = iconEditorFrame.getEditor();
    Assert.assertNotNull(iconEditor);
    iconEditor._sysNametext.setText("IT0");
    iconEditor.addToTable();
    TurnoutIcon icon = _editor.addTurnout(iconEditor);
    Assert.assertNotNull(icon);
    Turnout turnout = icon.getTurnout();
    Assert.assertNotNull(turnout);
    int x = 30;
    int y = 10;
    jmri.util.ThreadingUtil.runOnGUI(() -> {
        icon.setLocation(x, y);
        _panel.repaint();
    });
    java.awt.Point location = new java.awt.Point(x + icon.getSize().width / 2, y + icon.getSize().height / 2);
    Assert.assertEquals("initial state", Sensor.UNKNOWN, turnout.getState());
    getHelper().enterClickAndLeave(new MouseEventData(this, // component
    _panel, // number clicks
    1, // modifiers
    EventDataConstants.DEFAULT_MOUSE_MODIFIERS, // isPopUpTrigger
    false, // sleeptime
    10, // position
    EventDataConstants.CUSTOM, location));
    Assert.assertEquals("state after one click", Turnout.CLOSED, turnout.getState());
    // Click icon change state to inactive
    getHelper().enterClickAndLeave(new MouseEventData(this, icon));
    Assert.assertEquals("state after two clicks", Turnout.THROWN, turnout.getState());
    TestHelper.disposeWindow(iconEditorFrame, this);
}
Also used : MouseEventData(junit.extensions.jfcunit.eventdata.MouseEventData) PanelEditor(jmri.jmrit.display.panelEditor.PanelEditor) Turnout(jmri.Turnout)

Example 20 with MouseEventData

use of junit.extensions.jfcunit.eventdata.MouseEventData in project JMRI by JMRI.

the class IconEditorWindowTest method testLeftTOEditor.

public void testLeftTOEditor() throws Exception {
    if (GraphicsEnvironment.isHeadless()) {
        // can't Assume in TestCase
        return;
    }
    Editor.JFrameItem iconEditorFrame = _editor.getIconFrame("LeftTurnout");
    IconAdder iconEditor = iconEditorFrame.getEditor();
    Assert.assertNotNull(iconEditor);
    iconEditor._sysNametext.setText("IT1");
    iconEditor.addToTable();
    TurnoutIcon icon = _editor.addTurnout(iconEditor);
    Assert.assertNotNull(icon);
    Turnout turnout = icon.getTurnout();
    Assert.assertNotNull(turnout);
    int x = 30;
    int y = 10;
    jmri.util.ThreadingUtil.runOnGUI(() -> {
        icon.setLocation(x, y);
        _panel.repaint();
    });
    java.awt.Point location = new java.awt.Point(x + icon.getSize().width / 2, y + icon.getSize().height / 2);
    Assert.assertEquals("initial state", Sensor.UNKNOWN, turnout.getState());
    getHelper().enterClickAndLeave(new MouseEventData(this, // component
    _panel, // number clicks
    1, // modifiers
    EventDataConstants.DEFAULT_MOUSE_MODIFIERS, // isPopUpTrigger
    false, // sleeptime
    10, // position
    EventDataConstants.CUSTOM, location));
    Assert.assertEquals("state after one click", Turnout.CLOSED, turnout.getState());
    // Click icon change state to inactive
    getHelper().enterClickAndLeave(new MouseEventData(this, icon));
    Assert.assertEquals("state after two clicks", Turnout.THROWN, turnout.getState());
    TestHelper.disposeWindow(iconEditorFrame, this);
}
Also used : MouseEventData(junit.extensions.jfcunit.eventdata.MouseEventData) PanelEditor(jmri.jmrit.display.panelEditor.PanelEditor) Turnout(jmri.Turnout)

Aggregations

MouseEventData (junit.extensions.jfcunit.eventdata.MouseEventData)23 AbstractButtonFinder (junit.extensions.jfcunit.finder.AbstractButtonFinder)14 JButton (javax.swing.JButton)11 DialogFinder (junit.extensions.jfcunit.finder.DialogFinder)8 JDialog (javax.swing.JDialog)7 PanelEditor (jmri.jmrit.display.panelEditor.PanelEditor)7 JComponent (javax.swing.JComponent)6 Turnout (jmri.Turnout)5 Sensor (jmri.Sensor)4 NamedIcon (jmri.jmrit.catalog.NamedIcon)4 JFrame (javax.swing.JFrame)3 JTextField (javax.swing.JTextField)3 NamedComponentFinder (junit.extensions.jfcunit.finder.NamedComponentFinder)3 JCheckBox (javax.swing.JCheckBox)2 JComboBox (javax.swing.JComboBox)2 JmriJFrame (jmri.util.JmriJFrame)2 File (java.io.File)1 JRadioButton (javax.swing.JRadioButton)1 Block (jmri.Block)1 BlockManager (jmri.BlockManager)1