org.fest.swing.fixture
Class JRadioButtonFixture

java.lang.Object
  extended by org.fest.swing.fixture.ComponentFixture<JRadioButton>
      extended by org.fest.swing.fixture.JRadioButtonFixture
All Implemented Interfaces:
ClientPropertyStorageFixture, CommonComponentFixture, FocusableComponentFixture, JComponentFixture, JPopupMenuInvokerFixture, KeyboardInputSimulationFixture, MouseInputSimulationFixture, StateVerificationFixture, TextDisplayFixture, ToolTipDisplayFixture, TwoStateButtonFixture

public class JRadioButtonFixture
extends ComponentFixture<JRadioButton>
implements CommonComponentFixture, JComponentFixture, JPopupMenuInvokerFixture, TextDisplayFixture, TwoStateButtonFixture

Understands functional testing of JRadioButtons:

Author:
Yvonne Wang, Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.swing.fixture.ComponentFixture
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY, robot, target
 
Constructor Summary
JRadioButtonFixture(Robot robot, JRadioButton target)
          Creates a new JRadioButtonFixture.
JRadioButtonFixture(Robot robot, String buttonName)
          Creates a new JRadioButtonFixture.
 
Method Summary
 JRadioButtonFixture check()
          Checks (or selects) this fixture's JRadioButton only it is not already checked.
 JRadioButtonFixture click()
          Simulates a user clicking this fixture's JRadioButton.
 JRadioButtonFixture click(MouseButton button)
          Simulates a user clicking this fixture's JRadioButton.
 JRadioButtonFixture click(MouseClickInfo mouseClickInfo)
          Simulates a user clicking this fixture's JRadioButton.
 Object clientProperty(Object key)
          Returns the client property stored in this fixture's JRadioButton, under the given key.
 JRadioButtonFixture doubleClick()
          Simulates a user double-clicking this fixture's JRadioButton.
protected  void driver(AbstractButtonDriver newDriver)
          Sets the AbstractButtonDriver to be used by this fixture.
 JRadioButtonFixture focus()
          Gives input focus to this fixture's JRadioButton.
 JRadioButtonFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
          Simulates a user pressing given key with the given modifiers on this fixture's JRadioButton.
 JRadioButtonFixture pressAndReleaseKeys(int... keyCodes)
          Simulates a user pressing and releasing the given keys on this fixture's JRadioButton.
 JRadioButtonFixture pressKey(int keyCode)
          Simulates a user pressing the given key on this fixture's JRadioButton.
 JRadioButtonFixture releaseKey(int keyCode)
          Simulates a user releasing the given key on this fixture's JRadioButton.
 JRadioButtonFixture requireDisabled()
          Asserts that this fixture's JRadioButton is disabled.
 JRadioButtonFixture requireEnabled()
          Asserts that this fixture's JRadioButton is enabled.
 JRadioButtonFixture requireEnabled(Timeout timeout)
          Asserts that this fixture's JRadioButton is enabled.
 JRadioButtonFixture requireFocused()
          Asserts that this fixture's JRadioButton has input focus.
 JRadioButtonFixture requireNotSelected()
          Verifies that this fixture's JRadioButton is not selected.
 JRadioButtonFixture requireNotVisible()
          Asserts that this fixture's JRadioButton is not visible.
 JRadioButtonFixture requireSelected()
          Verifies that this fixture's JRadioButton is selected.
 JRadioButtonFixture requireText(Pattern pattern)
          Asserts that the text of this fixture's JRadioButton matches the given regular expression pattern.
 JRadioButtonFixture requireText(String expected)
          Asserts that the text of this fixture's JRadioButton matches the specified value.
 JRadioButtonFixture requireToolTip(Pattern pattern)
          Asserts that the toolTip in this fixture's JRadioButton matches the given regular expression pattern.
 JRadioButtonFixture requireToolTip(String expected)
          Asserts that the toolTip in this fixture's JRadioButton matches the given value.
 JRadioButtonFixture requireVisible()
          Asserts that this fixture's JRadioButton is visible.
 JRadioButtonFixture rightClick()
          Simulates a user right-clicking this fixture's JRadioButton.
 JPopupMenuFixture showPopupMenu()
          Shows a pop-up menu using this fixture's JRadioButton 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 JRadioButton as the invoker of the pop-up menu.
 String text()
          Returns the text of this fixture's JRadioButton.
 JRadioButtonFixture uncheck()
          Unchecks this fixture's JRadioButton 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

