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)
-
Field Summary
Fields inherited from class de.renebergelt.juitest.host.testscripts.UIAutomationTest
cancellationRequested, context, currentEvent, DEFAULT_TIMEOUT -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T extends Window>
TexpectWindow(de.renebergelt.juitest.core.Timeout timeout, Runnable winOpenAction, Class<T> windowClass)Execute the given action which should open a window of the given classstatic <T extends Component>
TfindComponent(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 childrenstatic <T extends Component>
TfindComponent(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 conditionvoiduiActionAsync(Runnable step)Schedules the given step in the EDT and returns immediatelyvoiduiActionWait(de.renebergelt.juitest.core.Timeout timeout, Runnable step)Execute the given method in the UI thread (i.e.<T> TuiActionWait(de.renebergelt.juitest.core.Timeout timeout, Supplier<T> step)Execute the given method, which produces a return value, in the UI thread (i.e.voiduiActionWait(Runnable step)Execute the given method in the UI thread (i.e.<T> TuiActionWait(Supplier<T> step)Execute the given method in the UI thread (i.e.voidwait(de.renebergelt.juitest.core.Timeout timeout)Wait for the given amount of timevoidwaitForAndDimissOptionPane(de.renebergelt.juitest.core.Timeout timeout, Object result)Waits for an JOptionPane based Dialog and closes it using the given resultvoidwaitForCondition(de.renebergelt.juitest.core.Timeout timeout, Supplier<Boolean> condition)Wait until the given condition is satisfied<T extends Window>
TwaitForWindow(de.renebergelt.juitest.core.Timeout timeout, Class<T> windowClass)Blocks until at least one window of the given class is opened and returns an open instance<T extends Window>
TwaitForWindow(de.renebergelt.juitest.core.Timeout timeout, Predicate<Window> condition)Wait for a window which fulfills the given condition<T extends Window>
TwaitForWindow_internal(de.renebergelt.juitest.core.Timeout timeout, Predicate<Window> condition)Wait for a window which fulfills the given conditionvoidwaitUntilWindowIsClosed(de.renebergelt.juitest.core.Timeout timeout, Window window)Wait until the given window has been closedMethods inherited from class de.renebergelt.juitest.host.testscripts.UIAutomationTest
afterTest, beforeTest, cancel, log, pause, resume, scriptAssert, scriptAssert, setContext, setExecutionListener
-
Constructor Details
-
SwingAutomationTest
public SwingAutomationTest()
-
-
Method Details
-
uiActionWait
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, TimeoutExceptionExecute 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 timestep- The function to execute- Throws:
CancellationException- Thrown if the user cancelled the executionTimeoutException- Thrown if the timeout occurred
-
uiActionWait
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, TimeoutExceptionExecute 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 timestep- The function to execute- Returns:
- The result as returned by the step function
- Throws:
CancellationException- Thrown if the user cancelled the executionTimeoutException- Thrown if the timeout occurred
-
uiActionAsync
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 TimeoutExceptionWait until the given condition is satisfied- Parameters:
timeout- The maximum wait timecondition- 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 TimeoutExceptionExecute 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 timewinOpenAction- Action, which should open a window of the given classwindowClass- 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 TimeoutExceptionBlocks 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 timewindowClass- 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 TimeoutExceptionWait until the given window has been closed- Parameters:
timeout- The maximum wait timewindow- 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 TimeoutExceptionWait for a window which fulfills the given condition- Type Parameters:
T- The window class- Parameters:
timeout- The maximum wait timecondition- 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 TimeoutExceptionWait for a window which fulfills the given condition- Type Parameters:
T- The window class- Parameters:
timeout- The maximum wait timecondition- 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 TimeoutExceptionWaits for an JOptionPane based Dialog and closes it using the given result- Parameters:
timeout- The maximum wait timeresult- 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
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 classcomponentClass- 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 classcomponentClass- The class of the component to findcondition- The condition to check- Returns:
- Component instance if found or null otherwise
-