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
JToggleButtons:
- 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.JToggleButtonFixtureJToggleButtonFixture(Robot robot, JToggleButton target) Creates a new.JToggleButtonFixture -
Method Summary
Modifier and TypeMethodDescriptioncheck()Checks (or selects) this fixture'sonly it is not already checked.JToggleButtonclick()Simulates a user clicking this fixture's.JToggleButtonclick(MouseButton button) Simulates a user clicking this fixture's.JToggleButtonclick(MouseClickInfo mouseClickInfo) Simulates a user clicking this fixture's.JToggleButtonclientProperty(Object key) Returns the client property stored in this fixture's, under the given key.JToggleButtonprivate voidSimulates a user double-clicking this fixture's.JToggleButtonprotected final voiddriver(AbstractButtonDriver newDriver) Sets theto be used by this fixture.AbstractButtonDriverfocus()Gives input focus to this fixture's.JToggleButtonpressAndReleaseKey(KeyPressInfo keyPressInfo) Simulates a user pressing given key with the given modifiers on this fixture's.JToggleButtonpressAndReleaseKeys(int... keyCodes) Simulates a user pressing and releasing the given keys on this fixture's.JToggleButtonpressKey(int keyCode) Simulates a user pressing the given key on this fixture's.JToggleButtonreleaseKey(int keyCode) Simulates a user releasing the given key on this fixture's.JToggleButtonAsserts that this fixture'sis disabled.JToggleButtonAsserts that this fixture'sis enabled.JToggleButtonrequireEnabled(Timeout timeout) Asserts that this fixture'sis enabled.JToggleButtonAsserts that this fixture'shas input focus.JToggleButtonVerifies that this fixture'sis not selected.JToggleButtonAsserts that this fixture'sis not visible.JToggleButtonVerifies that this fixture'sis selected.JToggleButtonrequireText(String expected) Asserts that the text of this fixture'smatches the specified value.JToggleButtonrequireText(Pattern pattern) Asserts that the text of this fixture'smatches the given regular expression pattern.JToggleButtonrequireToolTip(String expected) Asserts that the toolTip in this fixture'smatches the given value.JToggleButtonrequireToolTip(Pattern pattern) Asserts that the toolTip in this fixture'smatches the given regular expression pattern.JToggleButtonAsserts that this fixture'sis visible.JToggleButtonSimulates a user right-clicking this fixture's.JToggleButtonShows a pop-up menu using this fixture'sas the invoker of the pop-up menu.JToggleButtonShows a pop-up menu at the given point using this fixture'sas the invoker of the pop-up menu.JToggleButtontext()Returns the text of this fixture's.JToggleButtonuncheck()Unchecks this fixture'sonly if it is checked.JToggleButtonMethods 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- theJToggleButtonto be managed by this fixture.- Throws:
NullPointerException- ifrobotisnull.NullPointerException- iftargetisnull.
-
JToggleButtonFixture
Creates a new.JToggleButtonFixture- Parameters:
robot- performs simulation of user events on aJToggleButton.toggleButtonName- the name of theJToggleButtonto find using the givenRobot.- Throws:
NullPointerException- ifrobotisnull.ComponentLookupException- if a matchingJToggleButtoncould not be found.ComponentLookupException- if more than one matchingJToggleButtonis found.
-
-
Method Details
-
createDriver
private void createDriver() -
driver
Sets theto 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:
textin interfaceTextDisplayFixture- Returns:
- the text of this fixture's
JToggleButton.
-
check
Checks (or selects) this fixture'sonly it is not already checked.JToggleButton- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis not showing on the screen.
-
uncheck
Unchecks this fixture'sonly if it is checked.JToggleButton- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis not showing on the screen.
-
click
Simulates a user clicking this fixture's.JToggleButton- Specified by:
clickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis not showing on the screen.
-
click
Simulates a user clicking this fixture's.JToggleButton- Specified by:
clickin interfaceMouseInputSimulationFixture- Parameters:
button- the button to click.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenMouseButtonisnull.IllegalStateException- if this fixture'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis not showing on the screen.
-
click
Simulates a user clicking this fixture's.JToggleButton- Specified by:
clickin interfaceMouseInputSimulationFixture- Parameters:
mouseClickInfo- specifies the button to click and the times the button should be clicked.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenMouseClickInfoisnull.IllegalStateException- if this fixture'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis not showing on the screen.
-
doubleClick
Simulates a user double-clicking this fixture's.JToggleButton- Specified by:
doubleClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis not showing on the screen.
-
rightClick
Simulates a user right-clicking this fixture's.JToggleButton- Specified by:
rightClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis not showing on the screen.
-
focus
Gives input focus to this fixture's.JToggleButton- Specified by:
focusin interfaceFocusableComponentFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis 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 availableJToggleButtonmasks.InputEvent- Specified by:
pressAndReleaseKeyin interfaceKeyboardInputSimulationFixture- Parameters:
keyPressInfo- specifies the key and modifiers to press.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenKeyPressInfoisnull.IllegalArgumentException- if the given code is not a valid key code.IllegalStateException- if this fixture'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis not showing on the screen.- See Also:
-
pressAndReleaseKeys
Simulates a user pressing and releasing the given keys on this fixture's.JToggleButton- Specified by:
pressAndReleaseKeysin 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'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis not showing on the screen.- See Also:
-
pressKey
Simulates a user pressing the given key on this fixture's.JToggleButton- Specified by:
pressKeyin 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'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis not showing on the screen.- See Also:
-
releaseKey
Simulates a user releasing the given key on this fixture's.JToggleButton- Specified by:
releaseKeyin 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'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis not showing on the screen.- See Also:
-
requireSelected
Verifies that this fixture'sis selected.JToggleButton- Specified by:
requireSelectedin interfaceTwoStateButtonFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJToggleButtonis not selected.
-
requireNotSelected
Verifies that this fixture'sis not selected.JToggleButton- Specified by:
requireNotSelectedin interfaceTwoStateButtonFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJToggleButtonis selected.
-
requireText
Asserts that the text of this fixture'smatches the specified value.JToggleButton- Specified by:
requireTextin 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'smatches the given regular expression pattern.JToggleButton- Specified by:
requireTextin 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 targetJToggleButtondoes not match the given regular expression pattern.- Since:
- 1.2
-
requireFocused
Asserts that this fixture'shas input focus.JToggleButton- Specified by:
requireFocusedin interfaceFocusableComponentFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJToggleButtondoes not have input focus.
-
requireEnabled
Asserts that this fixture'sis enabled.JToggleButton- Specified by:
requireEnabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJToggleButtonis disabled.
-
requireEnabled
Asserts that this fixture'sis enabled.JToggleButton- Specified by:
requireEnabledin interfaceStateVerificationFixture- Parameters:
timeout- the time this fixture will wait for the component to be enabled.- Returns:
- this fixture.
- Throws:
WaitTimedOutError- if this fixture'sJToggleButtonis never enabled.
-
requireDisabled
Asserts that this fixture'sis disabled.JToggleButton- Specified by:
requireDisabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJToggleButtonis enabled.
-
requireVisible
Asserts that this fixture'sis visible.JToggleButton- Specified by:
requireVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJToggleButtonis not visible.
-
requireNotVisible
Asserts that this fixture'sis not visible.JToggleButton- Specified by:
requireNotVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJToggleButtonis visible.
-
requireToolTip
Asserts that the toolTip in this fixture'smatches the given value.JToggleButton- Specified by:
requireToolTipin interfaceToolTipDisplayFixture- Parameters:
expected- the given value. It can be a regular expression.- Returns:
- this fixture.
- Throws:
AssertionError- if the toolTip in this fixture'sJToggleButtondoes not match the given value.- Since:
- 1.2
-
requireToolTip
Asserts that the toolTip in this fixture'smatches the given regular expression pattern.JToggleButton- Specified by:
requireToolTipin 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'sJToggleButtondoes 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:
clientPropertyin 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
nullif the property was not found. - Throws:
NullPointerException- if the given key isnull.- Since:
- 1.2
-
showPopupMenu
Shows a pop-up menu using this fixture'sas the invoker of the pop-up menu.JToggleButton- Specified by:
showPopupMenuin interfaceJPopupMenuInvokerFixture- Returns:
- a fixture that manages the displayed pop-up menu.
- Throws:
IllegalStateException- if this fixture'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis 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'sas the invoker of the pop-up menu.JToggleButton- Specified by:
showPopupMenuAtin 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'sJToggleButtonis disabled.IllegalStateException- if this fixture'sJToggleButtonis not showing on the screen.ComponentLookupException- if a pop-up menu cannot be found.
-