Package org.fest.swing.fixture
Class 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:
- 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
ConstructorsConstructorDescriptionJScrollBarFixture(Robot robot, String scrollBarName) Creates a new.JScrollBarFixtureJScrollBarFixture(Robot robot, JScrollBar target) Creates a new.JScrollBarFixture -
Method Summary
Modifier and TypeMethodDescriptionclick()Simulates a user clicking this fixture's.JScrollBarclick(MouseButton button) Simulates a user clicking this fixture's.JScrollBarclick(MouseClickInfo mouseClickInfo) Simulates a user clicking this fixture's.JScrollBarclientProperty(Object key) Returns the client property stored in this fixture's, under the given key.JScrollBarprivate voidSimulates a user double-clicking this fixture's.JScrollBarprotected final voiddriver(JScrollBarDriver newDriver) Sets theto be used by this fixture.JScrollBarDriverfocus()Gives input focus to this fixture's.JScrollBarpressAndReleaseKey(KeyPressInfo keyPressInfo) Simulates a user pressing given key with the given modifiers on this fixture's.JScrollBarpressAndReleaseKeys(int... keyCodes) Simulates a user pressing and releasing the given keys on themanaged by this fixture.JScrollBarpressKey(int keyCode) Simulates a user pressing the given key on this fixture's.JScrollBarreleaseKey(int keyCode) Simulates a user releasing the given key on this fixture's.JScrollBarAsserts that this fixture'sis disabled.JScrollBarAsserts that this fixture'sis enabled.JScrollBarrequireEnabled(Timeout timeout) Asserts that this fixture'sis enabled.JScrollBarAsserts that this fixture'shas input focus.JScrollBarAsserts that this fixture'sis not visible.JScrollBarrequireToolTip(String expected) Asserts that the toolTip in this fixture'smatches the given value.JScrollBarrequireToolTip(Pattern pattern) Asserts that the toolTip in this fixture'smatches the given regular expression pattern.JScrollBarrequireValue(int value) Asserts that the value of this fixture'sis equal to the given one.JScrollBarAsserts that this fixture'sis visible.JScrollBarSimulates a user right-clicking this fixture's.JScrollBarSimulates a user scrolling down one block (usually a page.)scrollBlockDown(int times) Simulates a user scrolling down one block (usually a page,) the given number of times.Simulates a user scrolling up one block (usually a page.)scrollBlockUp(int times) Simulates a user scrolling up one block (usually a page,) the given number of times.scrollTo(int position) Simulates a user scrolling to the given position.Simulates a user scrolling to the maximum position of this fixture's.JScrollBarSimulates a user scrolling to the minimum position of this fixture's.JScrollBarSimulates a user scrolling down one unit (usually a line.)scrollUnitDown(int times) Simulates a user scrolling down one unit (usually a line,) the given number of times.Simulates a user scrolling up one unit (usually a line.)scrollUnitUp(int times) Simulates a user scrolling up one unit (usually a line,) the given number of times.Shows a pop-up menu using this fixture'sas the invoker of the pop-up menu.JScrollBarShows a pop-up menu at the given point using this fixture'sas the invoker of the pop-up menu.JScrollBarMethods inherited from class org.fest.swing.fixture.ComponentFixture
background, component, font, foreground, requireShowing, targetCastedTo, validateNotNull
-
Field Details
-
driver
-
-
Constructor Details
-
JScrollBarFixture
Creates a new.JScrollBarFixture- Parameters:
robot- performs simulation of user events on the givenJScrollBar.target- theJScrollBarto be managed by this fixture.- Throws:
NullPointerException- ifrobotisnull.NullPointerException- iftargetisnull.
-
JScrollBarFixture
Creates a new.JScrollBarFixture- Parameters:
robot- performs simulation of user events on aJScrollBar.scrollBarName- the name of theJScrollBarto find using the givenRobot.- Throws:
NullPointerException- ifrobotisnull.ComponentLookupException- if a matchingJScrollBarcould not be found.ComponentLookupException- if more than one matchingJScrollBaris found.
-
-
Method Details
-
createDriver
private void createDriver() -
driver
Sets theto be used by this fixture.JScrollBarDriver- Parameters:
newDriver- the newJScrollBarDriver.- Throws:
NullPointerException- if the given driver isnull.
-
click
Simulates a user clicking this fixture's.JScrollBar- Specified by:
clickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
click
Simulates a user clicking this fixture's.JScrollBar- Specified by:
clickin interfaceMouseInputSimulationFixture- Parameters:
button- the button to click.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenMouseButtonisnull.IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
click
Simulates a user clicking this fixture's.JScrollBar- 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'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
doubleClick
Simulates a user double-clicking this fixture's.JScrollBar- Specified by:
doubleClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
rightClick
Simulates a user right-clicking this fixture's.JScrollBar- Specified by:
rightClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
focus
Gives input focus to this fixture's.JScrollBar- Specified by:
focusin interfaceFocusableComponentFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris 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 availableJScrollBarmasks.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'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.- See Also:
-
pressAndReleaseKeys
Simulates a user pressing and releasing the given keys on themanaged by this fixture.JScrollBar- 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'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.- See Also:
-
pressKey
Simulates a user pressing the given key on this fixture's.JScrollBar- 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'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.- See Also:
-
releaseKey
Simulates a user releasing the given key on this fixture's.JScrollBar- 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'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.- See Also:
-
scrollBlockDown
Simulates a user scrolling down one block (usually a page.)- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
scrollBlockDown
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- iftimesis less than or equal to zero.IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
scrollBlockUp
Simulates a user scrolling up one block (usually a page.)- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
scrollBlockUp
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- iftimesis less than or equal to zero.IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
scrollTo
Simulates a user scrolling to the given position.- Parameters:
position- the position to scroll to.- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.IllegalArgumentException- if the given position is not within theJScrollBarbounds.
-
scrollToMaximum
Simulates a user scrolling to the maximum position of this fixture's.JScrollBar- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
scrollToMinimum
Simulates a user scrolling to the minimum position of this fixture's.JScrollBar- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
scrollUnitDown
Simulates a user scrolling down one unit (usually a line.)- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
scrollUnitDown
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- iftimesis less than or equal to zero.IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
scrollUnitUp
Simulates a user scrolling up one unit (usually a line.)- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
scrollUnitUp
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- iftimesis less than or equal to zero.IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.
-
requireValue
Asserts that the value of this fixture'sis equal to the given one.JScrollBar- Parameters:
value- the expected value.- Returns:
- this fixture.
- Throws:
AssertionError- if the value of this fixture'sJScrollBaris not equal to the given one.
-
requireFocused
Asserts that this fixture'shas input focus.JScrollBar- Specified by:
requireFocusedin interfaceFocusableComponentFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJScrollBardoes not have input focus.
-
requireEnabled
Asserts that this fixture'sis enabled.JScrollBar- Specified by:
requireEnabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJScrollBaris disabled.
-
requireEnabled
Asserts that this fixture'sis enabled.JScrollBar- 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'sJScrollBaris never enabled.
-
requireDisabled
Asserts that this fixture'sis disabled.JScrollBar- Specified by:
requireDisabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJScrollBaris enabled.
-
requireVisible
Asserts that this fixture'sis visible.JScrollBar- Specified by:
requireVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJScrollBaris not visible.
-
requireNotVisible
Asserts that this fixture'sis not visible.JScrollBar- Specified by:
requireNotVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJScrollBaris visible.
-
showPopupMenu
Shows a pop-up menu using this fixture'sas the invoker of the pop-up menu.JScrollBar- Specified by:
showPopupMenuin interfaceJPopupMenuInvokerFixture- Returns:
- a fixture that manages the displayed pop-up menu.
- Throws:
IllegalStateException- if this fixture'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris 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.JScrollBar- 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'sJScrollBaris disabled.IllegalStateException- if this fixture'sJScrollBaris not showing on the screen.ComponentLookupException- if a pop-up menu cannot be found.
-
clientProperty
Returns the client property stored in this fixture's, under the given key.JScrollBar- 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
-
requireToolTip
Asserts that the toolTip in this fixture'smatches the given value.JScrollBar- 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'sJScrollBardoes not match the given value.- Since:
- 1.2
-
requireToolTip
Asserts that the toolTip in this fixture'smatches the given regular expression pattern.JScrollBar- 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'sJScrollBardoes not match the given regular expression.- Since:
- 1.2
-