Search in sources :

Example 76 with Name

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);
}
Also used : Component(com.codename1.ui.Component)

Example 77 with Name

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);
}
Also used : Component(com.codename1.ui.Component)

Example 78 with Name

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);
}
Also used : Button(com.codename1.ui.Button)

Example 79 with Name

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 + "\"");
}
Also used : TextArea(com.codename1.ui.TextArea)

Example 80 with Name

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 + "\"");
}
Also used : TextArea(com.codename1.ui.TextArea)

Aggregations

IOException (java.io.IOException)36 Component (com.codename1.ui.Component)17 Hashtable (java.util.Hashtable)17 ArrayList (java.util.ArrayList)16 AnimationObject (com.codename1.ui.animations.AnimationObject)15 File (java.io.File)14 Form (com.codename1.ui.Form)13 ByteArrayInputStream (java.io.ByteArrayInputStream)13 FileInputStream (java.io.FileInputStream)13 InputStream (java.io.InputStream)12 Label (com.codename1.ui.Label)11 Button (com.codename1.ui.Button)10 Container (com.codename1.ui.Container)10 EncodedImage (com.codename1.ui.EncodedImage)10 TextArea (com.codename1.ui.TextArea)10 BorderLayout (com.codename1.ui.layouts.BorderLayout)10 Point (java.awt.Point)10 FileOutputStream (java.io.FileOutputStream)10 Paint (android.graphics.Paint)8 BufferedInputStream (com.codename1.io.BufferedInputStream)7