Package org.fest.swing.fixture
Class ComponentFixture<T extends Component>
java.lang.Object
org.fest.swing.fixture.ComponentFixture<T>
- Type Parameters:
T
- the type ofComponent
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
Understands functional testing of
Component
s:
- user input simulation
- state verification
- property value query
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final String
Name of the property "background".protected static final String
Name of the property "font".protected static final String
Name of the property "foreground".final Robot
Performs simulation of user events ontarget
final T
This fixture's
.Component
-
Constructor Summary
ConstructorsConstructorDescriptionComponentFixture
(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
Modifier and TypeMethodDescriptionfinal ColorFixture
Returns a fixture that verifies the background color of this fixture's
.Component
final T
Returns the GUI component in this fixture (same as
.)target
private 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 FontFixture
font()
Returns a fixture that verifies the font of this fixture's
.Component
final ColorFixture
Returns a fixture that verifies the foreground color of this fixture's
.Component
protected boolean
Returns whether showing components are the only ones participating in a component lookup.private static boolean
requireShowing
(Robot robot) final <C extends T>
CtargetCastedTo
(Class<C> type) Returns this fixture's
casted to the given sub-type.Component
private static void
(package private) static void
validateNotNull
(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
.Component
Note: 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 theComponent
to find using the givenRobotFixture
.- Throws:
NullPointerException
- ifrobot
isnull
.NullPointerException
- iftype
isnull
.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 theComponent
to find using the givenRobotFixture
.type
- the type of theComponent
to find using the givenRobotFixture
.- Throws:
NullPointerException
- ifrobot
isnull
.NullPointerException
- iftype
isnull
.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
- theComponent
to be managed by this fixture.- Throws:
NullPointerException
- ifrobot
isnull
.NullPointerException
- iftarget
isnull
.
-
-
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 the
stored in this fixture'scomponent lookup scope
.Robot
- Returns:
true
if only showing components can participate in a component lookup,false
otherwise.
-
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's
casted 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 managedComponent
will be casted to.- Returns:
- this fixture's
Component
casted to the given sub-type. - Throws:
AssertionError
- if this fixture'sComponent
is not an instance of the given type.
-
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
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.
-