use of com.codename1.rad.models.Property.Name 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);
}
use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.
the class TestUtils method pointerDrag.
/**
* A component drag 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 pointerDrag(float x, float y, String componentName) {
if (verbose) {
log("pointerDrag(" + 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().pointerDragged(actualX, actualY);
}
use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.
the class TestUtils method clickButtonByName.
/**
* Clicks the button with the given label
* @param name the name of the button
*/
public static void clickButtonByName(String name) {
if (verbose) {
log("clickButtonByName(" + name + ")");
}
Button b = (Button) findByName(name);
waitFor(20);
b.pressed();
waitFor(20);
b.released();
waitFor(20);
}
use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.
the class TestUtils method assertTextAreaContaining.
/**
* Asserts that we have a TextArea with the a text contains the given text and with the given name
* @param name the name of the TextArea
* @param text the sequence to search for in the TextArea
*/
public static void assertTextAreaContaining(String name, String text) {
if (verbose) {
log("assertTextAreaContaining(" + name + ", " + text + ")");
}
TextArea l = (TextArea) findByName(name);
assertBool(l != null, "Null area " + text);
assertBool(l.getText().indexOf(text) > -1, "assertTextArea: \"" + l.getText() + "\" is not containing: \"" + text + "\"");
}
use of com.codename1.rad.models.Property.Name in project CodenameOne by codenameone.
the class TestUtils method assertTextAreaEndingWith.
/**
* Asserts that we have a TextArea with the a text ending with the given text and with the given name
* @param name the name of the TextArea
* @param text the suffix to search for in the TextArea
*/
public static void assertTextAreaEndingWith(String name, String text) {
if (verbose) {
log("assertTextAreaEndingWith(" + name + ", " + text + ")");
}
TextArea l = (TextArea) findByName(name);
assertBool(l != null, "Null area " + text);
assertBool(l.getText().endsWith(text), "assertTextArea: \"" + l.getText() + "\" is not ending with: \"" + text + "\"");
}
Aggregations