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
JComponent
s:
- 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.JComponent
private static Object
clientPropertyIn
(JComponent c, Object key) protected final void
invokeAction
(JComponent c, String name) protected final boolean
isVisible
(JComponent c, Point p) protected static boolean
isVisible
(JComponent c, Rectangle r) Indicates whether the given
's visibleJComponent
contains the given one.Rectangle
private static KeyStroke[]
keyStrokesForAction
(JComponent component, String actionName) void
requireToolTip
(JComponent c, String expected) Asserts that the toolTip in the given
matches the given value.JComponent
void
requireToolTip
(JComponent c, Pattern pattern) Asserts that the toolTip in the given
matches the given regular expression pattern.JComponent
protected final void
Invoke
on the givenJComponent.scrollRectToVisible(Rectangle)
.JComponent
private void
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
-
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
Invoke
on the givenJComponent.scrollRectToVisible(Rectangle)
.JComponent
Note: 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 visibleJComponent
contains the given one.Rectangle
Note: 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
- theRectangle
to verify.- Returns:
true
if the givenRectangle
is contained in the givenJComponent
's visibleRectangle
.
-
isVisible
Indicates whether the given
's visibleJComponent
contains the givenRectangle
.Point
Note: 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
- thePoint
to verify.- Returns:
true
if the givenPoint
is contained in the givenJComponent
's visibleRectangle
.
-
invokeAction
- Parameters:
c
- the givenJComponent
.name
- the name of theAction
to invoke.- Throws:
ActionFailedException
- if anAction
cannot be found under the given name.ActionFailedException
- if aKeyStroke
cannot be found for theAction
under the given name.ActionFailedException
- if it is not possible to type any of the foundKeyStroke
s.
-
keyStrokesForAction
@RunsInCurrentThread private static KeyStroke[] keyStrokesForAction(JComponent component, String actionName) -
type
-
requireToolTip
Asserts that the toolTip in the given
matches 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 givenJComponent
does not match the given value.- Since:
- 1.2
-
requireToolTip
Asserts that the toolTip in the given
matches 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 givenJComponent
does 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
null
if the property was not found. - Throws:
NullPointerException
- if the given key isnull
.- Since:
- 1.2
-
clientPropertyIn
-