Package org.netbeans.jemmy

Examples of org.netbeans.jemmy.Waiter


     * Waits a state specified by a Waitable instance. Should be in org.netbeans.jemmy.operators.AbstractOperator
     *
     * @see org.netbeans.jemmy.operators.Operator
     */
    public void waitState(final Waitable state) {
        Waiter stateWaiter = new Waiter(state);
        stateWaiter.setTimeouts(getTimeouts().cloneThis());
        stateWaiter.getTimeouts().setTimeout("Waiter.WaitingTime", getTimeouts().getTimeout(WAIT_TIMEOUT_NAME));
        stateWaiter.setOutput(getOutput().createErrorOutput());
        JemmyBoundary.tryWaitAction(stateWaiter, state, fContext);
    }
View Full Code Here


    //End of mapping                                      //
    ////////////////////////////////////////////////////////

    private void waitPainted(int index) {
  Waiter drawingWaiter = new Waiter(new Waitable() {
    public Object actionProduced(Object param) {
        JList list = getFileList();
        int last_one = list.getModel().getSize() - 1;
        if(last_one == -1) {
      return("");
        }
        int current = (param != null) ? ((Integer)param).intValue() : 0;
                    try {
                        if(list.getCellBounds(current, current) != null) {
                            return(list.getCellBounds(last_one, last_one));
                        } else {
                            return(null);
                        }
                    } catch(NullPointerException e) {
                        //sometimes thrown from list.getCellBounds when item exists but not painted
                        return(null);
                    }
    }
    public String getDescription() {
        return("List drawed");
    }
      });
  drawingWaiter.setTimeoutsToCloneOf(getTimeouts(), "JFileChooserOperator.WaitListPaintedTimeout");
  drawingWaiter.setOutput(getOutput().createErrorOutput());
  try {
      drawingWaiter.waitAction((index != -1) ? new Integer(index) : null);
  } catch(InterruptedException e) {
      output.printStackTrace(e);
  }
    }
View Full Code Here

           }
       }, index));
    }

    private int findFileIndex(final String file, final StringComparator comparator) {
        Waiter fileWaiter = new Waiter(new Waitable() {
                public Object actionProduced(Object obj) {
                    File[] files = getFiles();
                    for(int i = 0; i < files.length; i++) {
                        if(comparator.equals(files[i].getName(),
                                             file)) {
                            return(new Integer(i));
                        }
                    }
                    return(null);
                }
                public String getDescription() {
                    return("\"" + file + "\" file to be displayed");
                }
            });
        fileWaiter.setOutput(getOutput().createErrorOutput());
        fileWaiter.setTimeoutsToCloneOf(getTimeouts(), "JFileChooserOperator.WaitListPaintedTimeout");
        try {
            return(((Integer)fileWaiter.waitAction(null)).intValue());
        } catch(InterruptedException e) {
            throw(new JemmyException("Waiting has been interrupted!"));
        }
    }
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.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!"));
  }
    }
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());
  pw.setTimeoutsToCloneOf(timeouts, "JComboBoxOperator.WaitListTimeout");
  try {
      return((JList)pw.waitAction(null));
  } catch(InterruptedException e) {
      output.printStackTrace(e);
  }
  return(null);
    }
View Full Code Here

     * Returns the root of the tree.
     * @return tree root.
     * @throws TimeoutExpiredException
     */
    public Object getRoot() {
  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.setTimeoutsToCloneOf(timeouts, "JTreeOperator.WaitNodeVisibleTimeout");
  rootWaiter.setOutput(output.createErrorOutput());
  try {
      return(rootWaiter.waitAction(null));
  } catch(InterruptedException e) {
      output.printStackTrace(e);
      return(null);
  }
    }
View Full Code Here

  output.printGolden("Search for a tree path");
  TreePath rootPath = new TreePath(getRoot());
  if(chooser.checkPath(rootPath, 0)) {
      return(rootPath);
  }
  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.setTimeoutsToCloneOf(timeouts, "JTreeOperator.WaitNextNodeTimeout");
  loadedWaiter.setOutput(output.createErrorOutput());
  return(findPathPrimitive(rootPath, chooser, loadedWaiter));
    }
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");
        }
    });
      waiter.setTimeoutsToCloneOf(timeouts, "ComponentOperator.WaitComponentTimeout");
      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);
  waiter.setTimeoutsToCloneOf(timeouts, "ComponentOperator.WaitComponentEnabledTimeout");
  waiter.waitAction(getSource());
    }
View Full Code Here

    /**
     * Waits for this Component has the keyboard focus.
     * @throws TimeoutExpiredException
     */
    public void waitHasFocus() {
  Waiter focusWaiter = new Waiter(new Waitable() {
      public Object actionProduced(Object obj) {
    return(hasFocus() ? "" : null);
      }
      public String getDescription() {
    return("Wait component has focus");
      }
  });
  focusWaiter.setTimeoutsToCloneOf(timeouts, "ComponentOperator.WaitFocusTimeout");
  focusWaiter.setOutput(output.createErrorOutput());
  try {
      focusWaiter.waitAction(null);
  } catch(InterruptedException e) {
      output.printStackTrace(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.