org.fest.swing.fixture
Class DialogFixture

java.lang.Object
  extended by org.fest.swing.fixture.ComponentFixture<T>
      extended by org.fest.swing.fixture.ContainerFixture<T>
          extended by org.fest.swing.fixture.WindowFixture<Dialog>
              extended by org.fest.swing.fixture.DialogFixture
All Implemented Interfaces:
CommonComponentFixture, ComponentContainerFixture, FocusableComponentFixture, JPopupMenuInvokerFixture, KeyboardInputSimulationFixture, MouseInputSimulationFixture, StateVerificationFixture, WindowLikeContainerFixture

public class DialogFixture
extends WindowFixture<Dialog>

Understands functional testing of Dialogs:

Author:
Alex Ruiz

Field Summary
 
Fields 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
DialogFixture(Dialog target)
          Creates a new DialogFixture.
DialogFixture(Robot robot, Dialog target)
          Creates a new DialogFixture.
DialogFixture(Robot robot, String dialogName)
          Creates a new DialogFixture.
DialogFixture(String dialogName)
          Creates a new DialogFixture.
 
Method Summary
 DialogFixture click()
          Simulates a user clicking this fixture's Dialog.
 DialogFixture click(MouseButton button)
          Simulates a user clicking this fixture's Dialog.
 DialogFixture click(MouseClickInfo mouseClickInfo)
          Simulates a user clicking this fixture's Dialog.
 void close()
          Simulates a user closing this fixture's Dialog.
 DialogFixture doubleClick()
          Simulates a user double-clicking this fixture's Dialog.
protected  void driver(DialogDriver newDriver)
          Sets the DialogDriver to be used by this fixture.
 DialogFixture focus()
          Gives input focus to this fixture's Dialog.
 DialogFixture moveTo(Point p)
          Simulates a user moving this fixture's Dialog to the given point.
 DialogFixture moveToBack()
          If the given Dialog is visible, sends it to the back and may cause it to lose focus or activation if it is the focused or active.
 DialogFixture moveToFront()
          If fixture's Dialog is visible, brings it to the front and may make it the focused one.
 DialogFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
          Simulates a user pressing given key with the given modifiers on this fixture's Dialog.
 DialogFixture pressAndReleaseKeys(int... keyCodes)
          Simulates a user pressing and releasing the given keys on this fixture's Dialog.
 DialogFixture pressKey(int keyCode)
          Simulates a user pressing the given key on this fixture's Dialog.
 DialogFixture releaseKey(int keyCode)
          Simulates a user releasing the given key on this fixture's Dialog.
 DialogFixture requireDisabled()
          Asserts that this fixture's Dialog is disabled.
 DialogFixture requireEnabled()
          Asserts that this fixture's Dialog is enabled.
 DialogFixture requireEnabled(Timeout timeout)
          Asserts that this fixture's Dialog is enabled.
 DialogFixture requireFocused()
          Asserts that this fixture's Dialog has input focus.
 DialogFixture requireModal()
          Asserts that this fixture's Dialog is modal.
 DialogFixture requireNotVisible()
          Asserts that this fixture's Dialog is not visible.
 DialogFixture requireSize(Dimension size)
          Asserts that the size of this fixture's Dialog is equal to given one.
 DialogFixture requireVisible()
          Asserts that this fixture's Dialog is visible.
 DialogFixture resizeHeightTo(int height)
          Simulates a user resizing vertically this fixture's Dialog.
 DialogFixture resizeTo(Dimension size)
          Simulates a user resizing this fixture's Dialog.
 DialogFixture resizeWidthTo(int width)
          Simulates a user resizing horizontally this fixture's Dialog.
 DialogFixture rightClick()
          Simulates a user right-clicking this fixture's Dialog.
 DialogFixture show()
          Shows this fixture's Dialog.
 DialogFixture show(Dimension size)
          Shows this fixture's Dialog, resized to the given size.
 JPopupMenuFixture showPopupMenu()
          Shows a pop-up menu using this fixture's Dialog as the invoker of the pop-up menu.
 JPopupMenuFixture showPopupMenuAt(Point p)
          Shows a pop-up menu at the given point using this fixture's Dialog as the invoker of the pop-up menu.
 
Methods inherited from class org.fest.swing.fixture.WindowFixture
cleanUp
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DialogFixture

