keyseq: add a couple of tests
authorRan Benita <ran234@gmail.com>
Fri, 8 Mar 2013 14:31:33 +0000 (16:31 +0200)
committerDaniel Stone <daniel@fooishbar.org>
Mon, 18 Mar 2013 22:20:06 +0000 (22:20 +0000)
Tests the filter refcounting.

Signed-off-by: Ran Benita <ran234@gmail.com>
test/keyseq.c

index d99be0e5fe88b7f5d323a0de91d0c8ee75d6046f..7f148f77183125aaaf7ceffb94a36f21063d3b3c 100644 (file)
@@ -206,6 +206,35 @@ main(void)
                         KEY_LEFTSHIFT,   UP,    XKB_KEY_Shift_L,  NEXT,
                         KEY_O,           BOTH,  XKB_KEY_o,        FINISH));
 
+    /*
+     * Two key presses from the same key (e.g. if two keyboards use the
+     * same xkb_state) should only be released after two releases.
+     */
+    assert(test_key_seq(keymap,
+                        KEY_H,           BOTH,  XKB_KEY_h,        NEXT,
+                        KEY_LEFTSHIFT,   DOWN,  XKB_KEY_Shift_L,  NEXT,
+                        KEY_H,           BOTH,  XKB_KEY_H,        NEXT,
+                        KEY_LEFTSHIFT,   DOWN,  XKB_KEY_Shift_L,  NEXT,
+                        KEY_H,           BOTH,  XKB_KEY_H,        NEXT,
+                        KEY_LEFTSHIFT,   UP,    XKB_KEY_Shift_L,  NEXT,
+                        KEY_H,           BOTH,  XKB_KEY_H,        NEXT,
+                        KEY_LEFTSHIFT,   UP,    XKB_KEY_Shift_L,  NEXT,
+                        KEY_H,           BOTH,  XKB_KEY_h,        FINISH));
+
+    /* Same as above with locked modifiers. */
+    assert(test_key_seq(keymap,
+                        KEY_H,           BOTH,  XKB_KEY_h,          NEXT,
+                        KEY_CAPSLOCK,    DOWN,  XKB_KEY_Caps_Lock,  NEXT,
+                        KEY_H,           BOTH,  XKB_KEY_H,          NEXT,
+                        KEY_CAPSLOCK,    DOWN,  XKB_KEY_Caps_Lock,  NEXT,
+                        KEY_H,           BOTH,  XKB_KEY_H,          NEXT,
+                        KEY_CAPSLOCK,    UP,    XKB_KEY_Caps_Lock,  NEXT,
+                        KEY_H,           BOTH,  XKB_KEY_H,          NEXT,
+                        KEY_CAPSLOCK,    UP,    XKB_KEY_Caps_Lock,  NEXT,
+                        KEY_H,           BOTH,  XKB_KEY_H,          NEXT,
+                        KEY_CAPSLOCK,    BOTH,  XKB_KEY_Caps_Lock,  NEXT,
+                        KEY_H,           BOTH,  XKB_KEY_h,          FINISH));
+
     /* Group switching / locking. */
     assert(test_key_seq(keymap,
                         KEY_H,        BOTH,  XKB_KEY_h,               NEXT,