Package org.fest.swing.driver
Class JSpinnerDriver
java.lang.Object
org.fest.swing.driver.ComponentDriver
org.fest.swing.driver.ContainerDriver
org.fest.swing.driver.JComponentDriver
org.fest.swing.driver.JSpinnerDriver
Understands functional testing of
JSpinner
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 static void
void
Decrements the value of the
.JSpinner
void
Decrements the value of the
the given number of times.JSpinner
private static void
decrementValue
(JSpinner spinner, int times) Returns the
used as editor in the givenJTextComponent
.JSpinner
void
Enters the given text in the
, assuming its editor has aJSpinner
under it.JTextComponent
void
enterTextAndCommit
(JSpinner spinner, String text) Enters and commits the given text in the
, assuming its editor has aJSpinner
under it.JTextComponent
private JTextComponent
findEditor
(JSpinner spinner) void
Increments the value of the
.JSpinner
void
Increments the value of the
the given number of times.JSpinner
private static void
incrementValue
(JSpinner spinner, int times) void
requireValue
(JSpinner spinner, Object value) Verifies that the value of the
is equal to the given one.JSpinner
void
selectValue
(JSpinner spinner, Object value) Selects the given value in the given
.JSpinner
Returns the text displayed in the given
.JSpinner
private void
private static void
validate
(JSpinner spinner, JTextComponent editor) private static void
validateAndDecrementValue
(JSpinner spinner) private static void
validateAndDecrementValue
(JSpinner spinner, int times) private static void
validateAndIncrementValue
(JSpinner spinner) private static void
validateAndIncrementValue
(JSpinner spinner, int times) 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
-
EDITOR_MATCHER
-
VALUE_PROPERTY
- See Also:
-
-
Constructor Details
-
JSpinnerDriver
Creates a newJSpinnerDriver
.- Parameters:
robot
- the robot to use to simulate user input.
-
-
Method Details
-
increment
Increments the value of the
the given number of times.JSpinner
- Parameters:
spinner
- the targetJSpinner
.times
- how many times the value of this fixture'sJSpinner
should be incremented.- Throws:
IllegalArgumentException
- iftimes
is less than or equal to zero.IllegalStateException
- if theJSpinner
is disabled.IllegalStateException
- if theJSpinner
is not showing on the screen.
-
validateAndIncrementValue
-
incrementValue
-
increment
Increments the value of the
.JSpinner
- Parameters:
spinner
- the targetJSpinner
.- Throws:
IllegalStateException
- if theJSpinner
is disabled.IllegalStateException
- if theJSpinner
is not showing on the screen.
-
validateAndIncrementValue
-
decrement
Decrements the value of the
the given number of times.JSpinner
- Parameters:
spinner
- the targetJSpinner
.times
- how many times the value of this fixture'sJSpinner
should be decremented.- Throws:
IllegalArgumentException
- iftimes
is less than or equal to zero.IllegalStateException
- if theJSpinner
is disabled.IllegalStateException
- if theJSpinner
is not showing on the screen.
-
validate
-
validateAndDecrementValue
-
decrementValue
-
decrement
Decrements the value of the
.JSpinner
- Parameters:
spinner
- the targetJSpinner
.- Throws:
IllegalStateException
- if theJSpinner
is disabled.IllegalStateException
- if theJSpinner
is not showing on the screen.
-
validateAndDecrementValue
-
textOf
Returns the text displayed in the given
. This method first tries to get the text displayed in theJSpinner
JSpinner
's editor, assuming it is a
. If the text from the editor cannot be retrieved, it will return theJTextComponent
String
representation of the value in theJSpinner
's model.- Parameters:
spinner
- the targetJSpinner
.- Returns:
- the text displayed in the given
JSpinner
. - Since:
- 1.2
-
enterTextAndCommit
Enters and commits the given text in the
, assuming its editor has aJSpinner
under it.JTextComponent
- Parameters:
spinner
- the targetJSpinner
.text
- the text to enter.- Throws:
IllegalStateException
- if theJSpinner
is disabled.IllegalStateException
- if theJSpinner
is not showing on the screen.ActionFailedException
- if the editor of theJSpinner
is not aJTextComponent
or cannot be found.UnexpectedException
- if entering the text in theJSpinner
's editor fails.
-
commit
-
enterText
Enters the given text in the
, assuming its editor has aJSpinner
under it. This method does not commit the value to theJTextComponent
JSpinner
.- Parameters:
spinner
- the targetJSpinner
.text
- the text to enter.- Throws:
IllegalStateException
- if theJSpinner
is disabled.IllegalStateException
- if theJSpinner
is not showing on the screen.ActionFailedException
- if the editor of theJSpinner
is not aJTextComponent
or cannot be found.UnexpectedException
- if entering the text in theJSpinner
's editor fails.- See Also:
-
findEditor
-
validate
-
selectValue
Selects the given value in the given
.JSpinner
- Parameters:
spinner
- the targetJSpinner
.value
- the value to select.- Throws:
IllegalStateException
- if theJSpinner
is disabled.IllegalStateException
- if theJSpinner
is not showing on the screen.IllegalArgumentException
- if the givenJSpinner
does not support the given value.
-
editor
Returns the
used as editor in the givenJTextComponent
.JSpinner
- Parameters:
spinner
- the targetJSpinner
.- Returns:
- the
JTextComponent
used as editor in the givenJSpinner
. - Throws:
ComponentLookupException
- if the givenJSpinner
does not have aJTextComponent
as editor.
-
requireValue
Verifies that the value of the
is equal to the given one.JSpinner
- Parameters:
spinner
- the targetJSpinner
.value
- the expected value.- Throws:
AssertionError
- if the value of theJSpinner
is not equal to the given one.
-