Class ComponentFixture<T extends Component>

java.lang.Object
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:
  • user input simulation
  • state verification
  • property value query
  • Field Details

    • FONT_PROPERTY

      protected static final String FONT_PROPERTY
      Name of the property "font".
      See Also:
    • BACKGROUND_PROPERTY

      protected static final String BACKGROUND_PROPERTY
      Name of the property "background".
      See Also:
    • FOREGROUND_PROPERTY

      protected static final String FOREGROUND_PROPERTY
      Name of the property "foreground".
      See Also:
    • 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 Details

  • Method Details

    • findTarget

      private static <C extends Component> C findTarget(Robot robot, Class<? extends C> type)
    • validateNotNull

      static void validateNotNull(ComponentDriver driver)
    • findTarget

      private static <C extends Component> C findTarget(Robot robot, String name, Class<? extends C> type)
    • validate

      private static void validate(Robot robot, Class<?> type)
    • 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.
    • requireShowing

      private static boolean requireShowing(Robot robot)
    • 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.