Class SwingAutomationTest<THost extends UIAutomationHost>

java.lang.Object
de.renebergelt.juitest.host.testscripts.UIAutomationTest<THost>
de.renebergelt.juitest.host.testscripts.SwingAutomationTest<THost>
Type Parameters:
THost - Type of the automation host instance

public abstract class SwingAutomationTest<THost extends UIAutomationHost> extends UIAutomationTest<THost>
Base class for UIAutomationTest which test Java Swing UIs (provides swing-related helper methods)
  • Constructor Details

    • SwingAutomationTest

      public SwingAutomationTest()
  • Method Details

    • uiActionWait

      public void uiActionWait(Runnable step) throws CancellationException
      Execute the given method in the UI thread (i.e. Swing's Event Dispatch Thread) and block until the action has finished
      Parameters:
      step - The action to run
      Throws:
      CancellationException - Thrown if the user cancelled the execution
    • uiActionWait

      public void uiActionWait(de.renebergelt.juitest.core.Timeout timeout, Runnable step) throws CancellationException, TimeoutException
      Execute the given method in the UI thread (i.e. Swing's Event Dispatch Thread) and block until the action has finished
      Parameters:
      timeout - The maximum wait time
      step - The function to execute
      Throws:
      CancellationException - Thrown if the user cancelled the execution
      TimeoutException - Thrown if the timeout occurred
    • uiActionWait

      public <T> T uiActionWait(Supplier<T> step) throws CancellationException
      Execute the given method in the UI thread (i.e. Swing's Event Dispatch Thread) and block until the action has finished
      Type Parameters:
      T - Type of the result
      Parameters:
      step - The function to execute
      Returns:
      THe result as produced by the step function
      Throws:
      CancellationException - Thrown if the user cancelled the execution
    • uiActionWait

      public <T> T uiActionWait(de.renebergelt.juitest.core.Timeout timeout, Supplier<T> step) throws CancellationException, TimeoutException
      Execute the given method, which produces a return value, in the UI thread (i.e. Swing's Event Dispatch Thread) and block until the action has finished. Returns the value produced by step
      Type Parameters:
      T - Type of the result
      Parameters:
      timeout - The maximum wait time
      step - The function to execute
      Returns:
      The result as returned by the step function
      Throws:
      CancellationException - Thrown if the user cancelled the execution
      TimeoutException - Thrown if the timeout occurred
    • uiActionAsync

      public void uiActionAsync(Runnable step) throws CancellationException
      Schedules the given step in the EDT and returns immediately
      Parameters:
      step - The function to execute
      Throws:
      CancellationException - Thrown if the user cancelled the execution
    • waitForCondition

      public void waitForCondition(de.renebergelt.juitest.core.Timeout timeout, Supplier<Boolean> condition) throws TimeoutException
      Wait until the given condition is satisfied
      Parameters:
      timeout - The maximum wait time
      condition - The condition check. It is not executed in the EDT!
      Throws:
      TimeoutException - Thrown if the timeout occurred
    • expectWindow

      public <T extends Window> T expectWindow(de.renebergelt.juitest.core.Timeout timeout, Runnable winOpenAction, Class<T> windowClass) throws TimeoutException
      Execute the given action which should open a window of the given class
      Type Parameters:
      T - The type of the wondow
      Parameters:
      timeout - The maximum wait time
      winOpenAction - Action, which should open a window of the given class
      windowClass - The class of the window
      Returns:
      The window instance
      Throws:
      TimeoutException - Thrown if the timeout occurred
    • waitForWindow

      public <T extends Window> T waitForWindow(de.renebergelt.juitest.core.Timeout timeout, Class<T> windowClass) throws TimeoutException
      Blocks until at least one window of the given class is opened and returns an open instance
      Type Parameters:
      T - The window class
      Parameters:
      timeout - The maximum wait time
      windowClass - The window class
      Returns:
      The window instance
      Throws:
      TimeoutException - Thrown if the timeout occurred
    • waitUntilWindowIsClosed

      public void waitUntilWindowIsClosed(de.renebergelt.juitest.core.Timeout timeout, Window window) throws TimeoutException
      Wait until the given window has been closed
      Parameters:
      timeout - The maximum wait time
      window - The window instance
      Throws:
      TimeoutException - Thrown if the timeout occurred
    • waitForWindow

      public <T extends Window> T waitForWindow(de.renebergelt.juitest.core.Timeout timeout, Predicate<Window> condition) throws TimeoutException
      Wait for a window which fulfills the given condition
      Type Parameters:
      T - The window class
      Parameters:
      timeout - The maximum wait time
      condition - The condition to check
      Returns:
      The window instance
      Throws:
      TimeoutException - Thrown if the timeout occurred
    • waitForWindow_internal

      public <T extends Window> T waitForWindow_internal(de.renebergelt.juitest.core.Timeout timeout, Predicate<Window> condition) throws TimeoutException
      Wait for a window which fulfills the given condition
      Type Parameters:
      T - The window class
      Parameters:
      timeout - The maximum wait time
      condition - The condition to check
      Returns:
      The window instance
      Throws:
      TimeoutException - Thrown if the timeout occurred
    • waitForAndDimissOptionPane

      public void waitForAndDimissOptionPane(de.renebergelt.juitest.core.Timeout timeout, Object result) throws TimeoutException
      Waits for an JOptionPane based Dialog and closes it using the given result
      Parameters:
      timeout - The maximum wait time
      result - The result object the JOptionPane should return
      Throws:
      TimeoutException - Thrown if the timeout occurred
    • wait

      public void wait(de.renebergelt.juitest.core.Timeout timeout)
      Wait for the given amount of time
      Parameters:
      timeout - The wait time
    • findComponent

      public static <T extends Component> T findComponent(Container parent, Class<T> componentClass)
      Return the first component of the given class which is a child of parent or contained in any of parent's children
      Type Parameters:
      T - The class of the component to find
      Parameters:
      parent - The container to start searching for the class
      componentClass - The class of the component to find
      Returns:
      Component instance if found or null otherwise
    • findComponent

      public static <T extends Component> T findComponent(Container parent, Class<T> componentClass, Predicate<T> condition)
      Return the first component of the given class which is a child of parent or contained in any of parent's children and which fulfills the given condition
      Type Parameters:
      T - The class of the component to find
      Parameters:
      parent - The container to start searching for the class
      componentClass - The class of the component to find
      condition - The condition to check
      Returns:
      Component instance if found or null otherwise