/** Sets given project location /** Returns operator for browse project location button * @return JButtonOperator */ public JButtonOperator btBrowseProjectLocation() { if ( _btBrowseProjectLocation==null ) { _btBrowseProjectLocation = new JButtonOperator(this, "Browse..."); } return _btBrowseProjectLocation; }
/** clicks on "Move Down" JButton */ public void moveDownTest() { btMoveDownTest().push(); }
public static void addTomcatServer() { String appServerPath = System.getProperty("tomcat.installRoot"); if (appServerPath == null) { throw new Error("Can't add tomcat server. tomcat.installRoot property is not set."); } String addServerMenuItem = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.actions.Bundle", "LBL_Add_Server_Instance"); // Add Server... String addServerInstanceDialogTitle = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.wizard.Bundle", "LBL_ASIW_Title"); //"Add Server Instance" String nextButtonCaption = Bundle.getStringTrimmed("org.openide.Bundle", "CTL_NEXT"); String finishButtonCaption = Bundle.getStringTrimmed("org.openide.Bundle", "CTL_FINISH"); RuntimeTabOperator rto = RuntimeTabOperator.invoke(); Node serversNode = new Node(rto.getRootNode(), "Servers"); // Let's check whether GlassFish is already added if (!serversNode.isChildPresent("Tomcat")) { serversNode.performPopupActionNoBlock(addServerMenuItem); NbDialogOperator addServerInstanceDialog = new NbDialogOperator(addServerInstanceDialogTitle); new JListOperator(addServerInstanceDialog, 1).selectItem("Tomcat"); new JButtonOperator(addServerInstanceDialog, nextButtonCaption).push(); new JTextFieldOperator(addServerInstanceDialog, 1).setText(appServerPath); new JCheckBoxOperator(addServerInstanceDialog,1).changeSelection(false); new JButtonOperator(addServerInstanceDialog, finishButtonCaption).push(); } }
JButtonOperator btn = new JButtonOperator(mainFrame, new TipNameButtonFinder(buttonName)); btn.setEnabled(true); System.out.println("button is enabled = " + btn.isEnabled()); btn.push(); JDialogOperator dialog = new JDialogOperator(windowName); if (!dialog.isActive()) { this.report("----------------------------- pressing button " + dialogButton); new JButtonOperator(dialog, new TipNameButtonFinder(dialogButton)) .push(); this.report("----------------------------- button prssed " + dialogButton);
/** * Shows and hides the EnhancedPanel instance several times in a * JOptionPane and counts these events. */ @Test public void testEvents4JOptionPane() throws Exception { final CountingPanelListener l = new CountingPanelListener(); instance.addPanelListener(l); final String title = EnhancedPanelIT.class.getSimpleName(); final Runnable makeVisible = new Runnable() { @Override public void run() { JOptionPane.showMessageDialog( null, instance, title, JOptionPane.INFORMATION_MESSAGE); } }; for (int i = 1; i <= 3; i++) { runOnEdt(makeVisible); final JDialogOperator dialog = new JDialogOperator(title); // wait for JOptionPane assertEquals(i, l.shown); assertEquals(i - 1, l.hidden); final JButtonOperator button = new JButtonOperator(dialog); button.push(); button.getQueueTool().waitEmpty(WAIT_EMPTY); assertEquals(i, l.shown); assertEquals(i, l.hidden); } }
/** * This method is designed to push a button using the the Jemmy support. The * method also activates a retry mechanism until the button is successfully * pressed. * * @param windowName * The window the button exist in (Lable of the window) * @param buttonName * The button name to push * @throws Exception */ public void pushButton(ContainerOperator mainFrame, String buttonName) throws Exception { int i = 0; JButtonOperator JB = new JButtonOperator(mainFrame, new TipNameButtonFinder(buttonName)); // keep clicking the mouse till it has an effect while (JB.isEnabled() && i < retryNumber) { this.report("Pushing button " + buttonName + " Attempt-" + i); JB.clickMouse(); Thread.sleep(1000); i++; } if (i == retryNumber && JB.isEnabled()) { // If the button was not // pressed successfully this.report("Pushing button " + buttonName + " failed"); } }
public static void addTomcatServer() { String appServerPath = System.getProperty("tomcat.installRoot"); if (appServerPath == null) { throw new Error("Can't add tomcat server. tomcat.installRoot property is not set."); } String addServerMenuItem = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.actions.Bundle", "LBL_Add_Server_Instance"); // Add Server... String addServerInstanceDialogTitle = Bundle.getStringTrimmed("org.netbeans.modules.j2ee.deployment.impl.ui.wizard.Bundle", "LBL_ASIW_Title"); //"Add Server Instance" String nextButtonCaption = Bundle.getStringTrimmed("org.openide.Bundle", "CTL_NEXT"); String finishButtonCaption = Bundle.getStringTrimmed("org.openide.Bundle", "CTL_FINISH"); RuntimeTabOperator rto = RuntimeTabOperator.invoke(); Node serversNode = new Node(rto.getRootNode(), "Servers"); // Let's check whether GlassFish is already added if (!serversNode.isChildPresent("Tomcat")) { serversNode.performPopupActionNoBlock(addServerMenuItem); NbDialogOperator addServerInstanceDialog = new NbDialogOperator(addServerInstanceDialogTitle); new JListOperator(addServerInstanceDialog, 1).selectItem("Tomcat"); new JButtonOperator(addServerInstanceDialog, nextButtonCaption).push(); new JTextFieldOperator(addServerInstanceDialog, 1).setText(appServerPath); new JCheckBoxOperator(addServerInstanceDialog,1).changeSelection(false); new JButtonOperator(addServerInstanceDialog, finishButtonCaption).push(); } }
int i = 0; JButtonOperator JB = new JButtonOperator(mainFrame, new TipNameButtonFinder(buttonName)); while (JB.isEnabled() && i < retryNumber) { this.report("Pushing button " + buttonName + " Attempt-" + i); JB.clickMouse(); Thread.sleep(1000); i++; JB.clickMouse(); Thread.sleep(2000); dialogOn = mainFrame.isActive();
/** Returns operator for browse project location button * @return JButtonOperator */ public JButtonOperator btBrowseLocation() { if ( _btBrowseProjectLocation==null ) { _btBrowseProjectLocation = new JButtonOperator(this, "Browse..."); } return _btBrowseProjectLocation; }
new JButtonOperator(addServerInstanceDialog,nextButtonCaption).push(); new JButtonOperator(addServerInstanceDialog,finishButtonCaption).push();
/** clicks on "Browse..." JButton */ public void browse() { btBrowse().push(); }
/** Returns operator for browse project folder button * @return JButtonOperator */ public JButtonOperator btBrowseFolder() { if ( _btBrowseFolder==null ) { _btBrowseFolder = new JButtonOperator(this, "Browse:", 1); } return _btBrowseFolder; }
NbDialogOperator addServerInstanceDialog = new NbDialogOperator(addServerInstanceDialogTitle); new JListOperator(addServerInstanceDialog, 1).selectItem(glassFishV3ListItem); new JButtonOperator(addServerInstanceDialog, nextButtonCaption).push(); new JTextFieldOperator(addServerInstanceDialog).enterText(appServerPath); new JButtonOperator(addServerInstanceDialog, finishButtonCaption).push();
/** clicks on "Remove" JButton */ public void removeSrc() { btRemoveSrc().push(); }
/** Tries to find "Add..." JButton in this dialog. * @return JButtonOperator */ public JButtonOperator btAdd() { if (_btAdd==null) { _btAdd = new JButtonOperator(this, "Add..."); } return _btAdd; }
@SuppressWarnings("ResultOfObjectAllocationIgnored") @Test public void testTabbedPane() { final ComponentChooser keyFileChooser = new NameComponentChooser("keyFileChooser"); new JTabbedPaneOperator(frame).selectPage(AuthenticationPanel.AUTH_KEY_FILE); // select tab for key files new JButtonOperator(frame, keyFileChooser).push(); // open file chooser JFileChooserOperator fc = new TFileChooserOperator(frame); fc.cancel(); new JTabbedPaneOperator(frame).selectPage(AuthenticationPanel.AUTH_PASSWD); // select tab for passwords new JLabelOperator(frame, LABEL_TEXT); fc = null; new JTabbedPaneOperator(frame).selectPage(AuthenticationPanel.AUTH_KEY_FILE); // select tab for key files new JButtonOperator(frame, keyFileChooser).push(); // open file chooser fc = new TFileChooserOperator(frame); final File file = new File("test"); fc.setSelectedFile(file); fc.approve(); fc.getQueueTool().waitEmpty(WAIT_EMPTY); JTextFieldOperator tf = new JTextFieldOperator(frame); assertEquals(file.getPath(), tf.getText()); fc = null; new JTabbedPaneOperator(frame).selectPage(AuthenticationPanel.AUTH_PASSWD); // select tab for passwords new JLabelOperator(frame, LABEL_TEXT); } }
/** clicks on "Move Down" JButton */ public void moveDownSrc() { btMoveDownSrc().push(); }
/** Tries to find "Move Up" JButton in this dialog. * @return JButtonOperator */ public JButtonOperator btMoveUpSrc() { if (_btMoveUpSrc==null) { String moveUp = Bundle.getStringTrimmed( "org.netbeans.modules.java.freeform.ui.Bundle", "BTN_SourceFoldersPanel_upFolder"); _btMoveUpSrc = new JButtonOperator(this, moveUp); } return _btMoveUpSrc; }
@Test public void testKeyFile() throws InterruptedException { final SafePbeParameters<?, ?> param = newPbeParameters(); new JTabbedPaneOperator(frame).selectPage(AuthenticationPanel.AUTH_KEY_FILE); // select tab for key files new JButtonOperator(frame, KEY_FILE_CHOOSER).push(); // open file chooser JFileChooserOperator fc = new TFileChooserOperator(frame); fc.chooseFile(NON_EXISTING_FILE); fc.getQueueTool().waitEmpty(WAIT_EMPTY); assertTrue(isBlank(error.getText())); assertFalse(updateParam(param)); assertFalse(isBlank(error.getText())); new JButtonOperator(frame, KEY_FILE_CHOOSER).push(); // open file chooser fc = new TFileChooserOperator(frame); final List<File> files = Arrays.asList(fc.getFiles()); Collections.shuffle(files); for (final File file : files) { if (!file.isFile()) continue; fc.setSelectedFile(file); fc.approve(); // close file chooser if (updateParam(param)) { assertNotNull(param.getPassword()); assertTrue(isBlank(error.getText())); } else { assertFalse(isBlank(error.getText())); } return; } fc.cancel(); // close file chooser }
/** clicks on "Browse..." JButton */ public void browse() { btBrowse().push(); }