test/keyseq: add test for setting depressed group

Tests the SetGroup action is working properly.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-10-29 20:20:51 +02:00
parent 7261f404d2
commit 94155878ec
1 changed files with 46 additions and 0 deletions

View File

@ -66,6 +66,8 @@ test_key_seq(struct xkb_keymap *keymap, ...)
unsigned int nsyms, i; unsigned int nsyms, i;
char ksbuf[64]; char ksbuf[64];
fprintf(stderr, "----\n");
state = xkb_state_new(keymap); state = xkb_state_new(keymap);
assert(state); assert(state);
@ -418,6 +420,50 @@ main(void)
KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT, KEY_COMPOSE, BOTH, XKB_KEY_ISO_Next_Group, NEXT,
KEY_H, BOTH, XKB_KEY_h, FINISH)); 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_keymap_unref(keymap);
xkb_context_unref(ctx); xkb_context_unref(ctx);
return 0; return 0;