org.fest.swing.fixture
Class JListFixture

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

public class JListFixture
extends ComponentFixture<JList>
implements CommonComponentFixture, ItemGroupFixture, JComponentFixture, JPopupMenuInvokerFixture

Understands functional testing of JLists:

The conversion between the values given in tests and the values being displayed by a JList renderer is performed by a JListCellReader. This fixture uses a BasicJListCellReader by default.

Author:
Alex Ruiz, Yvonne Wang, Fabien Barbero

Field Summary
 
Fields inherited from class org.fest.swing.fixture.ComponentFixture
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY, robot, target
 
Constructor Summary
JListFixture(Robot robot, JList target)
          Creates a new JListFixture.
JListFixture(Robot robot, String listName)
          Creates a new JListFixture.
 
Method Summary
 JListFixture cellReader(JListCellReader cellReader)
          Updates the implementation of JListCellReader to use when comparing internal values of this fixture's JList and the values expected in a test.
 JListFixture clearSelection()
          Clears the selection in this fixture's JList.
 JListFixture click()
          Simulates a user clicking this fixture's JList.
 JListFixture click(MouseButton button)
          Simulates a user clicking this fixture's JList.
 JListFixture click(MouseClickInfo mouseClickInfo)
          Simulates a user clicking this fixture's JList.
 JListFixture clickItem(int index)
          Simulates a user clicking an item in this fixture's JList.
 JListFixture clickItem(Pattern pattern)
          Simulates a user clicking an item in this fixture's JList.
 JListFixture clickItem(String text)
          Simulates a user clicking an item in this fixture's JList.
 Object clientProperty(Object key)
          Returns the client property stored in this fixture's JList, under the given key.
 String[] contents()
          Returns the String representation of the elements in this fixture's JList, using this fixture's JListCellReader.
 JListFixture doubleClick()
          Simulates a user double-clicking this fixture's JList.
 JListFixture doubleClickItem(int index)
          Deprecated. to be removed in version 2.0. Use item(int) and JListItemFixture.doubleClick() instead.
 JListFixture doubleClickItem(String text)
          Deprecated. to be removed in version 2.0. Use item(String) and JListItemFixture.doubleClick() instead.
 JListFixture drag(int index)
          Simulates a user dragging an item from this fixture's JList.
 JListFixture drag(Pattern pattern)
          Simulates a drag operation at the location of the first item in this fixture's JList matching the given regular expression pattern.
 JListFixture drag(String text)
          Simulates a drag operation at the location of the first item in this fixture's JList matching the given value.
