use of com.codename1.io.Log in project CodenameOne by codenameone.
the class TestUtils method pointerRelease.
/**
* A component release on a given named component at x/y where x and y are <b>NOT pixels</b>
* but rather a number between 0 to 1 representing the percentage within the component where the
* event took place. E.g. For a 100x100 component a press within 10,5 would be 0.1f, 0.05f.
* @param x the offset within the component as a number between 0 and 1
* @param y the offset within the component as a number between 0 and 1
* @param componentName the name of the component
*/
public static void pointerRelease(float x, float y, String componentName) {
if (verbose) {
log("pointerRelease(" + x + ", " + y + ", " + componentName + ")");
}
Component c = findByName(componentName);
int actualX = c.getAbsoluteX() + (int) (x * c.getWidth());
int actualY = c.getAbsoluteY() + (int) (y * c.getHeight());
Display.getInstance().getCurrent().pointerReleased(actualX, actualY);
waitFor(30);
}
use of com.codename1.io.Log in project CodenameOne by codenameone.
the class TestUtils method assertLabel.
/**
* Asserts that we have a label with the given text baring the given name
* @param text the text of the label
*/
public static void assertLabel(String text) {
if (verbose) {
log("assertLabel(" + text + ")");
}
Label l = findLabelText(text);
assertBool(l != null, "Null label " + text);
}
use of com.codename1.io.Log in project CodenameOne by codenameone.
the class TestUtils method goBack.
/**
* Executes the back command for the current form, similarly to pressing the back button
*/
public static void goBack() {
if (verbose) {
log("goBack()");
}
Form f = Display.getInstance().getCurrent();
Command c = f.getBackCommand();
assertBool(c != null, "The current form doesn't have a back command at this moment! for form name " + f.getName());
f.dispatchCommand(c, new ActionEvent(c, ActionEvent.Type.Command));
waitFor(20);
}
use of com.codename1.io.Log in project CodenameOne by codenameone.
the class TestUtils method assertTextAreaStartingWith.
/**
* Asserts that we have a TextArea with the a text starting with the given text and with the given name
* @param name the name of the TextArea
* @param text the prefix to search for in the TextArea
*/
public static void assertTextAreaStartingWith(String name, String text) {
if (verbose) {
log("assertTextAreaStartingWith(" + name + ", " + text + ")");
}
TextArea l = (TextArea) findByName(name);
assertBool(l != null, "Null area " + text);
assertBool(l.getText().startsWith(text), "assertTextArea: \"" + l.getText() + "\" is not starting with: \"" + text + "\"");
}
use of com.codename1.io.Log in project CodenameOne by codenameone.
the class TestUtils method pointerPress.
/**
* A component press on a given named component at x/y where x and y are <b>NOT pixels</b>
* but rather a number between 0 to 1 representing the percentage within the component where the
* event took place. E.g. For a 100x100 component a press within 10,5 would be 0.1f, 0.05f.
* @param x the offset within the component as a number between 0 and 1
* @param y the offset within the component as a number between 0 and 1
* @param componentName the name of the component
*/
public static void pointerPress(float x, float y, String componentName) {
if (verbose) {
if (componentName == null) {
log("pointerPress(" + x + ", " + y + ", null)");
} else {
log("pointerPress(" + x + ", " + y + ", " + componentName + ")");
}
}
waitFor(20);
if (componentName != null) {
Component c = findByName(componentName);
int actualX = c.getAbsoluteX() + (int) (x * c.getWidth());
int actualY = c.getAbsoluteY() + (int) (y * c.getHeight());
Display.getInstance().getCurrent().pointerPressed(actualX, actualY);
} else {
Display.getInstance().getCurrent().pointerPressed((int) (x * Display.getInstance().getDisplayWidth()), (int) (y * Display.getInstance().getDisplayHeight()));
}
waitFor(10);
}
Aggregations