summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAdam Wagner <wbadam@users.noreply.github.com>2018-02-02 12:25:35 +0200
committerIlia Motornyi <elmot@vaadin.com>2018-02-02 12:25:35 +0200
commitd2ef29e5b41d45f291d087760b02e212c75ff9eb (patch)
treef13c6e19627f96c11a8edce9d49e72e6867f3ed6 /uitest
parent875c98972e9c3da25a7c9c54cb267871921d4804 (diff)
downloadvaadin-framework-d2ef29e5b41d45f291d087760b02e212c75ff9eb.tar.gz
vaadin-framework-d2ef29e5b41d45f291d087760b02e212c75ff9eb.zip
Add flush() implementation to DateField (#10518)
Fixes #10488
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldShortcut.java44
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldShortcutTest.java39
2 files changed, 83 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldShortcut.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldShortcut.java
new file mode 100644
index 0000000000..406e13a5a3
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldShortcut.java
@@ -0,0 +1,44 @@
+package com.vaadin.tests.components.datefield;
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.event.ShortcutListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.DateField;
+import com.vaadin.ui.Notification;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class DateFieldShortcut extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ String dateFormat = "dd/MM/yyyy";
+
+ DateField dateField = new DateField();
+ dateField.setValue(LocalDate.of(2018, 1, 11));
+ dateField.setDateFormat(dateFormat);
+
+ dateField.addShortcutListener(
+ new ShortcutListener("Enter", KeyCode.ENTER, null) {
+ @Override
+ public void handleAction(Object sender, Object target) {
+ Notification.show(dateField.getValue()
+ .format(DateTimeFormatter
+ .ofPattern(dateFormat)));
+ }
+ });
+
+ addComponent(dateField);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Modify the date maually (without using the popup element) and"
+ + " then press Enter. The notification should show the modified"
+ + " value instead of the old value.";
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldShortcutTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldShortcutTest.java
new file mode 100644
index 0000000000..3e01a41b43
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldShortcutTest.java
@@ -0,0 +1,39 @@
+package com.vaadin.tests.components.datefield;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.DateFieldElement;
+import com.vaadin.testbench.elements.NotificationElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+import static org.junit.Assert.assertEquals;
+
+public class DateFieldShortcutTest extends SingleBrowserTest {
+
+ private static final String DATEFIELD_VALUE_ORIGINAL = "11/01/2018";
+ private static final String DATEFIELD_VALUE_MODIFIED = "21/01/2018";
+
+ @Test
+ public void modifyValueAndPressEnter() {
+ openTestURL();
+
+ DateFieldElement dateField = $(DateFieldElement.class).first();
+ WebElement dateFieldText = dateField.findElement(By.tagName("input"));
+
+ assertEquals("DateField value should be \"" + DATEFIELD_VALUE_ORIGINAL
+ + "\"", DATEFIELD_VALUE_ORIGINAL, dateField.getValue());
+
+ dateFieldText.click();
+ dateFieldText.sendKeys(Keys.HOME, Keys.DELETE, "2");
+ dateFieldText.sendKeys(Keys.ENTER);
+
+ assertEquals("DateField value should be \"" + DATEFIELD_VALUE_MODIFIED
+ + "\"", DATEFIELD_VALUE_MODIFIED, dateField.getValue());
+
+ assertEquals(DATEFIELD_VALUE_MODIFIED,
+ $(NotificationElement.class).first().getCaption());
+ }
+}