test/keyseq: add test for setting depressed group Tests the SetGroup action is working properly. Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
diff --git a/test/keyseq.c b/test/keyseq.c
index cb53739..5aa53a6 100644
--- a/test/keyseq.c
+++ b/test/keyseq.c
@@ -66,6 +66,8 @@ test_key_seq(struct xkb_keymap *keymap, ...)
unsigned int nsyms, i;
char ksbuf[64];
+ fprintf(stderr, "----\n");
+
state = xkb_state_new(keymap);
assert(state);
@@ -419,6 +421,50 @@ main(void)
KEY_H, BOTH, XKB_KEY_h, FINISH));
xkb_keymap_unref(keymap);
+ assert(ctx);
+ keymap = test_compile_rules(ctx, "evdev", "", "us,il,ru", "",
+ "grp:switch,grp:lswitch,grp:menu_toggle");
+ assert(keymap);
+
+ /* Test depressed group works (Mode_switch). */
+ assert(test_key_seq(keymap,
+ KEY_H, BOTH, XKB_KEY_h, NEXT,
+ KEY_RIGHTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
+ KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
+ KEY_RIGHTALT, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
+ KEY_H, BOTH, XKB_KEY_h, NEXT,
+ KEY_RIGHTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
+ KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
+ KEY_RIGHTALT, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
+ KEY_H, BOTH, XKB_KEY_h, FINISH));
+
+ /* Test locked+depressed group works, with wrapping and accumulation. */
+ assert(test_key_seq(keymap,
+ KEY_H, BOTH, XKB_KEY_h, NEXT,
+ KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
+ KEY_LEFTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
+ KEY_H, BOTH, XKB_KEY_Cyrillic_er, NEXT,
+ KEY_LEFTALT, UP, XKB_KEY_Mode_switch, NEXT,
+ KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
+ KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
+ KEY_LEFTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
+ /* Should wrap back to first group. */
+ KEY_H, BOTH, XKB_KEY_h, NEXT,
+ KEY_LEFTALT, UP, XKB_KEY_Mode_switch, NEXT,
+ KEY_H, BOTH, XKB_KEY_Cyrillic_er, NEXT,
+ KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
+ KEY_H, BOTH, XKB_KEY_h, NEXT,
+ /* Two SetGroup(+1)'s should add up. */
+ KEY_RIGHTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
+ KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
+ KEY_LEFTALT, DOWN, XKB_KEY_Mode_switch, NEXT,
+ KEY_H, BOTH, XKB_KEY_Cyrillic_er, NEXT,
+ KEY_LEFTALT, UP, XKB_KEY_Mode_switch, NEXT,
+ KEY_H, BOTH, XKB_KEY_hebrew_yod, NEXT,
+ KEY_RIGHTALT, UP, XKB_KEY_ISO_Level3_Shift, NEXT,
+ KEY_H, BOTH, XKB_KEY_h, FINISH));
+
+ xkb_keymap_unref(keymap);
xkb_context_unref(ctx);
return 0;
}