diff options
author | Anastasia Smirnova <anasmi@utu.fi> | 2019-12-05 20:33:31 +0200 |
---|---|---|
committer | Tatu Lund <tatu@vaadin.com> | 2019-12-05 20:33:31 +0200 |
commit | 877d7ef7ce3e29905e55fd36ee2d3ac8cf77ccf6 (patch) | |
tree | a8f0ed16add99eff11dbbe21c39df4eb6a24855f /uitest | |
parent | 7895a74211c12a45e614892ce3e24fba838186fd (diff) | |
download | vaadin-framework-877d7ef7ce3e29905e55fd36ee2d3ac8cf77ccf6.tar.gz vaadin-framework-877d7ef7ce3e29905e55fd36ee2d3ac8cf77ccf6.zip |
Close window on ESC, when maximized button is clicked (#11840)
Fixes #11838
Changes:
1. Close a window when maximized button is focused and ESC is pressed
2. Add additional check for a close button to react to the ESC key press
3. Rename a private method `onCloseClick` to `closeWindow` to allow code re-use
Diffstat (limited to 'uitest')
2 files changed, 68 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/CloseWindowOnEscapeMaximizedButtonFocused.java b/uitest/src/main/java/com/vaadin/tests/components/window/CloseWindowOnEscapeMaximizedButtonFocused.java new file mode 100644 index 0000000000..d1c0f3aeec --- /dev/null +++ b/uitest/src/main/java/com/vaadin/tests/components/window/CloseWindowOnEscapeMaximizedButtonFocused.java @@ -0,0 +1,41 @@ +package com.vaadin.tests.components.window; + +import com.vaadin.annotations.Widgetset; +import com.vaadin.server.VaadinRequest; +import com.vaadin.shared.ui.window.WindowMode; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.Button; +import com.vaadin.ui.Label; +import com.vaadin.ui.Window; + +@Widgetset("com.vaadin.DefaultWidgetSet") +public class CloseWindowOnEscapeMaximizedButtonFocused extends AbstractTestUI { + + @Override + protected void setup(VaadinRequest request) { + Label instructions = new Label("Press Maximise button and then ESC. " + + " Window should be closed"); + Button openWindow = new Button("Open Window"); + openWindow.setId("openW"); + openWindow.addClickListener(e -> { + Window win = new Window("Window test", new Label("Some content")); + win.setWindowMode(WindowMode.NORMAL); + win.setWidth("300px"); + win.setHeight("300px"); + win.center(); + addWindow(win); + }); + addComponent(instructions); + addComponent(openWindow); + } + + @Override + public String getTestDescription() { + return "A window should be closed after the ESC button is pressed, when a maximize button is focused"; + }; + + @Override + public Integer getTicketNumber() { + return 11838; + }; +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/CloseWindowOnEscapeMaximizedButtonFocusedTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/CloseWindowOnEscapeMaximizedButtonFocusedTest.java new file mode 100644 index 0000000000..e4be7413aa --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/components/window/CloseWindowOnEscapeMaximizedButtonFocusedTest.java @@ -0,0 +1,27 @@ +package com.vaadin.tests.components.window; + +import com.vaadin.testbench.elements.ButtonElement; +import com.vaadin.testbench.elements.WindowElement; +import com.vaadin.tests.tb3.MultiBrowserTest; +import org.junit.Test; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import static org.junit.Assert.assertTrue; + +public class CloseWindowOnEscapeMaximizedButtonFocusedTest + extends MultiBrowserTest { + + @Test + public void windowIsClosed() { + openTestURL(); + ButtonElement openWindow = $(ButtonElement.class).id("openW"); + openWindow.click(); + + WindowElement window = $(WindowElement.class).first(); + window.maximize(); + findElement(By.className("v-window-restorebox")).sendKeys(Keys.ESCAPE); + waitForElementNotPresent(By.className("v-window")); + assertTrue("Window should be removed after ESC key is pressed", + driver.findElements(By.className("v-window ")).isEmpty()); + } +} |