public class JTextComponentFixture extends AbstractJPopupMenuInvokerFixture<JTextComponentFixture,JTextComponent,JTextComponentDriver> implements TextInputFixture<JTextComponentFixture>
JTextComponent
s.BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY
Constructor and Description |
---|
JTextComponentFixture(Robot robot,
JTextComponent target)
Creates a new
JTextComponentFixture . |
JTextComponentFixture(Robot robot,
String textComponentName)
Creates a new
JTextComponentFixture . |
Modifier and Type | Method and Description |
---|---|
protected JTextComponentDriver |
createDriver(Robot robot) |
JTextComponentFixture |
deleteText()
Simulates a user deleting all the text in this fixture's
JTextComponent . |
JTextComponentFixture |
enterText(String text)
Simulates a user entering the given text in this fixture's
JTextComponent . |
JTextComponentFixture |
requireEditable()
Asserts that this fixture's
JTextComponent is editable. |
JTextComponentFixture |
requireEmpty()
Asserts that the target text component does not contain any text.
|
JTextComponentFixture |
requireNotEditable()
Asserts that this fixture's
JTextComponent is not editable. |
JTextComponentFixture |
requireText(Pattern pattern)
Asserts that the text of this fixture's
JTextComponent matches the given regular expression pattern. |
JTextComponentFixture |
requireText(String expected)
Asserts that the text of this fixture's
JTextComponent is equal to the specified value. |
JTextComponentFixture |
select(String text)
Simulates a user selecting the given text contained in this fixture's
JTextComponent . |
JTextComponentFixture |
selectAll()
Simulates a user selecting all the text contained in this fixture's
JTextComponent . |
JTextComponentFixture |
selectText(int start,
int end)
Simulates a user selecting a portion of the text contained in this fixture's
JTextComponent . |
JTextComponentFixture |
setText(String text)
Sets the text in this fixture's
JTextComponent . |
String |
text() |
showPopupMenu, showPopupMenuAt
clientProperty, requireToolTip, requireToolTip
background, 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, targetCastedTo
public JTextComponentFixture(@Nonnull Robot robot, @Nonnull JTextComponent target)
JTextComponentFixture
.robot
- performs simulation of user events on the given JTextComponent
.target
- the JTextComponent
to be managed by this fixture.NullPointerException
- if robot
is null
.NullPointerException
- if target
is null
.public JTextComponentFixture(@Nonnull Robot robot, @Nullable String textComponentName)
JTextComponentFixture
.robot
- performs simulation of user events on a JTextComponent
.textComponentName
- the name of the JTextComponent
to find using the given Robot
.NullPointerException
- if robot
is null
.ComponentLookupException
- if a matching JTextComponent
could not be found.ComponentLookupException
- if more than one matching JTextComponent
is found.@Nonnull protected JTextComponentDriver createDriver(@Nonnull Robot robot)
createDriver
in class AbstractComponentFixture<JTextComponentFixture,JTextComponent,JTextComponentDriver>
@Nullable public String text()
text
in interface TextDisplayFixture<JTextComponentFixture>
JTextComponent
.@Nonnull public JTextComponentFixture select(@Nonnull String text)
JTextComponent
.select
in interface TextInputFixture<JTextComponentFixture>
text
- the text to select.IllegalStateException
- if this fixture's JTextComponent
is disabled.IllegalStateException
- if this fixture's JTextComponent
is not showing on the screen.IllegalArgumentException
- if this fixture's JTextComponent
does not contain the given text to
select.ActionFailedException
- if the selecting the text in the given range fails.@Nonnull public JTextComponentFixture selectText(int start, int end)
JTextComponent
.selectText
in interface TextInputFixture<JTextComponentFixture>
start
- index where selection should start.end
- index where selection should end.IllegalStateException
- if this fixture's JTextComponent
is disabled.IllegalStateException
- if this fixture's JTextComponent
is not showing on the screen.ActionFailedException
- if the selecting the text in the given range fails.@Nonnull public JTextComponentFixture selectAll()
JTextComponent
.selectAll
in interface TextInputFixture<JTextComponentFixture>
IllegalStateException
- if this fixture's JTextComponent
is disabled.IllegalStateException
- if this fixture's JTextComponent
is not showing on the screen.@Nonnull public JTextComponentFixture deleteText()
JTextComponent
.deleteText
in interface TextInputFixture<JTextComponentFixture>
IllegalStateException
- if this fixture's JTextComponent
is disabled.IllegalStateException
- if this fixture's JTextComponent
is not showing on the screen.@Nonnull public JTextComponentFixture enterText(@Nonnull String text)
JTextComponent
.enterText
in interface TextInputFixture<JTextComponentFixture>
text
- the text to enter.IllegalStateException
- if this fixture's JTextComponent
is disabled.IllegalStateException
- if this fixture's JTextComponent
is not showing on the screen.@Nonnull public JTextComponentFixture setText(@Nullable String text)
JTextComponent
. Unlike enterText(String)
, this method bypasses the
event system and allows immediate updating on the underlying document model.
Primarily desired for speeding up tests when precise user event fidelity isn't necessary.
text
- the text to set.IllegalStateException
- if this fixture's JTextComponent
is disabled.IllegalStateException
- if this fixture's JTextComponent
is not showing on the screen.@Nonnull public JTextComponentFixture requireText(@Nullable String expected)
JTextComponent
is equal to the specified value.requireText
in interface TextDisplayFixture<JTextComponentFixture>
expected
- the text to match. It can be a regular expression pattern.AssertionError
- if the text of this fixture's JTextComponent
is not equal to the given one.@Nonnull public JTextComponentFixture requireText(@Nonnull Pattern pattern)
JTextComponent
matches the given regular expression pattern.requireText
in interface TextDisplayFixture<JTextComponentFixture>
pattern
- the regular expression pattern to match.NullPointerException
- if the given regular expression pattern is null
.AssertionError
- if the text of this fixture's JTextComponent
is not eual to the given one.@Nonnull public JTextComponentFixture requireEditable()
JTextComponent
is editable.requireEditable
in interface EditableComponentFixture<JTextComponentFixture>
AssertionError
- if this fixture's JTextComponent
is not editable.@Nonnull public JTextComponentFixture requireNotEditable()
JTextComponent
is not editable.requireNotEditable
in interface EditableComponentFixture<JTextComponentFixture>
AssertionError
- if this fixture's JTextComponent
is editable.@Nonnull public JTextComponentFixture requireEmpty()
AssertionError
- if the target text component is not empty.Copyright © 2014–2019 AssertJ. All rights reserved.