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
JOptionPanes:
- 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, targetFields inherited from interface org.fest.swing.fixture.ComponentContainerFixture
DEFAULT_DIALOG_LOOKUP_TIMEOUT -
Constructor Summary
ConstructorsConstructorDescriptionJOptionPaneFixture(Robot robot) Creates a new.JOptionPaneFixtureJOptionPaneFixture(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.JOptionPanebuttonWithText(Pattern pattern) Finds and returns a fixture wrapping a button (this fixture's) matching the given text.JOptionPaneReturns a fixture wrapping the "Cancel" button in this fixture's.JOptionPaneclick()Simulates a user clicking this fixture's.JOptionPaneclick(MouseButton button) Simulates a user clicking this fixture's.JOptionPaneclick(MouseClickInfo mouseClickInfo) Simulates a user clicking this fixture's.JOptionPaneSimulates a user double-clicking this fixture's.JOptionPaneprotected final voiddriver(JOptionPaneDriver newDriver) Sets theto be used by this fixture.JOptionPaneDriverprivate static JOptionPanefindShowingOptionPane(Robot robot) focus()Gives input focus to this fixture's.JOptionPanenoButton()Returns a fixture wrapping the "No" button in this fixture's.JOptionPaneokButton()Returns a fixture wrapping the "OK" button in this fixture's.JOptionPanepressAndReleaseKey(KeyPressInfo keyPressInfo) Simulates a user pressing given key with the given modifiers on this fixture's.JOptionPanepressAndReleaseKeys(int... keyCodes) Simulates a user pressing and releasing the given keys this fixture's.JOptionPanepressKey(int keyCode) Simulates a user pressing the given key on this fixture's.JOptionPanereleaseKey(int keyCode) Simulates a user releasing the given key on this fixture's.JOptionPaneAsserts that this fixture'sis disabled.JOptionPaneAsserts that this fixture'sis enabled.JOptionPanerequireEnabled(Timeout timeout) Asserts that this fixture'sis enabled.JOptionPaneAsserts that this fixture'sis displaying an error message.JOptionPaneAsserts that this fixture'shas input focus.JOptionPaneAsserts that this fixture'sis displaying an information message.JOptionPanerequireMessage(Object message) Asserts that the message of this fixture'smatches the given value.JOptionPanerequireMessage(Pattern pattern) Asserts that the message of this fixture'smatches the given regular expression pattern.JOptionPaneAsserts that this fixture'sis not visible.JOptionPanerequireOptions(Object[] options) Asserts that this fixture'shas the given options.JOptionPaneAsserts that this fixture'sis displaying a plain message.JOptionPaneAsserts that this fixture'sis displaying a question.JOptionPanerequireTitle(String title) Asserts that the title of this fixture'smatches the given value.JOptionPanerequireTitle(Pattern pattern) Asserts that the title of this fixture'smatches the given regular expression pattern.JOptionPaneAsserts that this fixture'sis visible.JOptionPaneAsserts that this fixture'sis displaying a warning message.JOptionPaneSimulates a user right-clicking this fixture's.JOptionPanetitle()Returns the title of this fixture's.JOptionPaneReturns a fixture wrapping the "Yes" button in this fixture's.JOptionPaneMethods 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, withMethods 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- ifrobotisnull.ComponentLookupException- if a showingJOptionPanecould not be found.ComponentLookupException- if more than one showingJOptionPaneis found.
-
JOptionPaneFixture
Creates a new.JOptionPaneFixture- Parameters:
robot- performs simulation of user events on the givenJOptionPane.target- theJOptionPaneto be managed by this fixture.- Throws:
NullPointerException- ifrobotisnull.IllegalArgumentException- iftargetisnull.
-
-
Method Details
-
findShowingOptionPane
-
driver
Sets theto 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:
clickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJOptionPaneis disabled.IllegalStateException- if this fixture'sJOptionPaneis not showing on the screen.
-
click
Simulates a user clicking this fixture's.JOptionPane- Specified by:
clickin interfaceMouseInputSimulationFixture- Parameters:
button- the button to click.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenMouseButtonisnull.IllegalStateException- if this fixture'sJOptionPaneis disabled.IllegalStateException- if this fixture'sJOptionPaneis not showing on the screen.
-
click
Simulates a user clicking this fixture's.JOptionPane- Specified by:
clickin interfaceMouseInputSimulationFixture- Parameters:
mouseClickInfo- specifies the button to click and the times the button should be clicked.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenMouseClickInfoisnull.IllegalStateException- if this fixture'sJOptionPaneis disabled.IllegalStateException- if this fixture'sJOptionPaneis not showing on the screen.
-
rightClick
Simulates a user right-clicking this fixture's.JOptionPane- Specified by:
rightClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJOptionPaneis disabled.IllegalStateException- if this fixture'sJOptionPaneis not showing on the screen.
-
doubleClick
Simulates a user double-clicking this fixture's.JOptionPane- Specified by:
doubleClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJOptionPaneis disabled.IllegalStateException- if this fixture'sJOptionPaneis not showing on the screen.
-
focus
Gives input focus to this fixture's.JOptionPane- Specified by:
focusin interfaceFocusableComponentFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJOptionPaneis disabled.IllegalStateException- if this fixture'sJOptionPaneis not showing on the screen.
-
requireErrorMessage
Asserts that this fixture'sis displaying an error message.JOptionPane- Returns:
- this fixture.
-
requireInformationMessage
Asserts that this fixture'sis displaying an information message.JOptionPane- Returns:
- this fixture.
-
requireWarningMessage
Asserts that this fixture'sis displaying a warning message.JOptionPane- Returns:
- this fixture.
-
requireQuestionMessage
Asserts that this fixture'sis displaying a question.JOptionPane- Returns:
- this fixture.
-
requirePlainMessage
Asserts that this fixture'sis 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 availableJOptionPanemasks.InputEvent- Specified by:
pressAndReleaseKeyin interfaceKeyboardInputSimulationFixture- Parameters:
keyPressInfo- specifies the key and modifiers to press.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenKeyPressInfoisnull.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:
pressAndReleaseKeysin 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:
pressKeyin 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:
releaseKeyin 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'smatches 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'smatches 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'smatches 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'smatches the given regular expression pattern. If the message in theJOptionPaneJOptionPaneis not aString, this method will use thetoStringrepresentation 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'shas 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'shas input focus.JOptionPane- Specified by:
requireFocusedin interfaceFocusableComponentFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJOptionPanedoes not have input focus.
-
requireEnabled
Asserts that this fixture'sis enabled.JOptionPane- Specified by:
requireEnabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJOptionPaneis disabled.
-
requireEnabled
Asserts that this fixture'sis enabled.JOptionPane- Specified by:
requireEnabledin interfaceStateVerificationFixture- Parameters:
timeout- the time this fixture will wait for the component to be enabled.- Returns:
- this fixture.
- Throws:
WaitTimedOutError- if this fixture'sJOptionPaneis never enabled.
-
requireDisabled
Asserts that this fixture'sis disabled.JOptionPane- Specified by:
requireDisabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJOptionPaneis enabled.
-
requireVisible
Asserts that this fixture'sis visible.JOptionPane- Specified by:
requireVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJOptionPaneis not visible.
-
requireNotVisible
Asserts that this fixture'sis not visible.JOptionPane- Specified by:
requireNotVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJOptionPaneis visible.
-