protected  void driver(JListDriver newDriver)
          Sets the JListDriver to be used by this fixture.
 JListFixture drop()
          Simulates a user dropping an item at the center of this fixture's JList.
 JListFixture drop(int index)
          Simulates a user dropping an item to this fixture's JList.
 JListFixture drop(Pattern pattern)
          Ends a drag operation at the location of the first item matching the given regular expression pattern.
 JListFixture drop(String text)
          Ends a drag operation at the location of the first item matching the given value.
 JListFixture focus()
          Gives input focus to this fixture's JList.
 JListItemFixture item(int index)
          Returns a fixture that manages the list item specified by the given index.
 JListItemFixture item(Pattern pattern)
          Returns a fixture that manages the list item whose text matches the given regular expression pattern.
 JListItemFixture item(String text)
          Returns a fixture that manages the list item specified by the given text.
 JListFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
          Simulates a user pressing given key with the given modifiers on this fixture's JList.
 JListFixture pressAndReleaseKeys(int... keyCodes)
          Simulates a user pressing and releasing the given keys on this fixture's JList.
 JListFixture pressKey(int keyCode)
          Simulates a user pressing the given key on this fixture's JList.
 JListFixture releaseKey(int keyCode)
          Simulates a user releasing the given key on this fixture's JList.
 JListFixture requireDisabled()
          Asserts that this fixture's JList is not enabled.
 JListFixture requireEnabled()
          Asserts that this fixture's JList is enabled.
 JListFixture requireEnabled(Timeout timeout)
          Asserts that this fixture's JList is enabled.
 JListFixture requireFocused()
          Asserts that this fixture's JList has input focus.
 JListFixture requireItemCount(int expected)
          Verifies that this fixture's JList has the expected number of items
 JListFixture requireNoSelection()
          Verifies that this fixture's JList does not have any selection.
 JListFixture requireNotVisible()
          Asserts that this fixture's JList is not visible.
 JListFixture requireSelectedItems(int... indices)
          Verifies that the given item indices are selected in this fixture's JList.
 JListFixture requireSelectedItems(Pattern[] patterns)
          Verifies that the String representations of the selected items in this fixture's JList match the given regular expression patterns.
 JListFixture requireSelectedItems(String... items)
          Verifies that the String representations of the selected items in this fixture's JList match the given text items.
 JListFixture requireSelection(int index)
          Verifies that the index of the selected item in this fixture's JList is equal to the given value.
 JListFixture requireSelection(Pattern pattern)
          Verifies that the String representation of the selected item in this fixture's JList matches the given regular expression pattern.
 JListFixture requireSelection(String text)
          Verifies that the String representation of the selected item in this fixture's JList matches the given text.
 JListFixture requireToolTip(Pattern pattern)
          Asserts that the toolTip in this fixture's JList matches the given regular expression pattern.
 JListFixture requireToolTip(String expected)
          Asserts that the toolTip in this fixture's JList matches the given value.
 JListFixture requireVisible()
          Asserts that this fixture's JList is visible.
 JListFixture rightClick()
          Simulates a user right-clicking this fixture's JList.
 String[] selection()
          Returns the String representation of the selected elements in this fixture's JList, using this fixture's JListCellReader.
 JListFixture selectItem(int index)
          Simulates a user selecting an item in this fixture's JList.
 JListFixture selectItem(Pattern pattern)
          Simulates a user selecting an item in this fixture's JList.
 JListFixture selectItem(String text)
          Simulates a user selecting an item in this fixture's JList.
 JListFixture selectItems(int... indices)
          Simulates a user selecting the specified items in this fixture's JList.
 JListFixture selectItems(Pattern... patterns)
          Simulates a user selecting the specified items in this fixture's JList.
 JListFixture selectItems(Range.From from, Range.To to)
          Simulates a user selecting the items (in the specified range) in this fixture's JList.
 JListFixture selectItems(String... items)
          Simulates a user selecting the specified items in this fixture's JList.
 JPopupMenuFixture showPopupMenu()
          Shows a pop-up menu using this fixture's JList as the invoker of the pop-up menu.
 JPopupMenuFixture showPopupMenuAt(int index)
          Shows a pop-up menu at the location of the specified item in this fixture's JList.
 JPopupMenuFixture showPopupMenuAt(Pattern pattern)
          Shows a pop-up menu at the location of the first item matching the given regular expression pattern in this fixture's JList.
 JPopupMenuFixture showPopupMenuAt(Point p)
          Shows a pop-up menu at the given point using this fixture's JList as the invoker of the pop-up menu.
 JPopupMenuFixture showPopupMenuAt(String text)
          Shows a pop-up menu at the location of the first item matching the given value in this fixture's JList.
 String valueAt(int index)
          Returns the String representation of the value of an item in this fixture's JList, using this fixture's JListCellReader.
 
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

JListFixture

public JListFixture(Robot robot,
                    String listName)
Creates a new JListFixture.

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

JListFixture

public JListFixture(Robot robot,
                    JList target)
Creates a new JListFixture.

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

driver

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

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

valueAt

public String valueAt(int index)
Returns the String representation of the value of an item in this fixture's JList, using this fixture's JListCellReader.

