@InternalApi public class JListDriver extends JComponentDriver
Supports functional testing of JLists.
Note: This class is intended for internal use only. Please use the classes in the package
org.assertj.swing.fixture in your tests.
robot| Constructor and Description |
|---|
JListDriver(Robot robot)
Creates a new
JListDriver. |
| Modifier and Type | Method and Description |
|---|---|
void |
clearSelection(JList list)
Clears the selection in the given
JList. |
void |
clickItem(JList list,
int index,
MouseButton button,
int times)
Clicks the item under the given index, using the specified mouse button, the given number times.
|
void |
clickItem(JList list,
Pattern pattern,
MouseButton button,
int times)
Clicks the first item matching the given regular expression pattern, using the specified mouse button, the given
number times.
|
void |
clickItem(JList list,
String value,
MouseButton button,
int times)
Clicks the first item matching the given value, using the specified mouse button, the given number times.
|
String[] |
contentsOf(JList list)
Returns an array of
Strings that represents the contents of the given JList. |
void |
drag(JList list,
int index)
Starts a drag operation at the location of the given index.
|
void |
drag(JList list,
Pattern pattern)
Starts a drag operation at the location of the first item matching the given regular expression pattern.
|
void |
drag(JList list,
String value)
Starts a drag operation at the location of the first item matching the given value.
|
void |
drop(JList list)
Ends a drag operation at the center of the
JList. |
void |
drop(JList list,
int index)
Ends a drag operation at the location of the given index.
|
void |
drop(JList list,
Pattern pattern)
Ends a drag operation at the location of the first item matching the given regular expression pattern.
|
void |
drop(JList list,
String value)
Ends a drag operation at the location of the first item matching the given value.
|
int |
indexOf(JList list,
Pattern pattern)
Returns the index of the first item matching the given regular expression pattern.
|
int |
indexOf(JList list,
String value)
Returns the index of the first item matching the given value.
|
Point |
pointAt(JList list,
String value)
Returns the coordinates of the first item matching the given value.
|
void |
replaceCellReader(JListCellReader newCellReader)
Updates the implementation of
JListCellReader to use when comparing internal values of a JList and
the values expected in a test. |
void |
requireItemCount(JList list,
int expected)
Verifies that number of items in the given
JList is equal to the expected one. |
void |
requireNoSelection(JList list)
Verifies that the
JList does not have a selection. |
void |
requireSelectedItems(JList list,
int... indices)
Verifies that the given item indices are selected in the
JList. |
void |
requireSelectedItems(JList list,
Pattern... patterns)
Verifies that the selected items in the
JList match the given regular expression patterns. |
void |
requireSelectedItems(JList list,
String... items)
Verifies that the selected items in the
JList match the given values. |
void |
requireSelection(JList list,
int index)
Verifies that the selected index in the
JList matches the given value. |
void |
requireSelection(JList list,
Pattern pattern)
Verifies that the selected item in the
JList matches the given regular expression pattern. |
void |
requireSelection(JList list,
String value)
Verifies that the selected item in the
JList matches the given value. |
String[] |
selectionOf(JList list)
Returns an array of
Strings that represents the selection in the given JList, using this driver's
JListCellReader. |
void |
selectItem(JList list,
int index)
Selects the item under the given index using left mouse button once.
|
void |
selectItem(JList list,
Pattern pattern)
Selects the item in the given
JList whose value matches the given regular expression pattern. |
void |
selectItem(JList list,
String value)
Selects the item in the given
JList whose value matches the given one. |
void |
selectItems(JList list,
int[] indices)
Selects the items under the given indices.
|
void |
selectItems(JList list,
int start,
int end)
Selects the items in the specified range.
|
void |
selectItems(JList list,
Pattern[] patterns)
Selects the items matching the given regular expression patterns.
|
void |
selectItems(JList list,
Range.From from,
Range.To to)
Selects the items in the specified range.
|
void |
selectItems(JList list,
String[] values)
Selects the items matching the given values.
|
JPopupMenu |
showPopupMenu(JList list,
int index)
Shows a pop-up menu at the location of the specified item in the
JList. |
JPopupMenu |
showPopupMenu(JList list,
Pattern pattern)
Shows a pop-up menu at the location of the specified item in the
JList. |
JPopupMenu |
showPopupMenu(JList list,
String value)
Shows a pop-up menu at the location of the specified item in the
JList. |
String |
value(JList list,
int index)
Returns the
String representation of the element under the given index, using this driver's
JListCellReader. |
clientProperty, invokeAction, isVisible, isVisible, requireToolTip, requireToolTip, scrollToVisibledoResizeHeight, doResizeWidth, isResizable, move, resizebackgroundOf, checkInEdtEnabledAndShowing, click, click, click, click, click, doubleClick, drag, dragOver, drop, focus, focusAndWaitForFocusGain, fontOf, foregroundOf, invokePopupMenu, invokePopupMenu, moveMouseIgnoringAnyError, moveMouseIgnoringAnyError, performAccessibleActionOf, pressAndReleaseKey, pressAndReleaseKey, pressAndReleaseKeys, pressKey, propertyName, releaseKey, requireDisabled, requireEnabled, requireEnabled, requireFocused, requireNotVisible, requireSize, requireVisible, rightClick, settings, waitForShowingpublic JListDriver(@Nonnull Robot robot)
JListDriver.robot - the robot to use to simulate user input.@RunsInEDT @Nonnull public String[] contentsOf(@Nonnull JList list)
Strings that represents the contents of the given JList.list - the target JList.Strings that represents the contents of the given JList.replaceCellReader(JListCellReader)@RunsInEDT public void selectItems(@Nonnull JList list, @Nonnull String[] values)
list - the target JList.values - the values to match. Each String can be a regular expression.NullPointerException - if the given array is null.IllegalArgumentException - if the given array is empty.IllegalStateException - if the JList is disabled.IllegalStateException - if the JList is not showing on the screen.LocationUnavailableException - if an element matching the any of the given values cannot be found.@RunsInEDT public void selectItems(@Nonnull JList list, @Nonnull Pattern[] patterns)
list - the target JList.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 the JList is disabled.IllegalStateException - if the JList is not showing on the screen.LocationUnavailableException - if an element matching the any of the given regular expression patterns cannot
be found.@RunsInEDT public void selectItem(@Nonnull JList list, @Nullable String value)
JList whose value matches the given one.list - the target JList.value - the value to match.IllegalStateException - if the JList is disabled.IllegalStateException - if the JList is not showing on the screen.LocationUnavailableException - if an element matching the given value cannot be found.@RunsInEDT public void selectItem(@Nonnull JList list, @Nonnull Pattern pattern)
JList whose value matches the given regular expression pattern.list - the target JList.pattern - the regular expression to match.IllegalStateException - if the JList is disabled.IllegalStateException - if the JList is not showing on the screen.LocationUnavailableException - if an element matching the given value cannot be found.NullPointerException - if the given regular expression pattern is null.public void clickItem(@Nonnull JList list, @Nullable String value, @Nonnull MouseButton button, int times)
list - the target JList.value - the value to match.button - the button to use.times - the number of times to click.IllegalStateException - if the JList is disabled.IllegalStateException - if the JList is not showing on the screen.LocationUnavailableException - if an element matching the given value cannot be found.public void clickItem(@Nonnull JList list, @Nonnull Pattern pattern, @Nonnull MouseButton button, int times)
list - the target JList.pattern - the regular expression pattern to match.button - the button to use.times - the number of times to click.IllegalStateException - if the JList is disabled.IllegalStateException - if the JList is not showing on the screen.NullPointerException - if the given regular expression pattern is null.LocationUnavailableException - if an element matching the given regular expression pattern cannot be found.public void selectItems(@Nonnull JList list, @Nonnull int[] indices)
list - the target JList.indices - the indices of the items to select.NullPointerException - if the given array is null.IllegalArgumentException - if the given array is empty.IllegalStateException - if the JList is disabled.IllegalStateException - if the JList is not showing on the screen.IndexOutOfBoundsException - if any of the indices is negative or greater than the index of the last item in
the JList.public void clearSelection(@Nonnull JList list)
JList. Since this method does not simulate user input, it does not
verifies that the JList is enabled and showing.list - the target JList.@RunsInEDT public void selectItems(@Nonnull JList list, @Nonnull Range.From from, @Nonnull Range.To to)
list - the target JList.from - the starting point of the selection.to - the last item to select.IllegalStateException - if the JList is disabled.IllegalStateException - if the 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.@RunsInEDT public void selectItems(@Nonnull JList list, int start, int end)
list - the target JList.start - the starting point of the selection.end - the last item to select (inclusive.)IllegalStateException - if the JList is disabled.IllegalStateException - if the 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.@RunsInEDT public void selectItem(@Nonnull JList list, int index)
list - the target JList.index - the index of the item to click.IllegalStateException - if the JList is disabled.IllegalStateException - if the 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.@RunsInEDT public void clickItem(@Nonnull JList list, int index, @Nonnull MouseButton button, int times)
list - the target JList.index - the index of the item to click.button - the button to use.times - the number of times to click.IllegalStateException - if the JList is disabled.IllegalStateException - if the 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.@RunsInEDT public void requireSelection(@Nonnull JList list, @Nullable String value)
JList matches the given value.list - the target JList.value - the value to match. It can be a regular expression pattern.AssertionError - if the selected item does not match the value.replaceCellReader(JListCellReader)@RunsInEDT public void requireSelection(@Nonnull JList list, @Nonnull Pattern pattern)
JList matches the given regular expression pattern.list - the target JList.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)@RunsInEDT public void requireSelection(@Nonnull JList list, int index)
JList matches the given value.list - the target JList.index - the selection index to match.AssertionError - if the selected index does not match the value.@RunsInEDT @Nonnull public String[] selectionOf(@Nonnull JList list)
Strings that represents the selection in the given JList, using this driver's
JListCellReader.list - the target JList.Strings that represents the selection in the given JList.replaceCellReader(JListCellReader)@RunsInEDT public void requireSelectedItems(@Nonnull JList list, @Nonnull String... items)
JList match the given values.list - the target JList.items - the values to match. Each value can be a regular expression pattern.NullPointerException - if the given array is null.IllegalArgumentException - if the given array is empty.AssertionError - if the selected items do not match the given values.@RunsInEDT public void requireSelectedItems(@Nonnull JList list, @Nonnull Pattern... patterns)
JList match the given regular expression patterns.list - the target JList.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 array is null.AssertionError - if the selected items do not match the given values.replaceCellReader(JListCellReader)@RunsInEDT public void requireSelectedItems(@Nonnull JList list, @Nonnull int... indices)
JList.list - the target 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 the JList does not match the given one.@RunsInEDT public void requireNoSelection(@Nonnull JList list)
JList does not have a selection.list - the target JList.AssertionError - if the JList has a selection.@RunsInEDT public void drag(@Nonnull JList list, @Nullable String value)
list - the target JList.value - the value to match. It can be a regular expression.IllegalStateException - if the JList is disabled.IllegalStateException - if the JList is not showing on the screen.LocationUnavailableException - if an element matching the given value cannot be found.replaceCellReader(JListCellReader)@RunsInEDT public void drag(@Nonnull JList list, @Nonnull Pattern pattern)
list - the target JList.pattern - the regular expression pattern to match.IllegalStateException - if the JList is disabled.IllegalStateException - if the JList is not showing on the screen.NullPointerException - if the regular expression pattern is null.LocationUnavailableException - if an element matching the given regular expression pattern cannot be found.replaceCellReader(JListCellReader)@RunsInEDT public void drop(@Nonnull JList list, @Nullable String value)
list - the target JList.value - the value to match. It can be a regular expression.IllegalStateException - if the JList is disabled.IllegalStateException - if the JList is not showing on the screen.LocationUnavailableException - if an element matching the given value cannot be found.ActionFailedException - if there is no drag action in effect.public void drop(@Nonnull JList list, @Nonnull Pattern pattern)
list - the target JList.pattern - the regular expression pattern to match.IllegalStateException - if the JList is disabled.IllegalStateException - if the JList is not showing on the screen.NullPointerException - if the given regular expression pattern is null.LocationUnavailableException - if an element matching the given value cannot be found.ActionFailedException - if there is no drag action in effect.@RunsInEDT public void drag(@Nonnull JList list, int index)
list - the target JList.index - the given index.IllegalStateException - if the JList is disabled.IllegalStateException - if the 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.@RunsInEDT public void drop(@Nonnull JList list, int index)
list - the target JList.index - the given index.IllegalStateException - if the JList is disabled.IllegalStateException - if the 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.@RunsInEDT public void drop(@Nonnull JList list)
JList.list - the target JList.IllegalStateException - if the JList is disabled.IllegalStateException - if the JList is not showing on the screen.ActionFailedException - if there is no drag action in effect.@RunsInEDT public JPopupMenu showPopupMenu(@Nonnull JList list, @Nullable String value)
JList.list - the target JList.value - the value to match. It can be a regular expression pattern.IllegalStateException - if the JList is disabled.IllegalStateException - if the 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.@RunsInEDT public JPopupMenu showPopupMenu(@Nonnull JList list, @Nonnull Pattern pattern)
JList.list - the target JList.pattern - the regular expression pattern to match.IllegalStateException - if the JList is disabled.IllegalStateException - if the JList is not showing on the screen.NullPointerException - if the 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.@RunsInEDT @Nonnull public JPopupMenu showPopupMenu(@Nonnull JList list, int index)
JList.list - the target JList.index - the index of the item.IllegalStateException - if the JList is disabled.IllegalStateException - if the 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.@RunsInEDT @Nonnull public Point pointAt(@Nonnull JList list, @Nullable String value)
list - the target JList.value - the value to match.LocationUnavailableException - if an element matching the given value cannot be found.@RunsInEDT public int indexOf(@Nonnull JList list, @Nullable String value)
list - the target JListvalue - the value to match. It can be a regular expression.LocationUnavailableException - if an element matching the given value cannot be found.@RunsInEDT public int indexOf(@Nonnull JList list, @Nonnull Pattern pattern)
list - the target JList.pattern - the regular expression pattern to match.LocationUnavailableException - if an element matching the given value cannot be found.NullPointerException - if the given regular expression pattern is null.@RunsInEDT @Nullable public String value(@Nonnull JList list, int index)
String representation of the element under the given index, using this driver's
JListCellReader.list - the target JList.index - the given index.IndexOutOfBoundsException - if the given index is negative or greater than the index of the last item in the
JList.replaceCellReader(JListCellReader)public void replaceCellReader(@Nonnull JListCellReader newCellReader)
JListCellReader to use when comparing internal values of a JList and
the values expected in a test.newCellReader - the new JListCellValueReader to use.NullPointerException - if newCellReader is null.@RunsInEDT public void requireItemCount(@Nonnull JList list, int expected)
JList is equal to the expected one.list - the target JList.expected - the expected number of items.AssertionError - if the number of items in the given JList is not equal to the expected one.Copyright © 2014 AssertJ. All rights reserved.