diff options
author | Teemu Pòˆntelin <teemu@vaadin.com> | 2014-03-20 00:15:45 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2014-03-24 18:42:50 +0000 |
commit | 445e86c25a94a83ef1314f6c6e27d46dcb6780dc (patch) | |
tree | 732f0ff71158fcf2f8fbef8e3ba078dfd3eeb26b /uitest/src/com/vaadin/tests/components/datefield | |
parent | d5ce54586a445550b3df5168fe83accb3945901e (diff) | |
download | vaadin-framework-445e86c25a94a83ef1314f6c6e27d46dcb6780dc.tar.gz vaadin-framework-445e86c25a94a83ef1314f6c6e27d46dcb6780dc.zip |
Esc now closes the date popup even if focused on the time selectors (#12314)
Change-Id: I68bc7922074c8c03957fbffce8a3d453726e8c1a
Diffstat (limited to 'uitest/src/com/vaadin/tests/components/datefield')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEsc.java | 6 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEscTest.java | 33 |
2 files changed, 30 insertions, 9 deletions
diff --git a/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEsc.java b/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEsc.java index af43f143c1..f1422b28a3 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEsc.java +++ b/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEsc.java @@ -25,6 +25,10 @@ public class PopupClosingWithEsc extends AbstractTestUI { @Override protected void setup(VaadinRequest request) { + DateField df0 = new DateField("Minute"); + df0.setId("minute"); + df0.setResolution(Resolution.MINUTE); + DateField df1 = new DateField("Day"); df1.setId("day"); df1.setResolution(Resolution.DAY); @@ -40,7 +44,7 @@ public class PopupClosingWithEsc extends AbstractTestUI { VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); - layout.addComponents(df1, df2, df3); + layout.addComponents(df0, df1, df2, df3); setContent(layout); } diff --git a/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEscTest.java b/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEscTest.java index 4c4b894b2b..834517e1bb 100644 --- a/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEscTest.java +++ b/uitest/src/com/vaadin/tests/components/datefield/PopupClosingWithEscTest.java @@ -22,13 +22,27 @@ import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; -import org.openqa.selenium.interactions.Actions; import com.vaadin.tests.tb3.MultiBrowserTest; public class PopupClosingWithEscTest extends MultiBrowserTest { @Test + public void testPopupClosingFromTimeSelect() { + openTestURL(); + + openPopup("minute"); + assertTrue(isPopupVisible()); + + // Send ESC to the select element to simulate user being + // focused on the select while hitting the ESC key. + WebElement select = driver.findElement(By + .cssSelector(".v-datefield-popup select:first-child")); + select.sendKeys(Keys.ESCAPE); + assertFalse(isPopupVisible()); + } + + @Test public void testPopupClosingDayResolution() { testPopupClosing("day"); } @@ -46,22 +60,25 @@ public class PopupClosingWithEscTest extends MultiBrowserTest { private void testPopupClosing(String dateFieldId) { openTestURL(); - driver.findElement( - vaadinLocator("PID_S" + dateFieldId + "#popupButton")).click(); + openPopup(dateFieldId); assertTrue(isPopupVisible()); - sendEsc(); + sendEscToCalendarPanel(); assertFalse(isPopupVisible()); } + private void openPopup(String dateFieldId) { + driver.findElement( + vaadinLocator("PID_S" + dateFieldId + "#popupButton")).click(); + } + private boolean isPopupVisible() { return !(driver.findElements(By.cssSelector(".v-datefield-popup")) .isEmpty()); } - private void sendEsc() { - WebElement elem = driver.findElement(By - .cssSelector(".v-datefield-calendarpanel")); - new Actions(driver).sendKeys(elem, Keys.ESCAPE).perform(); + private void sendEscToCalendarPanel() { + driver.findElement(By.cssSelector(".v-datefield-calendarpanel")) + .sendKeys(Keys.ESCAPE); } } |