org.fest.swing.fixture
Class FrameFixture

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<Frame>
              extended by org.fest.swing.fixture.FrameFixture
All Implemented Interfaces:
CommonComponentFixture, ComponentContainerFixture, FocusableComponentFixture, FrameLikeFixture, JPopupMenuInvokerFixture, KeyboardInputSimulationFixture, MouseInputSimulationFixture, StateVerificationFixture, WindowLikeContainerFixture

public class FrameFixture
extends WindowFixture<Frame>
implements FrameLikeFixture

Understands functional testing of Frames:

Author:
Yvonne Wang, 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
FrameFixture(Frame target)
          Creates a new FrameFixture.
FrameFixture(Robot robot, Frame target)
          Creates a new FrameFixture.
FrameFixture(Robot robot, String name)
          Creates a new FrameFixture.
FrameFixture(String name)
          Creates a new FrameFixture.
 
Method Summary
 FrameFixture click()
          Simulates a user clicking this fixture's Frame.
 FrameFixture click(MouseButton button)
          Simulates a user clicking this fixture's Frame.
 FrameFixture click(MouseClickInfo mouseClickInfo)
          Simulates a user clicking this fixture's Frame.
 void close()
          Simulates a user closing this fixture's Frame.
 FrameFixture deiconify()
          Simulates a user deiconifying this fixture's Frame.
 FrameFixture doubleClick()
          Simulates a user double-clicking this fixture's Frame.
protected  void driver(FrameDriver newDriver)
          Sets the FrameDriver to be used by this fixture.
 FrameFixture focus()
          Gives input focus to this fixture's Frame.
 FrameFixture iconify()
          Simulates a user iconifying this fixture's Frame.
 FrameFixture maximize()
          Simulates a user maximizing this fixture's Frame.
 FrameFixture moveTo(Point p)
          Simulates a user moving this fixture's Frame to the given point.
 FrameFixture moveToBack()
          If the given Frame is visible, sends it to the back and may cause it to lose focus or activation if it is the focused or active.
 FrameFixture moveToFront()
          If fixture's Frame is visible, brings it to the front and may make it the focused one.
 FrameFixture normalize()
          Simulates a user normalizing this fixture's Frame.
 FrameFixture pressAndReleaseKey(KeyPressInfo keyPressInfo)
          Simulates a user pressing given key with the given modifiers on this fixture's Frame.
 FrameFixture pressAndReleaseKeys(int... keyCodes)
          Simulates a user pressing and releasing the given keys on this fixture's Frame.
 FrameFixture pressKey(int keyCode)
          Simulates a user pressing the given key on this fixture's Frame.
 FrameFixture releaseKey(int keyCode)
          Simulates a user releasing the given key on this fixture's Frame.
 FrameFixture requireDisabled()
          Asserts that this fixture's Frame is disabled.
 FrameFixture requireEnabled()
          Asserts that this fixture's Frame is enabled.
 FrameFixture requireEnabled(Timeout timeout)
          Asserts that this fixture's Frame is enabled.
 FrameFixture requireFocused()
          Asserts that this fixture's Frame has input focus.
 FrameFixture requireNotVisible()
          Asserts that this fixture's Frame is not visible.
 FrameFixture requireSize(Dimension size)
          Asserts that the size of this fixture's Frame is equal to given one.
 FrameFixture requireVisible()
          Asserts that this fixture's Frame is visible.
 FrameFixture resizeHeightTo(int height)
          Simulates a user resizing vertically this fixture's Frame.
 FrameFixture resizeTo(Dimension size)
          Simulates a user resizing this fixture's Frame.
 FrameFixture resizeWidthTo(int width)
          Simulates a user resizing horizontally this fixture's Frame.
 FrameFixture rightClick()
          Simulates a user right-clicking this fixture's Frame.
 FrameFixture show()
          Shows this fixture's Frame.
 FrameFixture show(Dimension size)
          Shows this fixture's Frame, resized to the given size.
 JPopupMenuFixture showPopupMenu()
          Shows a pop-up menu using this fixture's Frame 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 Frame 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

FrameFixture

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

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

FrameFixture

public FrameFixture(Robot robot,
                    Frame target)
Creates a new FrameFixture.

Parameters:
robot - performs user events on the given window and verifies expected output.
target - the Frame to be managed by this fixture.
Throws:
NullPointerException - if the given robot is null.
NullPointerException - if the given frame is null.

FrameFixture

public FrameFixture(Robot robot,
                    String name)
Creates a new FrameFixture.

Parameters:
robot - performs user events on the given window and verifies expected output.
name - the name of the Frame to find using the given Robot.
Throws:
NullPointerException - if the given robot is null.
ComponentLookupException - if a Frame having a matching name could not be found.
ComponentLookupException - if more than one Frame having a matching name is found.

FrameFixture

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

Parameters:
name - the name of the Frame to find.
Throws:
ComponentLookupException - if a Frame having a matching name could not be found.
ComponentLookupException - if more than one Frame having a matching name is found.
Method Detail

driver

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

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

click

public FrameFixture click()
Simulates a user clicking this fixture's Frame.

Specified by:
click in interface MouseInputSimulationFixture
Returns:
this fixture.

click

public FrameFixture click(MouseButton button)
Simulates a user clicking this fixture's Frame.

Specified by:
click in interface MouseInputSimulationFixture
Parameters:
button - the button to click.
Returns:
this fixture.

click