public DialogFixture(Dialog target)
Creates a new DialogFixture. This constructor creates a new Robot containing the current AWT hierarchy.

Parameters:
target - the Dialog to be managed by this fixture.
Throws:
NullPointerException - if target is null.
See Also:
BasicRobot.robotWithCurrentAwtHierarchy()

DialogFixture

public DialogFixture(Robot robot,
                     Dialog target)
Creates a new DialogFixture.

Parameters:
robot - performs simulation of user events on the given Dialog.
target - the Dialog to be managed by this fixture.
Throws:
NullPointerException - if robot is null.
NullPointerException - if target is null.

DialogFixture

public DialogFixture(Robot robot,
                     String dialogName)
Creates a new DialogFixture.

Parameters:
robot - performs simulation of user events on a Dialog.
dialogName - the name of the Dialog to find using the given Robot.
Throws:
NullPointerException - if robot is null.
ComponentLookupException - if a Dialog having a matching name could not be found.
ComponentLookupException - if more than one Dialog having a matching name is found.

DialogFixture

public DialogFixture(String dialogName)
Creates a new DialogFixture. This constructor creates a new Robot containing the current AWT hierarchy.

Parameters:
dialogName - the name of the Dialog to find.
Throws:
ComponentLookupException - if a Dialog having a matching name could not be found.
ComponentLookupException - if more than one Dialog having a matching name is found.
See Also:
BasicRobot.robotWithCurrentAwtHierarchy()
Method Detail

driver

protected final void driver(DialogDriver newDriver)
Sets the DialogDriver to be used by this fixture.

Parameters:
newDriver - the new DialogDriver.
Throws:
NullPointerException - if the given driver is null.

click

public DialogFixture click()
Simulates a user clicking this fixture's Dialog.

Returns:
this fixture.

click

public DialogFixture click(MouseButton button)
Simulates a user clicking this fixture's Dialog.

Parameters:
button - the button to click.
Returns:
this fixture.

click

public DialogFixture click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's Dialog.

Parameters:
mouseClickInfo - specifies the button to click and the times the button should be clicked.
Returns:
this fixture.
Throws:
NullPointerException - if the given MouseClickInfo is null.

doubleClick

public DialogFixture doubleClick()
Simulates a user double-clicking this fixture's Dialog.

Returns:
this fixture.

focus

public DialogFixture focus()
Gives input focus to this fixture's Dialog.

Returns:
this fixture.

moveTo

public DialogFixture moveTo(Point p)
Simulates a user moving this fixture's Dialog to the given point.

Parameters:
p - the point to move this fixture's Dialog to.
Returns:
this fixture.
Throws:
ActionFailedException - if the Window is not movable.
ActionFailedException - if the given Window is not showing on the screen.

moveToFront

public DialogFixture moveToFront()
If fixture's Dialog is visible, brings it to the front and may make it the focused one.

Returns:
this fixture.

moveToBack

public DialogFixture moveToBack()
If the given Dialog is visible, sends it to the back and may cause it to lose focus or activation if it is the focused or active.

Returns:
this fixture.

pressAndReleaseKey

public DialogFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
Simulates a user pressing given key with the given modifiers on this fixture's Dialog. Modifiers is a mask from the available InputEvent masks.

Parameters:
keyPressInfo - specifies the key and modifiers to press.
Returns:
this fixture.
Throws:
NullPointerException - if the given KeyPressInfo is null.
IllegalArgumentException - if the given code is not a valid key code.
See Also:
KeyPressInfo

pressAndReleaseKeys

public DialogFixture pressAndReleaseKeys(int... keyCodes)
Simulates a user pressing and releasing the given keys on this fixture's Dialog.

Parameters:
keyCodes - one or more codes of the keys to press.
Returns:
this fixture.
Throws:
NullPointerException - if the given array of codes is null.
IllegalArgumentException - if any of the given code is not a valid key code.
See Also:
KeyEvent

pressKey

public DialogFixture pressKey(int keyCode)
Simulates a user pressing the given key on this fixture's Dialog.

Parameters:
keyCode - the code of the key to press.
Returns:
this fixture.
Throws:
IllegalArgumentException - if the given code is not a valid key code.
See Also:
KeyEvent

releaseKey

