Skip to content

Commit

Permalink
Working on test code
Browse files Browse the repository at this point in the history
  • Loading branch information
geowar1 committed Nov 8, 2019
1 parent 58e3221 commit 527c39e
Show file tree
Hide file tree
Showing 8 changed files with 575 additions and 428 deletions.
Expand Up @@ -66,9 +66,9 @@ protected void enterGridSizes() {
//setup primary grid sizes
JPanel panel3 = new JPanel();
panel3.setLayout(new FlowLayout());
JLabel primaryGridSIzeLabel = new JLabel(Bundle.getMessage("PrimaryGridSize"));
panel3.add(primaryGridSIzeLabel);
primaryGridSIzeLabel.setLabelFor(primaryGridSizeField);
JLabel primaryGridSizeLabel = new JLabel(Bundle.getMessage("PrimaryGridSize"));
panel3.add(primaryGridSizeLabel);
primaryGridSizeLabel.setLabelFor(primaryGridSizeField);
panel3.add(primaryGridSizeField);
primaryGridSizeField.setToolTipText(Bundle.getMessage("PrimaryGridSizeHint"));
theContentPane.add(panel3);
Expand Down
Expand Up @@ -170,6 +170,7 @@ SecondTurnoutInvert = Invert Second Turnout
SetArcAngle = Set Arc Angle
SetArcAngleHint = Set Arc Angle
EditTurnout = Edit Turnout
EditXover = Edit Crossover
EditXing = Edit Level Crossing
EditSlip = Edit Slip
#EditTrackSegment = Edit Track Segment # already in DisplayBundle.properties
Expand Down Expand Up @@ -229,7 +230,8 @@ ReporterLocationYHint = Enter vertical coordinate of upper left corner.
AddNewLabel = Add New Label
HideTrack = Hide Track
HideTurnout = Hide Turnout
HideCrossing = Hide Crossing
HideXover = Hide Crossover
HideCrossing = Hide Level Crossing
HideSlip = Hide Slip
HiddenToolTip = Check to hide this track segment when not in edit mode.
AssignBlockToSelectionTitle = Assign Block To Selection
Expand Down
223 changes: 144 additions & 79 deletions java/src/jmri/jmrit/display/layoutEditor/LayoutTrackEditors.java

Large diffs are not rendered by default.

Expand Up @@ -62,17 +62,22 @@ public void testCtor() {
}

@Test
public void testEnterGridSizes() {
public void testEnterGridSizesCanceled() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());

enterGridSizesDialog.enterGridSizes();
JFrameOperator jFrameOperator = new JFrameOperator(Bundle.getMessage("SetGridSizes"));

new JButtonOperator(jFrameOperator, Bundle.getMessage("ButtonCancel")).doClick(); // NOI18N
Assert.assertTrue("SetGridSizes Dialog closed.", !jFrameOperator.isActive());

jFrameOperator.waitClosed(); // make sure the dialog actually closed
}

@Test
public void testEnterGridSizes() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());

enterGridSizesDialog.enterGridSizes();
jFrameOperator = new JFrameOperator(Bundle.getMessage("SetGridSizes"));
JFrameOperator jFrameOperator = new JFrameOperator(Bundle.getMessage("SetGridSizes"));

JLabelOperator primaryGridSizeLabelOperator = new JLabelOperator(
jFrameOperator, Bundle.getMessage("PrimaryGridSize"));
Expand Down Expand Up @@ -117,7 +122,7 @@ public void testEnterGridSizes() {
secondaryGridSizeTextFieldOperator.setText(Integer.toString(oldGridSize2nd ^ 1));

doneButtonOperator.doClick();
Assert.assertTrue("SetGridSizes Dialog closed.", !jFrameOperator.isActive());
jFrameOperator.waitClosed(); // make sure the dialog actually closed

Assert.assertEquals("new grid size 1st", oldGridSize1st ^ 1, layoutEditor.getGridSize());
Assert.assertEquals("new grid size 2nd", oldGridSize2nd ^ 1, layoutEditor.getGridSize2nd());
Expand Down
Expand Up @@ -62,18 +62,23 @@ public void testCtor() {
}

@Test
public void testEnterReporter() {
public void testEnterReporterCanceled() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());

enterReporterDialog.enterReporter(150, 200);
JFrameOperator jFrameOperator = new JFrameOperator(Bundle.getMessage("AddReporter"));

// cancel the dialog
new JButtonOperator(jFrameOperator, Bundle.getMessage("ButtonCancel")).doClick(); // NOI18N
Assert.assertTrue("AddReporter Dialog closed.", !jFrameOperator.isActive());
jFrameOperator.waitClosed(); // make sure the dialog actually closed
}

@Test
public void testEnterReporter() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());

enterReporterDialog.enterReporter(150, 200);
jFrameOperator = new JFrameOperator(Bundle.getMessage("AddReporter"));
JFrameOperator jFrameOperator = new JFrameOperator(Bundle.getMessage("AddReporter"));

// Try to press Add New Label button with reporter name blank... should get an error dialog
JLabelOperator reporterNameLabelOperator = new JLabelOperator(
Expand Down Expand Up @@ -113,7 +118,7 @@ public void testEnterReporter() {
JLabelOperator reporterLocationX = new JLabelOperator(
jFrameOperator, Bundle.getMessage("ReporterLocationX"));
JTextFieldOperator xLocationTextFieldOperator = new JTextFieldOperator(
(JTextField) reporterLocationX.getLabelFor());
(JTextField) reporterLocationX.getLabelFor());
xLocationTextFieldOperator.setText("NumberFormatException string");

Thread misc2 = jmri.util.swing.JemmyUtil.createModalDialogOperatorThread(
Expand All @@ -130,7 +135,7 @@ public void testEnterReporter() {
JLabelOperator reporterLocationY = new JLabelOperator(
jFrameOperator, Bundle.getMessage("ReporterLocationY"));
JTextFieldOperator yLocationTextFieldOperator = new JTextFieldOperator(
(JTextField) reporterLocationY.getLabelFor());
(JTextField) reporterLocationY.getLabelFor());
yLocationTextFieldOperator.setText("NumberFormatException string");

Thread misc3 = jmri.util.swing.JemmyUtil.createModalDialogOperatorThread(
Expand All @@ -145,6 +150,6 @@ public void testEnterReporter() {

// and everything should work!
addNewLabelButtonOperator.doClick();
Assert.assertTrue("AddReporter Dialog closed.", !jFrameOperator.isActive());
jFrameOperator.waitClosed(); // make sure the dialog actually closed
}
}

0 comments on commit 527c39e

Please sign in to comment.