diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-04-21 10:24:12 +0300 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-04-21 10:24:12 +0300 |
commit | fa6f39bc84fa94f876248f6e967a3c9cefcd097b (patch) | |
tree | 29644e1376a93fec862f185da221845346265fad /uitest/src/com/vaadin | |
parent | 1bb67a02544e0fbf2999e5a814c79475d1b05c9b (diff) | |
parent | b2f283b414129407f4e839470380e5e5d0383fb4 (diff) | |
download | vaadin-framework-fa6f39bc84fa94f876248f6e967a3c9cefcd097b.tar.gz vaadin-framework-fa6f39bc84fa94f876248f6e967a3c9cefcd097b.zip |
Merge remote-tracking branch 'origin/master' into feature/mavenize
Change-Id: I1c55d6158caf32b796a9ad0d9e8df5392812e9a6
Diffstat (limited to 'uitest/src/com/vaadin')
-rw-r--r-- | uitest/src/com/vaadin/tests/components/ui/WindowAndUIShortcuts.java | 76 | ||||
-rw-r--r-- | uitest/src/com/vaadin/tests/components/ui/WindowAndUIShortcutsTest.java | 43 |
2 files changed, 119 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/ui/WindowAndUIShortcuts.java b/uitest/src/com/vaadin/tests/components/ui/WindowAndUIShortcuts.java new file mode 100644 index 0000000000..c5c9c16e2d --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/WindowAndUIShortcuts.java @@ -0,0 +1,76 @@ +package com.vaadin.tests.components.ui; + +import com.vaadin.annotations.Theme; +import com.vaadin.event.ShortcutAction; +import com.vaadin.server.VaadinRequest; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; +import com.vaadin.ui.Notification; +import com.vaadin.ui.TextField; +import com.vaadin.ui.UI; +import com.vaadin.ui.VerticalLayout; +import com.vaadin.ui.Window; +import com.vaadin.ui.themes.ValoTheme; + +@Theme(ValoTheme.THEME_NAME) +public class WindowAndUIShortcuts extends UI { + + @Override + protected void init(VaadinRequest request) { + VerticalLayout layout = new VerticalLayout(); + layout.setSizeFull(); + layout.setMargin(true); + + final VerticalLayout mainLayout = new VerticalLayout(); + + mainLayout.addComponent(new Button("Show page", + new Button.ClickListener() { + @Override + public void buttonClick(Button.ClickEvent clickEvent) { + final VerticalLayout pageLayout = new VerticalLayout(); + pageLayout.setSpacing(true); + + pageLayout.addComponent(new Label("Page")); + pageLayout.addComponent(new Button( + "Open dialog window", + new Button.ClickListener() { + @Override + public void buttonClick( + Button.ClickEvent clickEvent) { + Window dialog = new Window(); + dialog.setModal(true); + dialog.setCaption("Press ESC shortcut"); + dialog.setWidth("300px"); + dialog.setHeight("100px"); + + dialog.setContent(new TextField( + "TextField in window")); + addWindow(dialog); + } + })); + Button closeButton = new Button("Close page", + new Button.ClickListener() { + @Override + public void buttonClick( + Button.ClickEvent clickEvent) { + mainLayout.removeComponent(pageLayout); + + Notification + .show("OMG! Page is also closed!"); + } + }); + closeButton + .setClickShortcut(ShortcutAction.KeyCode.ESCAPE); + pageLayout.addComponent(closeButton); + + mainLayout.addComponent(pageLayout); + mainLayout.setExpandRatio(pageLayout, 1); + } + })); + + layout.addComponent(mainLayout); + layout.setExpandRatio(mainLayout, 1); + + setContent(layout); + } +} diff --git a/uitest/src/com/vaadin/tests/components/ui/WindowAndUIShortcutsTest.java b/uitest/src/com/vaadin/tests/components/ui/WindowAndUIShortcutsTest.java new file mode 100644 index 0000000000..93324f0792 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/ui/WindowAndUIShortcutsTest.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.ui; + +import org.junit.Assert; +import org.junit.Test; +import org.openqa.selenium.Keys; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.TextFieldElement; +import com.vaadin.testbench.elements.WindowElement; +import com.vaadin.tests.tb3.SingleBrowserTest; + +public class WindowAndUIShortcutsTest extends SingleBrowserTest { + + @Test + public void windowShortcutShouldNotReachUI() { + openTestURL(); + $(ButtonElement.class).caption("Show page").first().click(); + $(ButtonElement.class).caption("Open dialog window").first().click(); + + WindowElement window = $(WindowElement.class).first(); + window.$(TextFieldElement.class).first().sendKeys(Keys.ESCAPE); + + // Window should have been closed + Assert.assertTrue($(WindowElement.class).all().isEmpty()); + // "Close page" should not have been clicked + Assert.assertTrue($(ButtonElement.class).caption("Close page").exists()); + } +} |