public class JComboBoxFixture extends AbstractJPopupMenuInvokerFixture<JComboBoxFixture,JComboBox,JComboBoxDriver> implements EditableComponentFixture<JComboBoxFixture>, ItemGroupFixture<JComboBoxFixture>
Supports functional testing of JComboBoxes.
The conversion between the values given in tests and the values being displayed by a JComboBox renderer is
performed by a JComboBoxCellReader. This fixture uses a JComboBoxCellReader by default.
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY| Constructor and Description |
|---|
JComboBoxFixture(Robot robot,
JComboBox target)
Creates a new
JComboBoxFixture. |
JComboBoxFixture(Robot robot,
String comboBoxName)
Creates a new
JComboBoxFixture. |
| Modifier and Type | Method and Description |
|---|---|
JComboBoxFixture |
clearSelection()
Clears the selection in this fixture's
JComboBox. |
String[] |
contents() |
protected JComboBoxDriver |
createDriver(Robot robot) |
JComboBoxFixture |
enterText(String text)
Simulates a user entering the specified text in this fixture's
JComboBox. |
JList |
list()
Finds and returns the
JList in the pop-up raised by this fixture's JComboBox. |
void |
replaceCellReader(JComboBoxCellReader cellReader) |
JComboBoxFixture |
replaceText(String text)
Simulates a user entering the specified text in the
JComboBox, replacing any text. |
JComboBoxFixture |
requireEditable()
Asserts that this fixture's
JComboBox is editable. |
JComboBoxFixture |
requireItemCount(int expected)
Verifies that this fixture's
JComboBox has the expected number of items |
JComboBoxFixture |
requireNoSelection()
Verifies that this fixture's
JComboBox does not have any selection. |
JComboBoxFixture |
requireNotEditable()
Asserts that this fixture's
JComboBox is not editable. |
JComboBoxFixture |
requireSelection(int index)
Verifies that the index of the selected item in this fixture's
JComboBox is equal to the given value. |
JComboBoxFixture |
requireSelection(Pattern pattern)
Verifies that the
String representation of the selected item in this fixture's JComboBox matches
the given regular expression pattern. |
JComboBoxFixture |
requireSelection(String value)
Verifies that the
String representation of the selected item in this fixture's JComboBox matches
the given text. |
JComboBoxFixture |
selectAllText()
Simulates a user selecting the text in the
JComboBox. |
String |
selectedItem()
Returns the selected value of this fixture's
JComboBox as plain text. |
JComboBoxFixture |
selectItem(int index)
Simulates a user selecting an item in this fixture's
JComboBox. |
JComboBoxFixture |
selectItem(Pattern pattern)
Simulates a user selecting an item in this fixture's
JComboBox. |
JComboBoxFixture |
selectItem(String text)
Simulates a user selecting an item in this fixture's
JComboBox. |
String |
valueAt(int index)
Returns the
String representation of the value of an item in this fixture's JComboBox, using this
fixture's JComboBoxCellReader. |
showPopupMenu, showPopupMenuAtclientProperty, requireToolTip, requireToolTipbackground, click, click, click, doubleClick, driver, drop, equals, focus, font, foreground, hashCode, isEnabled, myself, pressAndReleaseKey, pressAndReleaseKeys, pressKey, pressKeyWhileRunning, releaseKey, replaceDriverWith, requireDisabled, requireEnabled, requireEnabled, requireFocused, requireNotVisible, requireShowing, requireVisible, rightClick, robot, target, targetCastedTopublic JComboBoxFixture(@Nonnull Robot robot, @Nonnull JComboBox target)
JComboBoxFixture.robot - performs simulation of user events on the given JComboBox.target - the JComboBox to be managed by this fixture.NullPointerException - if robot is null.NullPointerException - if target is null.public JComboBoxFixture(@Nonnull Robot robot, @Nullable String comboBoxName)
JComboBoxFixture.robot - performs simulation of user events on a JComboBox.comboBoxName - the name of the JComboBox to find using the given Robot.NullPointerException - if robot is null.ComponentLookupException - if a matching JComboBox could not be found.ComponentLookupException - if more than one matching JComboBox is found.@Nonnull protected JComboBoxDriver createDriver(@Nonnull Robot robot)
createDriver in class AbstractComponentFixture<JComboBoxFixture,JComboBox,JComboBoxDriver>@Nonnull public String[] contents()
contents in interface ItemGroupFixture<JComboBoxFixture>String representation of the elements in this fixture's JComboBox, using this fixture's
JComboBoxCellReader.replaceCellReader(JComboBoxCellReader)@Nonnull public JComboBoxFixture clearSelection()
JComboBox. Since this method does not simulate user input, it does
not verifies that this fixture's JComboBox is enabled and showing.clearSelection in interface ItemGroupFixture<JComboBoxFixture>@Nonnull public JComboBoxFixture selectItem(int index)
JComboBox.selectItem in interface ItemGroupFixture<JComboBoxFixture>index - the index of the item to select.IllegalStateException - if this fixture's JComboBox is disabled.IllegalStateException - if this fixture's JComboBox is not showing on the screen.IndexOutOfBoundsException - if the given index is negative or greater than the index of the last item in the
JComboBox.@Nonnull public JComboBoxFixture selectItem(@Nullable String text)
JComboBox. The text of the item to select must match
the given String. Such text is retrieved by this fixture's JComboBoxCellReader.selectItem in interface ItemGroupFixture<JComboBoxFixture>text - the text of the item to select. It can be a regular expression.LocationUnavailableException - if an element matching the given text cannot be found.IllegalStateException - if this fixture's JComboBox is disabled.IllegalStateException - if this fixture's JComboBox is not showing on the screen.replaceCellReader(JComboBoxCellReader)@Nonnull public JComboBoxFixture selectItem(@Nonnull Pattern pattern)
JComboBox. The text of the item to select must match
the given regular expression pattern. Such text is retrieved by this fixture's JComboBoxCellReader.selectItem in interface ItemGroupFixture<JComboBoxFixture>pattern - the regular expression pattern to match.LocationUnavailableException - if an element matching the given pattern cannot be found.IllegalStateException - if this fixture's JComboBox is disabled.IllegalStateException - if this fixture's JComboBox is not showing on the screen.NullPointerException - if the given regular expression pattern is null.replaceCellReader(JComboBoxCellReader)@Nullable public String valueAt(int index)
String representation of the value of an item in this fixture's JComboBox, using this
fixture's JComboBoxCellReader.valueAt in interface ItemGroupFixture<JComboBoxFixture>index - the index of the item to return.String representation of the value of an item in this fixture's JComboBox.IndexOutOfBoundsException - if the given index is negative or greater than the index of the last item in the
JComboBox.replaceCellReader(JComboBoxCellReader)@Nonnull public JComboBoxFixture requireSelection(@Nullable String value)
String representation of the selected item in this fixture's JComboBox matches
the given text.requireSelection in interface ItemGroupFixture<JComboBoxFixture>value - the text to match. It can be a regular expression.AssertionError - if the selected item does not match the given text.replaceCellReader(JComboBoxCellReader)@Nonnull public JComboBoxFixture requireSelection(@Nonnull Pattern pattern)
String representation of the selected item in this fixture's JComboBox matches
the given regular expression pattern.requireSelection in interface ItemGroupFixture<JComboBoxFixture>pattern - the regular expression pattern to match.NullPointerException - if the given regular expression pattern is null.AssertionError - if the selected item does not match the given regular expression pattern.replaceCellReader(JComboBoxCellReader)@Nonnull public JComboBoxFixture requireSelection(int index)
JComboBox is equal to the given value.requireSelection in interface ItemGroupFixture<JComboBoxFixture>index - the expected selection index.AssertionError - if the selected index is not equal to the given one.@Nonnull public JComboBoxFixture requireNoSelection()
JComboBox does not have any selection.requireNoSelection in interface ItemGroupFixture<JComboBoxFixture>AssertionError - if this fixture's JComboBox has a selection.@Nonnull public JComboBoxFixture requireItemCount(int expected)
JComboBox has the expected number of itemsrequireItemCount in interface ItemGroupFixture<JComboBoxFixture>expected - the expected number of items.AssertionError - if the number of items in this fixture's JComboBox is not equal to the expected one.@Nullable public String selectedItem()
JComboBox as plain text. This method returns null if
the {code JComboBox} does not have any selection.null if the {code
JComboBox} does not have any selection.@Nonnull public JComboBoxFixture requireEditable()
JComboBox is editable.requireEditable in interface EditableComponentFixture<JComboBoxFixture>AssertionError - if this fixture's JComboBox is not editable.@Nonnull public JComboBoxFixture requireNotEditable()
JComboBox is not editable.requireNotEditable in interface EditableComponentFixture<JComboBoxFixture>AssertionError - if this fixture's JComboBox is editable.@Nonnull public JComboBoxFixture replaceText(@Nonnull String text)
JComboBox, replacing any text. This action is executed
only if the JComboBox is editable.text - the text to enter.IllegalStateException - if this fixture's JComboBox is disabled.IllegalStateException - if this fixture's JComboBox is not showing on the screen.IllegalStateException - if this fixture's JComboBox is not editable.@Nonnull public JComboBoxFixture selectAllText()
JComboBox. This action is executed only if the JComboBox
is editable.IllegalStateException - if this fixture's JComboBox is disabled.IllegalStateException - if this fixture's JComboBox is not showing on the screen.IllegalStateException - if this fixture's JComboBox is not editable.@Nonnull public JComboBoxFixture enterText(@Nonnull String text)
JComboBox. This action is executed only if
the JComboBox is editable.text - the text to enter.IllegalStateException - if this fixture's JComboBox is disabled.IllegalStateException - if this fixture's JComboBox is not showing on the screen.IllegalStateException - if this fixture's JComboBox is not editable.ActionFailedException - if this fixture's JComboBox does not have an editor.@Nonnull public JList list()
JList in the pop-up raised by this fixture's JComboBox.JList in the pop-up raised by this fixture's JComboBox.ComponentLookupException - if the JList in the pop-up could not be found.public void replaceCellReader(@Nonnull JComboBoxCellReader cellReader)
Copyright © 2014–2019 AssertJ. All rights reserved.