Skip to content

Commit

Permalink
Created TRL/Rules tests; added @OverRide for Find and Replace Done bu…
Browse files Browse the repository at this point in the history
…tton change; added two more mininal class tests.
  • Loading branch information
dsand47 committed Feb 24, 2019
1 parent b1b98ef commit 1ed21d2
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 38 deletions.
17 changes: 10 additions & 7 deletions java/src/jmri/jmrit/ctc/editor/gui/DlgFindAndReplace.java
Expand Up @@ -28,9 +28,9 @@ public class DlgFindAndReplace extends javax.swing.JDialog {
private final CTCSerialData _mCTCSerialData;
private final DefaultTableModel _mDefaultTableModel;
private String _mSearchForTextFrozen = "";

private ArrayList<FindAndReplace.SearchResults> _mSearchResults = null;

public DlgFindAndReplace(java.awt.Frame parent, boolean modal, AwtWindowProperties awtWindowProperties, CTCSerialData ctcSerialData) {
super(parent, modal);
initComponents();
Expand All @@ -39,7 +39,7 @@ public DlgFindAndReplace(java.awt.Frame parent, boolean modal, AwtWindowProperti
_mDefaultTableModel = (DefaultTableModel)_mResults.getModel(); // We know this is the type by default construction!
_mContains.setSelected(true);
_mSearchForText.requestFocusInWindow();
_mAwtWindowProperties.setWindowState(this, FORM_PROPERTIES);
_mAwtWindowProperties.setWindowState(this, FORM_PROPERTIES);
TableColumnModel tableColumnModel = _mResults.getColumnModel();
_mResults.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // Otherwise these don't work:
tableColumnModel.getColumn(0).setPreferredWidth(60);
Expand All @@ -50,7 +50,7 @@ public DlgFindAndReplace(java.awt.Frame parent, boolean modal, AwtWindowProperti
_mSelectDeselectAll.setText(Bundle.getMessage("InfoDlgFindSelectAll")); // NOI18N
CommonSubs.numberButtonGroup(_mHowReplace);
CommonSubs.setButtonSelected(_mHowReplace, 1);

_mResults.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent event) {
if (!event.getValueIsAdjusting()) {
Expand All @@ -59,7 +59,7 @@ public void valueChanged(ListSelectionEvent event) {
}
});
}

private void updateSelectionCount() {
int selectionCount = _mResults.getSelectedRows().length;
_mCountSelected.setText(Bundle.getMessage("InfoDlgFindCount") + " " + Integer.toString(selectionCount)); // NOI18N
Expand Down Expand Up @@ -104,6 +104,7 @@ private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
setTitle(Bundle.getMessage("TitleDlgFind"));
addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent evt) {
formWindowClosing(evt);
}
Expand Down Expand Up @@ -170,10 +171,12 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
false, false, false
};

@Override
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}

