public class TestUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
assertBool(boolean b)
Assertions allow for simpler test code
|
static void |
assertBool(boolean b,
String errorMessage)
Assertions allow for simpler test code
|
static void |
assertLabel(int[] path,
String text)
Asserts that we have a label with the given text baring the given name
|
static void |
assertLabel(String text)
Asserts that we have a label with the given text baring the given name
|
static void |
assertLabel(String name,
String text)
Asserts that we have a label with the given text baring the given name
|
static void |
assertTextArea(int[] path,
String text)
Asserts that we have a label with the given text baring the given name
|
static void |
assertTextArea(String text)
Asserts that we have a label with the given text baring the given name
|
static void |
assertTextArea(String name,
String text)
Asserts that we have a label with the given text baring the given name
|
static void |
assertTitle(String title)
Verifies the current title is the same otherwise throws an exception
|
static void |
clickButtonByLabel(String text)
Clicks the button with the given label
|
static void |
clickButtonByName(String name)
Clicks the button with the given label
|
static void |
clickButtonByPath(int[] path)
Clicks the button with the given component path
|
static void |
clickMenuItem(String name)
Executes a menu command with the given name
|
static void |
ensureVisible(Component c)
Scrolls to show the component in case it is invisible currently
|
static void |
ensureVisible(int[] path)
Scrolls to show the component in case it is invisible currently
|
static void |
ensureVisible(String componentName)
Scrolls to show the component in case it is invisible currently
|
static Component |
findByName(String componentName)
Finds a component with the given name, works even with UI's that weren't created with the GUI builder
|
static Label |
findLabelText(String text)
Finds a component with the given name, works even with UI's that weren't created with the GUI builder
|
static TextArea |
findTextAreaText(String text)
Finds a component with the given name, works even with UI's that weren't created with the GUI builder
|
static void |
gameKeyPress(int gameKey)
Simulates a game key press
|
static void |
gameKeyRelease(int gameKey)
Simulates a game key release
|
static Component |
getComponentByPath(int[] path)
Gets the component from the current form based on its path.
|
static void |
goBack()
Executes the back command for the current form, similarly to pressing the back button
|
static void |
keyPress(int keyCode)
Simulates a device key press
|
static void |
keyRelease(int keyCode)
Simulates a device key release
|
static void |
log(String t)
Log to the test log
|
static void |
log(Throwable t)
Log to the test log
|
static void |
pointerDrag(float x,
float y,
int[] path)
A component drag on a given named component at x/y where x and y are NOT pixels
but rather a number between 0 to 1 representing the percentage within the component where the
event took place.
|
static void |
pointerDrag(float x,
float y,
String componentName)
A component drag on a given named component at x/y where x and y are NOT pixels
but rather a number between 0 to 1 representing the percentage within the component where the
event took place.
|
static void |
pointerPress(float x,
float y,
int[] path)
A component press on a given named component at x/y where x and y are NOT pixels
but rather a number between 0 to 1 representing the percentage within the component where the
event took place.
|
static void |
pointerPress(float x,
float y,
String componentName)
A component press on a given named component at x/y where x and y are NOT pixels
but rather a number between 0 to 1 representing the percentage within the component where the
event took place.
|
static void |
pointerRelease(float x,
float y,
int[] path)
A component release on a given named component at x/y where x and y are NOT pixels
but rather a number between 0 to 1 representing the percentage within the component where the
event took place.
|
static void |
pointerRelease(float x,
float y,
String componentName)
A component release on a given named component at x/y where x and y are NOT pixels
but rather a number between 0 to 1 representing the percentage within the component where the
event took place.
|
static boolean |
screenshotTest(String screenshotName)
The screenshot test takes a screenshot of the screen and compares it to
a prior screenshot, if both are 100% identical the test passes.
|
static void |
selectInList(int[] path,
int offset)
Selects the given offset in a list
|
static void |
selectInList(String listName,
int offset)
Selects the given offset in a list
|
static void |
setText(int[] path,
String text)
Sets the text for the given component
|
static void |
setText(String name,
String text)
Sets the text for the given component
|
static void |
setVerboseMode(boolean v)
Activates/deactivates the verbose test mode
|
static void |
waitFor(int millis)
Waits for the given number of milliseconds even if the waiting is on the EDT thread
|
static void |
waitForFormName(String name)
Waits for a form change and if no form change occurred after a given timeout then fail the test
|
static void |
waitForFormTitle(String title)
Waits for a form change and if no form change occurred after a given timeout then fail the test
|
public static void setVerboseMode(boolean v)
v
- true for verbositypublic static void waitFor(int millis)
millis
- the number of milliseconds to waitpublic static Component findByName(String componentName)
componentName
- the name of the component to findpublic static void selectInList(String listName, int offset)
listName
- the name of the list componentoffset
- the offset to selectpublic static void selectInList(int[] path, int offset)
listName
- the name of the list componentoffset
- the offset to selectpublic static Label findLabelText(String text)
text
- the text of the label/buttonpublic static void clickButtonByLabel(String text)
text
- the text on the buttonpublic static void clickButtonByName(String name)
name
- the name of the buttonpublic static void clickButtonByPath(int[] path)
path
- the pathpublic static void goBack()
public static void clickMenuItem(String name)
name
- the name of the commandpublic static void ensureVisible(Component c)
c
- the componentpublic static void ensureVisible(String componentName)
componentName
- the componentpublic static void ensureVisible(int[] path)
path
- the path to the componentpublic static void waitForFormTitle(String title)
title
- the title of the form to wait forpublic static void waitForFormName(String name)
name
- the name of the form to wait forpublic static boolean screenshotTest(String screenshotName)
screenshotName
- the name to use for the storage, must be unique!public static void log(String t)
t
- the string to logpublic static void log(Throwable t)
t
- exception to logpublic static void keyPress(int keyCode)
keyCode
- the keycodepublic static void keyRelease(int keyCode)
keyCode
- the keycodepublic static void gameKeyPress(int gameKey)
gameKey
- the game key (arrows etc.)public static void gameKeyRelease(int gameKey)
gameKey
- the game key (arrows etc.)public static void pointerPress(float x, float y, String componentName)
x
- the offset within the component as a number between 0 and 1y
- the offset within the component as a number between 0 and 1componentName
- the name of the componentpublic static void pointerRelease(float x, float y, String componentName)
x
- the offset within the component as a number between 0 and 1y
- the offset within the component as a number between 0 and 1componentName
- the name of the componentpublic static void pointerDrag(float x, float y, String componentName)
x
- the offset within the component as a number between 0 and 1y
- the offset within the component as a number between 0 and 1componentName
- the name of the componentpublic static void pointerPress(float x, float y, int[] path)
x
- the offset within the component as a number between 0 and 1y
- the offset within the component as a number between 0 and 1path
- the path to the componentpublic static void pointerRelease(float x, float y, int[] path)
x
- the offset within the component as a number between 0 and 1y
- the offset within the component as a number between 0 and 1path
- the path to the componentpublic static void pointerDrag(float x, float y, int[] path)
x
- the offset within the component as a number between 0 and 1y
- the offset within the component as a number between 0 and 1path
- the path to the componentpublic static Component getComponentByPath(int[] path)
path
- an arraypublic static void setText(String name, String text)
name
- the name of the componenttext
- the text to setpublic static void setText(int[] path, String text)
path
- the path to the componenttext
- the text to setpublic static void assertBool(boolean b)
b
- must be true, otherwise an exception is thrown thus failing the testpublic static void assertBool(boolean b, String errorMessage)
b
- must be true, otherwise an exception is thrown thus failing the testpublic static void assertTitle(String title)
title
- the tile to verifypublic static void assertLabel(String name, String text)
name
- the name of the labeltext
- the text of the labelpublic static void assertLabel(int[] path, String text)
path
- the path of the labeltext
- the text of the labelpublic static void assertLabel(String text)
text
- the text of the labelpublic static void assertTextArea(String name, String text)
name
- the name of the labeltext
- the text of the labelpublic static void assertTextArea(int[] path, String text)
path
- the path to the text areatext
- the text of the labelpublic static void assertTextArea(String text)
text
- the text of the label