summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2016-01-01 11:53:42 +0200
committerTeemu Suo-Anttila <teemusa@vaadin.com>2016-01-05 14:06:42 +0200
commit29a368d0f7efe24237b36e716e1c59418073163f (patch)
tree63260558f00854b44788869fca089feeb4cd1e65 /uitest/src/com/vaadin
parent691fcd02c0dab910caaccff1af57da6613be9009 (diff)
downloadvaadin-framework-29a368d0f7efe24237b36e716e1c59418073163f.tar.gz
vaadin-framework-29a368d0f7efe24237b36e716e1c59418073163f.zip
Listen to body for shortcut actions for standalone apps (#19392)
Change-Id: I2e9d5e95c7b0ba3907c9772aee9fbfadb6baabde
Diffstat (limited to 'uitest/src/com/vaadin')
-rw-r--r--uitest/src/com/vaadin/tests/components/abstractfield/ShortcutWhenBodyFocused.java40
-rw-r--r--uitest/src/com/vaadin/tests/components/abstractfield/ShortcutWhenBodyFocusedTest.java42
2 files changed, 82 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutWhenBodyFocused.java b/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutWhenBodyFocused.java
new file mode 100644
index 0000000000..41a5febc16
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutWhenBodyFocused.java
@@ -0,0 +1,40 @@
+/*
+ * 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.abstractfield;
+
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+
+public class ShortcutWhenBodyFocused extends AbstractTestUIWithLog {
+ @Override
+ protected void setup(VaadinRequest request) {
+ Button b = new Button("Hello", new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent event) {
+ log("Hello clicked");
+ }
+ });
+ b.setClickShortcut(KeyCode.A);
+ addComponent(b);
+
+ getPage().getStyles().add("body { width: 50% !important}");
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutWhenBodyFocusedTest.java b/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutWhenBodyFocusedTest.java
new file mode 100644
index 0000000000..2d9c9a494b
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/abstractfield/ShortcutWhenBodyFocusedTest.java
@@ -0,0 +1,42 @@
+/*
+ * 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.abstractfield;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.tests.tb3.SingleBrowserTest;
+
+public class ShortcutWhenBodyFocusedTest extends SingleBrowserTest {
+
+ @Test
+ public void triggerShortcutOnBody() {
+ openTestURL();
+ ButtonElement b = $(ButtonElement.class).caption("Hello").first();
+ b.click();
+ Assert.assertEquals("1. Hello clicked", getLogRow(0));
+
+ b.sendKeys("A");
+ Assert.assertEquals("2. Hello clicked", getLogRow(0));
+
+ WebElement body = findElement(By.xpath("//body"));
+ body.sendKeys("A");
+ Assert.assertEquals("3. Hello clicked", getLogRow(0));
+ }
+}