org.fest.swing.fixture
Class JScrollBarFixture

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

public class JScrollBarFixture
extends ComponentFixture<JScrollBar>
implements CommonComponentFixture, JComponentFixture, JPopupMenuInvokerFixture

Understands functional testing of JScrollBars:

Author:
Alex Ruiz

Field Summary
 
Fields inherited from class org.fest.swing.fixture.ComponentFixture
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY, robot, target
 
Constructor Summary
JScrollBarFixture(Robot robot, JScrollBar target)
          Creates a new JScrollBarFixture.
JScrollBarFixture(Robot robot, String scrollBarName)
          Creates a new JScrollBarFixture.
 
Method Summary
 JScrollBarFixture click()
          Simulates a user clicking this fixture's JScrollBar.
 JScrollBarFixture click(MouseButton button)
          Simulates a user clicking this fixture's JScrollBar.
 JScrollBarFixture click(MouseClickInfo mouseClickInfo)
          Simulates a user clicking this fixture's JScrollBar.
 Object clientProperty(Object key)
          Returns the client property stored in this fixture's JScrollBar, under the given key.
 JScrollBarFixture doubleClick()
          Simulates a user double-clicking this fixture's JScrollBar.
protected  void driver(JScrollBarDriver newDriver)
          Sets the JScrollBarDriver to be used by this fixture.
 JScrollBarFixture focus()
          Gives input focus to this fixture's JScrollBar.
 JScrollBarFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
          Simulates a user pressing given key with the given modifiers on this fixture's JScrollBar.
 JScrollBarFixture pressAndReleaseKeys(int... keyCodes)
          Simulates a user pressing and releasing the given keys on the JScrollBar managed by this fixture.
 JScrollBarFixture pressKey(int keyCode)
          Simulates a user pressing the given key on this fixture's JScrollBar.
 JScrollBarFixture releaseKey(int keyCode)
          Simulates a user releasing the given key on this fixture's JScrollBar.
 JScrollBarFixture requireDisabled()
          Asserts that this fixture's JScrollBar is disabled.
 JScrollBarFixture requireEnabled()
          Asserts that this fixture's JScrollBar is enabled.
 JScrollBarFixture requireEnabled(Timeout timeout)
          Asserts that this fixture's JScrollBar is enabled.
 JScrollBarFixture requireFocused()
          Asserts that this fixture's JScrollBar has input focus.
 JScrollBarFixture requireNotVisible()
          Asserts that this fixture's JScrollBar is not visible.
 JScrollBarFixture requireToolTip(Pattern pattern)
          Asserts that the toolTip in this fixture's JScrollBar matches the given regular expression pattern.
 JScrollBarFixture requireToolTip(String expected)
          Asserts that the toolTip in this fixture's JScrollBar matches the given value.
 JScrollBarFixture requireValue(int value)
          Asserts that the value of this fixture's JScrollBar is equal to the given one.
 JScrollBarFixture requireVisible()
          Asserts that this fixture's JScrollBar is visible.
 JScrollBarFixture rightClick()
          Simulates a user right-clicking this fixture's JScrollBar.
 JScrollBarFixture scrollBlockDown()
          Simulates a user scrolling down one block (usually a page.)
 JScrollBarFixture scrollBlockDown(int times)
          Simulates a user scrolling down one block (usually a page,) the given number of times.
 JScrollBarFixture scrollBlockUp()
          Simulates a user scrolling up one block (usually a page.)
 JScrollBarFixture scrollBlockUp(int times)
          Simulates a user scrolling up one block (usually a page,) the given number of times.
 JScrollBarFixture scrollTo(int position)
          Simulates a user scrolling to the given position.
 JScrollBarFixture scrollToMaximum()
          Simulates a user scrolling to the maximum position of this fixture's JScrollBar.
 JScrollBarFixture scrollToMinimum()
          Simulates a user scrolling to the minimum position of this fixture's JScrollBar.
 JScrollBarFixture scrollUnitDown()
          Simulates a user scrolling down one unit (usually a line.)
 JScrollBarFixture scrollUnitDown(int times)
          Simulates a user scrolling down one unit (usually a line,) the given number of times.
 JScrollBarFixture scrollUnitUp()
          Simulates a user scrolling up one unit (usually a line.)
 JScrollBarFixture scrollUnitUp(int times)
          Simulates a user scrolling up one unit (usually a line,) the given number of times.
 JPopupMenuFixture showPopupMenu()
          Shows a pop-up menu using this fixture's JScrollBar 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 JScrollBar as the invoker of the pop-up menu.
 
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

JScrollBarFixture

public JScrollBarFixture(Robot robot,
                         JScrollBar target)
Creates a new JScrollBarFixture.

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

JScrollBarFixture

public JScrollBarFixture(Robot robot,
                         String scrollBarName)
Creates a new JScrollBarFixture.

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

driver

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

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

click

public JScrollBarFixture click()
Simulates a user clicking this fixture's JScrollBar.

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

click

public JScrollBarFixture click(MouseButton button)
Simulates a user clicking this fixture's JScrollBar.

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

click

public JScrollBarFixture click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's JScrollBar.

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

doubleClick

