Java Code Examples for org.netbeans.jemmy.Waiter#waitAction()
The following examples show how to use
org.netbeans.jemmy.Waiter#waitAction() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProgressOperator.java From netbeans with Apache License 2.0 | 6 votes |
/** Wait process with given name finished. */ public static void waitFinished(final String name, long timeout) { try { Waiter waiter = new Waiter(new Waitable() { public Object actionProduced(Object anObject) { return processInProgress(name) ? null : Boolean.TRUE; } public String getDescription() { return("Wait process "+name+" is finished."); } }); waiter.getTimeouts().setTimeout("Waiter.WaitingTime", timeout); waiter.waitAction(null); } catch (InterruptedException e) { throw new JemmyException("Interrupted.", e); } }
Example 2
Source File: ProgressSupport.java From netbeans with Apache License 2.0 | 6 votes |
/** Wait process started. */ public static void waitStarted(final String name, long timeout) { try { Waiter waiter = new Waiter(new Waitable() { public Object actionProduced(Object anObject) { return processInProgress(name) ? Boolean.TRUE : null; } public String getDescription() { return("Wait process "+name+" is started."); } }); waiter.getTimeouts().setTimeout("Waiter.WaitingTime", timeout); waiter.waitAction(null); } catch (InterruptedException e) { throw new JemmyException("Interrupted.", e); } }
Example 3
Source File: ComponentOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Waits for this Component has the keyboard focus. * * @throws TimeoutExpiredException */ public void waitHasFocus() { Waiter<String, Void> focusWaiter = new Waiter<>(new Waitable<String, Void>() { @Override public String actionProduced(Void obj) { return hasFocus() ? "" : null; } @Override public String getDescription() { return "Wait component has focus"; } @Override public String toString() { return "ComponentOperator.waitHasFocus.Waitable{description = " + getDescription() + '}'; } }); focusWaiter.setTimeoutsToCloneOf(timeouts, "ComponentOperator.WaitFocusTimeout"); focusWaiter.setOutput(output.createErrorOutput()); try { focusWaiter.waitAction(null); } catch (InterruptedException e) { output.printStackTrace(e); } }
Example 4
Source File: JTreeOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
private TreePath findPathPrimitive(TreePath path, TreePathChooser chooser, Waiter<Object[], Object[]> loadedWaiter) { if (!isExpanded(path)) { if (!isPathSelected(path)) { clickOnPath(path); } expandPath(path); } Object[] waitParam = {chooser, path}; Object[] waitResult = null; try { waitResult = loadedWaiter.waitAction(waitParam); } catch (InterruptedException e) { output.printStackTrace(e); return null; } TreePath nextPath = (TreePath) waitResult[0]; boolean found = (Boolean) waitResult[1]; if (found) { return nextPath; } else { return findPathPrimitive(nextPath, chooser, loadedWaiter); } }
Example 5
Source File: WidgetOperator.java From netbeans with Apache License 2.0 | 6 votes |
/** * Waits for index-th widget specified by WidgetChooser under given parent * widget. * * @param parentWidget parent Widget * @param widgetChooser WidgetChooser implementation * @param index index to be found * @return Widget instance if found or throws JemmyException if not found. */ private static Widget waitWidget(final Widget parentWidget, final WidgetChooser widgetChooser, final int index) { try { Waiter waiter = new Waiter(new Waitable() { @Override public Object actionProduced(Object obj) { return findWidget(parentWidget, widgetChooser, index); } @Override public String getDescription() { return (index > 0 ? index + "-th " : "") + (widgetChooser == null ? "Widget " : widgetChooser.getDescription()) + " displayed"; } }); Timeouts timeouts = JemmyProperties.getCurrentTimeouts().cloneThis(); timeouts.setTimeout("Waiter.WaitingTime", timeouts.getTimeout("WidgetOperator.WaitWidgetTimeout")); waiter.setTimeouts(timeouts); waiter.setOutput(JemmyProperties.getCurrentOutput()); return (Widget) waiter.waitAction(null); } catch (InterruptedException ex) { throw new JemmyException("Interrupted.", ex); } }
Example 6
Source File: PropertySheetOperator.java From netbeans with Apache License 2.0 | 6 votes |
/** Waits for property sheet anywhere in IDE. First it tries to find TopComponent * representing global properties and if not found, it tries to find * property sheet in all dialogs owned by Main Window or other frames. * @param sheetName name of property sheet * @param index index of property sheet */ private static JComponent waitPropertySheet(final String sheetName, final int index) { try { Waiter waiter = new Waiter(new Waitable() { public Object actionProduced(Object obj) { return findPropertySheet(sheetName, index); } public String getDescription() { return("Wait PropertySheet with name="+sheetName+ " index="+index+" loaded"); } }); Timeouts times = JemmyProperties.getCurrentTimeouts().cloneThis(); times.setTimeout("Waiter.WaitingTime", times.getTimeout("ComponentOperator.WaitComponentTimeout")); waiter.setTimeouts(times); waiter.setOutput(JemmyProperties.getCurrentOutput()); return (JComponent)waiter.waitAction(null); } catch(InterruptedException e) { throw new JemmyException("Interrupted.", e); } }
Example 7
Source File: NodeUtils.java From netbeans with Apache License 2.0 | 6 votes |
/** Test cut */ public static void testClipboard(final Object clipboard1) { Waiter waiter = new Waiter(new Waitable() { public Object actionProduced(Object obj) { Object clipboard2 = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); return clipboard1 != clipboard2 ? Boolean.TRUE : null; } public String getDescription() { return("Wait clipboard contains data"); // NOI18N } }); try { waiter.waitAction(null); } catch (InterruptedException e) { throw new JemmyException("Waiting interrupted.", e); } }
Example 8
Source File: JavaScriptDebugger.java From netbeans with Apache License 2.0 | 6 votes |
/** * Waits for variable to appear in Variables window (since Variables is * minimized by default, there could be "loading" message). * * @param expectedVariable */ public void waitForVariable(final String expectedVariable) { try { Waiter waiter = new Waiter(new Waitable() { @Override public Object actionProduced(Object obj) { try { VariablesOperator vo = new VariablesOperator("Variables"); return ((Map<String, Variable>) vo.getVariables()).get(expectedVariable) != null ? Boolean.TRUE : null; } catch (Exception ex) { return null; } } @Override public String getDescription() { return ("Wait for Variables to contain " + expectedVariable); } }); waiter.getTimeouts().setTimeout("Waiter.WaitingTime", VARIABLES_TIMEOUTS); waiter.waitAction(null); } catch (InterruptedException e) { } }
Example 9
Source File: ProgressOperator.java From netbeans with Apache License 2.0 | 6 votes |
/** Wait process with given name finished. */ public static void waitFinished(final String name, long timeout) { try { Waiter waiter = new Waiter(new Waitable() { public Object actionProduced(Object anObject) { return processInProgress(name) ? null : Boolean.TRUE; } public String getDescription() { return("Wait process "+name+" is finished."); } }); waiter.getTimeouts().setTimeout("Waiter.WaitingTime", timeout); waiter.waitAction(null); } catch (InterruptedException e) { throw new JemmyException("Interrupted.", e); } }
Example 10
Source File: ProgressOperator.java From netbeans with Apache License 2.0 | 6 votes |
/** Wait process started. */ public static void waitStarted(final String name, long timeout) { try { Waiter waiter = new Waiter(new Waitable() { public Object actionProduced(Object anObject) { return processInProgress(name) ? Boolean.TRUE : null; } public String getDescription() { return("Wait process "+name+" is started."); } }); waiter.getTimeouts().setTimeout("Waiter.WaitingTime", timeout); waiter.waitAction(null); } catch (InterruptedException e) { throw new JemmyException("Interrupted.", e); } }
Example 11
Source File: CutActionTest.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void tearDown() throws Exception { Waiter waiter = new Waiter(new Waitable() { @Override public Object actionProduced(Object obj) { Object clipboard2 = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); return clipboard1 != clipboard2 ? Boolean.TRUE : null; } @Override public String getDescription() { return ("Wait clipboard contains data"); } }); waiter.waitAction(null); }
Example 12
Source File: AbstractJ2eeFile.java From netbeans with Apache License 2.0 | 6 votes |
protected boolean srcFileExist(String name) { boolean retVal = false; File f = new File(FileUtil.toFile(prjRoot), srcRoot); try { final File ff = new File(f, name); //System.err.println(ff.getAbsolutePath()); //System.err.println("srcEx: " + ff.exists()); Waiter waiter = new Waiter(new Waitable() { @Override public Object actionProduced(Object anObject) { return ff.exists() ? Boolean.TRUE : null; } @Override public String getDescription() { return "file " + ff + " exists"; } }); waiter.waitAction(null); retVal = ff.exists(); } catch (Exception e) { } return retVal; }
Example 13
Source File: QueueJMenuDriver.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private JMenuItem runAction(final OneReleaseAction action, ComponentOperator env, long waitingTime, final String description) { Waiter<MenuElement, Void> waiter = new Waiter<>(new Waitable<MenuElement, Void>() { @Override public MenuElement actionProduced(Void param) { return queueTool.invokeSmoothly(action); } @Override public String getDescription() { return description; } @Override public String toString() { return "runAction.Waiter{description = " + getDescription() + '}'; } }); waiter.setOutput(env.getOutput().createErrorOutput()); waiter.setTimeouts(env.getTimeouts().cloneThis()); waiter.getTimeouts().setTimeout("Waiter.WaitingTime", waitingTime); waiter.getTimeouts().setTimeout("Waiter.TimeDelta", 100); //1.5 workaround if (System.getProperty("java.specification.version").compareTo("1.4") > 0) { queueTool.setOutput(env.getOutput().createErrorOutput()); queueTool.waitEmpty(10); queueTool.waitEmpty(10); queueTool.waitEmpty(10); } //end of 1.5 workaround try { return (JMenuItem) waiter.waitAction(null); } catch (InterruptedException e) { action.stop(); throw (new JemmyException("Waiting has been interrupted", e)); } }
Example 14
Source File: DefaultJMenuDriver.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
protected JMenuItem waitItem(ComponentOperator oper, MenuElement element, PathChooser chooser, int depth) { Waiter<MenuElement, Void> waiter = new Waiter<>(new JMenuItemWaiter(element, chooser, depth)); waiter.setOutput(oper.getOutput().createErrorOutput()); waiter.setTimeouts(oper.getTimeouts()); try { return (JMenuItem) waiter.waitAction(null); } catch (InterruptedException e) { throw (new JemmyException("Waiting has been interrupted", e)); } }
Example 15
Source File: ComponentOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Waits for the component to be enabled. * * @throws TimeoutExpiredException * @throws InterruptedException */ public void waitComponentEnabled() throws InterruptedException { Waiter<Component, Component> waiter = new Waiter<>(new Waitable<Component, Component>() { @Override public Component actionProduced(Component obj) { if (obj.isEnabled()) { return obj; } else { return null; } } @Override public String getDescription() { return ("Component enabled: " + getSource().getClass().toString()); } @Override public String toString() { return "ComponentOperator.waitComponentEnabled.Waitable{description = " + getDescription() + '}'; } }); waiter.setOutput(output); waiter.setTimeoutsToCloneOf(timeouts, "ComponentOperator.WaitComponentEnabledTimeout"); waiter.waitAction(getSource()); }
Example 16
Source File: Operator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Waits a state specified by a ComponentChooser instance. * * @param state a ComponentChooser defining the state criteria. * @throws TimeoutExpiredException if the state has not achieved in a value * defined by {@code "ComponentOperator.WaitStateTimeout"} */ public void waitState(final ComponentChooser state) { Waiter<String, Void> stateWaiter = new Waiter<>(new Waitable<String, Void>() { @Override public String actionProduced(Void obj) { return state.checkComponent(getSource()) ? "" : null; } @Override public String getDescription() { return "Wait \"" + state.getDescription() + "\" state to be reached"; } @Override public String toString() { return "Operator.waitState.Waitable{description = " + getDescription() + '}'; } }); stateWaiter.setTimeoutsToCloneOf(getTimeouts(), "ComponentOperator.WaitStateTimeout"); stateWaiter.setOutput(getOutput().createErrorOutput()); try { stateWaiter.waitAction(null); } catch (InterruptedException e) { throw (new JemmyException("Waiting of \"" + state.getDescription() + "\" state has been interrupted!")); } }
Example 17
Source File: JTreeOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns the root of the tree. * * @return tree root. * @throws TimeoutExpiredException */ public Object getRoot() { Waiter<Object, Void> rootWaiter = new Waiter<>(new Waitable<Object, Void>() { @Override public Object actionProduced(Void obj) { Object root = getModel().getRoot(); if (root == null || root.toString().equals("null")) { return null; } else { return root; } } @Override public String getDescription() { return "Wait root node"; } @Override public String toString() { return "JTreeOperator.getRoot.Waitable{description = " + getDescription() + '}'; } }); rootWaiter.setTimeoutsToCloneOf(timeouts, "JTreeOperator.WaitNodeVisibleTimeout"); rootWaiter.setOutput(output.createErrorOutput()); try { return rootWaiter.waitAction(null); } catch (InterruptedException e) { output.printStackTrace(e); return null; } }
Example 18
Source File: JProgressBarOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Waits for criteria defined by {@code chooser} to be reached. * * @param chooser an object specifying waiting criteria. * @see #waitValue(int) * @deprecated Use waitState(ComponentChooser) instead. */ @Deprecated public void waitValue(final ValueChooser chooser) { output.printLine("Wait \"" + chooser.getDescription() + "\" value in progressbar\n : " + toStringSource()); output.printGolden("Wait \"" + chooser.getDescription() + "\" value in progressbar"); Waiter<String, Void> wt = new Waiter<>(new Waitable<String, Void>() { @Override public String actionProduced(Void obj) { return (chooser.checkValue(((JProgressBar) getSource()).getValue()) ? "" : null); } @Override public String getDescription() { return "\"" + chooser.getDescription() + "\" value"; } @Override public String toString() { return "JProgressBarOperator.waitValue.Waitable{description = " + getDescription() + '}'; } }); wt.setTimeoutsToCloneOf(timeouts, "JProgressBarOperator.WaitValueTimeout"); wt.setOutput(output.createErrorOutput()); try { wt.waitAction(null); } catch (InterruptedException e) { throw (new JemmyException("Exception during progressbar value waiting", e)); } }
Example 19
Source File: JFileChooserOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private int findFileIndex(final String file, final StringComparator comparator) { Waiter<Integer, Void> fileWaiter = new Waiter<>(new Waitable<Integer, Void>() { @Override public Integer actionProduced(Void obj) { File[] files = getFiles(); for (int i = 0; i < files.length; i++) { if (comparator.equals(files[i].getName(), file)) { return i; } } return null; } @Override public String getDescription() { return "\"" + file + "\" file to be displayed"; } @Override public String toString() { return "JFileChooserOperator.findFileIndex.Waitable{description = " + getDescription() + '}'; } }); fileWaiter.setOutput(getOutput().createErrorOutput()); fileWaiter.setTimeoutsToCloneOf(getTimeouts(), "JFileChooserOperator.WaitListPaintedTimeout"); try { return fileWaiter.waitAction(null); } catch (InterruptedException e) { throw (new JemmyException("Waiting has been interrupted!")); } }
Example 20
Source File: NewProjectWizardsTest.java From netbeans with Apache License 2.0 | 4 votes |
private void checkProjectStructure(final int prjType) { final RequiredFiles r; switch (prjType) { case EJB: r = readRF("structures/ejbProject" + version + ".str"); break; case WEB: r = readRF("structures/webProject" + version + ".str"); break; case EAR: r = readRF("structures/defEAR" + version + ".str"); break; case APP_CLIENT: r = readRF("structures/carProject" + version + ".str"); break; default: throw new IllegalArgumentException(); } final String projectPath = projectLocation + File.separatorChar + projectName; final AtomicReference<Set> missingRef = new AtomicReference<Set>(); final AtomicReference<Set> extraRef = new AtomicReference<Set>(); Waiter waiter = new Waiter(new Waitable() { @Override public Object actionProduced(Object obj) { Set<String> expected = r.getRequiredFiles(); Set<String> actual = J2eeProjectSupport.getFileSet(projectPath); reporter.ref("Project: " + projectPath); reporter.ref("Expected: " + expected); reporter.ref("Real: " + actual); Set missing = getDifference(actual, expected); missingRef.set(missing); Set extra = getDifference(expected, actual); extraRef.set(extra); if (missing.isEmpty() && extra.isEmpty()) { return Boolean.TRUE; } else { new EventTool().waitNoEvent(2000); return null; } } @Override public String getDescription() { return "wait for project files"; } }); try { waiter.waitAction(null); } catch (InterruptedException ex) { //do nothing } catch (TimeoutExpiredException tee) { assertTrue("Files: " + missingRef.get() + " are missing in project at: " + projectPath, missingRef.get().isEmpty()); assertTrue("Files: " + extraRef.get() + " are new in project: " + projectPath, extraRef.get().isEmpty()); } }