org.fest.swing.fixture
Class ComponentFixture<T extends Component>

java.lang.Object
  extended by org.fest.swing.fixture.ComponentFixture<T>
Type Parameters:
T - the type of Component that this fixture can manage.
Direct Known Subclasses:
ContainerFixture, GenericComponentFixture, JButtonFixture, JCheckBoxFixture, JComboBoxFixture, JFileChooserFixture, JLabelFixture, JListFixture, JMenuItemFixture, JPopupMenuFixture, JProgressBarFixture, JRadioButtonFixture, JScrollBarFixture, JScrollPaneFixture, JSliderFixture, JSpinnerFixture, JSplitPaneFixture, JTabbedPaneFixture, JTableFixture, JTableHeaderFixture, JTextComponentFixture, JToggleButtonFixture, JTreeFixture

public abstract class ComponentFixture<T extends Component>
extends Object

Understands functional testing of Components:

Author:
Alex Ruiz, Yvonne Wang

Field Summary
protected static String BACKGROUND_PROPERTY
          Name of the property "background".
protected static String FONT_PROPERTY
          Name of the property "font".
protected static String FOREGROUND_PROPERTY
          Name of the property "foreground".
 Robot robot
          Performs simulation of user events on target
 T target
          This fixture's Component.
 
Constructor Summary
ComponentFixture(Robot robot, Class<? extends T> type)
          Creates a new ComponentFixture.
ComponentFixture(Robot robot, String name, Class<? extends T> type)
          Creates a new ComponentFixture.
ComponentFixture(Robot robot, T target)
          Creates a new ComponentFixture.
 
Method Summary
 ColorFixture background()
          Returns a fixture that verifies the background color of this fixture's Component.
 T component()
          Returns the GUI component in this fixture (same as target.)
 FontFixture font()
          Returns a fixture that verifies the font of this fixture's Component.
 ColorFixture foreground()
          Returns a fixture that verifies the foreground color of this fixture's Component.
protected  boolean requireShowing()
          Returns whether showing components are the only ones participating in a component lookup.
<C extends T>
C
targetCastedTo(Class<C> type)
          Returns this fixture's Component casted to the given sub-type.
protected static void validateNotNull(ComponentDriver driver)
          Validates that the given ComponentDriver is not null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FONT_PROPERTY

protected static final String FONT_PROPERTY
Name of the property "font".

See Also:
Constant Field Values

BACKGROUND_PROPERTY

protected static final String BACKGROUND_PROPERTY
Name of the property "background".

See Also:
Constant Field Values

FOREGROUND_PROPERTY

protected static final String FOREGROUND_PROPERTY
Name of the property "foreground".

See Also:
Constant Field Values

robot

public final Robot robot
Performs simulation of user events on target


target

public final T extends Component target
This fixture's Component.

Note: Access to this GUI component must be executed in the event dispatch thread. To do so, please execute a GuiQuery or GuiTask (depending on what you need to do,) inside a GuiActionRunner. To learn more about Swing threading, please read the Swing Threading Policy.

Constructor Detail

ComponentFixture

public ComponentFixture(Robot robot,
                        Class<? extends T> type)
Creates a new ComponentFixture.

Parameters:
robot - performs simulation of user events on a Component.
type - the type of the Component to find using the given RobotFixture.
Throws:
NullPointerException - if robot is null.
NullPointerException - if type is null.
ComponentLookupException - if a matching component could not be found.
ComponentLookupException - if more than one matching component is found.

ComponentFixture

public ComponentFixture(Robot robot,
                        String name,
                        Class<? extends T> type)
Creates a new ComponentFixture.

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

ComponentFixture

public ComponentFixture(Robot robot,
                        T target)
Creates a new ComponentFixture.

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

validateNotNull

protected static void validateNotNull(ComponentDriver driver)
Validates that the given ComponentDriver is not null.

Parameters:
driver - the ComponentDriver to validate.
Throws:
NullPointerException - if driver is null.

requireShowing

protected boolean requireShowing()
Returns whether showing components are the only ones participating in a component lookup. The returned value is obtained from the component lookup scope stored in this fixture's Robot.

Returns:
true if only showing components can participate in a component lookup, false otherwise.

font

public final FontFixture font()
Returns a fixture that verifies the font of this fixture's Component.

Returns:
a fixture that verifies the font of this fixture's Component.

background

public final ColorFixture background()
Returns a fixture that verifies the background color of this fixture's Component.

Returns:
a fixture that verifies the background color of this fixture's Component.

foreground

public final ColorFixture foreground()
Returns a fixture that verifies the foreground color of this fixture's Component.

Returns:
a fixture that verifies the foreground color of this fixture's Component.

targetCastedTo

public final <C extends T> C targetCastedTo(Class<C> type)
Returns this fixture's Component casted to the given sub-type.

Type Parameters:
C - enforces that the given type is a sub-type of the managed Component.
Parameters:
type - the type that the managed Component will be casted to.
Returns:
this fixture's Component casted to the given sub-type.
Throws:
AssertionError - if this fixture's Component is not an instance of the given type.

component

public final T component()
Returns the GUI component in this fixture (same as target.)

Note: Access to the GUI component returned by this method must be executed in the event dispatch thread. To do so, please execute a GuiQuery or GuiTask (depending on what you need to do,) inside a GuiActionRunner. To learn more about Swing threading, please read the Swing Threading Policy.

Returns:
the GUI component in this fixture.


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