public DialogFixture releaseKey(int keyCode)
Simulates a user releasing the given key on this fixture's Dialog.

Parameters:
keyCode - the code of the key to release.
Returns:
this fixture.
Throws:
IllegalArgumentException - if the given code is not a valid key code.
See Also:
KeyEvent

requireFocused

public DialogFixture requireFocused()
Asserts that this fixture's Dialog has input focus.

Returns:
this fixture.
Throws:
AssertionError - if this fixture's Dialog does not have input focus.

requireDisabled

public DialogFixture requireDisabled()
Asserts that this fixture's Dialog is disabled.

Returns:
this fixture.
Throws:
AssertionError - if this fixture's Dialog is enabled.

requireEnabled

public DialogFixture requireEnabled()
Asserts that this fixture's Dialog is enabled.

Returns:
this fixture.
Throws:
AssertionError - if this fixture's Dialog is disabled.

requireEnabled

public DialogFixture requireEnabled(Timeout timeout)
Asserts that this fixture's Dialog is enabled.

Parameters:
timeout - the time this fixture will wait for the component to be enabled.
Returns:
this fixture.
Throws:
WaitTimedOutError - if this fixture's Dialog is never enabled.

requireModal

public DialogFixture requireModal()
Asserts that this fixture's Dialog is modal.

Returns:
this fixture.
Throws:
AssertionError - if this fixture's Dialog is not modal.

requireNotVisible

public DialogFixture requireNotVisible()
Asserts that this fixture's Dialog is not visible.

Returns:
this fixture.
Throws:
AssertionError - if this fixture's Dialog is visible.

requireSize

public DialogFixture requireSize(Dimension size)
Asserts that the size of this fixture's Dialog is equal to given one.

Parameters:
size - the given size to match.
Returns:
this fixture.
Throws:
AssertionError - if the size of this fixture's Dialog is not equal to the given size.

requireVisible

public DialogFixture requireVisible()
Asserts that this fixture's Dialog is visible.

Returns:
this fixture.
Throws:
AssertionError - if this fixture's Dialog is not visible.

resizeHeightTo

public DialogFixture resizeHeightTo(int height)
Simulates a user resizing vertically this fixture's Dialog.

Parameters:
height - the height that this fixture's Dialog should have after being resized.
Returns:
this fixture.
Throws:
ActionFailedException - if the Window is not resizable.

resizeTo

public DialogFixture resizeTo(Dimension size)
Simulates a user resizing this fixture's Dialog.

Parameters:
size - the size that the target window should have after being resized.
Returns:
this fixture.
Throws:
ActionFailedException - if the Window is not resizable.

resizeWidthTo

public DialogFixture resizeWidthTo(int width)
Simulates a user resizing horizontally this fixture's Dialog.

Parameters:
width - the width that this fixture's Dialog should have after being resized.
Returns:
this fixture.
Throws:
ActionFailedException - if the Window is not resizable.

rightClick

public DialogFixture rightClick()
Simulates a user right-clicking this fixture's Dialog.

Returns:
this fixture.

show

public DialogFixture show()
Shows this fixture's Dialog.

Specified by:
show in class WindowFixture<Dialog>
Returns:
this fixture.

show

public DialogFixture show(Dimension size)
Shows this fixture's Dialog, resized to the given size.

Specified by:
show in class WindowFixture<Dialog>
Parameters:
size - the size to resize this fixture's Dialog to.
Returns:
this fixture.

showPopupMenu

public JPopupMenuFixture showPopupMenu()
Shows a pop-up menu using this fixture's Dialog as the invoker of the pop-up menu.

Returns:
a fixture that manages the displayed pop-up menu.
Throws:
IllegalStateException - if this fixture's Dialog is disabled.
IllegalStateException - if this fixture's Dialog is not showing on the screen.
ComponentLookupException - if a pop-up menu cannot be found.

showPopupMenuAt

public JPopupMenuFixture showPopupMenuAt(Point p)
Shows a pop-up menu at the given point using this fixture's Dialog as the invoker of the pop-up menu.

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's Dialog is disabled.
IllegalStateException - if this fixture's Dialog is not showing on the screen.
ComponentLookupException - if a pop-up menu cannot be found.

close

public void close()
Simulates a user closing this fixture's Dialog.



Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.