Specified by:
valueAt in interface ItemGroupFixture
Parameters:
index - the index of the item to return.
Returns:
the String representation of the value of an item in this fixture's JList.
Throws:
IndexOutOfBoundsException - if the given index is negative or greater than the index of the last item in the JList.
See Also:
cellReader(JListCellReader)

contents

public String[] contents()
Returns the String representation of the elements in this fixture's JList, using this fixture's JListCellReader.

Specified by:
contents in interface ItemGroupFixture
Returns:
the String representation of the elements in this fixture's JList.
See Also:
cellReader(JListCellReader)

selection

public String[] selection()
Returns the String representation of the selected elements in this fixture's JList, using this fixture's JListCellReader.

Returns:
the String representation of the selected elements in this fixture's JList.
See Also:
cellReader(JListCellReader)

item

public JListItemFixture item(int index)
Returns a fixture that manages the list item specified by the given index.

Parameters:
index - of the item.
Returns:
a fixture that manages the list item specified by the given index.
Throws:
IndexOutOfBoundsException - if the index is out of bounds.

item

public JListItemFixture item(String text)
Returns a fixture that manages the list item specified by the given text.

Parameters:
text - the text of the item. It can be a regular expression.
Returns:
a fixture that manages the list item specified by the given text.
Throws:
LocationUnavailableException - if an element matching the given text cannot be found.

item

public JListItemFixture item(Pattern pattern)
Returns a fixture that manages the list item whose text matches the given regular expression pattern.

Parameters:
pattern - the regular expression pattern to match.
Returns:
a fixture that manages the list item whose text matches the given regular expression pattern.
Throws:
LocationUnavailableException - if an element matching the given text cannot be found.
NullPointerException - if the given regular expression pattern is null.
Since:
1.2

clearSelection

public JListFixture clearSelection()
Clears the selection in this fixture's JList. Since this method does not simulate user input, it does not verifies that this fixture's JList is enabled and showing.

Specified by:
clearSelection in interface ItemGroupFixture
Returns:
this fixture.
Since:
1.2

selectItems

public JListFixture selectItems(Range.From from,
                                Range.To to)
Simulates a user selecting the items (in the specified range) in this fixture's JList.

Parameters:
from - the starting point of the selection.
to - the last item to select (inclusive.)
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
IndexOutOfBoundsException - if the any index is negative or greater than the index of the last item in the JList.

selectItems

public JListFixture selectItems(int... indices)
Simulates a user selecting the specified items in this fixture's JList.

Parameters:
indices - the indices of the items to select.
Returns:
this fixture.
Throws:
NullPointerException - if the given array is null.
IllegalArgumentException - if the given array is empty.
IndexOutOfBoundsException - if any of the indices is negative or greater than the index of the last item in the JList.
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.

selectItems

public JListFixture selectItems(String... items)
Simulates a user selecting the specified items in this fixture's JList. The items to select should match the given values.

Parameters:
items - the text of the items to select. Each String can be a regular expression.
Returns:
this fixture.
Throws:
NullPointerException - if the given array is null.
IllegalArgumentException - if the given array is empty.
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
LocationUnavailableException - if an element matching the any of the given values cannot be found.
See Also:
cellReader(JListCellReader)

selectItems

public JListFixture selectItems(Pattern... patterns)
Simulates a user selecting the specified items in this fixture's JList. The items to select should select the given regular expression patterns.

Parameters:
patterns - the regular expression patterns to match.
Returns:
this fixture.
Throws:
NullPointerException - if the given array is null.
NullPointerException - if any of the regular expression patterns is null.
IllegalArgumentException - if the given array is empty.
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
LocationUnavailableException - if an element matching the any of the given regular expression patterns cannot be found.
Since:
1.2
See Also:
cellReader(JListCellReader)

selectItem

public JListFixture selectItem(int index)
Simulates a user selecting an item in this fixture's JList.

