mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-20 05:40:04 +01:00
test: expand the tablet mode switch test to check for fake key releases
If a key is still down when the tablet mode switch goes on, make sure we release the key before the switch goes in effect. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
9bd0604ea3
commit
3fb876a49d
3 changed files with 39 additions and 4 deletions
|
|
@ -3995,6 +3995,21 @@ litest_is_switch_event(struct libinput_event *event,
|
|||
return swev;
|
||||
}
|
||||
|
||||
void
|
||||
litest_assert_switch_event(struct libinput *li,
|
||||
enum libinput_switch sw,
|
||||
enum libinput_switch_state state)
|
||||
{
|
||||
struct libinput_event *event;
|
||||
|
||||
litest_wait_for_event(li);
|
||||
event = libinput_get_event(li);
|
||||
|
||||
litest_is_switch_event(event, sw, state);
|
||||
|
||||
libinput_event_destroy(event);
|
||||
}
|
||||
|
||||
void
|
||||
litest_assert_pad_button_event(struct libinput *li,
|
||||
unsigned int button,
|
||||
|
|
|
|||
|
|
@ -837,6 +837,11 @@ litest_assert_button_event(struct libinput *li,
|
|||
unsigned int button,
|
||||
enum libinput_button_state state);
|
||||
|
||||
void
|
||||
litest_assert_switch_event(struct libinput *li,
|
||||
enum libinput_switch sw,
|
||||
enum libinput_switch_state state);
|
||||
|
||||
void
|
||||
litest_assert_scroll(struct libinput *li,
|
||||
enum libinput_event_type axis_type,
|
||||
|
|
|
|||
|
|
@ -1097,13 +1097,23 @@ START_TEST(tablet_mode_disable_keyboard)
|
|||
|
||||
litest_keyboard_key(keyboard, KEY_A, true);
|
||||
litest_keyboard_key(keyboard, KEY_A, false);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_KEYBOARD_KEY);
|
||||
litest_keyboard_key(keyboard, KEY_B, true); /* KEY_B down but not up */
|
||||
libinput_dispatch(li);
|
||||
|
||||
litest_assert_key_event(li, KEY_A, LIBINPUT_KEY_STATE_PRESSED);
|
||||
litest_assert_key_event(li, KEY_A, LIBINPUT_KEY_STATE_RELEASED);
|
||||
litest_assert_key_event(li, KEY_B, LIBINPUT_KEY_STATE_PRESSED); /* KEY_B down but not up */
|
||||
|
||||
litest_switch_action(sw,
|
||||
LIBINPUT_SWITCH_TABLET_MODE,
|
||||
LIBINPUT_SWITCH_STATE_ON);
|
||||
litest_drain_events(li);
|
||||
|
||||
/* The key currently down must be released */
|
||||
litest_assert_key_event(li, KEY_B, LIBINPUT_KEY_STATE_RELEASED);
|
||||
litest_assert_switch_event(li, LIBINPUT_SWITCH_TABLET_MODE, LIBINPUT_SWITCH_STATE_ON);
|
||||
litest_assert_empty_queue(li);
|
||||
|
||||
litest_keyboard_key(keyboard, KEY_B, false); /* release the kernel device */
|
||||
litest_keyboard_key(keyboard, KEY_A, true);
|
||||
litest_keyboard_key(keyboard, KEY_A, false);
|
||||
litest_assert_empty_queue(li);
|
||||
|
|
@ -1111,11 +1121,16 @@ START_TEST(tablet_mode_disable_keyboard)
|
|||
litest_switch_action(sw,
|
||||
LIBINPUT_SWITCH_TABLET_MODE,
|
||||
LIBINPUT_SWITCH_STATE_OFF);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_SWITCH_TOGGLE);
|
||||
litest_assert_switch_event(li, LIBINPUT_SWITCH_TABLET_MODE, LIBINPUT_SWITCH_STATE_OFF);
|
||||
|
||||
litest_keyboard_key(keyboard, KEY_A, true);
|
||||
litest_keyboard_key(keyboard, KEY_A, false);
|
||||
litest_assert_only_typed_events(li, LIBINPUT_EVENT_KEYBOARD_KEY);
|
||||
litest_keyboard_key(keyboard, KEY_B, true);
|
||||
litest_keyboard_key(keyboard, KEY_B, false);
|
||||
litest_assert_key_event(li, KEY_A, LIBINPUT_KEY_STATE_PRESSED);
|
||||
litest_assert_key_event(li, KEY_A, LIBINPUT_KEY_STATE_RELEASED);
|
||||
litest_assert_key_event(li, KEY_B, LIBINPUT_KEY_STATE_PRESSED);
|
||||
litest_assert_key_event(li, KEY_B, LIBINPUT_KEY_STATE_RELEASED);
|
||||
|
||||
litest_delete_device(keyboard);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue