]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix the closing of a popup DateField (#14086, #14375).
authorMika Murtojarvi <mika@vaadin.com>
Wed, 6 Aug 2014 16:22:30 +0000 (19:22 +0300)
committerLeif Åstrand <leif@vaadin.com>
Thu, 28 Aug 2014 16:20:18 +0000 (19:20 +0300)
The popup is made non-modal.

Change-Id: Ia396ff1e2e88639b97c9f556d7d3866f76755436

client/src/com/vaadin/client/ui/VPopupCalendar.java
uitest/src/com/vaadin/tests/components/datefield/DateFieldClose.java [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/datefield/DateFieldCloseTest.java [new file with mode: 0644]

index 7dea959bb4001a9766b2e746d8480b1202527d0b..1474ad3b71526c4b9272d2f44cd3488286a55665 100644 (file)
@@ -145,7 +145,7 @@ public class VPopupCalendar extends VTextualDate implements Field,
             }
         });
 
-        popup = new VOverlay(true, true, true);
+        popup = new VOverlay(true, false, true);
         popup.setOwner(this);
 
         FlowPanel wrapper = new FlowPanel();
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldClose.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldClose.java
new file mode 100644 (file)
index 0000000..9ce190a
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.datefield;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.DateField;
+
+public class DateFieldClose extends AbstractTestUI {
+
+    static final String DATEFIELD_ID = "datefield";
+
+    @Override
+    protected void setup(VaadinRequest request) {
+        final DateField df = new DateField();
+        df.setId(DATEFIELD_ID);
+        addComponent(df);
+    }
+
+    @Override
+    protected String getTestDescription() {
+        return "A click on the button should open a calendar and a second click should close it.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 14086;
+    }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldCloseTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldCloseTest.java
new file mode 100644 (file)
index 0000000..e6f7520
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.datefield;
+
+import static com.vaadin.tests.components.datefield.DateFieldClose.DATEFIELD_ID;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class DateFieldCloseTest extends MultiBrowserTest {
+    private WebElement dateField;
+
+    @Test
+    public void closeByClickingCalendarButton() throws Exception {
+        openTestURL();
+        dateField = driver.findElement(By.id(DATEFIELD_ID));
+        clickButton();
+        checkForCalendarHeader(true);
+        closePopup();
+        checkForCalendarHeader(false);
+    }
+
+    private void checkForCalendarHeader(boolean headerShouldExist) {
+        boolean headerExists = isElementPresent(By
+                .className("v-datefield-calendarpanel-header"));
+        if (headerShouldExist) {
+            assertTrue("The calendar should be visible", headerExists);
+        } else {
+            assertFalse("The calendar should not be visible", headerExists);
+        }
+    }
+
+    private void clickButton() {
+        WebElement dateFieldButton = dateField.findElement(By
+                .className("v-datefield-button"));
+        testBenchElement(dateFieldButton).click(5, 5);
+    }
+
+    private void closePopup() {
+        WebElement dateFieldButton = dateField.findElement(By
+                .className("v-datefield-button"));
+        // To work reliably with IE, need to click and hold instead of just
+        // clicking the button.
+        Actions actions = new Actions(driver);
+        actions.clickAndHold(dateFieldButton).perform();
+    }
+}