Package org.netbeans.jemmy

Examples of org.netbeans.jemmy.Waiter


        }
        return(result);
    }

    private JMenuItem runAction(final OneReleaseAction action, ComponentOperator env, long waitingTime, final String description) {
        Waiter waiter = new Waiter(new Waitable() {
                public Object actionProduced(Object param) {
                    return(queueTool.invokeSmoothly(action));
                }
                public String getDescription() {
                    return(description);
                }
            });
        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));
        }
    }
View Full Code Here


    protected static Component waitComponent(final Container cont,
               final ComponentChooser chooser,
               final int index,
               Timeouts timeouts, final TestOut output) {
  try {
      Waiter waiter = new Waiter(new Waitable() {
        public Object actionProduced(Object obj) {
      return(findComponent(cont, new VisibleComponentFinder(chooser), index,
               output.createErrorOutput()));
        }
        public String getDescription() {
      return("Wait " + chooser.getDescription() + " loaded");
        }
    });
      Timeouts times = timeouts.cloneThis();
      times.setTimeout("Waiter.WaitingTime", times.getTimeout("ComponentOperator.WaitComponentTimeout"));
      waiter.setTimeouts(times);
      waiter.setOutput(output);
      return((Component)waiter.waitAction(null));
  } catch(InterruptedException e) {
      return(null);
  }
    }
View Full Code Here

     * Waits for the component to be enabled.
     * @throws TimeoutExpiredException
     * @throws InterruptedException
     */
    public void waitComponentEnabled() throws InterruptedException{
  Waiter waiter = new Waiter(new Waitable() {
      public Object actionProduced(Object obj) {
    if(((Component)obj).isEnabled()) {
        return(obj);
    } else {
        return(null);
    }
      }
      public String getDescription() {
    return("Component enabled: " +
           getSource().getClass().toString());
      }
  });
  waiter.setOutput(output);
  Timeouts times = timeouts.cloneThis();
  times.setTimeout("Waiter.WaitingTime",
       times.getTimeout("ComponentOperator.WaitComponentEnabledTimeout"));
  waiter.setTimeouts(times);
  waiter.waitAction(getSource());
    }
View Full Code Here

     */
    public void waitHasFocus() {
  Timeouts times = timeouts.cloneThis();
  times.setTimeout("Waiter.WaitingTime",
       times.getTimeout("ComponentOperator.WaitFocusTimeout"));
  Waiter focusWaiter = new Waiter(new Waitable() {
      public Object actionProduced(Object obj) {
    return(hasFocus() ? "" : null);
      }
      public String getDescription() {
    return("Wait component has focus");
      }
  });
  focusWaiter.setTimeouts(times);
  focusWaiter.setOutput(output.createErrorOutput());
  try {
      focusWaiter.waitAction(null);
  } catch(InterruptedException e) {
      output.printStackTrace(e);
  }
    }
View Full Code Here

     * @throws TimeoutExpiredException
     */
    public Object getRoot() {
  Timeouts times = timeouts.cloneThis();
  times.setTimeout("Waiter.WaitingTime", timeouts.getTimeout("JTreeOperator.WaitNodeVisibleTimeout"));
  Waiter rootWaiter = new Waiter(new Waitable() {
      public Object actionProduced(Object obj) {
    Object root = ((TreeModel)getModel()).getRoot();
    if(root == null || root.toString() == null || root.toString().equals("null")) {
        return(null);
    } else {
        return(root);
    }
      }
      public String getDescription() {
    return("Wait root node");
      }
  });
  rootWaiter.setTimeouts(times);
  rootWaiter.setOutput(output.createErrorOutput());
  try {
      return(rootWaiter.waitAction(null));
  } catch(InterruptedException e) {
      output.printStackTrace(e);
      return(null);
  }
    }
