org.eclipse.emf.ecp.view.test.common.swt
Class SWTTestUtil

java.lang.Object
  extended by org.eclipse.emf.ecp.view.test.common.swt.SWTTestUtil

public final class SWTTestUtil
extends Object

Util class for SWT Tests.

Author:
jfaltermeier

Method Summary
static void clickButton(org.eclipse.swt.widgets.Button button)
          Simulates a click on the given Button.
static
<T extends org.eclipse.swt.widgets.Control>
T
findControl(org.eclipse.swt.widgets.Control control, int index, Class<T> clazz)
           Iterates over the hierarchy of the given Control and looks for a control of the given class.
static org.eclipse.swt.custom.StackLayout findStackLayout(org.eclipse.swt.widgets.Control control, int index)
           Iterates over the hierarchy of the given Control and looks for a Composite with a StackLayout.
static void pressAndReleaseKey(org.eclipse.swt.widgets.Control control, int keyCode)
          Simulates a key down and key up event on the given Control.
static void selectWidget(org.eclipse.swt.widgets.Widget widget)
          Selects the given widget.
static void typeAndFocusOut(org.eclipse.swt.widgets.Text text, String string)
          Sets the given string on the Text and simulates a focus out event.
static void waitForUIThread()
          Waits for the ui thread to complete its work.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findStackLayout

public static org.eclipse.swt.custom.StackLayout findStackLayout(org.eclipse.swt.widgets.Control control,
                                                                 int index)
                                                          throws NoSuchElementException

Iterates over the hierarchy of the given Control and looks for a Composite with a StackLayout. The index specifies which composite with a stack layout should be returned.

This method uses a depth-first-search.

Parameters:
control - the parent control
index - the index of the layout
Returns:
the layout
Throws:
NoSuchElementException - if no layout with the index can be found

findControl

public static <T extends org.eclipse.swt.widgets.Control> T findControl(org.eclipse.swt.widgets.Control control,
                                                                        int index,
                                                                        Class<T> clazz)
                                                             throws NoSuchElementException

Iterates over the hierarchy of the given Control and looks for a control of the given class. The index specifies which control should be returned.

This method uses a depth-first-search.

Type Parameters:
T - the type of the control to find
Parameters:
control - the parent control
index - the index of the control to find
clazz - the class of the control to find
Returns:
the control
Throws:
NoSuchElementException - if no control with the index can be found

waitForUIThread

public static void waitForUIThread()
Waits for the ui thread to complete its work. Fails a testcase after 5 seconds.


clickButton

public static void clickButton(org.eclipse.swt.widgets.Button button)
Simulates a click on the given Button.

Parameters:
button - the button to press

selectWidget

public static void selectWidget(org.eclipse.swt.widgets.Widget widget)
Selects the given widget.

Parameters:
widget - the control to select.

pressAndReleaseKey

public static void pressAndReleaseKey(org.eclipse.swt.widgets.Control control,
                                      int keyCode)
Simulates a key down and key up event on the given Control.

Parameters:
control - the control
keyCode - the key code

typeAndFocusOut

public static void typeAndFocusOut(org.eclipse.swt.widgets.Text text,
                                   String string)
Sets the given string on the Text and simulates a focus out event.

Parameters:
text - the text
string - the string to enter in the text


Copyright © 2015. All Rights Reserved.