- java.lang.Object
-
- de.carne.test.swt.tester.SWTTest.Script
-
- Enclosing class:
- SWTTest
public final class SWTTest.Script extends java.lang.ObjectThis class defines the actual test setup/script:- the SWT application to run and to run the script actions against.
- the optional command line arguments submitted to the SWT application.
- one or more script actions performing the actual test actions and checks.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SWTTest.Scriptadd(java.lang.Runnable doAction)Adds an action to be executed during the test.SWTTest.Scriptadd(java.lang.Runnable doAction, boolean async)Adds an action to be executed during the test.<T,A extends Accessor<T>>
SWTTest.Scriptadd(java.util.function.Supplier<A> supplyAction, java.util.function.Consumer<A> consumeAction)Adds supply/consume action to be consumed during the test.<T,A extends Accessor<T>>
SWTTest.Scriptadd(java.util.function.Supplier<A> supplyAction, java.util.function.Consumer<A> consumeAction, long timeoutMillis)Adds supply/consume action to be consumed during the test.SWTTest.Scriptargs(java.lang.String... args)Sets the command line arguments the SWT application should be invoked with.voidexecute()Execute all script actions.voidexecute(boolean ignoreRemaining)Execute all script actions.voidexecute(boolean ignoreRemaining, java.time.Duration timeout)Execute all script actions.booleanpassed()Checks whether all scripts tests have been passed and the script completed successfully.
-
-
-
Method Detail
-
args
public SWTTest.Script args(java.lang.String... args)
Sets the command line arguments the SWT application should be invoked with.If not set an empty command line is used to start the SWT application.
- Parameters:
args- the command line arguments to use.- Returns:
- the updated script.
-
add
public SWTTest.Script add(java.lang.Runnable doAction)
Adds an action to be executed during the test.The action will be executed on the UI thread.
- Parameters:
doAction- the action to add.- Returns:
- the updated script.
-
add
public SWTTest.Script add(java.lang.Runnable doAction, boolean async)
Adds an action to be executed during the test.The action will be executed on the UI thread.
- Parameters:
doAction- the action to add.async- whether to execute the action asynchronously (true) or not (false).- Returns:
- the updated script.
-
add
public <T,A extends Accessor<T>> SWTTest.Script add(java.util.function.Supplier<A> supplyAction, java.util.function.Consumer<A> consumeAction)
Adds supply/consume action to be consumed during the test.During test execution the supply action is invoked until the result is not empty. The supplied result is afterwards submitted to the consumer. A test failure is signaled if the default timeout is reached while polling the supply action for a non-empty result.
- Type Parameters:
T- the supplied and consumed object type.A- the corresponding accessor type.- Parameters:
supplyAction- the supply action to invoke.consumeAction- the consume action to invoke with the supply action result.- Returns:
- the updated script.
- See Also:
add(Supplier, Consumer, long)
-
add
public <T,A extends Accessor<T>> SWTTest.Script add(java.util.function.Supplier<A> supplyAction, java.util.function.Consumer<A> consumeAction, long timeoutMillis)
Adds supply/consume action to be consumed during the test.During test execution the supply action is invoked until the result is not empty. The supplied result is afterwards submitted to the consumer. A test failure is signaled if the given timeout is reached while polling the supply action for a non-empty result.
- Type Parameters:
T- the supplied and consumed object type.A- the corresponding accessor type.- Parameters:
supplyAction- the supply action to invoke.consumeAction- the consume action to invoke with the supply action result.timeoutMillis- the timeout in milliseconds for polling the supply action.- Returns:
- the updated script.
-
execute
public void execute()
Execute all script actions.Invoking this function is equivalent to invoking
execute(false).- See Also:
execute(boolean)
-
execute
public void execute(boolean ignoreRemaining)
Execute all script actions.Invoking this function is equivalent to invoking
execute(false, Duration.ofMillis(Timing.TEST_TIMEOUT)).- Parameters:
ignoreRemaining- whether to ignore any remaining application artifacts after execution and silently dispose them (true) or to signal a test failure (false).
-
execute
public void execute(boolean ignoreRemaining, java.time.Duration timeout)Execute all script actions.- Parameters:
ignoreRemaining- whether to ignore any remaining application artifacts after execution and silently dispose them (true) or to signal a test failure (false).timeout- timeout (in ms) after which the script execution will be stopped and the test considered failed.
-
passed
public boolean passed()
Checks whether all scripts tests have been passed and the script completed successfully.- Returns:
trueif all script tests have been passed and the script completed successfully.
-
-