summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorAnna Miroshnik <anna.miroshnik@arcadia.spb.ru>2014-11-17 17:33:54 +0300
committerSauli Tähkäpää <sauli@vaadin.com>2014-12-16 22:40:39 +0200
commit854644a8ccfb004e5ec5891def64628bc7a2e50e (patch)
tree983f412f28816995fd809ad6f184ca40c3a489a0 /uitest
parent138183483a084b2a14b58b7e19ae014e913e9e79 (diff)
downloadvaadin-framework-854644a8ccfb004e5ec5891def64628bc7a2e50e.tar.gz
vaadin-framework-854644a8ccfb004e5ec5891def64628bc7a2e50e.zip
DateField popup doesn't close when popup button is clicked (#14857)
Change-Id: Ieb6ff2f072726fe8707d3cce61569dd623b13ebd
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java43
-rw-r--r--uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java81
2 files changed, 124 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java
new file mode 100644
index 0000000000..60508a30d4
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosing.java
@@ -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 DateFieldPopupClosing 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 "DateField popup should be closed when click on popup button";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14857;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java
new file mode 100644
index 0000000000..9fd6fe82e2
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/datefield/DateFieldPopupClosingTest.java
@@ -0,0 +1,81 @@
+package com.vaadin.tests.components.datefield;
+
+import java.io.IOException;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.interactions.Actions;
+import org.openqa.selenium.support.ui.ExpectedCondition;
+import org.openqa.selenium.support.ui.ExpectedConditions;
+
+import com.vaadin.testbench.elements.DateFieldElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class DateFieldPopupClosingTest extends MultiBrowserTest {
+
+ @Test
+ public void testDateFieldPopupClosingLongClick()
+ throws InterruptedException, IOException {
+ openTestURL();
+
+ fastClickDateDatePickerButton();
+
+ assertThatPopupIsVisible();
+
+ longClickDateDatePickerButton();
+
+ assertThatPopupIsInvisible();
+ }
+
+ private void assertThatPopupIsVisible() {
+ waitUntil(ExpectedConditions.visibilityOfElementLocated(By
+ .className("v-datefield-popup")));
+ }
+
+ private void assertThatPopupIsInvisible() {
+ // ExpectedConditions.invisibilityOfElementLocated doesn't work
+ // with PhantomJS when running with a hub:
+ // https://code.google.com/p/selenium/issues/detail?id=5000
+ // so we need to make our own.
+
+ waitUntil(new ExpectedCondition<Boolean>() {
+ @Override
+ public Boolean apply(WebDriver input) {
+ try {
+ return !(findElement(By.className("v-datefield-popup"))
+ .isDisplayed());
+ } catch (Exception e) {
+ return true;
+ }
+ }
+
+ @Override
+ public String toString() {
+ // Timed out after 10 seconds waiting for ...
+ return "popup to not be visible";
+ }
+ });
+ }
+
+ private void longClickDateDatePickerButton() {
+ WebElement button = getToggleButton();
+
+ new Actions(getDriver()).clickAndHold(button).perform();
+ assertThatPopupIsInvisible();
+
+ new Actions(getDriver()).release(button).perform();
+ }
+
+ private WebElement getToggleButton() {
+ DateFieldElement dateField = $(DateFieldElement.class).first();
+
+ return dateField.findElement(By.tagName("button"));
+ }
+
+ private void fastClickDateDatePickerButton() {
+ getToggleButton().click();
+ }
+
+} \ No newline at end of file