use of org.netbeans.jemmy.operators.JDialogOperator in project JMRI by JMRI.
the class TurnoutTableActionTest method testAddAndInvoke.
/**
* Check Turnout Table GUI, menus and graphic state presentation.
* @since 4.7.4
*/
@Test
public void testAddAndInvoke() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
// show table
a.actionPerformed(null);
// create 2 turnouts and see if they exist
Turnout it1 = InstanceManager.turnoutManagerInstance().provideTurnout("IT1");
Turnout it2 = InstanceManager.turnoutManagerInstance().provideTurnout("IT2");
it1.setCommandedState(Turnout.THROWN);
it2.setCommandedState(Turnout.CLOSED);
// set graphic state column display preference to false, read by createModel()
InstanceManager.getDefault(GuiLafPreferencesManager.class).setGraphicTableState(false);
TurnoutTableAction _tTable;
_tTable = new TurnoutTableAction();
Assert.assertNotNull("found TurnoutTable frame", _tTable);
// prevent there are 2 menubars with the same name
_tTable.dispose();
// set to true, use icons
InstanceManager.getDefault(GuiLafPreferencesManager.class).setGraphicTableState(true);
TurnoutTableAction _t1Table;
_t1Table = new TurnoutTableAction();
Assert.assertNotNull("found TurnoutTable1 frame", _t1Table);
JFrame t1Frame = JFrameOperator.waitJFrame(Bundle.getMessage("TitleTurnoutTable"), true, true);
// test Add pane
_t1Table.addPressed(null);
JFrame af = JFrameOperator.waitJFrame(Bundle.getMessage("TitleAddTurnout"), true, true);
Assert.assertNotNull("found Add frame", af);
// close Add pane
_t1Table.cancelPressed(null);
// more Turnout Add pane tests are in TurnoutTableWindowTest
// Open Automation pane to test Automation menu
jmri.jmrit.turnoutoperations.TurnoutOperationFrame tof = new jmri.jmrit.turnoutoperations.TurnoutOperationFrame(null);
// create dialog (bypassing menu)
// TODO I18N using Bundle
JDialogOperator am = new JDialogOperator("Turnout Operation Editor");
Assert.assertNotNull("found Automation menu dialog", am);
// close pane
JButtonOperator jbo = new JButtonOperator(am, "OK");
// instead of .push();
jbo.pushNoBlock();
// Open Speed pane to test Speed menu, which displays a JOptionPane
//System.out.println("Speed pane started at " + java.time.LocalTime.now()); // debug
// method 1: open as method
//_t1Table.setDefaultSpeeds(null); // create dialog (bypassing menu, but is not found)
//_t1Table.setDefaultSpeeds(t1Frame); // create dialog by frame (bypassing menu, but is also not found)
// JFrameOperator main = new JFrameOperator(Bundle.getMessage("TitleTurnoutTable")); // create dialog (through menu)
// method 2: Alternatively, used GUI menu to open Speeds pane:
// pushMenuNoBlock is used, because dialog is modal
// JMenuBarOperator mainbar = new JMenuBarOperator(main);
// mainbar.pushMenuNoBlock("Speeds"); // stops at top level
// JMenuOperator jmo = new JMenuOperator(mainbar, "Speeds");
// JPopupMenu jpm = jmo.getPopupMenu();
// JMenuItem firstMenuItem = (JMenuItem)jpm.getComponent(0); // first item is [Defaults...]
// JMenuItemOperator jmio = new JMenuItemOperator(firstMenuItem);
// jmio.pushNoBlock();
// wait for Speeds dialog
// for Jemmy to work, we need the Turnout Speeds pane inside a JDialog
// TODO activate test when we manage to find pane:
// JDialogOperator as = new JDialogOperator(Bundle.getMessage("TurnoutGlobalSpeedMessageTitle"));
// Assert.assertNotNull("found Speeds menu dialog", as);
//System.out.println("Speed pane found at " + java.time.LocalTime.now()); // debug
// close pane
// JButtonOperator jbs = new JButtonOperator(as, "OK");
// jbs.pushNoBlock();
// clean up
af.dispose();
am.dispose();
//as.dispose(); // uncomment when test is Speeds menu activated
tof.dispose();
_t1Table.dispose();
}
use of org.netbeans.jemmy.operators.JDialogOperator in project JMRI by JMRI.
the class AboutDialogTest method testShowAndClose.
@Test
public void testShowAndClose() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
AboutDialog dialog = new AboutDialog(null, true);
new Thread(() -> {
// constructor for jdo will wait until the dialog is visible
JDialogOperator jdo = new JDialogOperator(Bundle.getMessage("TitleAbout", jmri.Application.getApplicationName()));
jdo.close();
}).start();
ThreadingUtil.runOnGUI(() -> {
dialog.setVisible(true);
});
JUnitUtil.waitFor(() -> {
return !dialog.isVisible();
}, "About dialog did not close");
}
use of org.netbeans.jemmy.operators.JDialogOperator in project JMRI by JMRI.
the class OperationsSwingTestCase method pressDialogButton.
protected void pressDialogButton(JmriJFrame f, String buttonName) {
JFrameOperator jfo = new JFrameOperator(f);
// wait for the first dialog.
JDialogOperator jdo = new JDialogOperator(jfo, 1);
NameComponentChooser bChooser = new NameComponentChooser(buttonName);
//JButtonOperator jbo = new JButtonOperator(jdo,buttonName);
JButtonOperator jbo = new JButtonOperator(jdo, bChooser);
// Click button
jbo.push();
}
Aggregations