Class JTabbedPaneDriver


public class JTabbedPaneDriver extends JComponentDriver
Understands functional testing of JTabbedPanes:
  • user input simulation
  • state verification
  • property value query
This class is intended for internal use only. Please use the classes in the package org.fest.swing.fixture in your tests.
  • Field Details

  • Constructor Details

    • JTabbedPaneDriver

      public JTabbedPaneDriver(Robot robot)
      Creates a new JTabbedPaneDriver.
      Parameters:
      robot - the robot to use to simulate user input.
    • JTabbedPaneDriver

      JTabbedPaneDriver(Robot robot, JTabbedPaneLocation location)
      Creates a new JTabbedPaneDriver.
      Parameters:
      robot - the robot to use to simulate user input.
      location - knows how to find the location of a tab.
  • Method Details

    • tabTitles

      @RunsInEDT public String[] tabTitles(JTabbedPane tabbedPane)
      Returns the titles of all the tabs.
      Parameters:
      tabbedPane - the target JTabbedPane.
      Returns:
      the titles of all the tabs.
    • selectTab

      @RunsInEDT public void selectTab(JTabbedPane tabbedPane, String title)
      Simulates a user selecting the tab containing the given title.
      Parameters:
      tabbedPane - the target JTabbedPane.
      title - the given text to match. It can be a regular expression.
      Throws:
      IllegalStateException - if the JTabbedPane is disabled.
      IllegalStateException - if the JTabbedPane is not showing on the screen.
      LocationUnavailableException - if a tab matching the given title could not be found.
    • selectTab

      @RunsInEDT public void selectTab(JTabbedPane tabbedPane, Pattern pattern)
      Simulates a user selecting the tab whose title matches the given regular expression pattern.
      Parameters:
      tabbedPane - the target JTabbedPane.
      pattern - the regular expression pattern to match.
      Throws:
      IllegalStateException - if the JTabbedPane is disabled.
      IllegalStateException - if the JTabbedPane is not showing on the screen.
      NullPointerException - if the given regular expression pattern is null.
      LocationUnavailableException - if a tab matching the given regular expression pattern could not be found.
      Since:
      1.2
    • selectTab

      @RunsInEDT private void selectTab(JTabbedPane tabbedPane, TextMatcher matcher)
    • tabToSelectInfo

      @RunsInEDT private static Pair<Integer,Point> tabToSelectInfo(JTabbedPaneLocation location, JTabbedPane tabbedPane, TextMatcher matcher)
    • selectTab

      public void selectTab(JTabbedPane tabbedPane, int index)
      Simulates a user selecting the tab located at the given index.
      Parameters:
      tabbedPane - the target JTabbedPane.
      index - the index of the tab to select.
      Throws:
      IllegalStateException - if the JTabbedPane is disabled.
      IllegalStateException - if the JTabbedPane is not showing on the screen.
      IndexOutOfBoundsException - if the given index is not within the JTabbedPane bounds.
    • validateAndGetPoint

      @RunsInEDT private static Point validateAndGetPoint(JTabbedPaneLocation location, JTabbedPane tabbedPane, int index)
    • setTabDirectly

      @RunsInEDT void setTabDirectly(JTabbedPane tabbedPane, int index)
    • moveMouseToTab

      private void moveMouseToTab(JTabbedPane tabbedPane, int index)
    • pointAtTab

      @RunsInEDT private static Point pointAtTab(JTabbedPaneLocation location, JTabbedPane tabbedPane, int index)
    • selectedComponentOf

      @RunsInEDT public Component selectedComponentOf(JTabbedPane tabbedPane)
      Returns the currently selected component for the given JTabbedPane.
      Parameters:
      tabbedPane - the target JTabbedPane.
      Returns:
      the currently selected component for the given JTabbedPane.
    • selectedComponent

      @RunsInEDT private static Component selectedComponent(JTabbedPane tabbedPane)
    • requireTabTitle

      @RunsInEDT public void requireTabTitle(JTabbedPane tabbedPane, String title, Index index)
      Asserts that the title of the tab at the given index matches the given value.
      Parameters:
      tabbedPane - the target JTabbedPane.
      title - the expected title. It can be a regular expression.
      index - the index of the tab.
      Throws:
      IndexOutOfBoundsException - if the given index is not within the JTabbedPane bounds.
      AssertionError - if the title of the tab at the given index does not match the given one.
    • requireTabTitle

      @RunsInEDT public void requireTabTitle(JTabbedPane tabbedPane, Pattern pattern, Index index)
      Asserts that the title of the tab at the given index matches the given regular expression pattern.
      Parameters:
      tabbedPane - the target JTabbedPane.
      pattern - the regular expression pattern to match.
      index - the index of the tab.
      Throws:
      NullPointerException - if the given regular expression pattern is null.
      IndexOutOfBoundsException - if the given index is not within the JTabbedPane bounds.
      AssertionError - if the title of the tab at the given index does not match the given one.
      Since:
      1.2
    • titleAtProperty

      @RunsInEDT private org.fest.assertions.Description titleAtProperty(JTabbedPane tabbedPane)
    • titleAt

      @RunsInEDT private static String titleAt(JTabbedPane tabbedPane, Index index)
    • requireTabTitles

      @RunsInEDT public void requireTabTitles(JTabbedPane tabbedPane, String[] titles)
      Asserts that the tabs of the given JTabbedPane have the given titles. The tab titles are evaluated by index order, for example, the first tab is expected to have the first title in the given array, and so on.
      Parameters:
      tabbedPane - the target JTabbedPane.
      titles - the expected titles.
      Throws:
      AssertionError - if the title of any of the tabs is not equal to the expected titles.
    • allTabTitlesIn

      @RunsInEDT private static String[] allTabTitlesIn(JTabbedPane tabbedPane)