public FrameFixture click(MouseClickInfo mouseClickInfo)
Simulates a user clicking this fixture's Frame.

Specified by:
click in interface MouseInputSimulationFixture
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 FrameFixture doubleClick()
Simulates a user double-clicking this fixture's Frame.

Specified by:
doubleClick in interface MouseInputSimulationFixture
Returns:
this fixture.

rightClick

public FrameFixture rightClick()
Simulates a user right-clicking this fixture's Frame.

Specified by:
rightClick in interface MouseInputSimulationFixture
Returns:
this fixture.

iconify

public FrameFixture iconify()
Simulates a user iconifying this fixture's Frame.

Specified by:
iconify in interface FrameLikeFixture
Returns:
this fixture.

deiconify

public FrameFixture deiconify()
Simulates a user deiconifying this fixture's Frame.

Specified by:
deiconify in interface FrameLikeFixture
Returns:
this fixture.

maximize

public FrameFixture maximize()
Simulates a user maximizing this fixture's Frame.

Specified by:
maximize in interface FrameLikeFixture
Returns:
this fixture.
Throws:
ActionFailedException - if the operating system does not support maximizing frames.

normalize

public FrameFixture normalize()
Simulates a user normalizing this fixture's Frame.

Specified by:
normalize in interface FrameLikeFixture
Returns:
this fixture.

focus

public FrameFixture focus()
Gives input focus to this fixture's Frame.

Specified by:
focus in interface FocusableComponentFixture
Returns:
this fixture.

moveTo

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

Specified by:
moveTo in interface WindowLikeContainerFixture
Parameters:
p - the point to move this fixture's Frame to.
Returns:
this fixture.

pressAndReleaseKey

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

Specified by:
pressAndReleaseKey in interface KeyboardInputSimulationFixture
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 FrameFixture pressAndReleaseKeys(int... keyCodes)
Simulates a user pressing and releasing the given keys on this fixture's Frame.

Specified by:
pressAndReleaseKeys in interface KeyboardInputSimulationFixture
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 FrameFixture pressKey(int keyCode)
Simulates a user pressing the given key on this fixture's Frame.

Specified by:
pressKey in interface KeyboardInputSimulationFixture
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:
KeyEvent

releaseKey

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

Specified by:
releaseKey in interface KeyboardInputSimulationFixture
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:
KeyEvent

requireFocused

public FrameFixture requireFocused()
Asserts that this fixture's Frame has input focus.

Specified by:
requireFocused in interface FocusableComponentFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's Frame does not have input focus.

requireDisabled

public FrameFixture requireDisabled()
Asserts that this fixture's Frame is disabled.

Specified by:
requireDisabled in interface StateVerificationFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's Frame is enabled.

requireEnabled

public FrameFixture requireEnabled()
Asserts that this fixture's Frame is enabled.

Specified by:
requireEnabled in interface StateVerificationFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's Frame is disabled.

requireEnabled

public FrameFixture requireEnabled(Timeout timeout)
Asserts that this fixture's Frame is enabled.

Specified by:
requireEnabled in interface StateVerificationFixture
Parameters:
timeout - the time this fixture will wait for the component to be enabled.
Returns:
this fixture.
Throws:
WaitTimedOutError - if this fixture's Frame is never enabled.

requireNotVisible

public FrameFixture requireNotVisible()
Asserts that this fixture's Frame is not visible.

Specified by:
requireNotVisible in interface StateVerificationFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's Frame is visible.

requireSize

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

Specified by:
requireSize in interface WindowLikeContainerFixture
Parameters:
size - the given size to match.
Returns:
this fixture.
Throws:
AssertionError - if the size of this fixture's Frame is not equal to the given size.

requireVisible

public FrameFixture requireVisible()
Asserts that this fixture's Frame is visible.

Specified by:
requireVisible in interface StateVerificationFixture
Returns:
this fixture.
Throws:
AssertionError - if this fixture's Frame is not visible.

resizeHeightTo

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

Specified by:
resizeHeightTo in interface WindowLikeContainerFixture
Parameters:
height - the height that this fixture's Frame should have after being resized.
Returns:
this fixture.

resizeTo

public FrameFixture resizeTo(Dimension size)
Simulates a user resizing this fixture's Frame.

Specified by:
resizeTo in interface WindowLikeContainerFixture
Parameters:
size - the size that the target window should have after being resized.
Returns:
this fixture.

resizeWidthTo

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

Specified by:
resizeWidthTo in interface WindowLikeContainerFixture
Parameters:
width - the width that this fixture's Frame should have after being resized.
Returns:
this fixture.

show

public FrameFixture show()
Shows this fixture's Frame.

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

show

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

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

moveToFront

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

Specified by:
moveToFront in interface WindowLikeContainerFixture
Returns:
this fixture.

moveToBack

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

Specified by:
moveToBack in interface WindowLikeContainerFixture
Returns:
this fixture.

showPopupMenu

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

Specified by:
showPopupMenu in interface JPopupMenuInvokerFixture
Returns:
a fixture that manages the displayed pop-up menu.
Throws:
IllegalStateException - if this fixture's Frame is disabled.
IllegalStateException - if this fixture's Frame 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 Frame as the invoker of the pop-up menu.

Specified by:
showPopupMenuAt in interface JPopupMenuInvokerFixture
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 Frame is disabled.
IllegalStateException - if this fixture's Frame 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 Frame.

Specified by:
close in interface WindowLikeContainerFixture


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