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
JFileChooser
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
-
Constructor Summary
ConstructorsConstructorDescriptionJFileChooserFixture
(Robot robot) Creates a new
.JFileChooserFixture
JFileChooserFixture
(Robot robot, String fileChooserName) Creates a new
.JFileChooserFixture
JFileChooserFixture
(Robot robot, JFileChooser target) Creates a new
.JFileChooserFixture
-
Method Summary
Modifier and TypeMethodDescriptionvoid
approve()
Simulates a user pressing the "Approve" button in this fixture's
.JFileChooser
Finds the "Approve" button in this fixture's
.JFileChooser
void
cancel()
Simulates a user pressing the "Cancel" button in this fixture's
.JFileChooser
Finds the "Cancel" button in this fixture's
.JFileChooser
click()
Simulates a user clicking this fixture's
.JFileChooser
click
(MouseButton button) Simulates a user clicking this fixture's
.JFileChooser
click
(MouseClickInfo mouseClickInfo) Simulates a user clicking this fixture's
.JFileChooser
private void
Simulates a user double-clicking this fixture's
.JFileChooser
protected final void
driver
(JFileChooserDriver newDriver) Sets the
to be used by this fixture.JFileChooserDriver
Returns a fixture that manages the field where the user can enter the name of the file to select in this fixture's
.JFileChooser
focus()
Gives input focus to this fixture's
.JFileChooser
pressAndReleaseKey
(KeyPressInfo keyPressInfo) Simulates a user pressing given key with the given modifiers on this fixture's
.JFileChooser
pressAndReleaseKeys
(int... keyCodes) Simulates a user pressing and releasing the given keys on the
managed by this fixture.JFileChooser
pressKey
(int keyCode) Simulates a user pressing the given key on this fixture's
.JFileChooser
releaseKey
(int keyCode) Simulates a user releasing the given key on this fixture's
.JFileChooser
Asserts that this fixture's
is disabled.JFileChooser
Asserts that this fixture's
is enabled.JFileChooser
requireEnabled
(Timeout timeout) Asserts that this fixture's
is enabled.JFileChooser
Asserts that this fixture's
has input focus.JFileChooser
Asserts that this fixture's
is not visible.JFileChooser
Asserts that this fixture's
is visible.JFileChooser
Simulates a user right-clicking this fixture's
.JFileChooser
selectFile
(File file) Selects the given file in this fixture's
.JFileChooser
selectFiles
(File... files) Selects the given files in this fixture's
.JFileChooser
setCurrentDirectory
(File dir) Sets the current directory of this fixture's
to the given one.JFileChooser
Methods 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
- ifrobot
isnull
.ComponentLookupException
- if a matchingJFileChooser
could not be found.ComponentLookupException
- if more than one matchingJFileChooser
is found.
-
JFileChooserFixture
Creates a new
.JFileChooserFixture
- Parameters:
robot
- performs simulation of user events on the givenJFileChooser
.target
- theJFileChooser
to be managed by this fixture.- Throws:
NullPointerException
- ifrobot
isnull
.NullPointerException
- iftarget
isnull
.
-
JFileChooserFixture
Creates a new
.JFileChooserFixture
- Parameters:
robot
- performs simulation of user events on aJFileChooser
.fileChooserName
- the name of theJFileChooser
to find using the givenRobotFixture
.- Throws:
NullPointerException
- ifrobot
isnull
.ComponentLookupException
- if a matchingJFileChooser
could not be found.ComponentLookupException
- if more than one matchingJFileChooser
is found.
-
-
Method Details
-
createDriver
private void createDriver() -
driver
Sets the
to 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'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is not showing on the screen.IllegalArgumentException
- if this fixture'sJFileChooser
can select directories only and the file to select is not a directory.IllegalArgumentException
- if this fixture'sJFileChooser
cannot 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'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is not showing on the screen.IllegalStateException
- if this fixture'sJFileChooser
does not support multiple selection and there is more than one file to select.IllegalArgumentException
- if this fixture'sJFileChooser
can select directories only and any of the files to select is not a directory.IllegalArgumentException
- if this fixture'sJFileChooser
cannot select directories and any of the files to select is a directory.
-
setCurrentDirectory
Sets the current directory of this fixture's
to the given one.JFileChooser
- Parameters:
dir
- the directory to set as current.- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is not showing on the screen.
-
click
Simulates a user clicking this fixture's
.JFileChooser
- Specified by:
click
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is not showing on the screen.
-
click
Simulates a user clicking this fixture's
.JFileChooser
- Specified by:
click
in interfaceMouseInputSimulationFixture
- Parameters:
button
- the button to click.- Returns:
- this fixture.
- Throws:
NullPointerException
- if the givenMouseButton
isnull
.IllegalStateException
- if this fixture'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is not showing on the screen.
-
click
Simulates a user clicking this fixture's
.JFileChooser
- 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'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is not showing on the screen.
-
doubleClick
Simulates a user double-clicking this fixture's
.JFileChooser
- Specified by:
doubleClick
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is not showing on the screen.
-
rightClick
Simulates a user right-clicking this fixture's
.JFileChooser
- Specified by:
rightClick
in interfaceMouseInputSimulationFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is not showing on the screen.
-
focus
Gives input focus to this fixture's
.JFileChooser
- Specified by:
focus
in interfaceFocusableComponentFixture
- Returns:
- this fixture.
- Throws:
IllegalStateException
- if this fixture'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is 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 availableJFileChooser
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.IllegalStateException
- if this fixture'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is not showing on the screen.- See Also:
-
pressAndReleaseKeys
Simulates a user pressing and releasing the given keys on the
managed by this fixture.JFileChooser
- 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.IllegalStateException
- if this fixture'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is not showing on the screen.- See Also:
-
pressKey
Simulates a user pressing the given key on this fixture's
.JFileChooser
- 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.IllegalStateException
- if this fixture'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is not showing on the screen.- See Also:
-
releaseKey
Simulates a user releasing the given key on this fixture's
.JFileChooser
- 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.IllegalStateException
- if this fixture'sJFileChooser
is disabled.IllegalStateException
- if this fixture'sJFileChooser
is not showing on the screen.- See Also:
-
requireFocused
Asserts that this fixture's
has input focus.JFileChooser
- Specified by:
requireFocused
in interfaceFocusableComponentFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJFileChooser
does not have input focus.
-
requireEnabled
Asserts that this fixture's
is enabled.JFileChooser
- Specified by:
requireEnabled
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJFileChooser
is disabled.
-
requireEnabled
Asserts that this fixture's
is enabled.JFileChooser
- 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'sJFileChooser
is never enabled.
-
requireDisabled
Asserts that this fixture's
is disabled.JFileChooser
- Specified by:
requireDisabled
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJFileChooser
is enabled.
-
requireVisible
Asserts that this fixture's
is visible.JFileChooser
- Specified by:
requireVisible
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJFileChooser
is not visible.
-
requireNotVisible
Asserts that this fixture's
is not visible.JFileChooser
- Specified by:
requireNotVisible
in interfaceStateVerificationFixture
- Returns:
- this fixture.
- Throws:
AssertionError
- if this fixture'sJFileChooser
is visible.
-