org.fest.swing.driver
Class JComponentDriver

java.lang.Object
  extended by org.fest.swing.driver.ComponentDriver
      extended by org.fest.swing.driver.ContainerDriver
          extended by org.fest.swing.driver.JComponentDriver
Direct Known Subclasses:
AbstractButtonDriver, JComboBoxDriver, JFileChooserDriver, JInternalFrameDriver, JLabelDriver, JListDriver, JMenuItemDriver, JOptionPaneDriver, JPopupMenuDriver, JProgressBarDriver, JScrollBarDriver, JScrollPaneDriver, JSliderDriver, JSpinnerDriver, JSplitPaneDriver, JTabbedPaneDriver, JTableDriver, JTableHeaderDriver, JTextComponentDriver, JToolBarDriver, JTreeDriver

public class JComponentDriver
extends ContainerDriver

Understands functional testing of JComponents:

This class is intended for internal use only. Please use the classes in the package org.fest.swing.fixture in your tests.

Author:
Alex Ruiz, Yvonne Wang

Field Summary
 
Fields inherited from class org.fest.swing.driver.ComponentDriver
robot
 
Constructor Summary
JComponentDriver(Robot robot)
          Creates a new JComponentDriver.
 
Method Summary
 Object clientProperty(JComponent c, Object key)
          Returns the client property stored in the given JComponent, under the given key.
protected  void invokeAction(JComponent c, String name)
          Invoke an Action from the JComponent's ActionMap.
protected  boolean isVisible(JComponent c, Point p)
          Indicates whether the given JComponent's visible Rectangle contains the given Point.
protected static boolean isVisible(JComponent c, Rectangle r)
          Indicates whether the given JComponent's visible Rectangle contains the given one.
 void requireToolTip(JComponent c, Pattern pattern)
          Asserts that the toolTip in the given JComponent matches the given regular expression pattern.
 void requireToolTip(JComponent c, String expected)
          Asserts that the toolTip in the given JComponent matches the given value.
protected  void scrollToVisible(JComponent c, Rectangle r)
          Invoke JComponent.scrollRectToVisible(Rectangle) on the given JComponent.
 
Methods inherited from class org.fest.swing.driver.ContainerDriver
move, resize, resizeHeight, resizeWidth
 
Methods inherited from class org.fest.swing.driver.ComponentDriver
assertIsEnabledAndShowing, click, click, click, click, click, doubleClick, drag, dragOver, drop, focus, focusAndWaitForFocusGain, invokePopupMenu, invokePopupMenu, moveMouseIgnoringAnyError, moveMouseIgnoringAnyError, performAccessibleActionOf, pressAndReleaseKey, pressAndReleaseKey, pressAndReleaseKeys, pressKey, propertyName, releaseKey, requireDisabled, requireEnabled, requireEnabled, requireFocused, requireNotVisible, requireSize, requireVisible, rightClick, settings, waitForShowing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JComponentDriver

public JComponentDriver(Robot robot)
Creates a new JComponentDriver.

Parameters:
robot - the robot the robot to use to simulate user input.
Method Detail

scrollToVisible

@RunsInCurrentThread
protected final void scrollToVisible(JComponent c,
                                                         Rectangle r)
Invoke JComponent.scrollRectToVisible(Rectangle) on the given JComponent.

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Parameters:
c - the given JComponent.
r - the visible Rectangle.

isVisible

@RunsInCurrentThread
protected static boolean isVisible(JComponent c,
                                                       Rectangle r)
Indicates whether the given JComponent's visible Rectangle contains the given one.

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Parameters:
c - the given JComponent.
r - the Rectangle to verify.
Returns:
true if the given Rectangle is contained in the given JComponent's visible Rectangle.

isVisible

@RunsInCurrentThread
protected final boolean isVisible(JComponent c,
                                                      Point p)
Indicates whether the given JComponent's visible Rectangle contains the given Point.

Note: This method is not guaranteed to be executed in the event dispatch thread (EDT.) Clients are responsible for calling this method from the EDT.

Parameters:
c - the given JComponent.
p - the Point to verify.
Returns:
true if the given Point is contained in the given JComponent's visible Rectangle.

invokeAction

@RunsInEDT
protected final void invokeAction(JComponent c,
                                            String name)
Invoke an Action from the JComponent's ActionMap.

Parameters:
c - the given JComponent.
name - the name of the Action to invoke.
Throws:
ActionFailedException - if an Action cannot be found under the given name.
ActionFailedException - if a KeyStroke cannot be found for the Action under the given name.
ActionFailedException - if it is not possible to type any of the found KeyStrokes.

requireToolTip

@RunsInEDT
public void requireToolTip(JComponent c,
                                     String expected)
Asserts that the toolTip in the given JComponent matches the given value.

Parameters:
c - the given JComponent.
expected - the expected toolTip. It can be a regular expression.
Throws:
AssertionError - if the toolTip of the given JComponent does not match the given value.
Since:
1.2

requireToolTip

@RunsInEDT
public void requireToolTip(JComponent c,
                                     Pattern pattern)
Asserts that the toolTip in the given JComponent matches the given regular expression pattern.

Parameters:
c - the given JComponent.
pattern - the regular expression pattern to match.
Throws:
NullPointerException - if the given regular expression pattern is null.
AssertionError - if the toolTip of the given JComponent does not match the given value.
Since:
1.2

clientProperty

@RunsInEDT
public Object clientProperty(JComponent c,
                                       Object key)
Returns the client property stored in the given JComponent, under the given key.

Parameters:
c - the given JComponent.
key - the key to use to retrieve the client property.
Returns:
the value of the client property stored under the given key, or null if the property was not found.
Throws:
NullPointerException - if the given key is null.
Since:
1.2


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.