- java.lang.Object
-
- de.carne.test.swt.tester.SWTTest
-
public abstract class SWTTest extends java.lang.ObjectBase class for SWT application tests.The test is performed by running the SWT application subject to testing within the context of the test class. The
SWTTestclass provides the necessary functionality to execute all kinds of actions and checks against the running application (see SWTTest.Script). The latter is achieved by creating a separate script runner thread which issues the necessary events.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classSWTTest.ScriptThis 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. By invoking the SWTTest.Script.execute() function the SWT application is started and the scripts actions are executed.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ShellAccessoraccessActiveShell()Gets the currently active Shell.protected ShellAccessoraccessShell()Convenience function for single Shell applications which gets this unique Shell.protected ShellAccessoraccessShell(java.lang.String text)Convenience function which gets a specific Shell identified by it's text.protected ShellAccessoraccessShell(java.util.regex.Pattern textPattern)Convenience function which gets a specific Shell identified by it's text.protected org.eclipse.swt.widgets.Displaydisplay()Gets the SWT Display.protected DialogMock<org.eclipse.swt.graphics.RGB>mockColorDialog()Gets the test's ColorDialog mock.protected DialogMock<java.lang.String>mockDirectoryDialog()Gets the test's DirectoryDialog mock.protected DialogMock<java.lang.String>mockFileDialog()Gets the test's FileDialog mock.protected DialogMock<org.eclipse.swt.graphics.FontData>mockFontDialog()Gets the test's FontDialog mock.protected IntDialogMockmockMessageBox()Gets the test's MessageBox mock.protected DialogMock<org.eclipse.swt.printing.PrinterData>mockPrintDialog()Gets the test's PrintDialog mock.SWTTest.Scriptscript(MainFunction application)Creates a SWTTest.Script instance to be executed after the necessary actions have been added.protected java.util.stream.Stream<org.eclipse.swt.widgets.Shell>shells()Gets all non disposed Shell instances.protected voidtraceAction()Traces the calling function in the test run's debug log.
-
-
-
Method Detail
-
script
public SWTTest.Script script(MainFunction application)
Creates a SWTTest.Script instance to be executed after the necessary actions have been added.- Parameters:
application- the main function of the SWT application to test.- Returns:
- the created SWTTest.Script instance.
- See Also:
SWTTest.Script
-
traceAction
protected void traceAction()
Traces the calling function in the test run's debug log.
-
display
protected org.eclipse.swt.widgets.Display display()
Gets the SWT Display.A test failure is signaled in case no SWT Display exists. The latter is the case if the current thread is not the UI thread or if the Display has either not yet been created or has already been disposed.
- Returns:
- the SWT Display.
-
shells
protected java.util.stream.Stream<org.eclipse.swt.widgets.Shell> shells()
Gets all non disposed Shell instances.- Returns:
- all non disposed Shell instances.
-
accessActiveShell
protected ShellAccessor accessActiveShell()
Gets the currently active Shell.A test failure is signaled if no active Shell exists.
- Returns:
- the application's active Shell.
-
accessShell
protected ShellAccessor accessShell()
Convenience function for single Shell applications which gets this unique Shell.A test failure is signaled if either no Shell exists or more than one.
- Returns:
- the application's unique Shell.
-
accessShell
protected ShellAccessor accessShell(java.lang.String text)
Convenience function which gets a specific Shell identified by it's text.A test failure is signaled if either none or more than one Shell with the given text exists.
- Parameters:
text- the text of the Shell to get.- Returns:
- the found Shell.
-
accessShell
protected ShellAccessor accessShell(java.util.regex.Pattern textPattern)
Convenience function which gets a specific Shell identified by it's text.A test failure is signaled if either none or more than one Shell with the given text exists.
- Parameters:
textPattern- the text pattern of the Shell to get.- Returns:
- the found Shell.
-
mockMessageBox
protected IntDialogMock mockMessageBox()
Gets the test's MessageBox mock.- Returns:
- the test's MessageBox mock.
-
mockFileDialog
protected DialogMock<java.lang.String> mockFileDialog()
Gets the test's FileDialog mock.- Returns:
- the test's FileDialog mock.
-
mockDirectoryDialog
protected DialogMock<java.lang.String> mockDirectoryDialog()
Gets the test's DirectoryDialog mock.- Returns:
- the test's DirectoryDialog mock.
-
mockPrintDialog
protected DialogMock<org.eclipse.swt.printing.PrinterData> mockPrintDialog()
Gets the test's PrintDialog mock.- Returns:
- the test's PrintDialog mock.
-
mockColorDialog
protected DialogMock<org.eclipse.swt.graphics.RGB> mockColorDialog()
Gets the test's ColorDialog mock.- Returns:
- the test's ColorDialog mock.
-
mockFontDialog
protected DialogMock<org.eclipse.swt.graphics.FontData> mockFontDialog()
Gets the test's FontDialog mock.- Returns:
- the test's FontDialog mock.
-
-