Specified by:
selectItem in interface ItemGroupFixture
Parameters:
index - the index of the item to select.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
IndexOutOfBoundsException - if the given index is negative or greater than the index of the last item in the JList.
See Also:
item(int), JListItemFixture.select()

selectItem

public JListFixture selectItem(String text)
Simulates a user selecting an item in this fixture's JList.

Specified by:
selectItem in interface ItemGroupFixture
Parameters:
text - the text of the item to select. It can be a regular expression.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
LocationUnavailableException - if an element matching the given text cannot be found.
See Also:
item(String), JListItemFixture.select(), cellReader(JListCellReader)

selectItem

public JListFixture selectItem(Pattern pattern)
Simulates a user selecting an item in this fixture's JList. The value of the item to select must match the given regular expression pattern.

Specified by:
selectItem in interface ItemGroupFixture
Parameters:
pattern - the regular expression pattern to match.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
LocationUnavailableException - if an element matching the given text cannot be found.
NullPointerException - if the given regular expression pattern is null.
Since:
1.2
See Also:
item(Pattern), JListItemFixture.select(), cellReader(JListCellReader)

clickItem

public JListFixture clickItem(int index)
Simulates a user clicking an item in this fixture's JList.

Parameters:
index - the index of the item to clicking.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
IndexOutOfBoundsException - if the given index is negative or greater than the index of the last item in the JList.
Since:
1.2
See Also:
item(int), JListItemFixture.click()

clickItem

public JListFixture clickItem(String text)
Simulates a user clicking an item in this fixture's JList.

Parameters:
text - the text of the item to select. It can be a regular expression.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
LocationUnavailableException - if an element matching the given text cannot be found.
Since:
1.2
See Also:
item(String), JListItemFixture.select(), cellReader(JListCellReader)

clickItem

public JListFixture clickItem(Pattern pattern)
Simulates a user clicking an item in this fixture's JList. The value of the item to select must match the given regular expression pattern.

Parameters:
pattern - the regular expression pattern to match.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
LocationUnavailableException - if an element matching the given text cannot be found.
NullPointerException - if the given regular expression pattern is null.
Since:
1.2
See Also:
item(Pattern), JListItemFixture.select(), cellReader(JListCellReader)

doubleClickItem

@Deprecated
public JListFixture doubleClickItem(int index)
Deprecated. to be removed in version 2.0. Use item(int) and JListItemFixture.doubleClick() instead.

Simulates a user double-clicking an item in this fixture's JList.

Parameters:
index - the index of the item to double-click.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
IndexOutOfBoundsException - if the given index is negative or greater than the index of the last item in the JList.

doubleClickItem

@Deprecated
public JListFixture doubleClickItem(String text)
Deprecated. to be removed in version 2.0. Use item(String) and JListItemFixture.doubleClick() instead.

Simulates a user double-clicking an item in this fixture's JList.

Parameters:
text - the text of the item to double-click.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
LocationUnavailableException - if an element matching the given String cannot be found.

click

public JListFixture click()
Simulates a user clicking this fixture's JList.

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

click

public JListFixture click(MouseButton button)
Simulates a user clicking this fixture's JList.

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

click

public JListFixture click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's JList.

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

doubleClick

public JListFixture doubleClick()
Simulates a user double-clicking this fixture's JList.

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

rightClick

public JListFixture rightClick()
Simulates a user right-clicking this fixture's JList.

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

focus

public JListFixture focus()
Gives input focus to this fixture's JList.

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

pressAndReleaseKey

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

pressAndReleaseKeys

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

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

pressKey

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

Specified by:
pressKey in interface KeyboardInputSimulationFixture
Parameters:
keyCode - the code of the key to press.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
See Also:
KeyEvent

releaseKey

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

Specified by:
releaseKey in interface KeyboardInputSimulationFixture
Parameters:
keyCode - the code of the key to release.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
See Also:
KeyEvent

drag

public JListFixture drag(String text)
Simulates a drag operation at the location of the first item in this fixture's JList matching the given value.

