summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAnastasia Smirnova <anasmi@utu.fi>2018-10-17 11:12:03 +0300
committerSun Zhe <31067185+ZheSun88@users.noreply.github.com>2018-10-17 11:12:03 +0300
commita52993ba9ca67c15e6ca311ca308528752b589c9 (patch)
treee5dd7ac201c7eb2f37f3ce5a644d42e3d35a7a14 /uitest
parente94e97444fe086cc3743289cdb9653c16816fea9 (diff)
downloadvaadin-framework-a52993ba9ca67c15e6ca311ca308528752b589c9.tar.gz
vaadin-framework-a52993ba9ca67c15e6ca311ca308528752b589c9.zip
Rebuild calendar pop-up on readOnly state change (#11249)
* Rebuild calendar pop-up on readOnly state change Fixes https://github.com/vaadin/framework/issues/6565
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/datefield/DateTimeFieldAfterReadOnly.java37
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldAfterReadOnlyTest.java33
2 files changed, 70 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateTimeFieldAfterReadOnly.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateTimeFieldAfterReadOnly.java
new file mode 100644
index 0000000000..25f3e608d5
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateTimeFieldAfterReadOnly.java
@@ -0,0 +1,37 @@
+package com.vaadin.tests.components.datefield;
+
+import com.vaadin.annotations.Widgetset;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.datefield.DateTimeResolution;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.DateTimeField;
+
+import java.time.LocalDateTime;
+import java.util.Locale;
+
+@Widgetset("com.vaadin.DefaultWidgetSet")
+public class DateTimeFieldAfterReadOnly extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final DateTimeField timeField = new DateTimeField(
+ "A read-only datefield");
+ timeField.setResolution(DateTimeResolution.MINUTE);
+ timeField.setLocale(new Locale("fi"));
+ timeField.setId("dF");
+ // Set date so that testing always has same time
+ timeField.setValue(LocalDateTime.now());
+ timeField.setReadOnly(true);
+
+ addComponent(timeField);
+
+ Button b = new Button("Switch read-only");
+ b.addClickListener(event -> {
+ timeField.setReadOnly(!timeField.isReadOnly());
+ });
+ b.setId("readOnlySwitch");
+
+ addComponent(b);
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldAfterReadOnlyTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldAfterReadOnlyTest.java
new file mode 100644
index 0000000000..6e2f748015
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateTimeFieldAfterReadOnlyTest.java
@@ -0,0 +1,33 @@
+package com.vaadin.tests.components.datefield;
+
+import com.vaadin.testbench.By;
+import com.vaadin.testbench.elements.AbstractDateFieldElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+import org.junit.Test;
+
+import static junit.framework.TestCase.assertEquals;
+
+public class DateTimeFieldAfterReadOnlyTest extends MultiBrowserTest {
+
+ @Test
+ public void readOnlyDateFieldPopupShouldNotOpen() {
+ openTestURL();
+ toggleReadOnly();
+ openPopup();
+ assertEquals(2, numberOfSelectsField());
+ }
+
+ private void openPopup() {
+ $(AbstractDateFieldElement.class).first()
+ .findElement(By.tagName("button")).click();
+ }
+
+ private void toggleReadOnly() {
+ findElement(By.id("readOnlySwitch")).click();
+ }
+
+ private int numberOfSelectsField() {
+ return findElement(By.className("v-datefield-calendarpanel-time"))
+ .findElements(By.className("v-select")).size();
+ }
+}