Package org.fest.swing.fixture
Class ComponentFixture<T extends Component>
java.lang.Object
org.fest.swing.fixture.ComponentFixture<T>
- Type Parameters:
T- the type ofComponentthat 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
Understands functional testing of
Components:
- user input simulation
- state verification
- property value query
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringName of the property "background".protected static final StringName of the property "font".protected static final StringName of the property "foreground".final RobotPerforms simulation of user events ontargetfinal TThis fixture's.Component -
Constructor Summary
ConstructorsConstructorDescriptionComponentFixture(Robot robot, Class<? extends T> type) Creates a new.ComponentFixtureComponentFixture(Robot robot, String name, Class<? extends T> type) Creates a new.ComponentFixtureComponentFixture(Robot robot, T target) Creates a new.ComponentFixture -
Method Summary
Modifier and TypeMethodDescriptionfinal ColorFixtureReturns a fixture that verifies the background color of this fixture's.Componentfinal TReturns the GUI component in this fixture (same as.)targetprivate static <C extends Component>
CfindTarget(Robot robot, Class<? extends C> type) private static <C extends Component>
CfindTarget(Robot robot, String name, Class<? extends C> type) final FontFixturefont()Returns a fixture that verifies the font of this fixture's.Componentfinal ColorFixtureReturns a fixture that verifies the foreground color of this fixture's.Componentprotected booleanReturns whether showing components are the only ones participating in a component lookup.private static booleanrequireShowing(Robot robot) final <C extends T>
CtargetCastedTo(Class<C> type) Returns this fixture'scasted to the given sub-type.Componentprivate static void(package private) static voidvalidateNotNull(ComponentDriver driver)
-
Field Details
-
FONT_PROPERTY
Name of the property "font".- See Also:
-
BACKGROUND_PROPERTY
Name of the property "background".- See Also:
-
FOREGROUND_PROPERTY
Name of the property "foreground".- See Also:
-
robot
Performs simulation of user events ontarget -
target
This fixture's.ComponentNote: Access to this GUI component must be executed in the event dispatch thread. To do so, please execute a
orGuiQuery(depending on what you need to do,) inside aGuiTask. To learn more about Swing threading, please read the Swing Threading Policy.GuiActionRunner
-
-
Constructor Details
-
ComponentFixture
Creates a new.ComponentFixture- Parameters:
robot- performs simulation of user events on aComponent.type- the type of theComponentto find using the givenRobotFixture.- Throws:
NullPointerException- ifrobotisnull.NullPointerException- iftypeisnull.ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.
-
ComponentFixture
Creates a new.ComponentFixture- Parameters:
robot- performs simulation of user events on aComponent.name- the name of theComponentto find using the givenRobotFixture.type- the type of theComponentto find using the givenRobotFixture.- Throws:
NullPointerException- ifrobotisnull.NullPointerException- iftypeisnull.ComponentLookupException- if a matching component could not be found.ComponentLookupException- if more than one matching component is found.
-
ComponentFixture
Creates a new.ComponentFixture- Parameters:
robot- performs simulation of user events on the givenComponent.target- theComponentto be managed by this fixture.- Throws:
NullPointerException- ifrobotisnull.NullPointerException- iftargetisnull.
-
-
Method Details
-
findTarget
-
validateNotNull
-
findTarget
-
validate
-
requireShowing
protected boolean requireShowing()Returns whether showing components are the only ones participating in a component lookup. The returned value is obtained from thestored in this fixture'scomponent lookup scope.Robot- Returns:
trueif only showing components can participate in a component lookup,falseotherwise.
-
requireShowing
-
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
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
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
Returns this fixture'scasted to the given sub-type.Component- Type Parameters:
C- enforces that the given type is a sub-type of the managedComponent.- Parameters:
type- the type that the managedComponentwill be casted to.- Returns:
- this fixture's
Componentcasted to the given sub-type. - Throws:
AssertionError- if this fixture'sComponentis not an instance of the given type.
-
component
Returns the GUI component in this fixture (same as.)targetNote: Access to the GUI component returned by this method must be executed in the event dispatch thread. To do so, please execute a
orGuiQuery(depending on what you need to do,) inside aGuiTask. To learn more about Swing threading, please read the Swing Threading Policy.GuiActionRunner- Returns:
- the GUI component in this fixture.
-