View Full Code Here

  if(chooser.checkPath(rootPath, 0)) {
      return(rootPath);
  }
  Timeouts times = timeouts.cloneThis();
  times.setTimeout("Waiter.WaitingTime", timeouts.getTimeout("JTreeOperator.WaitNextNodeTimeout"));
  Waiter loadedWaiter = new Waiter(new Waitable() {
            // fields used in getDescription() method
            TreePath currentPath;
            String requestedPath;
           
      public Object actionProduced(Object obj) {
    TreePathChooser chsr = (TreePathChooser)((Object[])obj)[0];
                requestedPath = chsr.getDescription();
    TreePath path = (TreePath)((Object[])obj)[1];
                currentPath = path;
    Object[] result = new Object[2];
                Object[] children = getChildren(path.getLastPathComponent());
                for(int j = 0; j < children.length; j++) {
                    result[0] = path.pathByAddingChild(children[j]);
        if(chsr.checkPath((TreePath)result[0], j)) {
      result[1] = Boolean.TRUE;
      return(result);
        }
        if(chsr.hasAsParent((TreePath)result[0], j)) {
      result[1] = Boolean.FALSE;
      return(result);
        }
    }
    return(null);
      }
      public String getDescription() {
                return "Wait next node loaded under parent "+currentPath+ " when requested was "+requestedPath;
      }
  });
  loadedWaiter.setTimeouts(times);
  loadedWaiter.setOutput(output.createErrorOutput());
  return(findPathPrimitive(rootPath, chooser, loadedWaiter));
    }
View Full Code Here

     * @return JList object if it was displayed in JComboBoxOperator.WaitListTimeout millisecont,
     * null otherwise.
     * @throws TimeoutExpiredException
     */
    public JList waitList() {
  Waiter pw = new ListWater();
  pw.setOutput(output.createErrorOutput());
  Timeouts times = timeouts.cloneThis();
  times.setTimeout("Waiter.WaitingTime",
       times.getTimeout("JComboBoxOperator.WaitListTimeout"));
  pw.setTimeouts(times);
  try {
      return((JList)pw.waitAction(null));
  } catch(InterruptedException e) {
      output.printStackTrace(e);
  }
  return(null);
    }
View Full Code Here

                }
            }).getSource());
    }

    protected JMenuItem waitItem(ComponentOperator oper, MenuElement element, PathChooser chooser, int depth) {
  Waiter 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));
  }
    }
View Full Code Here

     * @param state a ComponentChooser defining the state criteria.
     * @throws TimeoutExpiredException if the state has not
     * achieved in a value defined by <code>"ComponentOperator.WaitStateTimeout"</code>
     */
    public void waitState(final ComponentChooser state) {
  Waiter stateWaiter = new Waiter(new Waitable() {
    public Object actionProduced(Object obj) {
        return(state.checkComponent(getSource()) ?
         "" : null);
    }
    public String getDescription() {
        return("Wait \"" + state.getDescription() +
         "\" state to be reached");
    }
      });
  stateWaiter.setTimeouts(getTimeouts().cloneThis());
  stateWaiter.getTimeouts().
      setTimeout("Waiter.WaitingTime",
           getTimeouts().
           getTimeout("ComponentOperator.WaitStateTimeout"));
  stateWaiter.setOutput(getOutput().createErrorOutput());
  try {
      stateWaiter.waitAction(null);
  } catch(InterruptedException e) {
      throw(new JemmyException("Waiting of \"" + state.getDescription() +
             "\" state has been interrupted!"));
  }
    }
View Full Code Here

  output.printLine("Wait \"" + chooser.getDescription() +
       "\" value in progressbar\n    : " +
       toStringSource());
  output.printGolden("Wait \"" + chooser.getDescription() +
       "\" value in progressbar");
  Waiter wt = new Waiter(new Waitable() {
    public Object actionProduced(Object obj) {
        return(chooser.checkValue(((JProgressBar)getSource()).getValue()) ?
         "" : null);
    }
    public String getDescription() {
        return("\"" + chooser.getDescription() + "\" value");
    }
      });
  wt.setTimeouts(timeouts.cloneThis());
  wt.getTimeouts().setTimeout("Waiter.WaitingTime",
            getTimeouts().getTimeout("JProgressBarOperator.WaitValueTimeout"));
  wt.setOutput(output.createErrorOutput());
  try {
      wt.waitAction(null);
  } catch (InterruptedException e) {
      throw(new JemmyException("Exception during progressbar value waiting", e));
  }
    }
View Full Code Here

TOP

Related Classes of org.netbeans.jemmy.Waiter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.