@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
Expand Down Expand Up @@ -335,7 +338,7 @@ private void _mSelectDeselectAllActionPerformed(java.awt.event.ActionEvent evt)
_mResults.setRowSelectionInterval(0, _mResults.getRowCount() - 1);
}
_mSelectDeselectAll.setText(Bundle.getMessage("InfoDlgFindDeselectAll")); // NOI18N
} else {
} else {
_mResults.clearSelection();
_mSelectDeselectAll.setText(Bundle.getMessage("InfoDlgFindSelectAll")); // NOI18N
}
Expand All @@ -349,7 +352,7 @@ private void _mReplaceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR
for (int selectedRow : selectedRows) {
selectedSearchResults.add(_mSearchResults.get(selectedRow));
}
// Perform the action the user requested:
// Perform the action the user requested:
switch (ProjectsCommonSubs.getButtonSelectedInt(_mHowReplace)) {
case 0: // Replace completely:
for (FindAndReplace.SearchResults selectedSearchResult : selectedSearchResults) {
Expand Down
42 changes: 13 additions & 29 deletions java/test/jmri/jmrit/ctc/editor/CtcEditorActionTest.java
Expand Up @@ -200,35 +200,14 @@ void editTests() {
jbIL.doClick();
JUnitUtil.waitFor(()->{return !(editIL.isAlive());}, "editIL finished"); // NOI18N

// TRL button - requires special handling.
// First a left/right Edit has to be selected which gets the rules dialog.
// After exiting the rules dialog, the initial dialog returns and needs OK.
// 1 - TRL, select edit
// 2 - Rules, select save close, may need focus
// 3 - TRL, select OK

// jlo.clickOnItem(0, 1);
// JButtonOperator jbTRL = new JButtonOperator(_jfo, "Edit", 3);
// jbTRL.doClick();
// JDialogOperator jdo = new JDialogOperator("TitleDlgTRL");
// JButtonOperator jbo = new JButtonOperator(jdo, Bundle.getMessage("ButtonOK"));
// new EventTool().waitNoEvent(2000);
// jbo.pushNoBlock();

// Thread editTRL1 = createModalDialogOperatorThread(Bundle.getMessage("TitleDlgTRL"), "Edit", "editTRL1"); // NOI18N
// Thread editRules = createModalDialogOperatorThread(Bundle.getMessage("TitleDlgTRLRules"), Bundle.getMessage("ButtonSaveClose"), "editRules"); // NOI18N
// // JUnitUtil.waitFor(()->{return !(editTRL1.isAlive());}, "editTRL 1 finished"); // NOI18N
// JUnitUtil.waitFor(()->{return !(editRules.isAlive());}, "editRules finished"); // NOI18N


// Thread editRules = createModalDialogOperatorThread(Bundle.getMessage("TitleDlgTUL"), Bundle.getMessage("ButtonSaveClose"), "editRules"); // NOI18N
// jbTRL.doClick();
// JUnitUtil.waitFor(()->{return !(editTRL.isAlive());}, "editTRL finished"); // NOI18N
// JButtonOperator jbTRL = new JButtonOperator(_jfo, "Edit", 3);
// jbTRL.doClick();
// JUnitUtil.waitFor(()->{return !(editTRL.isAlive());}, "editTRL finished"); // NOI18N


// TRL button -- Special handling required since the TRL dialog starts the Rules dialog.
// This test should also be the last one.
jlo.clickOnItem(0, 1);
Thread editRules= createModalDialogOperatorThread("Edit Right traffic locking rules", Bundle.getMessage("ButtonSaveClose"), "editRules"); // NOI18N
Thread editTRL= createModalDialogOperatorThread(Bundle.getMessage("TitleDlgTRL"), Bundle.getMessage("ButtonOK"), "editTRL"); // NOI18N
JButtonOperator jbTRL = new JButtonOperator(_jfo, Bundle.getMessage("ButtonEdit"), 3);
jbTRL.doClick();
JUnitUtil.waitFor(()->{return !(editTRL.isAlive());}, "editTRL finished"); // NOI18N

}

Expand All @@ -238,6 +217,11 @@ Thread createModalDialogOperatorThread(String dialogTitle, String buttonText, St
JDialogOperator jdo = new JDialogOperator(dialogTitle);
JButtonOperator jbo = new JButtonOperator(jdo, buttonText);
// new EventTool().waitNoEvent(2000);
if (threadName.equals("editTRL")) {
// Start the rules dialog
JButtonOperator jbTRL = new JButtonOperator(jdo, Bundle.getMessage("ButtonEdit"), 0);
jbTRL.doClick();
}
jbo.pushNoBlock();
});
t.setName(dialogTitle + " Close Dialog Thread: " + threadName); // NOI18N
Expand Down
25 changes: 25 additions & 0 deletions java/test/jmri/jmrit/ctc/editor/code/ClassCompareContentsTest.java
@@ -0,0 +1,25 @@
package jmri.jmrit.ctc.editor.code;

import org.junit.*;

/*
* Tests for the ClassCompareContents Class
* @author Dave Sand Copyright (C) 2019
*/
public class ClassCompareContentsTest {

@Test
public void testCtor() {
Assert.assertNotNull("ClassCompareContents Constructor Return", new ClassCompareContents());
}

@Before
public void setUp() {
jmri.util.JUnitUtil.setUp();
}

@After
public void tearDown() {
jmri.util.JUnitUtil.tearDown();
}
}
25 changes: 25 additions & 0 deletions java/test/jmri/jmrit/ctc/editor/code/FindAndReplaceTest.java
@@ -0,0 +1,25 @@
package jmri.jmrit.ctc.editor.code;

import org.junit.*;

/*
* Tests for the FindAndReplace Class
* @author Dave Sand Copyright (C) 2019
*/
public class FindAndReplaceTest {

@Test
public void testCtor() {
Assert.assertNotNull("FindAndReplace Constructor Return", new FindAndReplace());
}

@Before
public void setUp() {
jmri.util.JUnitUtil.setUp();
}

@After
public void tearDown() {
jmri.util.JUnitUtil.tearDown();
}
}
4 changes: 2 additions & 2 deletions java/test/jmri/jmrit/ctc/editor/code/PackageTest.java
Expand Up @@ -13,15 +13,15 @@
// AwtWindowPropertiesTest.class,
BundleTest.class,
// CheckJMRIObjectTest.class,
// ClassCompareContentsTest.class,
ClassCompareContentsTest.class,
// CodeButtonHandlerDataRoutinesTest.class,
// ColumnsTest.class,
// CommonSubsTest.class,
// CreateGUIObjectsXMLFileTest.class,
// CreateInternalSensorsXMLFileTest.class,
// CreateVirtualSignalsXMLFileTest.class,
// CreateXMLFilesTest.class,
// FindAndReplaceTest.class,
FindAndReplaceTest.class,
// InternalSensorManagerTest.class,
// OriginalCopyTest.class,
// ProgramPropertiesTest.class
Expand Down

0 comments on commit 1ed21d2

Please sign in to comment.