diff options
author | Teemu Pöntelin <tehapo@gmail.com> | 2016-04-03 23:22:48 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-04-11 13:16:59 +0000 |
commit | 9b46608f6c645c4289b854e2949bae3b1a2f5147 (patch) | |
tree | b900ab05e67e49c10536eb037ecfdc843a30088b /uitest/src | |
parent | 306f2935bf269538b730a8fc33433a2d3945cad5 (diff) | |
download | vaadin-framework-9b46608f6c645c4289b854e2949bae3b1a2f5147.tar.gz vaadin-framework-9b46608f6c645c4289b854e2949bae3b1a2f5147.zip |
Prevent closing of uncloseable Window on esc (#19700)
Change-Id: I4d67cd84c6f4179da6d6fea6b881e8ccd65e70d9
Diffstat (limited to 'uitest/src')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/window/UncloseableWindowCloseShortcut.java | 46 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/window/UncloseableWindowCloseShortcutTest.java | 45 |
2 files changed, 91 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/window/UncloseableWindowCloseShortcut.java b/uitest/src/com/vaadin/tests/components/window/UncloseableWindowCloseShortcut.java new file mode 100644 index 0000000000..1db8e0c87b --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/UncloseableWindowCloseShortcut.java @@ -0,0 +1,46 @@ +/* + * 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.window; + +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Label; +import com.vaadin.ui.Window; + +public class UncloseableWindowCloseShortcut extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Window uncloseable = new Window("Uncloseable", + new Label("Try and close me with esc")); + uncloseable.setClosable(false); + addWindow(uncloseable); + + uncloseable.center(); + uncloseable.focus(); + } + + @Override + protected String getTestDescription() { + return "An uncloseable Window should not be closed with esc key."; + } + + @Override + protected Integer getTicketNumber() { + return 19700; + } + +} diff --git a/uitest/src/com/vaadin/tests/components/window/UncloseableWindowCloseShortcutTest.java b/uitest/src/com/vaadin/tests/components/window/UncloseableWindowCloseShortcutTest.java new file mode 100644 index 0000000000..4574e7b3eb --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/window/UncloseableWindowCloseShortcutTest.java @@ -0,0 +1,45 @@ +/* + * 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.window; + +import static org.junit.Assert.assertTrue; + +import org.junit.Test; +import org.openqa.selenium.Keys; + +import com.vaadin.testbench.By; +import com.vaadin.testbench.elements.WindowElement; +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class UncloseableWindowCloseShortcutTest extends SingleBrowserTest { + + @Test + public void testEscShortcut() { + openTestURL(); + + // Hit esc and verify that the Window was not closed. + driver.findElement(By.cssSelector(".v-window-contents .v-scrollable")) + .sendKeys(Keys.ESCAPE); + assertTrue( + "Uncloseable Window should remain open after esc is pressed.", + isWindowOpen()); + } + + private boolean isWindowOpen() { + return $(WindowElement.class).exists(); + } + +} |