summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorTeemu Pöntelin <tehapo@gmail.com>2016-04-30 16:20:35 +0300
committerVaadin Code Review <review@vaadin.com>2016-05-11 10:02:30 +0000
commitaa2cdc96ec1df19ab8b1d8a9b616d76f18abe0c7 (patch)
tree916635b4fd8551408960b4ad13314cedc4ff8196 /uitest
parent790b9cbada28b972f3c1dabc0ebe65d4af380e58 (diff)
downloadvaadin-framework-aa2cdc96ec1df19ab8b1d8a9b616d76f18abe0c7.tar.gz
vaadin-framework-aa2cdc96ec1df19ab8b1d8a9b616d76f18abe0c7.zip
Always return cursor position 0 when displaying input prompt (#19766)
Change-Id: Ibca58259a0bbcda7141b996020bae8614f0c2114
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPosition.java42
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPositionTest.java30
2 files changed, 72 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPosition.java b/uitest/src/main/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPosition.java
new file mode 100644
index 0000000000..b8f9c9aa3f
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPosition.java
@@ -0,0 +1,42 @@
+package com.vaadin.tests.components.textfield;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+
+public class InputPromptAndCursorPosition extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final TextField tf = new TextField();
+ tf.setColumns(40);
+ tf.setValue("Delete this text to reveal input prompt and update cursor position.");
+ tf.setInputPrompt("This is an input prompt");
+
+ final Label l = new Label("Cursor position: ?");
+ Button button = new Button("Update cursor position", new Button.ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent 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;
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPositionTest.java b/uitest/src/test/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPositionTest.java
new file mode 100644
index 0000000000..e688a313d3
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/textfield/InputPromptAndCursorPositionTest.java
@@ -0,0 +1,30 @@
+package com.vaadin.tests.components.textfield;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.testbench.elements.TextFieldElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class InputPromptAndCursorPositionTest extends MultiBrowserTest {
+
+ @Test
+ public void verifyDatePattern() {
+ openTestURL();
+
+ // Clear the current value and reveal the input prompt.
+ TextFieldElement textFieldElement = $(TextFieldElement.class).get(0);
+ textFieldElement.setValue("");
+
+ // Update cursor position.
+ $(ButtonElement.class).get(0).click();
+
+ // The cursor position should now be zero (not the input prompt length).
+ LabelElement cursorPosLabel = $(LabelElement.class).get(1);
+ assertEquals(cursorPosLabel.getText(), "Cursor position: 0");
+ }
+
+}