Parameters:
text - the text of the item to drag. It can be a regular expression.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
LocationUnavailableException - if an element matching the given text cannot be found.
See Also:
cellReader(JListCellReader)

drop

public JListFixture drop(String text)
Ends a drag operation at the location of the first item matching the given value.

Parameters:
text - the text of the item to drop. It can be a regular expression.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
LocationUnavailableException - if an element matching the given text cannot be found.
ActionFailedException - if there is no drag action in effect.

drag

public JListFixture drag(Pattern pattern)
Simulates a drag operation at the location of the first item in this fixture's JList matching the given regular expression pattern.

Parameters:
pattern - the regular expression pattern to match.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
NullPointerException - if the given regular expression pattern in null.
LocationUnavailableException - if an element matching the given regular expression pattern cannot be found.
Since:
1.2
See Also:
cellReader(JListCellReader)

drop

public JListFixture drop(Pattern pattern)
Ends a drag operation at the location of the first item matching the given regular expression pattern.

Parameters:
pattern - the regular expression pattern to match.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
NullPointerException - if the given regular expression pattern in null.
LocationUnavailableException - if an element matching the given text cannot be found.
ActionFailedException - if there is no drag action in effect.
Since:
1.2
See Also:
cellReader(JListCellReader)

drop

public JListFixture drop()
Simulates a user dropping an item at the center of this fixture's JList.

Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
ActionFailedException - if there is no drag action in effect.

drag

public JListFixture drag(int index)
Simulates a user dragging an item from this fixture's JList.

Parameters:
index - the index of the item to drag.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
IndexOutOfBoundsException - if the given index is negative or greater than the index of the last item in the JList.

drop

public JListFixture drop(int index)
Simulates a user dropping an item to this fixture's JList.

Parameters:
index - the index of the item to drop.
Returns:
this fixture.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
IndexOutOfBoundsException - if the given index is negative or greater than the index of the last item in the JList.
ActionFailedException - if there is no drag action in effect.

showPopupMenuAt

public JPopupMenuFixture showPopupMenuAt(int index)
Shows a pop-up menu at the location of the specified item in this fixture's JList.

Parameters:
index - the index of the item.
Returns:
a fixture that manages the displayed pop-up menu.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
ComponentLookupException - if a pop-up menu cannot be found.
IndexOutOfBoundsException - if the given index is negative or greater than the index of the last item in the JList.

showPopupMenuAt

public JPopupMenuFixture showPopupMenuAt(String text)
Shows a pop-up menu at the location of the first item matching the given value in this fixture's JList.

Parameters:
text - the text of the item. It can be a regular expression.
Returns:
a fixture that manages the displayed pop-up menu.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
ComponentLookupException - if a pop-up menu cannot be found.
LocationUnavailableException - if an element matching the given value cannot be found.

showPopupMenuAt

public JPopupMenuFixture showPopupMenuAt(Pattern pattern)
Shows a pop-up menu at the location of the first item matching the given regular expression pattern in this fixture's JList.

Parameters:
pattern - the regular expression pattern to match.
Returns:
a fixture that manages the displayed pop-up menu.
Throws:
IllegalStateException - if this fixture's JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
NullPointerException - if the given regular expression pattern is null.
ComponentLookupException - if a pop-up menu cannot be found.
LocationUnavailableException - if an element matching the given value cannot be found.
Since:
1.2

requireFocused

public JListFixture requireFocused()
Asserts that this fixture's JList has input focus.

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

requireEnabled

public JListFixture requireEnabled()
Asserts that this fixture's JList is enabled.

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

requireEnabled

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

requireDisabled

public JListFixture requireDisabled()
Asserts that this fixture's JList is not enabled.

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

requireVisible

public JListFixture requireVisible()
Asserts that this fixture's JList is visible.

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

requireNotVisible

public JListFixture requireNotVisible()
Asserts that this fixture's JList is not visible.

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

