summaryrefslogtreecommitdiffstats
path: root/server/tests
diff options
context:
space:
mode:
authorpatrik <patrik@vaadin.com>2015-08-06 14:08:38 +0300
committerVaadin Code Review <review@vaadin.com>2015-08-28 07:22:24 +0000
commit1d36db6d112c818a9c75e7cd10eb6b3519119406 (patch)
tree107d6b67a75216dc5adca0833d90049751807fd3 /server/tests
parentc6622ac5cbf4ddbcec35e02f92f74cf46d147e71 (diff)
downloadvaadin-framework-1d36db6d112c818a9c75e7cd10eb6b3519119406.tar.gz
vaadin-framework-1d36db6d112c818a9c75e7cd10eb6b3519119406.zip
Add better keyboard Close Shortcut API for Window (#17383)
Change-Id: I29c7d288fe35f6801cf3576ba06751adce821340
Diffstat (limited to 'server/tests')
-rw-r--r--server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java4
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/window/WindowDeclarativeTest.java39
3 files changed, 40 insertions, 5 deletions
diff --git a/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java b/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java
index acee3e2ca8..6510d8ad40 100644
--- a/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java
+++ b/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java
@@ -203,7 +203,7 @@ public class DesignFormatterTest {
ShortcutAction action = new ShortcutAction("&^d");
String formatted = formatter.format(action);
// note the space here - it separates key combination from caption
- assertEquals("alt-ctrl-d d", formatted);
+ assertEquals("ctrl-alt-d d", formatted);
ShortcutAction result = formatter
.parse(formatted, ShortcutAction.class);
@@ -215,7 +215,7 @@ public class DesignFormatterTest {
ShortcutAction action = new ShortcutAction(null, KeyCode.D, new int[] {
ModifierKey.ALT, ModifierKey.CTRL });
String formatted = formatter.format(action);
- assertEquals("alt-ctrl-d", formatted);
+ assertEquals("ctrl-alt-d", formatted);
ShortcutAction result = formatter
.parse(formatted, ShortcutAction.class);
diff --git a/server/tests/src/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java
index 51abf6be96..b1c10789b4 100644
--- a/server/tests/src/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/button/ButtonDeclarativeTest.java
@@ -98,7 +98,7 @@ public class ButtonDeclarativeTest extends DeclarativeTestBase<Button> {
@Test
public void testAttributes() {
String design = "<v-button tabindex=3 plain-text='' icon-alt=OK "
- + "click-shortcut=ctrl-shift-o></v-button>";
+ + "click-shortcut=shift-ctrl-o></v-button>";
Button b = new Button("");
b.setTabIndex(3);
b.setIconAlternateText("OK");
diff --git a/server/tests/src/com/vaadin/tests/server/component/window/WindowDeclarativeTest.java b/server/tests/src/com/vaadin/tests/server/component/window/WindowDeclarativeTest.java
index 1d233af494..607fb471b9 100644
--- a/server/tests/src/com/vaadin/tests/server/component/window/WindowDeclarativeTest.java
+++ b/server/tests/src/com/vaadin/tests/server/component/window/WindowDeclarativeTest.java
@@ -71,8 +71,9 @@ public class WindowDeclarativeTest extends DeclarativeTestBase<Window> {
expected.setClosable(!expected.isClosable());
expected.setDraggable(!expected.isDraggable());
- expected.setCloseShortcut(KeyCode.ESCAPE, ModifierKey.CTRL,
- ModifierKey.ALT);
+ expected.removeAllCloseShortcuts();
+ expected.addCloseShortcut(KeyCode.ESCAPE, ModifierKey.ALT,
+ ModifierKey.CTRL);
expected.setAssistivePrefix("Hello");
expected.setAssistivePostfix("World");
@@ -86,6 +87,40 @@ public class WindowDeclarativeTest extends DeclarativeTestBase<Window> {
}
@Test
+ public void testMultiCloseShortcuts() {
+
+ Window expected = new Window();
+
+ // Add two shortcuts - should now contain three (default escape + two
+ // added)
+ expected.addCloseShortcut(KeyCode.SPACEBAR);
+ expected.addCloseShortcut(KeyCode.ARROW_LEFT, ModifierKey.ALT,
+ ModifierKey.CTRL);
+
+ // Try to add the same shortcut again, should be no-op
+ expected.addCloseShortcut(KeyCode.ARROW_LEFT, ModifierKey.CTRL,
+ ModifierKey.ALT);
+
+ // Add a third shortcut, should total four (default escape + three
+ // added)
+ expected.addCloseShortcut(KeyCode.ARROW_RIGHT, ModifierKey.CTRL);
+
+ // Test validity
+ String design = "<v-window close-shortcut='escape spacebar ctrl-alt-left ctrl-right' />";
+ testRead(design, expected);
+ testWrite(design, expected);
+
+ // Try removing the spacebar shortcut
+ expected.removeCloseShortcut(KeyCode.SPACEBAR);
+
+ // Test again
+ design = "<v-window close-shortcut='escape ctrl-alt-left ctrl-right' />";
+ testRead(design, expected);
+ testWrite(design, expected);
+
+ }
+
+ @Test
public void testInvalidPosition() {
assertInvalidPosition("");
assertInvalidPosition("1");