Search in sources :

Example 26 with Log

use of com.codename1.io.Log in project CodenameOne by codenameone.

the class TestUtils method clickButtonByLabel.

/**
 * Clicks the button with the given label
 * @param text the text on the button
 */
public static void clickButtonByLabel(String text) {
    if (verbose) {
        log("clickButtonByLabel(" + text + ")");
    }
    Button b = (Button) findLabelText(text);
    waitFor(20);
    b.pressed();
    waitFor(20);
    b.released();
    waitFor(20);
}
Also used : Button(com.codename1.ui.Button)

Example 27 with Log

use of com.codename1.io.Log in project CodenameOne by codenameone.

the class TestUtils method setText.

/**
 * Sets the text for the given component
 * @param path the path to the component
 * @param text the text to set
 */
public static void setText(int[] path, String text) {
    if (verbose) {
        log("setText(" + toString(path) + ", " + text + ")");
    }
    Component c = getComponentByPath(path);
    if (c instanceof Label) {
        ((Label) c).setText(text);
        return;
    }
    ((TextArea) c).setText(text);
}
Also used : TextArea(com.codename1.ui.TextArea) Label(com.codename1.ui.Label) Component(com.codename1.ui.Component)

Example 28 with Log

use of com.codename1.io.Log in project CodenameOne by codenameone.

the class TestUtils method findByName.

/**
 * Finds a component with the given name, works even with UI's that weren't created with the GUI builder
 * @param componentName the name of the component to find
 * @return the component with the given name within the tree
 */
private static Component findByName(Container root, String componentName) {
    if (verbose) {
        log("findByName(" + root + ", " + componentName + ")");
    }
    int count = root.getComponentCount();
    for (int iter = 0; iter < count; iter++) {
        Component c = root.getComponentAt(iter);
        String n = c.getName();
        if (n != null && n.equals(componentName)) {
            return c;
        }
        if (c instanceof Container) {
            c = findByName((Container) c, componentName);
            if (c != null) {
                return c;
            }
        }
    }
    return null;
}
Also used : Container(com.codename1.ui.Container) Component(com.codename1.ui.Component)

Example 29 with Log

use of com.codename1.io.Log 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 30 with Log

use of com.codename1.io.Log 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

Component (com.codename1.ui.Component)9 IOException (java.io.IOException)9 TextArea (com.codename1.ui.TextArea)8 Label (com.codename1.ui.Label)4 InputStream (java.io.InputStream)4 Button (com.codename1.ui.Button)3 Form (com.codename1.ui.Form)3 BorderLayout (com.codename1.ui.layouts.BorderLayout)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ParseException (java.text.ParseException)3 Date (java.util.Date)3 TimerTask (java.util.TimerTask)3 Cursor (android.database.Cursor)2 Address (com.codename1.contacts.Address)2 Contact (com.codename1.contacts.Contact)2 BufferedInputStream (com.codename1.io.BufferedInputStream)2 Location (com.codename1.location.Location)2 Command (com.codename1.ui.Command)2 ActionEvent (com.codename1.ui.events.ActionEvent)2 SimpleDateFormat (java.text.SimpleDateFormat)2