Package org.fest.swing.fixture
Class JPanelFixture
- All Implemented Interfaces:
ClientPropertyStorageFixture,CommonComponentFixture,ComponentContainerFixture,FocusableComponentFixture,JComponentFixture,JPopupMenuInvokerFixture,KeyboardInputSimulationFixture,MouseInputSimulationFixture,StateVerificationFixture,ToolTipDisplayFixture
public class JPanelFixture
extends ContainerFixture<JPanel>
implements CommonComponentFixture, JComponentFixture, JPopupMenuInvokerFixture
Understands functional testing of
JPanels:
- 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
ConstructorsConstructorDescriptionJPanelFixture(Robot robot, String panelName) Creates a new.JPanelFixtureJPanelFixture(Robot robot, JPanel target) Creates a new.JPanelFixture -
Method Summary
Modifier and TypeMethodDescriptionclick()Simulates a user clicking this fixture's.JPanelclick(MouseButton button) Simulates a user clicking this fixture's.JPanelclick(MouseClickInfo mouseClickInfo) Simulates a user clicking this fixture's.JPanelclientProperty(Object key) Returns the client property stored in this fixture's, under the given key.JPanelprivate voidSimulates a user double-clicking this fixture's.JPanelprotected final voiddriver(JComponentDriver newDriver) Sets theto be used by this fixture.JComponentDriverfocus()Gives input focus to this fixture's.JPanelpressAndReleaseKey(KeyPressInfo keyPressInfo) Simulates a user pressing given key with the given modifiers on this fixture's.JPanelpressAndReleaseKeys(int... keyCodes) Simulates a user pressing and releasing the given keys on themanaged by this fixture.JPanelpressKey(int keyCode) Simulates a user pressing the given key on this fixture's.JPanelreleaseKey(int keyCode) Simulates a user releasing the given key on this fixture's.JPanelAsserts that this fixture'sis disabled.JPanelAsserts that this fixture'sis enabled.JPanelrequireEnabled(Timeout timeout) Asserts that this fixture'sis enabled.JPanelAsserts that this fixture'shas input focus.JPanelAsserts that this fixture'sis not visible.JPanelrequireToolTip(String expected) Asserts that the toolTip in this fixture'smatches the given value.JPanelrequireToolTip(Pattern pattern) Asserts that the toolTip in this fixture'smatches the given regular expression pattern.JPanelAsserts that this fixture'sis visible.JPanelSimulates a user right-clicking this fixture's.JPanelShows a pop-up menu using this fixture'sas the invoker of the pop-up menu.JPanelShows a pop-up menu at the given point using this fixture'sas the invoker of the pop-up menu.JPanelMethods 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
-
JPanelFixture
Creates a new.JPanelFixture- Parameters:
robot- performs simulation of user events on aJPanel.panelName- the name of theJPanelto find using the givenRobot.- Throws:
NullPointerException- ifrobotisnull.ComponentLookupException- if a matchingJPanelcould not be found.ComponentLookupException- if more than one matchingJPanelis found.
-
JPanelFixture
Creates a new.JPanelFixture- Parameters:
robot- performs simulation of user events on the givenJPanel.target- theJPanelto be managed by this fixture.- Throws:
NullPointerException- ifrobotisnull.NullPointerException- iftargetisnull.
-
-
Method Details
-
createDriver
private void createDriver() -
driver
Sets theto be used by this fixture.JComponentDriver- Parameters:
newDriver- the newJComponentDriver.- Throws:
NullPointerException- if the given driver isnull.
-
click
Simulates a user clicking this fixture's.JPanel- Specified by:
clickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
-
click
Simulates a user clicking this fixture's.JPanel- Specified by:
clickin interfaceMouseInputSimulationFixture- Parameters:
button- the button to click.- Returns:
- this fixture.
-
click
Simulates a user clicking this fixture's.JPanel- 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.
-
rightClick
Simulates a user right-clicking this fixture's.JPanel- Specified by:
rightClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
-
doubleClick
Simulates a user double-clicking this fixture's.JPanel- Specified by:
doubleClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
-
focus
Gives input focus to this fixture's.JPanel- Specified by:
focusin interfaceFocusableComponentFixture- Returns:
- this fixture.
-
pressAndReleaseKey
Simulates a user pressing given key with the given modifiers on this fixture's. Modifiers is a mask from the availableJPanelmasks.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 on themanaged by this fixture.JPanel- 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.JPanel- 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.JPanel- 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:
-
requireFocused
Asserts that this fixture'shas input focus.JPanel- Specified by:
requireFocusedin interfaceFocusableComponentFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJPaneldoes not have input focus.
-
requireEnabled
Asserts that this fixture'sis enabled.JPanel- Specified by:
requireEnabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJPanelis disabled.
-
requireEnabled
Asserts that this fixture'sis enabled.JPanel- 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'sJPanelis never enabled.
-
requireDisabled
Asserts that this fixture'sis disabled.JPanel- Specified by:
requireDisabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJPanelis enabled.
-
requireVisible
Asserts that this fixture'sis visible.JPanel- Specified by:
requireVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJPanelis not visible.
-
requireNotVisible
Asserts that this fixture'sis not visible.JPanel- Specified by:
requireNotVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJPanelis visible.
-
requireToolTip
Asserts that the toolTip in this fixture'smatches the given value.JPanel- Specified by:
requireToolTipin interfaceToolTipDisplayFixture- Parameters:
expected- the given value. It can be a regular expression.- Returns:
- this fixture.
- Throws:
AssertionError- if the toolTip in this fixture'sJPaneldoes not match the given value.- Since:
- 1.2
-
requireToolTip
Asserts that the toolTip in this fixture'smatches the given regular expression pattern.JPanel- Specified by:
requireToolTipin interfaceToolTipDisplayFixture- Parameters:
pattern- the regular expression pattern to match.- Returns:
- this fixture.
- Throws:
NullPointerException- if the given regular expression pattern isnull.AssertionError- if the toolTip in this fixture'sJPaneldoes not match the given regular expression.- Since:
- 1.2
-
clientProperty
Returns the client property stored in this fixture's, under the given key.JPanel- Specified by:
clientPropertyin interfaceClientPropertyStorageFixture- Parameters:
key- the key to use to retrieve the client property.- Returns:
- the value of the client property stored under the given key, or
nullif the property was not found. - Throws:
NullPointerException- if the given key isnull.- Since:
- 1.2
-
showPopupMenu
Shows a pop-up menu using this fixture'sas the invoker of the pop-up menu.JPanel- Specified by:
showPopupMenuin interfaceJPopupMenuInvokerFixture- Returns:
- a fixture that manages the displayed pop-up menu.
- Throws:
IllegalStateException- if this fixture'sJPanelis disabled.IllegalStateException- if this fixture'sJPanelis not showing on the screen.ComponentLookupException- if a pop-up menu cannot be found.
-
showPopupMenuAt
Shows a pop-up menu at the given point using this fixture'sas the invoker of the pop-up menu.JPanel- Specified by:
showPopupMenuAtin interfaceJPopupMenuInvokerFixture- Parameters:
p- the given point where to show the pop-up menu.- Returns:
- a fixture that manages the displayed pop-up menu.
- Throws:
IllegalStateException- if this fixture'sJPanelis disabled.IllegalStateException- if this fixture'sJPanelis not showing on the screen.ComponentLookupException- if a pop-up menu cannot be found.
-