summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorSun Zhe <31067185+ZheSun88@users.noreply.github.com>2018-10-26 15:55:38 +0300
committerGitHub <noreply@github.com>2018-10-26 15:55:38 +0300
commit242ee1c15a17bed92245a02fac944bddb425dc3e (patch)
tree063a9c95c6b43ad875a5f52727fbe61709f26aec /uitest
parentb370b042f2b796b26033ab091c6f67d7cd658921 (diff)
downloadvaadin-framework-242ee1c15a17bed92245a02fac944bddb425dc3e.tar.gz
vaadin-framework-242ee1c15a17bed92245a02fac944bddb425dc3e.zip
Refactor the usage of KeyMapper in ActionManager. (#11265)
* Add Test for closing window with focused textfield verify issue #10642 * Refactor the code about using keyMapper
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/window/CloseWindowWithFocusedTextField.java37
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/window/CloseWindowWithFocusedTextFieldTest.java29
2 files changed, 66 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/window/CloseWindowWithFocusedTextField.java b/uitest/src/main/java/com/vaadin/tests/components/window/CloseWindowWithFocusedTextField.java
new file mode 100644
index 0000000000..2c0b2e4acf
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/window/CloseWindowWithFocusedTextField.java
@@ -0,0 +1,37 @@
+package com.vaadin.tests.components.window;
+
+import com.vaadin.event.ShortcutAction;
+import com.vaadin.event.ShortcutListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.shared.ui.ValueChangeMode;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class CloseWindowWithFocusedTextField extends AbstractTestUI {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final VerticalLayout layout = new VerticalLayout();
+
+ Button button1 = new Button("open window");
+ button1.addClickListener(event -> {
+
+ Window window = new Window();
+ window.setModal(true);
+
+ TextField textField = new TextField("focus me");
+ textField.focus();
+
+ window.setContent(textField);
+ getUI().addWindow(window);
+ });
+
+ layout.addComponents(button1);
+
+ addComponent(layout);
+ }
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/window/CloseWindowWithFocusedTextFieldTest.java b/uitest/src/test/java/com/vaadin/tests/components/window/CloseWindowWithFocusedTextFieldTest.java
new file mode 100644
index 0000000000..898e15ce51
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/window/CloseWindowWithFocusedTextFieldTest.java
@@ -0,0 +1,29 @@
+package com.vaadin.tests.components.window;
+
+import org.junit.Test;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.interactions.Actions;
+
+import com.vaadin.testbench.annotations.RunLocally;
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.WindowElement;
+import com.vaadin.testbench.parallel.Browser;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class CloseWindowWithFocusedTextFieldTest extends MultiBrowserTest {
+
+ @Test
+ public void OpenWindow_CloseWithEscapeKey_WindowClosed() {
+ openTestURL();
+ $(ButtonElement.class).first().click();
+ assertTrue("Window should be opened", $(WindowElement.class).exists());
+
+ new Actions(getDriver()).sendKeys(Keys.ESCAPE).build().perform();
+ assertFalse("Window found when there should be none.",
+ $(WindowElement.class).exists());
+ }
+
+}