public class JListFixture extends AbstractJPopupMenuInvokerFixture<JListFixture,JList,JListDriver> implements ItemGroupFixture<JListFixture>
Supports functional testing of JList
s.
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.
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY
Constructor and Description |
---|
JListFixture(Robot robot,
JList target)
Creates a new
JListFixture . |
JListFixture(Robot robot,
String listName)
Creates a new
JListFixture . |
Modifier and Type | Method and Description |
---|---|
JListFixture |
clearSelection()
Clears the selection in 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 . |
String[] |
contents()
Returns the
String representation of the elements in this fixture's JList , using this fixture's
JListCellReader . |
protected JListDriver |
createDriver(Robot robot) |
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. |
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.
|
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.
|
void |
replaceCellReader(JListCellReader cellReader) |
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 |
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. |
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 |
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(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 . |
showPopupMenu, showPopupMenuAt
clientProperty, requireToolTip, requireToolTip
background, click, click, click, doubleClick, driver, focus, font, foreground, isEnabled, myself, pressAndReleaseKey, pressAndReleaseKeys, pressKey, releaseKey, replaceDriverWith, requireDisabled, requireEnabled, requireEnabled, requireFocused, requireNotVisible, requireShowing, requireVisible, rightClick, robot, target, targetCastedTo
public JListFixture(@Nonnull Robot robot, @Nullable String listName)
JListFixture
.robot
- performs simulation of user events on a JList
.listName
- the name of the JList
to find using the given Robot
.NullPointerException
- if robot
is null
.ComponentLookupException
- if a matching JList
could not be found.ComponentLookupException
- if more than one matching JList
is found.public JListFixture(@Nonnull Robot robot, @Nonnull JList target)
JListFixture
.robot
- performs simulation of user events on the given JList
.target
- the JList
to be managed by this fixture.NullPointerException
- if robot
is null
.NullPointerException
- if target
is null
.@Nonnull protected JListDriver createDriver(@Nonnull Robot robot)
createDriver
in class AbstractComponentFixture<JListFixture,JList,JListDriver>
@Nullable public String valueAt(int index)
String
representation of the value of an item in this fixture's JList
, using this
fixture's JListCellReader
.valueAt
in interface ItemGroupFixture<JListFixture>
index
- the index of the item to return.String
representation of the value of an item in this fixture's JList
.IndexOutOfBoundsException
- if the given index is negative or greater than the index of the last item in the
JList
.replaceCellReader(JListCellReader)
@Nonnull public String[] contents()
String
representation of the elements in this fixture's JList
, using this fixture's
JListCellReader
.contents
in interface ItemGroupFixture<JListFixture>
String
representation of the elements in this fixture's JList
.replaceCellReader(JListCellReader)
@Nonnull public String[] selection()
String
representation of the selected elements in this fixture's JList
, using this
fixture's JListCellReader
.String
representation of the selected elements in this fixture's JList
.replaceCellReader(JListCellReader)
@Nonnull public JListItemFixture item(int index)
index
- of the item.IndexOutOfBoundsException
- if the index is out of bounds.@Nonnull public JListItemFixture item(@Nullable String text)
text
- the text of the item. It can be a regular expression.LocationUnavailableException
- if an element matching the given text cannot be found.@Nonnull public JListItemFixture item(@Nonnull Pattern pattern)
pattern
- the regular expression pattern to match.LocationUnavailableException
- if an element matching the given text cannot be found.NullPointerException
- if the given regular expression pattern is null
.@Nonnull public JListFixture clearSelection()
JList
. Since this method does not simulate user input, it does not
verifies that this fixture's JList
is enabled and showing.clearSelection
in interface ItemGroupFixture<JListFixture>
@Nonnull public JListFixture selectItem(int index)
JList
.selectItem
in interface ItemGroupFixture<JListFixture>
index
- the index of the item to select.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
.item(int)
,
JListItemFixture.select()
@Nonnull public JListFixture selectItem(@Nullable String text)
JList
.selectItem
in interface ItemGroupFixture<JListFixture>
text
- the text of the item to select. It can be a regular expression.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.item(String)
,
JListItemFixture.select()
,
replaceCellReader(JListCellReader)
@Nonnull public JListFixture selectItem(@Nonnull Pattern pattern)
JList
. The value of the item to select must match the
given regular expression pattern.selectItem
in interface ItemGroupFixture<JListFixture>
pattern
- the regular expression pattern to match.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
.item(Pattern)
,
JListItemFixture.select()
,
replaceCellReader(JListCellReader)
@Nonnull public JListFixture requireSelection(@Nullable String text)
String
representation of the selected item in this fixture's JList
matches the
given text.requireSelection
in interface ItemGroupFixture<JListFixture>
text
- the text to match. It can be a regular expression pattern.AssertionError
- if the selected item does not match the given text.replaceCellReader(JListCellReader)
@Nonnull public JListFixture requireSelection(@Nonnull Pattern pattern)
String
representation of the selected item in this fixture's JList
matches the
given regular expression pattern.requireSelection
in interface ItemGroupFixture<JListFixture>
pattern
- the regular expression pattern to match.AssertionError
- if the selected item does not match the given regular expression pattern.NullPointerException
- if the given regular expression pattern is null
.replaceCellReader(JListCellReader)
@Nonnull public JListFixture requireSelection(int index)
JList
is equal to the given value.requireSelection
in interface ItemGroupFixture<JListFixture>
index
- the expected selection index.AssertionError
- if the selected index is not equal to the given one.@Nonnull public JListFixture requireNoSelection()
JList
does not have any selection.requireNoSelection
in interface ItemGroupFixture<JListFixture>
AssertionError
- if this fixture's JList
has a selection.@Nonnull public JListFixture requireItemCount(int expected)
JList
has the expected number of itemsrequireItemCount
in interface ItemGroupFixture<JListFixture>
expected
- the expected number of items.AssertionError
- if the number of items in this fixture's JList
is not equal to the expected one.@Nonnull public JListFixture selectItems(@Nonnull Range.From from, @Nonnull Range.To to)
JList
.from
- the starting point of the selection.to
- the last item to select (inclusive.)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
.@Nonnull public JListFixture selectItems(@Nonnull int... indices)
JList
.indices
- the indices of the items to select.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.@Nonnull public JListFixture selectItems(@Nonnull String... items)
JList
. The items to select should match
the given values.items
- the text of the items to select. Each String
can be a regular expression.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.replaceCellReader(JListCellReader)
@Nonnull public JListFixture selectItems(@Nonnull Pattern... patterns)
JList
. The items to select should select
the given regular expression patterns.patterns
- the regular expression patterns to match.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.replaceCellReader(JListCellReader)
@Nonnull public JListFixture clickItem(int index)
JList
.index
- the index of the item to clicking.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
.item(int)
,
JListItemFixture.click()
public JListFixture clickItem(@Nullable String text)
JList
.text
- the text of the item to select. It can be a regular expression.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.item(String)
,
JListItemFixture.select()
,
replaceCellReader(JListCellReader)
@Nonnull public JListFixture clickItem(@Nonnull Pattern pattern)
JList
. The value of the item to select must match the
given regular expression pattern.pattern
- the regular expression pattern to match.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
.item(Pattern)
,
JListItemFixture.select()
,
replaceCellReader(JListCellReader)
@Nonnull public JListFixture requireSelectedItems(@Nonnull int... indices)
JList
.indices
- the expected indices of the selected items.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.@Nonnull public JListFixture requireSelectedItems(@Nonnull String... items)
String
representations of the selected items in this fixture's JList
match the
given text items.items
- text items to match. Each String
can be a regular expression.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.replaceCellReader(JListCellReader)
@Nonnull public JListFixture requireSelectedItems(@Nonnull Pattern[] patterns)
String
representations of the selected items in this fixture's JList
match the
given regular expression patterns.patterns
- the regular expression patterns to match.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.replaceCellReader(JListCellReader)
@Nonnull public JListFixture drag(int index)
JList
.index
- the index of the item to drag.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
.@Nonnull public JListFixture drop(int index)
JList
.index
- the index of the item to drop.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.@Nonnull public JListFixture drag(@Nullable String text)
JList
matching the given
value.text
- the text of the item to drag. It can be a regular expression.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.@Nonnull public JListFixture drop(@Nullable String text)
text
- the text of the item to drop. It can be a regular expression.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.@Nonnull public JListFixture drag(@Nonnull Pattern pattern)
JList
matching the given
regular expression pattern.pattern
- the regular expression pattern to match.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.@Nonnull public JListFixture drop(@Nonnull Pattern pattern)
pattern
- the regular expression pattern to match.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.@Nonnull public JPopupMenuFixture showPopupMenuAt(int index)
JList
.index
- the index of the item.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
.@Nonnull public JPopupMenuFixture showPopupMenuAt(@Nullable String text)
JList
.text
- the text of the item. It can be a regular expression.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.@Nonnull public JPopupMenuFixture showPopupMenuAt(@Nonnull Pattern pattern)
JList
.pattern
- the regular expression pattern to match.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.public void replaceCellReader(@Nonnull JListCellReader cellReader)
Copyright © 2014-2015 AssertJ. All Rights Reserved.