requireSelection

public JListFixture requireSelection(String text)
Verifies that the String representation of the selected item in this fixture's JList matches the given text.

Specified by:
requireSelection in interface ItemGroupFixture
Parameters:
text - the text to match. It can be a regular expression pattern.
Returns:
this fixture.
Throws:
AssertionError - if the selected item does not match the given text.
See Also:
cellReader(JListCellReader)

requireSelection

public JListFixture requireSelection(Pattern pattern)
Verifies that the String representation of the selected item in this fixture's JList matches the given regular expression pattern.

Specified by:
requireSelection in interface ItemGroupFixture
Parameters:
pattern - the regular expression pattern to match.
Returns:
this fixture.
Throws:
AssertionError - if the selected item does not match the given regular expression pattern.
NullPointerException - if the given regular expression pattern is null.
Since:
1.2
See Also:
cellReader(JListCellReader)

requireSelection

public JListFixture requireSelection(int index)
Verifies that the index of the selected item in this fixture's JList is equal to the given value.

Specified by:
requireSelection in interface ItemGroupFixture
Parameters:
index - the expected selection index.
Returns:
this fixture.
Throws:
AssertionError - if the selected index is not equal to the given one.
Since:
1.2

requireSelectedItems

public JListFixture requireSelectedItems(String... items)
Verifies that the String representations of the selected items in this fixture's JList match the given text items.

Parameters:
items - text items to match. Each String can be a regular expression.
Returns:
this fixture.
Throws:
NullPointerException - if the given array is null.
IllegalArgumentException - if the given array is empty.
AssertionError - if the selected items do not match the given text items.
See Also:
cellReader(JListCellReader)

requireSelectedItems

public JListFixture requireSelectedItems(Pattern[] patterns)
Verifies that the String representations of the selected items in this fixture's JList match the given regular expression patterns.

Parameters:
patterns - the regular expression patterns to match.
Returns:
this fixture.
Throws:
NullPointerException - if the given array is null.
IllegalArgumentException - if the given array is empty.
NullPointerException - if any of the patterns in the given array is null.
AssertionError - if the selected items do not match the given regular expression patterns.
Since:
1.2
See Also:
cellReader(JListCellReader)

requireSelectedItems

public JListFixture requireSelectedItems(int... indices)
Verifies that the given item indices are selected in this fixture's JList.

Parameters:
indices - the expected indices of the selected items.
Returns:
this fixture.
Throws:
NullPointerException - if the given array is null.
IllegalArgumentException - if the given array is empty.
AssertionError - if the selection in this fixture's JList does not match the given one.
Since:
1.2

requireNoSelection

public JListFixture requireNoSelection()
Verifies that this fixture's JList does not have any selection.

Specified by:
requireNoSelection in interface ItemGroupFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's JList has a selection.

requireItemCount

public JListFixture requireItemCount(int expected)
Verifies that this fixture's JList has the expected number of items

Specified by:
requireItemCount in interface ItemGroupFixture
Parameters:
expected - the expected number of items.
Returns:
this fixture.
Throws:
AssertionError - if the number of items in this fixture's JList is not equal to the expected one.
Since:
1.2

requireToolTip

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

requireToolTip

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

clientProperty

public Object clientProperty(Object key)
Returns the client property stored in this fixture's JList, 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 JList 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 JList is disabled.
IllegalStateException - if this fixture's JList 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 JList 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 JList is disabled.
IllegalStateException - if this fixture's JList is not showing on the screen.
ComponentLookupException - if a pop-up menu cannot be found.

cellReader

public JListFixture cellReader(JListCellReader cellReader)
Updates the implementation of JListCellReader to use when comparing internal values of this fixture's JList and the values expected in a test. The default implementation to use is BasicJListCellReader.

Parameters:
cellReader - the new JListCellValueReader to use.
Returns:
this fixture.
Throws:
NullPointerException - if cellReader is null.


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