Package org.fest.swing.fixture
Class JOptionPaneFixture
- All Implemented Interfaces:
CommonComponentFixture
,ComponentContainerFixture
,FocusableComponentFixture
,KeyboardInputSimulationFixture
,MouseInputSimulationFixture
,StateVerificationFixture
public class JOptionPaneFixture
extends ContainerFixture<JOptionPane>
implements CommonComponentFixture
Understands functional testing of
JOptionPane
s:
- user input simulation
- state verification
- property value query
-
Field Summary
FieldsFields inherited from class org.fest.swing.fixture.ComponentFixture
BACKGROUND_PROPERTY, FONT_PROPERTY, FOREGROUND_PROPERTY, robot, target
Fields inherited from interface org.fest.swing.fixture.ComponentContainerFixture
DEFAULT_DIALOG_LOOKUP_TIMEOUT
-
Constructor Summary
ConstructorsConstructorDescriptionJOptionPaneFixture
(Robot robot) Creates a new
.JOptionPaneFixture
JOptionPaneFixture
(Robot robot, JOptionPane target) Creates a new
.JOptionPaneFixture
-
Method Summary
Modifier and TypeMethodDescriptionbuttonWithText
(String text) Finds and returns a fixture wrapping a button (this fixture's
) matching the given text.JOptionPane
buttonWithText
(Pattern pattern) Finds and returns a fixture wrapping a button (this fixture's
) matching the given text.JOptionPane
Returns a fixture wrapping the "Cancel" button in this fixture's
.JOptionPane
click()
Simulates a user clicking this fixture's
.JOptionPane
click
(MouseButton button) Simulates a user clicking this fixture's
.JOptionPane
click
(MouseClickInfo mouseClickInfo) Simulates a user clicking this fixture's
.JOptionPane
Simulates a user double-clicking this fixture's
.JOptionPane
protected final void
driver
(JOptionPaneDriver newDriver) Sets the
to be used by this fixture.JOptionPaneDriver
private static JOptionPane
findShowingOptionPane
(Robot robot) focus()
Gives input focus to this fixture's
.JOptionPane
noButton()
Returns a fixture wrapping the "No" button in this fixture's
.JOptionPane
okButton()
Returns a fixture wrapping the "OK" button in this fixture's
.JOptionPane
pressAndReleaseKey
(KeyPressInfo keyPressInfo) Simulates a user pressing given key with the given modifiers on this fixture's
.JOptionPane
pressAndReleaseKeys
(int... keyCodes) Simulates a user pressing and releasing the given keys this fixture's
.JOptionPane
pressKey
(int keyCode) Simulates a user pressing the given key on this fixture's
.JOptionPane
releaseKey
(int keyCode) Simulates a user releasing the given key on this fixture's
.JOptionPane
Asserts that this fixture's
is disabled.JOptionPane
Asserts that this fixture's
is enabled.JOptionPane
requireEnabled
(Timeout timeout) Asserts that this fixture's
is enabled.JOptionPane
Asserts that this fixture's
is displaying an error message.JOptionPane
Asserts that this fixture's
has input focus.JOptionPane
Asserts that this fixture's
is displaying an information message.JOptionPane
requireMessage
(Object message) Asserts that the message of this fixture's
matches the given value.JOptionPane
requireMessage
(Pattern pattern) Asserts that the message of this fixture's
matches the given regular expression pattern.JOptionPane
Asserts that this fixture's
is not visible.JOptionPane
requireOptions
(Object[] options) Asserts that this fixture's
has the given options.JOptionPane
Asserts that this fixture's
is displaying a plain message.JOptionPane
Asserts that this fixture's
is displaying a question.JOptionPane
requireTitle
(String title) Asserts that the title of this fixture's
matches the given value.JOptionPane
requireTitle
(Pattern pattern) Asserts that the title of this fixture's
matches the given regular expression pattern.JOptionPane
Asserts that this fixture's
is visible.JOptionPane
Asserts that this fixture's
is displaying a warning message.JOptionPane
Simulates a user right-clicking this fixture's
.JOptionPane
title()
Returns the title of this fixture's
.JOptionPane
Returns a fixture wrapping the "Yes" button in this fixture's
.JOptionPane
Methods inherited from class org.fest.swing.fixture.ContainerFixture
button, button, button, checkBox, checkBox, checkBox, comboBox, comboBox, comboBox, dialog, dialog, dialog, dialog, dialog, dialog, fileChooser, fileChooser, fileChooser, fileChooser, fileChooser, fileChooser, find, findByName, findByType, finder, label, label, label, list, list, list, menuItem, menuItem, menuItemWithPath, optionPane, optionPane, panel, panel, panel, progressBar, progressBar, progressBar, radioButton, radioButton, radioButton, scrollBar, scrollBar, scrollBar, scrollPane, scrollPane, scrollPane, slider, slider, slider, spinner, spinner, spinner, splitPane, splitPane, splitPane, tabbedPane, tabbedPane, tabbedPane, table, table, table, textBox, textBox, textBox, toggleButton, toggleButton, toggleButton, toolBar, toolBar, toolBar, tree, tree, tree, with
Methods inherited from class org.fest.swing.fixture.ComponentFixture
background, component, font, foreground, requireShowing, targetCastedTo, validateNotNull
-
Field Details
-
driver
-
-
Constructor Details
-
JOptionPaneFixture
Creates a new
.JOptionPaneFixture
- Parameters:
robot
- finds a showingJOptionPane
, which will be managed by this fixture.- Throws:
NullPointerException
- ifrobot
isnull
.ComponentLookupException
- if a showingJOptionPane
could not be found.ComponentLookupException
- if more than one showingJOptionPane
is found.
-
JOptionPaneFixture
Creates a new
.JOptionPaneFixture
- Parameters:
robot
- performs simulation of user events on the givenJOptionPane
.target
- theJOptionPane
to be managed by this fixture.- Throws:
NullPointerException
- ifrobot
isnull
.IllegalArgumentException
- iftarget
isnull
.
-
-
Method Details
-
findShowingOptionPane
-
driver
Sets the
to be used by this fixture.JOptionPaneDriver
- Parameters:
newDriver
- the newJOptionPaneDriver
.- Throws:
NullPointerException
- if the given driver isnull
.
-
title
Returns the title of this fixture's
.JOptionPane
- Returns:
- the title of this fixture's
JOptionPane
. - Since:
- 1.2
-
okButton
Returns a fixture wrapping the "OK" button in this fixture's
. This method is locale-independent and platform-independent.JOptionPane
- Returns:
- a fixture wrapping the "OK" button.
- Throws:
ComponentLookupException
- if the a "OK" button cannot be found.
-
cancelButton
Returns a fixture wrapping the "Cancel" button in this fixture's
. This method is locale-independent and platform-independent.JOptionPane
- Returns:
- a fixture wrapping the "Cancel" button.
- Throws:
ComponentLookupException
- if the a "Cancel" button cannot be found.
-
yesButton
Returns a fixture wrapping the "Yes" button in this fixture's
. This method is locale-independent and platform-independent.JOptionPane
- Returns:
- a fixture wrapping the "Yes" button.
- Throws:
ComponentLookupException
- if the a "Yes" button cannot be found.
-
noButton
Returns a fixture wrapping the "No" button in this fixture's
. This method is locale-independent and platform-independent.JOptionPane
- Returns:
- a fixture wrapping the "No" button.
- Throws:
ComponentLookupException
- if the a "No" button cannot be found.
-
buttonWithText
Finds and returns a fixture wrapping a button (this fixture's
) matching the given text.JOptionPane
- Parameters:
text
- the text of the button to find. It can be a regular expression.- Returns:
- a fixture wrapping a button matching the given text.
- Throws:
ComponentLookupException
- if the a button with the given text cannot be found.
-
buttonWithText
Finds and returns a fixture wrapping a button (this fixture's
) matching the given text.JOptionPane
- Parameters:
pattern
- the regular expression pattern to match.- Returns:
- a fixture wrapping a button matching the given regular expression pattern.
- Throws:
NullPointerException
- if the given regular expression pattern isnull
.ComponentLookupException
- if the a button with the given text cannot be found.- Since:
- 1.2
-
click
Simulates a user clicking this fixture's
.JOptionPane
- Specified by:
click
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJOptionPane
is disabled.IllegalStateException
- if this fixture'sJOptionPane
is not showing on the screen.
-
click
Simulates a user clicking this fixture's
.JOptionPane
- Specified by:
click
in interfaceMouseInputSimulationFixture
- Parameters:
button
- the button to click.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the givenMouseButton
isnull
.IllegalStateException
- if this fixture'sJOptionPane
is disabled.IllegalStateException
- if this fixture'sJOptionPane
is not showing on the screen.
-
click
Simulates a user clicking this fixture's
.JOptionPane
- Specified by:
click
in interfaceMouseInputSimulationFixture
- Parameters:
mouseClickInfo
- specifies the button to click and the times the button should be clicked.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the givenMouseClickInfo
isnull
.IllegalStateException
- if this fixture'sJOptionPane
is disabled.IllegalStateException
- if this fixture'sJOptionPane
is not showing on the screen.
-
rightClick
Simulates a user right-clicking this fixture's
.JOptionPane
- Specified by:
rightClick
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJOptionPane
is disabled.IllegalStateException
- if this fixture'sJOptionPane
is not showing on the screen.
-
doubleClick
Simulates a user double-clicking this fixture's
.JOptionPane
- Specified by:
doubleClick
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJOptionPane
is disabled.IllegalStateException
- if this fixture'sJOptionPane
is not showing on the screen.
-
focus
Gives input focus to this fixture's
.JOptionPane
- Specified by:
focus
in interfaceFocusableComponentFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJOptionPane
is disabled.IllegalStateException
- if this fixture'sJOptionPane
is not showing on the screen.
-
requireErrorMessage
Asserts that this fixture's
is displaying an error message.JOptionPane
- Returns:
- this fixture.
-
requireInformationMessage
Asserts that this fixture's
is displaying an information message.JOptionPane
- Returns:
- this fixture.
-
requireWarningMessage
Asserts that this fixture's
is displaying a warning message.JOptionPane
- Returns:
- this fixture.
-
requireQuestionMessage
Asserts that this fixture's
is displaying a question.JOptionPane
- Returns:
- this fixture.
-
requirePlainMessage
Asserts that this fixture's
is displaying a plain message.JOptionPane
- Returns:
- this fixture.
-
pressAndReleaseKey
Simulates a user pressing given key with the given modifiers on this fixture's
. Modifiers is a mask from the availableJOptionPane
masks.InputEvent
- Specified by:
pressAndReleaseKey
in interfaceKeyboardInputSimulationFixture
- Parameters:
keyPressInfo
- specifies the key and modifiers to press.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the givenKeyPressInfo
isnull
.IllegalArgumentException
- if the given code is not a valid key code.- See Also:
-
pressAndReleaseKeys
Simulates a user pressing and releasing the given keys this fixture's
. This method does not affect the current focus.JOptionPane
- Specified by:
pressAndReleaseKeys
in interfaceKeyboardInputSimulationFixture
- Parameters:
keyCodes
- one or more codes of the keys to press.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the given array of codes isnull
.IllegalArgumentException
- if any of the given code is not a valid key code.- See Also:
-
pressKey
Simulates a user pressing the given key on this fixture's
.JOptionPane
- Specified by:
pressKey
in interfaceKeyboardInputSimulationFixture
- Parameters:
keyCode
- the code of the key to press.- Returns:
- this fixture.
- Throws:
IllegalArgumentException
- if any of the given code is not a valid key code.- See Also:
-
releaseKey
Simulates a user releasing the given key on this fixture's
.JOptionPane
- Specified by:
releaseKey
in interfaceKeyboardInputSimulationFixture
- Parameters:
keyCode
- the code of the key to release.- Returns:
- this fixture.
- Throws:
IllegalArgumentException
- if any of the given code is not a valid key code.- See Also:
-
requireTitle
Asserts that the title of this fixture's
matches the given value.JOptionPane
- Parameters:
title
- the title to match. It can be a regular expression.- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture's JOptionPaneFixture does not have the given title.
-
requireTitle
Asserts that the title of this fixture's
matches the given regular expression pattern.JOptionPane
- Parameters:
pattern
- the regular expression pattern to match.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the given regular expression isnull
.AssertionError
- if this fixture's JOptionPaneFixture does not have the given title.- Since:
- 1.2
-
requireMessage
Asserts that the message of this fixture's
matches the given value.JOptionPane
- Parameters:
message
- the message to verify. If it is aString
, it can be specified as a regular expression.- Returns:
- this fixture.
- Throws:
AssertionError
- if the message in this fixture's JOptionPaneFixture is not equal to or does not match the given message.
-
requireMessage
Asserts that the message of this fixture's
matches the given regular expression pattern. If the message in theJOptionPane
JOptionPane
is not aString
, this method will use thetoString
representation of such message.- Parameters:
pattern
- the regular expression to match.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the given regular expression pattern isnull
.AssertionError
- if the message in this fixture's JOptionPaneFixture does not match the given regular expression pattern.- Since:
- 1.2
-
requireOptions
Asserts that this fixture's
has the given options.JOptionPane
- Parameters:
options
- the options to verify.- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture's JOptionPaneFixture does not have the given options.
-
requireFocused
Asserts that this fixture's
has input focus.JOptionPane
- Specified by:
requireFocused
in interfaceFocusableComponentFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJOptionPane
does not have input focus.
-
requireEnabled
Asserts that this fixture's
is enabled.JOptionPane
- Specified by:
requireEnabled
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJOptionPane
is disabled.
-
requireEnabled
Asserts that this fixture's
is enabled.JOptionPane
- Specified by:
requireEnabled
in interfaceStateVerificationFixture
- Parameters:
timeout
- the time this fixture will wait for the component to be enabled.- Returns:
- this fixture.
- Throws:
WaitTimedOutError
- if this fixture'sJOptionPane
is never enabled.
-
requireDisabled
Asserts that this fixture's
is disabled.JOptionPane
- Specified by:
requireDisabled
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJOptionPane
is enabled.
-
requireVisible
Asserts that this fixture's
is visible.JOptionPane
- Specified by:
requireVisible
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJOptionPane
is not visible.
-
requireNotVisible
Asserts that this fixture's
is not visible.JOptionPane
- Specified by:
requireNotVisible
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJOptionPane
is visible.
-