org.fest.swing.fixture
Class JToggleButtonFixture

java.lang.Object
  extended by org.fest.swing.fixture.ComponentFixture<JToggleButton>
      extended by org.fest.swing.fixture.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:

Author:
Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.swing.fixture.ComponentFixture
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY, robot, target
 
Constructor Summary
JToggleButtonFixture(Robot robot, JToggleButton target)
          Creates a new JToggleButtonFixture.
JToggleButtonFixture(Robot robot, String toggleButtonName)
          Creates a new JToggleButtonFixture.
 
Method Summary
 JToggleButtonFixture check()
          Checks (or selects) this fixture's JToggleButton only it is not already checked.
 JToggleButtonFixture click()
          Simulates a user clicking this fixture's JToggleButton.
 JToggleButtonFixture click(MouseButton button)
          Simulates a user clicking this fixture's JToggleButton.
 JToggleButtonFixture click(MouseClickInfo mouseClickInfo)
          Simulates a user clicking this fixture's JToggleButton.
 Object clientProperty(Object key)
          Returns the client property stored in this fixture's JToggleButton, under the given key.
 JToggleButtonFixture doubleClick()
          Simulates a user double-clicking this fixture's JToggleButton.
protected  void driver(AbstractButtonDriver newDriver)
          Sets the AbstractButtonDriver to be used by this fixture.
 JToggleButtonFixture focus()
          Gives input focus to this fixture's JToggleButton.
 JToggleButtonFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
          Simulates a user pressing given key with the given modifiers on this fixture's JToggleButton.
 JToggleButtonFixture pressAndReleaseKeys(int... keyCodes)
          Simulates a user pressing and releasing the given keys on this fixture's JToggleButton.
 JToggleButtonFixture pressKey(int keyCode)
          Simulates a user pressing the given key on this fixture's JToggleButton.
 JToggleButtonFixture releaseKey(int keyCode)
          Simulates a user releasing the given key on this fixture's JToggleButton.
 JToggleButtonFixture requireDisabled()
          Asserts that this fixture's JToggleButton is disabled.
 JToggleButtonFixture requireEnabled()
          Asserts that this fixture's JToggleButton is enabled.
 JToggleButtonFixture requireEnabled(Timeout timeout)
          Asserts that this fixture's JToggleButton is enabled.
 JToggleButtonFixture requireFocused()
          Asserts that this fixture's JToggleButton has input focus.
 JToggleButtonFixture requireNotSelected()
          Verifies that this fixture's JToggleButton is not selected.
 JToggleButtonFixture requireNotVisible()
          Asserts that this fixture's JToggleButton is not visible.
 JToggleButtonFixture requireSelected()
          Verifies that this fixture's JToggleButton is selected.
 JToggleButtonFixture requireText(Pattern pattern)
          Asserts that the text of this fixture's JToggleButton matches the given regular expression pattern.
 JToggleButtonFixture requireText(String expected)
          Asserts that the text of this fixture's JToggleButton matches the specified value.
 JToggleButtonFixture requireToolTip(Pattern pattern)
          Asserts that the toolTip in this fixture's JToggleButton matches the given regular expression pattern.
 JToggleButtonFixture requireToolTip(String expected)
          Asserts that the toolTip in this fixture's JToggleButton matches the given value.
 JToggleButtonFixture requireVisible()
          Asserts that this fixture's JToggleButton is visible.
 JToggleButtonFixture rightClick()
          Simulates a user right-clicking this fixture's JToggleButton.
 JPopupMenuFixture showPopupMenu()
          Shows a pop-up menu using this fixture's JToggleButton as the invoker of the pop-up menu.
 JPopupMenuFixture showPopupMenuAt(Point p)
          Shows a pop-up menu at the given point using this fixture's JToggleButton as the invoker of the pop-up menu.
 String text()
          Returns the text of this fixture's JToggleButton.
 JToggleButtonFixture uncheck()
          Unchecks this fixture's JToggleButton only if it is checked.
 
Methods inherited from class org.fest.swing.fixture.ComponentFixture
background, component, font, foreground, requireShowing, targetCastedTo, validateNotNull
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JToggleButtonFixture

public JToggleButtonFixture(Robot robot,
                            JToggleButton target)
Creates a new JToggleButtonFixture.

Parameters:
robot - performs simulation of user events on the given JToggleButton.
target - the JToggleButton to be managed by this fixture.
Throws:
NullPointerException - if robot is null.
NullPointerException - if target is null.

