Package org.fest.swing.driver
Class JComponentDriver
java.lang.Object
org.fest.swing.driver.ComponentDriver
org.fest.swing.driver.ContainerDriver
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
Understands functional testing of
JComponents:
- user input simulation
- state verification
- property value query
org.fest.swing.fixture in your tests.-
Field Summary
FieldsFields inherited from class org.fest.swing.driver.ComponentDriver
robot -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclientProperty(JComponent c, Object key) Returns the client property stored in the given, under the given key.JComponentprivate static ObjectclientPropertyIn(JComponent c, Object key) protected final voidinvokeAction(JComponent c, String name) protected final booleanisVisible(JComponent c, Point p) protected static booleanisVisible(JComponent c, Rectangle r) Indicates whether the given's visibleJComponentcontains the given one.Rectangleprivate static KeyStroke[]keyStrokesForAction(JComponent component, String actionName) voidrequireToolTip(JComponent c, String expected) Asserts that the toolTip in the givenmatches the given value.JComponentvoidrequireToolTip(JComponent c, Pattern pattern) Asserts that the toolTip in the givenmatches the given regular expression pattern.JComponentprotected final voidInvokeon the givenJComponent.scrollRectToVisible(Rectangle).JComponentprivate voidMethods inherited from class org.fest.swing.driver.ContainerDriver
move, resize, resizeHeight, resizeWidthMethods 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
-
Field Details
-
TOOL_TIP_TEXT_PROPERTY
- See Also:
-
-
Constructor Details
-
JComponentDriver
Creates a newJComponentDriver.- Parameters:
robot- the robot the robot to use to simulate user input.
-
-
Method Details
-
scrollToVisible
Invokeon the givenJComponent.scrollRectToVisible(Rectangle).JComponentNote: This method is not executed in the event dispatch thread (EDT.) Clients are responsible for invoking this method in the EDT.
- Parameters:
c- the givenJComponent.r- the visibleRectangle.
-
isVisible
Indicates whether the given's visibleJComponentcontains the given one.RectangleNote: This method is not executed in the event dispatch thread (EDT.) Clients are responsible for invoking this method in the EDT.
- Parameters:
c- the givenJComponent.r- theRectangleto verify.- Returns:
trueif the givenRectangleis contained in the givenJComponent's visibleRectangle.
-
isVisible
Indicates whether the given's visibleJComponentcontains the givenRectangle.PointNote: This method is not executed in the event dispatch thread (EDT.) Clients are responsible for invoking this method in the EDT.
- Parameters:
c- the givenJComponent.p- thePointto verify.- Returns:
trueif the givenPointis contained in the givenJComponent's visibleRectangle.
-
invokeAction
- Parameters:
c- the givenJComponent.name- the name of theActionto invoke.- Throws:
ActionFailedException- if anActioncannot be found under the given name.ActionFailedException- if aKeyStrokecannot be found for theActionunder the given name.ActionFailedException- if it is not possible to type any of the foundKeyStrokes.
-
keyStrokesForAction
@RunsInCurrentThread private static KeyStroke[] keyStrokesForAction(JComponent component, String actionName) -
type
-
requireToolTip
Asserts that the toolTip in the givenmatches the given value.JComponent- Parameters:
c- the givenJComponent.expected- the expected toolTip. It can be a regular expression.- Throws:
AssertionError- if the toolTip of the givenJComponentdoes not match the given value.- Since:
- 1.2
-
requireToolTip
Asserts that the toolTip in the givenmatches the given regular expression pattern.JComponent- Parameters:
c- the givenJComponent.pattern- the regular expression pattern to match.- Throws:
NullPointerException- if the given regular expression pattern isnull.AssertionError- if the toolTip of the givenJComponentdoes not match the given value.- Since:
- 1.2
-
clientProperty
Returns the client property stored in the given, under the given key.JComponent- Parameters:
c- the givenJComponent.key- the key to use to retrieve the client property.- Returns:
- the value of the client property stored under the given key, or
nullif the property was not found. - Throws:
NullPointerException- if the given key isnull.- Since:
- 1.2
-
clientPropertyIn
-