Package org.fest.swing.fixture
Class JFileChooserFixture
- All Implemented Interfaces:
CommonComponentFixture,FocusableComponentFixture,KeyboardInputSimulationFixture,MouseInputSimulationFixture,StateVerificationFixture
public class JFileChooserFixture
extends ComponentFixture<JFileChooser>
implements CommonComponentFixture
Understands functional testing of
JFileChoosers:
- 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 -
Constructor Summary
ConstructorsConstructorDescriptionJFileChooserFixture(Robot robot) Creates a new.JFileChooserFixtureJFileChooserFixture(Robot robot, String fileChooserName) Creates a new.JFileChooserFixtureJFileChooserFixture(Robot robot, JFileChooser target) Creates a new.JFileChooserFixture -
Method Summary
Modifier and TypeMethodDescriptionvoidapprove()Simulates a user pressing the "Approve" button in this fixture's.JFileChooserFinds the "Approve" button in this fixture's.JFileChooservoidcancel()Simulates a user pressing the "Cancel" button in this fixture's.JFileChooserFinds the "Cancel" button in this fixture's.JFileChooserclick()Simulates a user clicking this fixture's.JFileChooserclick(MouseButton button) Simulates a user clicking this fixture's.JFileChooserclick(MouseClickInfo mouseClickInfo) Simulates a user clicking this fixture's.JFileChooserprivate voidSimulates a user double-clicking this fixture's.JFileChooserprotected final voiddriver(JFileChooserDriver newDriver) Sets theto be used by this fixture.JFileChooserDriverReturns a fixture that manages the field where the user can enter the name of the file to select in this fixture's.JFileChooserfocus()Gives input focus to this fixture's.JFileChooserpressAndReleaseKey(KeyPressInfo keyPressInfo) Simulates a user pressing given key with the given modifiers on this fixture's.JFileChooserpressAndReleaseKeys(int... keyCodes) Simulates a user pressing and releasing the given keys on themanaged by this fixture.JFileChooserpressKey(int keyCode) Simulates a user pressing the given key on this fixture's.JFileChooserreleaseKey(int keyCode) Simulates a user releasing the given key on this fixture's.JFileChooserAsserts that this fixture'sis disabled.JFileChooserAsserts that this fixture'sis enabled.JFileChooserrequireEnabled(Timeout timeout) Asserts that this fixture'sis enabled.JFileChooserAsserts that this fixture'shas input focus.JFileChooserAsserts that this fixture'sis not visible.JFileChooserAsserts that this fixture'sis visible.JFileChooserSimulates a user right-clicking this fixture's.JFileChooserselectFile(File file) Selects the given file in this fixture's.JFileChooserselectFiles(File... files) Selects the given files in this fixture's.JFileChoosersetCurrentDirectory(File dir) Sets the current directory of this fixture'sto the given one.JFileChooserMethods inherited from class org.fest.swing.fixture.ComponentFixture
background, component, font, foreground, requireShowing, targetCastedTo, validateNotNull
-
Field Details
-
driver
-
-
Constructor Details
-
JFileChooserFixture
Creates a new.JFileChooserFixture- Parameters:
robot- performs simulation of user events on aJFileChooser.- Throws:
NullPointerException- ifrobotisnull.ComponentLookupException- if a matchingJFileChoosercould not be found.ComponentLookupException- if more than one matchingJFileChooseris found.
-
JFileChooserFixture
Creates a new.JFileChooserFixture- Parameters:
robot- performs simulation of user events on the givenJFileChooser.target- theJFileChooserto be managed by this fixture.- Throws:
NullPointerException- ifrobotisnull.NullPointerException- iftargetisnull.
-
JFileChooserFixture
Creates a new.JFileChooserFixture- Parameters:
robot- performs simulation of user events on aJFileChooser.fileChooserName- the name of theJFileChooserto find using the givenRobotFixture.- Throws:
NullPointerException- ifrobotisnull.ComponentLookupException- if a matchingJFileChoosercould not be found.ComponentLookupException- if more than one matchingJFileChooseris found.
-
-
Method Details
-
createDriver
private void createDriver() -
driver
Sets theto be used by this fixture.JFileChooserDriver- Parameters:
newDriver- the newJFileChooserDriver.- Throws:
NullPointerException- if the given driver isnull.
-
approve
public void approve()Simulates a user pressing the "Approve" button in this fixture's.JFileChooser- Throws:
ComponentLookupException- if the "Approve" button cannot be found.IllegalStateException- if the "Approve" button is disabled.IllegalStateException- if the "Approve" button is not showing on the screen.
-
approveButton
Finds the "Approve" button in this fixture's.JFileChooser- Returns:
- the found "Approve" button.
- Throws:
ComponentLookupException- if the "Approve" button cannot be found.
-
cancel
public void cancel()Simulates a user pressing the "Cancel" button in this fixture's.JFileChooser- Throws:
ComponentLookupException- if the "Cancel" button cannot be found.IllegalStateException- if the "Cancel" button is disabled.IllegalStateException- if the "Cancel" button is not showing on the screen.
-
cancelButton
Finds the "Cancel" button in this fixture's.JFileChooser- Returns:
- the found "Cancel" button.
- Throws:
ComponentLookupException- if the "Cancel" button cannot be found.
-
fileNameTextBox
Returns a fixture that manages the field where the user can enter the name of the file to select in this fixture's.JFileChooser- Returns:
- the created fixture.
- Throws:
ComponentLookupException- if a matching textToMatch field could not be found.
-
selectFile
Selects the given file in this fixture's.JFileChooser- Parameters:
file- the file to select.- Returns:
- this fixture.
- Throws:
NullPointerException- if the given file isnull.IllegalStateException- if this fixture'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.IllegalArgumentException- if this fixture'sJFileChoosercan select directories only and the file to select is not a directory.IllegalArgumentException- if this fixture'sJFileChoosercannot select directories and the file to select is a directory.
-
selectFiles
Selects the given files in this fixture's.JFileChooser- Parameters:
files- the files to select.- Returns:
- this fixture.
- Throws:
NullPointerException- if the given array of files isnull.IllegalArgumentException- if the given array of files is empty.IllegalStateException- if this fixture'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.IllegalStateException- if this fixture'sJFileChooserdoes not support multiple selection and there is more than one file to select.IllegalArgumentException- if this fixture'sJFileChoosercan select directories only and any of the files to select is not a directory.IllegalArgumentException- if this fixture'sJFileChoosercannot select directories and any of the files to select is a directory.
-
setCurrentDirectory
Sets the current directory of this fixture'sto the given one.JFileChooser- Parameters:
dir- the directory to set as current.- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.
-
click
Simulates a user clicking this fixture's.JFileChooser- Specified by:
clickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.
-
click
Simulates a user clicking this fixture's.JFileChooser- Specified by:
clickin interfaceMouseInputSimulationFixture- Parameters:
button- the button to click.- Returns:
- this fixture.
- Throws:
NullPointerException- if the givenMouseButtonisnull.IllegalStateException- if this fixture'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.
-
click
Simulates a user clicking this fixture's.JFileChooser- 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'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.
-
doubleClick
Simulates a user double-clicking this fixture's.JFileChooser- Specified by:
doubleClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.
-
rightClick
Simulates a user right-clicking this fixture's.JFileChooser- Specified by:
rightClickin interfaceMouseInputSimulationFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.
-
focus
Gives input focus to this fixture's.JFileChooser- Specified by:
focusin interfaceFocusableComponentFixture- Returns:
- this fixture.
- Throws:
IllegalStateException- if this fixture'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.
-
pressAndReleaseKey
Simulates a user pressing given key with the given modifiers on this fixture's. Modifiers is a mask from the availableJFileChoosermasks.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.IllegalStateException- if this fixture'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.- See Also:
-
pressAndReleaseKeys
Simulates a user pressing and releasing the given keys on themanaged by this fixture.JFileChooser- 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.IllegalStateException- if this fixture'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.- See Also:
-
pressKey
Simulates a user pressing the given key on this fixture's.JFileChooser- 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.IllegalStateException- if this fixture'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.- See Also:
-
releaseKey
Simulates a user releasing the given key on this fixture's.JFileChooser- 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.IllegalStateException- if this fixture'sJFileChooseris disabled.IllegalStateException- if this fixture'sJFileChooseris not showing on the screen.- See Also:
-
requireFocused
Asserts that this fixture'shas input focus.JFileChooser- Specified by:
requireFocusedin interfaceFocusableComponentFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJFileChooserdoes not have input focus.
-
requireEnabled
Asserts that this fixture'sis enabled.JFileChooser- Specified by:
requireEnabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJFileChooseris disabled.
-
requireEnabled
Asserts that this fixture'sis enabled.JFileChooser- 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'sJFileChooseris never enabled.
-
requireDisabled
Asserts that this fixture'sis disabled.JFileChooser- Specified by:
requireDisabledin interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJFileChooseris enabled.
-
requireVisible
Asserts that this fixture'sis visible.JFileChooser- Specified by:
requireVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJFileChooseris not visible.
-
requireNotVisible
Asserts that this fixture'sis not visible.JFileChooser- Specified by:
requireNotVisiblein interfaceStateVerificationFixture- Returns:
- this fixture.
- Throws:
AssertionError- if this fixture'sJFileChooseris visible.
-