public JScrollBarFixture doubleClick()
Simulates a user double-clicking this fixture's JScrollBar.

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

rightClick

public JScrollBarFixture rightClick()
Simulates a user right-clicking this fixture's JScrollBar.

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

focus

public JScrollBarFixture focus()
Gives input focus to this fixture's JScrollBar.

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

pressAndReleaseKey

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

pressAndReleaseKeys

public JScrollBarFixture pressAndReleaseKeys(int... keyCodes)
Simulates a user pressing and releasing the given keys on the JScrollBar managed by this fixture.

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

pressKey

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

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

releaseKey

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

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

scrollBlockDown

public JScrollBarFixture scrollBlockDown()
Simulates a user scrolling down one block (usually a page.)

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

scrollBlockDown

public JScrollBarFixture scrollBlockDown(int times)
Simulates a user scrolling down one block (usually a page,) the given number of times.

Parameters:
times - the number of times to scroll down one block.
Returns:
this fixture.
Throws:
IllegalArgumentException - if times is less than or equal to zero.
IllegalStateException - if this fixture's JScrollBar is disabled.
IllegalStateException - if this fixture's JScrollBar is not showing on the screen.

scrollBlockUp

public JScrollBarFixture scrollBlockUp()
Simulates a user scrolling up one block (usually a page.)

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

scrollBlockUp

public JScrollBarFixture scrollBlockUp(int times)
Simulates a user scrolling up one block (usually a page,) the given number of times.

Parameters:
times - the number of times to scroll up one block.
Returns:
this fixture.
Throws:
IllegalArgumentException - if times is less than or equal to zero.
IllegalStateException - if this fixture's JScrollBar is disabled.
IllegalStateException - if this fixture's JScrollBar is not showing on the screen.

scrollTo

public JScrollBarFixture scrollTo(int position)
Simulates a user scrolling to the given position.

Parameters:
position - the position to scroll to.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JScrollBar is disabled.
IllegalStateException - if this fixture's JScrollBar is not showing on the screen.
IllegalArgumentException - if the given position is not within the JScrollBar bounds.

scrollToMaximum

public JScrollBarFixture scrollToMaximum()
Simulates a user scrolling to the maximum position of this fixture's JScrollBar.

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

scrollToMinimum

public JScrollBarFixture scrollToMinimum()
Simulates a user scrolling to the minimum position of this fixture's JScrollBar.

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

scrollUnitDown

public JScrollBarFixture scrollUnitDown()
Simulates a user scrolling down one unit (usually a line.)

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

scrollUnitDown

public JScrollBarFixture scrollUnitDown(int times)
Simulates a user scrolling down one unit (usually a line,) the given number of times.

Parameters:
times - the number of times to scroll down one unit.
Returns:
this fixture.
Throws:
IllegalArgumentException - if times is less than or equal to zero.
IllegalStateException - if this fixture's JScrollBar is disabled.
IllegalStateException - if this fixture's JScrollBar is not showing on the screen.

scrollUnitUp

public JScrollBarFixture scrollUnitUp()
Simulates a user scrolling up one unit (usually a line.)

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

scrollUnitUp

public JScrollBarFixture scrollUnitUp(int times)
Simulates a user scrolling up one unit (usually a line,) the given number of times.

Parameters:
times - the number of times to scroll up one unit.
Returns:
this fixture.
Throws:
IllegalArgumentException - if times is less than or equal to zero.
IllegalStateException - if this fixture's JScrollBar is disabled.
IllegalStateException - if this fixture's JScrollBar is not showing on the screen.

requireValue

public JScrollBarFixture requireValue(int value)
Asserts that the value of this fixture's JScrollBar is equal to the given one.

Parameters:
value - the expected value.
Returns:
this fixture.
Throws:
AssertionError - if the value of this fixture's JScrollBar is not equal to the given one.

requireFocused

public JScrollBarFixture requireFocused()
Asserts that this fixture's JScrollBar has input focus.

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

requireEnabled

public JScrollBarFixture requireEnabled()
Asserts that this fixture's JScrollBar is enabled.

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

requireEnabled

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

requireDisabled

public JScrollBarFixture requireDisabled()
Asserts that this fixture's JScrollBar is disabled.

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

requireVisible

public JScrollBarFixture requireVisible()
Asserts that this fixture's JScrollBar is visible.

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

requireNotVisible

public JScrollBarFixture requireNotVisible()
Asserts that this fixture's JScrollBar is not visible.

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

showPopupMenu

public JPopupMenuFixture showPopupMenu()
Shows a pop-up menu using this fixture's JScrollBar 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 JScrollBar is disabled.
IllegalStateException - if this fixture's JScrollBar 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 JScrollBar 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 JScrollBar is disabled.
IllegalStateException - if this fixture's JScrollBar is not showing on the screen.
ComponentLookupException - if a pop-up menu cannot be found.

clientProperty

public Object clientProperty(Object key)
Returns the client property stored in this fixture's JScrollBar, 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

requireToolTip

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

requireToolTip

public JScrollBarFixture requireToolTip(Pattern pattern)
Asserts that the toolTip in this fixture's JScrollBar 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 JScrollBar does not match the given regular expression.
Since:
1.2


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