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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations