summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorMichael Forstner <michael.forstner@bsi-in.de>2018-12-10 13:03:52 +0100
committerSun Zhe <31067185+ZheSun88@users.noreply.github.com>2018-12-10 14:03:52 +0200
commit5480d82bb8554d3980a55714c6128cfe1d63ec92 (patch)
treeb2f9c2f05b1044d7e801d71387ed24004b237bc8 /uitest
parente7b721f3e81534957b27a3af656021a643530cdd (diff)
downloadvaadin-framework-5480d82bb8554d3980a55714c6128cfe1d63ec92.tar.gz
vaadin-framework-5480d82bb8554d3980a55714c6128cfe1d63ec92.zip
Add missing FocusShortcutListener (#11289)
* Add missing FocusShortcutListener Was removed from 8.0 and not readded. Fixes #8297 * Update Release note for this change
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/components/FocusShortcuts.java30
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/FocusShortcutsTest.java43
2 files changed, 73 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/components/FocusShortcuts.java b/uitest/src/main/java/com/vaadin/tests/components/FocusShortcuts.java
new file mode 100644
index 0000000000..089f95a5d9
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/components/FocusShortcuts.java
@@ -0,0 +1,30 @@
+package com.vaadin.tests.components;
+
+import com.vaadin.event.FocusShortcut;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.event.ShortcutAction.ModifierKey;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.TextField;
+
+public class FocusShortcuts extends AbstractTestUIWithLog {
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ TextField name = new TextField("Name (Alt+N)");
+ name.addShortcutListener(
+ new FocusShortcut(name, KeyCode.N, ModifierKey.ALT));
+ name.addFocusListener(event -> log("Alt+N"));
+
+ TextField address = new TextField("Address (Alt+A)");
+ address.addShortcutListener(new FocusShortcut(address, "&Address"));
+ address.addFocusListener(event -> log("Alt+A"));
+
+ TextField name2 = new TextField("Name (Ctrl+Shift+D)");
+ name2.addShortcutListener(new FocusShortcut(name2, KeyCode.D,
+ ModifierKey.CTRL, ModifierKey.SHIFT));
+ name2.addFocusListener(event -> log("Ctrl+Shift+D"));
+
+ addComponents(name, address, name2);
+ }
+
+}
diff --git a/uitest/src/test/java/com/vaadin/tests/components/FocusShortcutsTest.java b/uitest/src/test/java/com/vaadin/tests/components/FocusShortcutsTest.java
new file mode 100644
index 0000000000..e67b8d3240
--- /dev/null
+++ b/uitest/src/test/java/com/vaadin/tests/components/FocusShortcutsTest.java
@@ -0,0 +1,43 @@
+package com.vaadin.tests.components;
+
+import org.junit.Assert;
+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.testbench.elements.TextFieldElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class FocusShortcutsTest extends SingleBrowserTest {
+
+ @Test
+ public void triggerShortCuts() {
+ openTestURL();
+
+ WebElement body = findElement(By.xpath("//body"));
+ Actions actions = new Actions(getDriver());
+ actions.keyDown(body, Keys.LEFT_ALT).sendKeys("a").keyUp(Keys.LEFT_ALT)
+ .build().perform();
+
+ Assert.assertEquals("1. Alt+A", getLogRow(0));
+
+ body.click();
+
+ actions = new Actions(getDriver());
+ actions.keyDown(body, Keys.LEFT_ALT).sendKeys("n").keyUp(Keys.LEFT_ALT)
+ .build().perform();
+
+ Assert.assertEquals("2. Alt+N", getLogRow(0));
+
+ body.click();
+
+ actions = new Actions(getDriver());
+ actions.keyDown(body, Keys.LEFT_CONTROL).keyDown(body, Keys.LEFT_SHIFT)
+ .sendKeys("d").keyUp(Keys.LEFT_CONTROL).keyUp(Keys.LEFT_SHIFT).build().perform();
+
+ Assert.assertEquals("3. Ctrl+Shift+D", getLogRow(0));
+ }
+
+}