Package org.fest.swing.driver
Class AbstractButtonDriver
java.lang.Object
org.fest.swing.driver.ComponentDriver
org.fest.swing.driver.ContainerDriver
org.fest.swing.driver.JComponentDriver
org.fest.swing.driver.AbstractButtonDriver
- All Implemented Interfaces:
TextDisplayDriver<AbstractButton>
public class AbstractButtonDriver
extends JComponentDriver
implements TextDisplayDriver<AbstractButton>
Understands functional testing of
AbstractButton
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 TypeMethodDescriptionprivate void
assertThatButtonIsSelected
(AbstractButton button, boolean selected) void
requireNotSelected
(AbstractButton button) Verifies that the button is not selected.void
requireSelected
(AbstractButton button) Verifies that the button is selected.void
requireText
(AbstractButton button, String expected) Asserts that the text in the given button is equal to or matches the specifiedString
.void
requireText
(AbstractButton button, Pattern pattern) Asserts that the text in the given button matches the given regular expression pattern.void
select
(AbstractButton button) Selects the given button only it is not already selected.private static org.fest.assertions.Description
selectedProperty
(AbstractButton button) textOf
(AbstractButton button) Returns the text of the given button.void
unselect
(AbstractButton button) Unselects the given button only if it is selected.private static boolean
Methods inherited from class org.fest.swing.driver.JComponentDriver
clientProperty, invokeAction, isVisible, isVisible, requireToolTip, requireToolTip, scrollToVisible
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
-
SELECTED_PROPERTY
- See Also:
-
TEXT_PROPERTY
- See Also:
-
-
Constructor Details
-
AbstractButtonDriver
Creates a newAbstractButtonDriver
.- Parameters:
robot
- the robot to use to simulate user input.
-
-
Method Details
-
requireText
Asserts that the text in the given button is equal to or matches the specifiedString
.- Specified by:
requireText
in interfaceTextDisplayDriver<AbstractButton>
- Parameters:
button
- the given button.expected
- the text to match. It can be a regular expression.- Throws:
AssertionError
- if the text of the button is not equal to or does not match the given one.
-
requireText
Asserts that the text in the given button matches the given regular expression pattern.- Specified by:
requireText
in interfaceTextDisplayDriver<AbstractButton>
- Parameters:
button
- the given button.pattern
- the regular expression pattern to match.- Throws:
NullPointerException
- if the given regular expression pattern isnull
.AssertionError
- if the text of the button does not match the given regular expression pattern.- Since:
- 1.2
-
textOf
Returns the text of the given button.- Specified by:
textOf
in interfaceTextDisplayDriver<AbstractButton>
- Parameters:
button
- the given button.- Returns:
- the text of the given button.
-
select
Selects the given button only it is not already selected.- Parameters:
button
- the target button.- Throws:
IllegalStateException
- if the button is disabled.IllegalStateException
- if the button is not showing on the screen.
-
unselect
Unselects the given button only if it is selected.- Parameters:
button
- the target button.- Throws:
IllegalStateException
- if the button is disabled.IllegalStateException
- if the button is not showing on the screen.
-
validateAndFindIsSelected
-
requireSelected
Verifies that the button is selected.- Parameters:
button
- the given button.- Throws:
AssertionError
- if the button is not selected.
-
requireNotSelected
Verifies that the button is not selected.- Parameters:
button
- the given button.- Throws:
AssertionError
- if the button is selected.
-
assertThatButtonIsSelected
-
selectedProperty
-