aboutsummaryrefslogtreecommitdiffstats
path: root/uitest/src/main/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPosition.java
blob: ca475f218bd9c55a1310889de90667a0d49c16ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.vaadin.tests.components.textfield;

import com.vaadin.server.VaadinRequest;
import com.vaadin.tests.components.AbstractReindeerTestUI;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;

public class InputPromptAndCursorPosition extends AbstractReindeerTestUI {

    @Override
    protected void setup(VaadinRequest request) {
        final TextField tf = new TextField();
        tf.setWidth("40em");
        tf.setValue(
                "Delete this text to reveal input prompt and update cursor position.");
        tf.setPlaceholder("This is an input prompt");

        final Label l = new Label("Cursor position: ?");
        Button button = new Button("Update cursor position", event -> l
                .setValue("Cursor position: " + tf.getCursorPosition()));

        addComponent(tf);
        addComponent(l);
        addComponent(button);
    }

    @Override
    protected String getTestDescription() {
        return "Cursor position should always be zero when input prompt is displayed.";
    }

    @Override
    protected Integer getTicketNumber() {
        return 19766;
    }
}