JRadioButtonFixture

public JRadioButtonFixture(Robot robot,
                           JRadioButton target)
Creates a new JRadioButtonFixture.

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

JRadioButtonFixture

public JRadioButtonFixture(Robot robot,
                           String buttonName)
Creates a new JRadioButtonFixture.

Parameters:
robot - performs simulation of user events on a JRadioButton.
buttonName - the name of the JRadioButton to find using the given Robot.
Throws:
NullPointerException - if robot is null.
ComponentLookupException - if a matching JRadioButton could not be found.
ComponentLookupException - if more than one matching JRadioButton 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 JRadioButton.

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

check

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

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

uncheck

public JRadioButtonFixture uncheck()
Unchecks this fixture's JRadioButton only if it is checked.

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

click

public JRadioButtonFixture click()
Simulates a user clicking this fixture's JRadioButton.

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

click

public JRadioButtonFixture click(MouseButton button)
Simulates a user clicking this fixture's JRadioButton.

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 JRadioButton is disabled.
IllegalStateException - if this fixture's JRadioButton is not showing on the screen.

click

public JRadioButtonFixture click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's JRadioButton.

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 JRadioButton is disabled.
IllegalStateException - if this fixture's JRadioButton is not showing on the screen.

doubleClick

public JRadioButtonFixture doubleClick()
Simulates a user double-clicking this fixture's JRadioButton.

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

rightClick

public JRadioButtonFixture rightClick()
Simulates a user right-clicking this fixture's JRadioButton.

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

focus

public JRadioButtonFixture focus()
Gives input focus to this fixture's JRadioButton.

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

pressAndReleaseKey

public JRadioButtonFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
Simulates a user pressing given key with the given modifiers on this fixture's JRadioButton. 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 JRadioButton is disabled.
IllegalStateException - if this fixture's JRadioButton is not showing on the screen.
See Also:
KeyPressInfo

pressAndReleaseKeys

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

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 JRadioButton is disabled.
IllegalStateException - if this fixture's JRadioButton is not showing on the screen.
See Also:
KeyEvent

pressKey

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

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 JRadioButton is disabled.
IllegalStateException - if this fixture's JRadioButton is not showing on the screen.
See Also:
KeyEvent

releaseKey

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

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 JRadioButton is disabled.
IllegalStateException - if this fixture's JRadioButton is not showing on the screen.
See Also:
KeyEvent

requireFocused

public JRadioButtonFixture requireFocused()
Asserts that this fixture's JRadioButton has input focus.

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

requireEnabled

public JRadioButtonFixture requireEnabled()
Asserts that this fixture's JRadioButton is enabled.

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

requireEnabled

public JRadioButtonFixture requireEnabled(Timeout timeout)
Asserts that this fixture's JRadioButton 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 JRadioButton is never enabled.

requireDisabled

public JRadioButtonFixture requireDisabled()
Asserts that this fixture's JRadioButton is disabled.

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

requireSelected

public JRadioButtonFixture requireSelected()
Verifies that this fixture's JRadioButton is selected.

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

requireNotSelected

public JRadioButtonFixture requireNotSelected()
Verifies that this fixture's JRadioButton is not selected.

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

requireVisible

public JRadioButtonFixture requireVisible()
Asserts that this fixture's JRadioButton is visible.

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

requireNotVisible

public JRadioButtonFixture requireNotVisible()
Asserts that this fixture's JRadioButton is not visible.

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

requireText

public JRadioButtonFixture requireText(String expected)
Asserts that the text of this fixture's JRadioButton 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 JRadioButton does not match the given one.

requireText

public JRadioButtonFixture requireText(Pattern pattern)
Asserts that the text of this fixture's JRadioButton 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 JRadioButton does not match the given regular expression pattern.
Since:
1.2

requireToolTip

public JRadioButtonFixture requireToolTip(String expected)
Asserts that the toolTip in this fixture's JRadioButton 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 JRadioButton does not match the given value.
Since:
1.2

requireToolTip

public JRadioButtonFixture requireToolTip(Pattern pattern)
Asserts that the toolTip in this fixture's JRadioButton 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 JRadioButton 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 JRadioButton, 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 JRadioButton 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 JRadioButton is disabled.
IllegalStateException - if this fixture's JRadioButton 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 JRadioButton 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 JRadioButton is disabled.
IllegalStateException - if this fixture's JRadioButton 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.