JToggleButtonFixture

public JToggleButtonFixture(Robot robot,
                            String toggleButtonName)
Creates a new JToggleButtonFixture.

Parameters:
robot - performs simulation of user events on a JToggleButton.
toggleButtonName - the name of the JToggleButton to find using the given Robot.
Throws:
NullPointerException - if robot is null.
ComponentLookupException - if a matching JToggleButton could not be found.
ComponentLookupException - if more than one matching JToggleButton is found.
Method Detail

driver

protected final void driver(AbstractButtonDriver newDriver)
Sets the AbstractButtonDriver to be used by this fixture.

Parameters:
newDriver - the new AbstractButtonDriver.
Throws:
NullPointerException - if the given driver is null.

text

public String text()
Returns the text of this fixture's JToggleButton.

Specified by:
text in interface TextDisplayFixture
Returns:
the text of this fixture's JToggleButton.

check

public JToggleButtonFixture check()
Checks (or selects) this fixture's JToggleButton only it is not already checked.

Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.

uncheck

public JToggleButtonFixture uncheck()
Unchecks this fixture's JToggleButton only if it is checked.

Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.

click

public JToggleButtonFixture click()
Simulates a user clicking this fixture's JToggleButton.

Specified by:
click in interface MouseInputSimulationFixture
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.

click

public JToggleButtonFixture click(MouseButton button)
Simulates a user clicking this fixture's JToggleButton.

Specified by:
click in interface MouseInputSimulationFixture
Parameters:
button - the button to click.
Returns:
this fixture.
Throws:
NullPointerException - if the given MouseButton is null.
IllegalStateException - if this fixture's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.

click

public JToggleButtonFixture click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's JToggleButton.

Specified by:
click in interface MouseInputSimulationFixture
Parameters:
mouseClickInfo - specifies the button to click and the times the button should be clicked.
Returns:
this fixture.
Throws:
NullPointerException - if the given MouseClickInfo is null.
IllegalStateException - if this fixture's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.

doubleClick

public JToggleButtonFixture doubleClick()
Simulates a user double-clicking this fixture's JToggleButton.

Specified by:
doubleClick in interface MouseInputSimulationFixture
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.

rightClick

public JToggleButtonFixture rightClick()
Simulates a user right-clicking this fixture's JToggleButton.

Specified by:
rightClick in interface MouseInputSimulationFixture
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.

focus

public JToggleButtonFixture focus()
Gives input focus to this fixture's JToggleButton.

Specified by:
focus in interface FocusableComponentFixture
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.

pressAndReleaseKey

public JToggleButtonFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
Simulates a user pressing given key with the given modifiers on this fixture's JToggleButton. Modifiers is a mask from the available InputEvent masks.

Specified by:
pressAndReleaseKey in interface KeyboardInputSimulationFixture
Parameters:
keyPressInfo - specifies the key and modifiers to press.
Returns:
this fixture.
Throws:
NullPointerException - if the given KeyPressInfo is null.
IllegalArgumentException - if the given code is not a valid key code.
IllegalStateException - if this fixture's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.
See Also:
KeyPressInfo

pressAndReleaseKeys

public JToggleButtonFixture pressAndReleaseKeys(int... keyCodes)
Simulates a user pressing and releasing the given keys on this fixture's JToggleButton.

Specified by:
pressAndReleaseKeys in interface KeyboardInputSimulationFixture
Parameters:
keyCodes - one or more codes of the keys to press.
Returns:
this fixture.
Throws:
NullPointerException - if the given array of codes is null.
IllegalArgumentException - if any of the given code is not a valid key code.
IllegalStateException - if this fixture's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.
See Also:
KeyEvent

pressKey

public JToggleButtonFixture pressKey(int keyCode)
Simulates a user pressing the given key on this fixture's JToggleButton.

Specified by:
pressKey in interface KeyboardInputSimulationFixture
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's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.
See Also:
KeyEvent

releaseKey

public JToggleButtonFixture releaseKey(int keyCode)
Simulates a user releasing the given key on this fixture's JToggleButton.

Specified by:
releaseKey in interface KeyboardInputSimulationFixture
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's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.
See Also:
KeyEvent

requireSelected

public JToggleButtonFixture requireSelected()
Verifies that this fixture's JToggleButton is selected.

