Package org.fest.swing.fixture
Class JToggleButtonFixture
- All Implemented Interfaces:
ClientPropertyStorageFixture
,CommonComponentFixture
,FocusableComponentFixture
,JComponentFixture
,JPopupMenuInvokerFixture
,KeyboardInputSimulationFixture
,MouseInputSimulationFixture
,StateVerificationFixture
,TextDisplayFixture
,ToolTipDisplayFixture
,TwoStateButtonFixture
public class JToggleButtonFixture
extends ComponentFixture<JToggleButton>
implements CommonComponentFixture, JComponentFixture, JPopupMenuInvokerFixture, TextDisplayFixture, TwoStateButtonFixture
Understands functional testing of
JToggleButton
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
ConstructorsConstructorDescriptionJToggleButtonFixture
(Robot robot, String toggleButtonName) Creates a new
.JToggleButtonFixture
JToggleButtonFixture
(Robot robot, JToggleButton target) Creates a new
.JToggleButtonFixture
-
Method Summary
Modifier and TypeMethodDescriptioncheck()
Checks (or selects) this fixture's
only it is not already checked.JToggleButton
click()
Simulates a user clicking this fixture's
.JToggleButton
click
(MouseButton button) Simulates a user clicking this fixture's
.JToggleButton
click
(MouseClickInfo mouseClickInfo) Simulates a user clicking this fixture's
.JToggleButton
clientProperty
(Object key) Returns the client property stored in this fixture's
, under the given key.JToggleButton
private void
Simulates a user double-clicking this fixture's
.JToggleButton
protected final void
driver
(AbstractButtonDriver newDriver) Sets the
to be used by this fixture.AbstractButtonDriver
focus()
Gives input focus to this fixture's
.JToggleButton
pressAndReleaseKey
(KeyPressInfo keyPressInfo) Simulates a user pressing given key with the given modifiers on this fixture's
.JToggleButton
pressAndReleaseKeys
(int... keyCodes) Simulates a user pressing and releasing the given keys on this fixture's
.JToggleButton
pressKey
(int keyCode) Simulates a user pressing the given key on this fixture's
.JToggleButton
releaseKey
(int keyCode) Simulates a user releasing the given key on this fixture's
.JToggleButton
Asserts that this fixture's
is disabled.JToggleButton
Asserts that this fixture's
is enabled.JToggleButton
requireEnabled
(Timeout timeout) Asserts that this fixture's
is enabled.JToggleButton
Asserts that this fixture's
has input focus.JToggleButton
Verifies that this fixture's
is not selected.JToggleButton
Asserts that this fixture's
is not visible.JToggleButton
Verifies that this fixture's
is selected.JToggleButton
requireText
(String expected) Asserts that the text of this fixture's
matches the specified value.JToggleButton
requireText
(Pattern pattern) Asserts that the text of this fixture's
matches the given regular expression pattern.JToggleButton
requireToolTip
(String expected) Asserts that the toolTip in this fixture's
matches the given value.JToggleButton
requireToolTip
(Pattern pattern) Asserts that the toolTip in this fixture's
matches the given regular expression pattern.JToggleButton
Asserts that this fixture's
is visible.JToggleButton
Simulates a user right-clicking this fixture's
.JToggleButton
Shows a pop-up menu using this fixture's
as the invoker of the pop-up menu.JToggleButton
Shows a pop-up menu at the given point using this fixture's
as the invoker of the pop-up menu.JToggleButton
text()
Returns the text of this fixture's
.JToggleButton
uncheck()
Unchecks this fixture's
only if it is checked.JToggleButton
Methods inherited from class org.fest.swing.fixture.ComponentFixture
background, component, font, foreground, requireShowing, targetCastedTo, validateNotNull
-
Field Details
-
driver
-
-
Constructor Details
-
JToggleButtonFixture
Creates a new
.JToggleButtonFixture
- Parameters:
robot
- performs simulation of user events on the givenJToggleButton
.target
- theJToggleButton
to be managed by this fixture.- Throws:
NullPointerException
- ifrobot
isnull
.NullPointerException
- iftarget
isnull
.
-
JToggleButtonFixture
Creates a new
.JToggleButtonFixture
- Parameters:
robot
- performs simulation of user events on aJToggleButton
.toggleButtonName
- the name of theJToggleButton
to find using the givenRobot
.- Throws:
NullPointerException
- ifrobot
isnull
.ComponentLookupException
- if a matchingJToggleButton
could not be found.ComponentLookupException
- if more than one matchingJToggleButton
is found.
-
-
Method Details
-
createDriver
private void createDriver() -
driver
Sets the
to be used by this fixture.AbstractButtonDriver
- Parameters:
newDriver
- the newAbstractButtonDriver
.- Throws:
NullPointerException
- if the given driver isnull
.
-
text
Returns the text of this fixture's
.JToggleButton
- Specified by:
text
in interfaceTextDisplayFixture
- Returns:
- the text of this fixture's
JToggleButton
.
-
check
Checks (or selects) this fixture's
only it is not already checked.JToggleButton
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
is not showing on the screen.
-
uncheck
Unchecks this fixture's
only if it is checked.JToggleButton
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
is not showing on the screen.
-
click
Simulates a user clicking this fixture's
.JToggleButton
- Specified by:
click
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
is not showing on the screen.
-
click
Simulates a user clicking this fixture's
.JToggleButton
- Specified by:
click
in interfaceMouseInputSimulationFixture
- Parameters:
button
- the button to click.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the givenMouseButton
isnull
.IllegalStateException
- if this fixture'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
is not showing on the screen.
-
click
Simulates a user clicking this fixture's
.JToggleButton
- 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'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
is not showing on the screen.
-
doubleClick
Simulates a user double-clicking this fixture's
.JToggleButton
- Specified by:
doubleClick
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
is not showing on the screen.
-
rightClick
Simulates a user right-clicking this fixture's
.JToggleButton
- Specified by:
rightClick
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
is not showing on the screen.
-
focus
Gives input focus to this fixture's
.JToggleButton
- Specified by:
focus
in interfaceFocusableComponentFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
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 availableJToggleButton
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'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
is not showing on the screen.- See Also:
-
pressAndReleaseKeys
Simulates a user pressing and releasing the given keys on this fixture's
.JToggleButton
- 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'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
is not showing on the screen.- See Also:
-
pressKey
Simulates a user pressing the given key on this fixture's
.JToggleButton
- 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'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
is not showing on the screen.- See Also:
-
releaseKey
Simulates a user releasing the given key on this fixture's
.JToggleButton
- 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'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
is not showing on the screen.- See Also:
-
requireSelected
Verifies that this fixture's
is selected.JToggleButton
- Specified by:
requireSelected
in interfaceTwoStateButtonFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJToggleButton
is not selected.
-
requireNotSelected
Verifies that this fixture's
is not selected.JToggleButton
- Specified by:
requireNotSelected
in interfaceTwoStateButtonFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJToggleButton
is selected.
-
requireText
Asserts that the text of this fixture's
matches the specified value.JToggleButton
- Specified by:
requireText
in interfaceTextDisplayFixture
- Parameters:
expected
- the text to match. It can be a regular expression.- Returns:
- this fixture.
- Throws:
AssertionError
- if the text of the target JToggleButton does not match the given one.
-
requireText
Asserts that the text of this fixture's
matches the given regular expression pattern.JToggleButton
- Specified by:
requireText
in interfaceTextDisplayFixture
- Parameters:
pattern
- the regular expression pattern to match.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the given regular expression pattern isnull
.AssertionError
- if the text of the targetJToggleButton
does not match the given regular expression pattern.- Since:
- 1.2
-
requireFocused
Asserts that this fixture's
has input focus.JToggleButton
- Specified by:
requireFocused
in interfaceFocusableComponentFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJToggleButton
does not have input focus.
-
requireEnabled
Asserts that this fixture's
is enabled.JToggleButton
- Specified by:
requireEnabled
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJToggleButton
is disabled.
-
requireEnabled
Asserts that this fixture's
is enabled.JToggleButton
- 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'sJToggleButton
is never enabled.
-
requireDisabled
Asserts that this fixture's
is disabled.JToggleButton
- Specified by:
requireDisabled
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJToggleButton
is enabled.
-
requireVisible
Asserts that this fixture's
is visible.JToggleButton
- Specified by:
requireVisible
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJToggleButton
is not visible.
-
requireNotVisible
Asserts that this fixture's
is not visible.JToggleButton
- Specified by:
requireNotVisible
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJToggleButton
is visible.
-
requireToolTip
Asserts that the toolTip in this fixture's
matches the given value.JToggleButton
- 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'sJToggleButton
does not match the given value.- Since:
- 1.2
-
requireToolTip
Asserts that the toolTip in this fixture's
matches the given regular expression pattern.JToggleButton
- 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'sJToggleButton
does not match the given regular expression.- Since:
- 1.2
-
clientProperty
Returns the client property stored in this fixture's
, under the given key.JToggleButton
- 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.JToggleButton
- Specified by:
showPopupMenu
in interfaceJPopupMenuInvokerFixture
- Returns:
- a fixture that manages the displayed pop-up menu.
- Throws:
IllegalStateException
- if this fixture'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
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.JToggleButton
- 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'sJToggleButton
is disabled.IllegalStateException
- if this fixture'sJToggleButton
is not showing on the screen.ComponentLookupException
- if a pop-up menu cannot be found.
-