Package org.fest.swing.fixture
Class JSpinnerFixture
- All Implemented Interfaces:
ClientPropertyStorageFixture
,CommonComponentFixture
,FocusableComponentFixture
,JComponentFixture
,JPopupMenuInvokerFixture
,KeyboardInputSimulationFixture
,MouseInputSimulationFixture
,StateVerificationFixture
,ToolTipDisplayFixture
public class JSpinnerFixture
extends ComponentFixture<JSpinner>
implements CommonComponentFixture, JComponentFixture, JPopupMenuInvokerFixture
Understands functional testing of
JSpinner
s:
- user input simulation
- state verification
- property value query
-
Field Summary
FieldsFields inherited from class org.fest.swing.fixture.ComponentFixture
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY, robot, target
-
Constructor Summary
ConstructorsConstructorDescriptionJSpinnerFixture
(Robot robot, String spinnerName) Creates a new
.JSpinnerFixture
JSpinnerFixture
(Robot robot, JSpinner target) Creates a new
.JSpinnerFixture
-
Method Summary
Modifier and TypeMethodDescriptionclick()
Simulates a user clicking this fixture's
.JSpinner
click
(MouseButton button) Simulates a user clicking this fixture's
.JSpinner
click
(MouseClickInfo mouseClickInfo) Simulates a user clicking this fixture's
.JSpinner
clientProperty
(Object key) Returns the client property stored in this fixture's
, under the given key.JSpinner
private void
Simulates a user decrementing the value of this fixture's
one time.JSpinner
decrement
(int times) Simulates a user decrementing the value of this fixture's
the given number of times.JSpinner
Simulates a user double-clicking this fixture's
.JSpinner
protected final void
driver
(JSpinnerDriver newDriver) Sets the
to be used by this fixture.JSpinnerDriver
Simulates a user entering the given text in this fixture's
(assuming its editor has aJSpinner
under it.) This method does not commit the value to theJTextComponent
JSpinner
.enterTextAndCommit
(String text) Simulates a user entering and committing the given text in this fixture's
(assuming its editor has aJSpinner
under it.)JTextComponent
focus()
Gives input focus to this fixture's
.JSpinner
Simulates a user incrementing the value of this fixture's
one time.JSpinner
increment
(int times) Simulates a user incrementing the value of this fixture's
the given number of times.JSpinner
pressAndReleaseKey
(KeyPressInfo keyPressInfo) Simulates a user pressing given key with the given modifiers on this fixture's
.JSpinner
pressAndReleaseKeys
(int... keyCodes) Simulates a user pressing and releasing the given keys on this fixture's
.JSpinner
pressKey
(int keyCode) Simulates a user pressing the given key on this fixture's
.JSpinner
releaseKey
(int keyCode) Simulates a user releasing the given key on this fixture's
.JSpinner
Asserts that this fixture's
is disabled.JSpinner
Asserts that this fixture's
is enabled.JSpinner
requireEnabled
(Timeout timeout) Asserts that this fixture's
is enabled.JSpinner
Asserts that this fixture's
has input focus.JSpinner
Asserts that this fixture's
is not visible.JSpinner
requireToolTip
(String expected) Asserts that the toolTip in this fixture's
matches the given value.JSpinner
requireToolTip
(Pattern pattern) Asserts that the toolTip in this fixture's
matches the given regular expression pattern.JSpinner
requireValue
(Object value) Verifies that the value of this fixture's
is equal to the given one.JSpinner
Asserts that this fixture's
is visible.JSpinner
Simulates a user right-clicking this fixture's
.JSpinner
Selects the given value in this fixture's
.JSpinner
Shows a pop-up menu using this fixture's
as the invoker of the pop-up menu.JSpinner
Shows a pop-up menu at the given point using this fixture's
as the invoker of the pop-up menu.JSpinner
text()
Returns the text displayed by this fixture's
.JSpinner
Methods inherited from class org.fest.swing.fixture.ComponentFixture
background, component, font, foreground, requireShowing, targetCastedTo, validateNotNull
-
Field Details
-
driver
-
-
Constructor Details
-
JSpinnerFixture
Creates a new
.JSpinnerFixture
- Parameters:
robot
- performs simulation of user events on aJSpinner
.spinnerName
- the name of theJSpinner
to find using the givenRobot
.- Throws:
NullPointerException
- ifrobot
isnull
.ComponentLookupException
- if a matchingJSpinner
could not be found.ComponentLookupException
- if more than one matchingJSpinner
is found.
-
JSpinnerFixture
Creates a new
.JSpinnerFixture
- Parameters:
robot
- performs simulation of user events on the givenJSpinner
.target
- theJSpinner
to be managed by this fixture.- Throws:
NullPointerException
- ifrobot
isnull
.NullPointerException
- iftarget
isnull
.
-
-
Method Details
-
createDriver
private void createDriver() -
driver
Sets the
to be used by this fixture.JSpinnerDriver
- Parameters:
newDriver
- the newJSpinnerDriver
.- Throws:
NullPointerException
- if the given driver isnull
.
-
increment
Simulates a user incrementing the value of this fixture's
the given number of times.JSpinner
- Parameters:
times
- how many times the value of this fixture'sJSpinner
should be incremented.- Returns:
- this fixture.
- Throws:
IllegalArgumentException
- iftimes
is less than or equal to zero.IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.
-
increment
Simulates a user incrementing the value of this fixture's
one time.JSpinner
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.
-
decrement
Simulates a user decrementing the value of this fixture's
the given number of times.JSpinner
- Parameters:
times
- how many times the value of this fixture'sJSpinner
should be decremented.- Returns:
- this fixture.
- Throws:
IllegalArgumentException
- iftimes
is less than or equal to zero.IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.
-
decrement
Simulates a user decrementing the value of this fixture's
one time.JSpinner
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.
-
enterText
Simulates a user entering the given text in this fixture's
(assuming its editor has aJSpinner
under it.) This method does not commit the value to theJTextComponent
JSpinner
.- Parameters:
text
- the text to enter.- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.ActionFailedException
- if the editor of theJSpinner
is not aJTextComponent
or cannot be found.UnexpectedException
- if the entering the text in theJSpinner
's editor fails.
-
enterTextAndCommit
Simulates a user entering and committing the given text in this fixture's
(assuming its editor has aJSpinner
under it.)JTextComponent
- Parameters:
text
- the text to enter.- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.ActionFailedException
- if the editor of theJSpinner
is not aJTextComponent
or cannot be found.UnexpectedException
- if the entering the text in theJSpinner
's editor fails.
-
select
Selects the given value in this fixture's
.JSpinner
- Parameters:
value
- the value to select.- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.IllegalArgumentException
- if theJSpinner
does not support the specifiedvalue
.
-
click
Simulates a user clicking this fixture's
.JSpinner
- Specified by:
click
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.
-
click
Simulates a user clicking this fixture's
.JSpinner
- Specified by:
click
in interfaceMouseInputSimulationFixture
- Parameters:
button
- the button to click.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the givenMouseButton
isnull
.IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.
-
click
Simulates a user clicking this fixture's
.JSpinner
- Specified by:
click
in interfaceMouseInputSimulationFixture
- Parameters:
mouseClickInfo
- specifies the button to click and the times the button should be clicked.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the givenMouseClickInfo
isnull
.IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.
-
rightClick
Simulates a user right-clicking this fixture's
.JSpinner
- Specified by:
rightClick
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.
-
doubleClick
Simulates a user double-clicking this fixture's
.JSpinner
- Specified by:
doubleClick
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.
-
focus
Gives input focus to this fixture's
.JSpinner
- Specified by:
focus
in interfaceFocusableComponentFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.
-
pressAndReleaseKey
Simulates a user pressing given key with the given modifiers on this fixture's
. Modifiers is a mask from the availableJSpinner
masks.InputEvent
- Specified by:
pressAndReleaseKey
in interfaceKeyboardInputSimulationFixture
- Parameters:
keyPressInfo
- specifies the key and modifiers to press.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the givenKeyPressInfo
isnull
.IllegalArgumentException
- if the given code is not a valid key code.IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.- See Also:
-
pressAndReleaseKeys
Simulates a user pressing and releasing the given keys on this fixture's
. This method does not affect the current focus.JSpinner
- Specified by:
pressAndReleaseKeys
in interfaceKeyboardInputSimulationFixture
- Parameters:
keyCodes
- one or more codes of the keys to press.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the given array of codes isnull
.IllegalArgumentException
- if any of the given code is not a valid key code.IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.- See Also:
-
pressKey
Simulates a user pressing the given key on this fixture's
.JSpinner
- Specified by:
pressKey
in interfaceKeyboardInputSimulationFixture
- Parameters:
keyCode
- the code of the key to press.- Returns:
- this fixture.
- Throws:
IllegalArgumentException
- if any of the given code is not a valid key code.IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.- See Also:
-
releaseKey
Simulates a user releasing the given key on this fixture's
.JSpinner
- Specified by:
releaseKey
in interfaceKeyboardInputSimulationFixture
- Parameters:
keyCode
- the code of the key to release.- Returns:
- this fixture.
- Throws:
IllegalArgumentException
- if any of the given code is not a valid key code.IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.- See Also:
-
requireFocused
Asserts that this fixture's
has input focus.JSpinner
- Specified by:
requireFocused
in interfaceFocusableComponentFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJSpinner
does not have input focus.
-
requireEnabled
Asserts that this fixture's
is enabled.JSpinner
- Specified by:
requireEnabled
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJSpinner
is disabled.
-
requireEnabled
Asserts that this fixture's
is enabled.JSpinner
- Specified by:
requireEnabled
in interfaceStateVerificationFixture
- Parameters:
timeout
- the time this fixture will wait for the component to be enabled.- Returns:
- this fixture.
- Throws:
WaitTimedOutError
- if this fixture'sJSpinner
is never enabled.
-
requireDisabled
Asserts that this fixture's
is disabled.JSpinner
- Specified by:
requireDisabled
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJSpinner
is enabled.
-
requireVisible
Asserts that this fixture's
is visible.JSpinner
- Specified by:
requireVisible
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJSpinner
is not visible.
-
requireNotVisible
Asserts that this fixture's
is not visible.JSpinner
- Specified by:
requireNotVisible
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJSpinner
is visible.
-
requireValue
Verifies that the value of this fixture's
is equal to the given one.JSpinner
- Parameters:
value
- the expected value of this fixture'sJSpinner
.- Returns:
- this fixture.
- Throws:
AssertionError
- if the value of this fixture'sJSpinner
is not equal to the given one.
-
text
Returns the text displayed by this fixture's
. 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.- Returns:
- the text displayed by this fixture's
JSpinner
. - Since:
- 1.2
-
requireToolTip
Asserts that the toolTip in this fixture's
matches the given value.JSpinner
- Specified by:
requireToolTip
in interfaceToolTipDisplayFixture
- Parameters:
expected
- the given value. It can be a regular expression.- Returns:
- this fixture.
- Throws:
AssertionError
- if the toolTip in this fixture'sJSpinner
does not match the given value.- Since:
- 1.2
-
requireToolTip
Asserts that the toolTip in this fixture's
matches the given regular expression pattern.JSpinner
- Specified by:
requireToolTip
in interfaceToolTipDisplayFixture
- Parameters:
pattern
- the regular expression pattern to match.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the given regular expression pattern isnull
.AssertionError
- if the toolTip in this fixture'sJSpinner
does not match the given regular expression.- Since:
- 1.2
-
clientProperty
Returns the client property stored in this fixture's
, under the given key.JSpinner
- Specified by:
clientProperty
in interfaceClientPropertyStorageFixture
- Parameters:
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
-
showPopupMenu
Shows a pop-up menu using this fixture's
as the invoker of the pop-up menu.JSpinner
- Specified by:
showPopupMenu
in interfaceJPopupMenuInvokerFixture
- Returns:
- a fixture that manages the displayed pop-up menu.
- Throws:
IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.ComponentLookupException
- if a pop-up menu cannot be found.
-
showPopupMenuAt
Shows a pop-up menu at the given point using this fixture's
as the invoker of the pop-up menu.JSpinner
- Specified by:
showPopupMenuAt
in interfaceJPopupMenuInvokerFixture
- Parameters:
p
- the given point where to show the pop-up menu.- Returns:
- a fixture that manages the displayed pop-up menu.
- Throws:
IllegalStateException
- if this fixture'sJSpinner
is disabled.IllegalStateException
- if this fixture'sJSpinner
is not showing on the screen.ComponentLookupException
- if a pop-up menu cannot be found.
-