Class SWTTest


  • public abstract class SWTTest
    extends java.lang.Object
    Base 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 SWTTest class 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
      class  SWTTest.Script
      This 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.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected SWTTest()
      Constructs a new SWTTest instance.
      protected SWTTest​(java.lang.String name)
      Constructs a new SWTTest instance.
    • Constructor Detail

      • SWTTest

        protected SWTTest()
        Constructs a new SWTTest instance.
      • SWTTest

        protected SWTTest​(java.lang.String name)
        Constructs a new SWTTest instance.
        Parameters:
        name - the name of the running test.
    • Method Detail

      • 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.