Specified by:
requireSelected in interface TwoStateButtonFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's JToggleButton is not selected.

requireNotSelected

public JToggleButtonFixture requireNotSelected()
Verifies that this fixture's JToggleButton is not selected.

Specified by:
requireNotSelected in interface TwoStateButtonFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's JToggleButton is selected.

requireText

public JToggleButtonFixture requireText(String expected)
Asserts that the text of this fixture's JToggleButton matches the specified value.

Specified by:
requireText in interface TextDisplayFixture
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

public JToggleButtonFixture requireText(Pattern pattern)
Asserts that the text of this fixture's JToggleButton matches the given regular expression pattern.

Specified by:
requireText in interface TextDisplayFixture
Parameters:
pattern - the regular expression pattern to match.
Returns:
this fixture.
Throws:
NullPointerException - if the given regular expression pattern is null.
AssertionError - if the text of the target JToggleButton does not match the given regular expression pattern.
Since:
1.2

requireFocused

public JToggleButtonFixture requireFocused()
Asserts that this fixture's JToggleButton has input focus.

Specified by:
requireFocused in interface FocusableComponentFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's JToggleButton does not have input focus.

requireEnabled

public JToggleButtonFixture requireEnabled()
Asserts that this fixture's JToggleButton is enabled.

Specified by:
requireEnabled in interface StateVerificationFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's JToggleButton is disabled.

requireEnabled

public JToggleButtonFixture requireEnabled(Timeout timeout)
Asserts that this fixture's JToggleButton is enabled.

Specified by:
requireEnabled in interface StateVerificationFixture
Parameters:
timeout - the time this fixture will wait for the component to be enabled.
Returns:
this fixture.
Throws:
WaitTimedOutError - if this fixture's JToggleButton is never enabled.

requireDisabled

public JToggleButtonFixture requireDisabled()
Asserts that this fixture's JToggleButton is disabled.

Specified by:
requireDisabled in interface StateVerificationFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's JToggleButton is enabled.

requireVisible

public JToggleButtonFixture requireVisible()
Asserts that this fixture's JToggleButton is visible.

Specified by:
requireVisible in interface StateVerificationFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's JToggleButton is not visible.

requireNotVisible

public JToggleButtonFixture requireNotVisible()
Asserts that this fixture's JToggleButton is not visible.

Specified by:
requireNotVisible in interface StateVerificationFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's JToggleButton is visible.

requireToolTip

public JToggleButtonFixture requireToolTip(String expected)
Asserts that the toolTip in this fixture's JToggleButton matches the given value.

Specified by:
requireToolTip in interface ToolTipDisplayFixture
Parameters:
expected - the given value. It can be a regular expression.
Returns:
this fixture.
Throws:
AssertionError - if the toolTip in this fixture's JToggleButton does not match the given value.
Since:
1.2

requireToolTip

public JToggleButtonFixture requireToolTip(Pattern pattern)
Asserts that the toolTip in this fixture's JToggleButton matches the given regular expression pattern.

Specified by:
requireToolTip in interface ToolTipDisplayFixture
Parameters:
pattern - the regular expression pattern to match.
Returns:
this fixture.
Throws:
NullPointerException - if the given regular expression pattern is null.
AssertionError - if the toolTip in this fixture's JToggleButton does not match the given regular expression.
Since:
1.2

clientProperty

public Object clientProperty(Object key)
Returns the client property stored in this fixture's JToggleButton, under the given key.

Specified by:
clientProperty in interface ClientPropertyStorageFixture
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 is null.
Since:
1.2

showPopupMenu

public JPopupMenuFixture showPopupMenu()
Shows a pop-up menu using this fixture's JToggleButton as the invoker of the pop-up menu.

Specified by:
showPopupMenu in interface JPopupMenuInvokerFixture
Returns:
a fixture that manages the displayed pop-up menu.
Throws:
IllegalStateException - if this fixture's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.
ComponentLookupException - if a pop-up menu cannot be found.

showPopupMenuAt

public JPopupMenuFixture showPopupMenuAt(Point p)
Shows a pop-up menu at the given point using this fixture's JToggleButton as the invoker of the pop-up menu.

Specified by:
showPopupMenuAt in interface JPopupMenuInvokerFixture
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's JToggleButton is disabled.
IllegalStateException - if this fixture's JToggleButton is not showing on the screen.
ComponentLookupException - if a pop-up menu cannot be found.


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.