summaryrefslogtreecommitdiff
path: root/test/test-switch.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2017-10-27 15:03:52 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2017-10-27 15:20:35 +1000
commit41a70bbe924c4867283bfdec67cd76012744afcb (patch)
tree8f144418f0336ce9ccfd97e743937ef623fdbe78 /test/test-switch.c
parent57c5a409d632c44928f4560c694efba9c26dce1e (diff)
downloadlibinput-41a70bbe924c4867283bfdec67cd76012744afcb.tar.gz
fallback: fix lid switch event listener being initialized twice
Once the lid is closed, the keyboard event listener is set up to open the lid for us on keyboard events. With the right sequence, we can trigger the listener to be added to the list multiple times, triggering an assert in the list test code (or an infinite loop in the 1.8 branch). Conditions: * SW_LID value 1 - sets up the keyboard listener * keyboard event - sets lid_is_closed to false * SW_LID value 0 - is ignored because we're already open * SW_LID value 1 - sets up the keyboard listener again https://bugs.freedesktop.org/show_bug.cgi?id=103298 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test/test-switch.c')
-rw-r--r--test/test-switch.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/test/test-switch.c b/test/test-switch.c
index 3a499bf7..d62ca9fa 100644
--- a/test/test-switch.c
+++ b/test/test-switch.c
@@ -513,30 +513,32 @@ START_TEST(lid_open_on_key)
keyboard = litest_add_device(li, LITEST_KEYBOARD);
- litest_switch_action(sw,
- LIBINPUT_SWITCH_LID,
- LIBINPUT_SWITCH_STATE_ON);
- litest_drain_events(li);
-
- litest_event(keyboard, EV_KEY, KEY_A, 1);
- litest_event(keyboard, EV_SYN, SYN_REPORT, 0);
- litest_event(keyboard, EV_KEY, KEY_A, 0);
- litest_event(keyboard, EV_SYN, SYN_REPORT, 0);
- libinput_dispatch(li);
+ for (int i = 0; i < 3; i++) {
+ litest_switch_action(sw,
+ LIBINPUT_SWITCH_LID,
+ LIBINPUT_SWITCH_STATE_ON);
+ litest_drain_events(li);
+
+ litest_event(keyboard, EV_KEY, KEY_A, 1);
+ litest_event(keyboard, EV_SYN, SYN_REPORT, 0);
+ litest_event(keyboard, EV_KEY, KEY_A, 0);
+ litest_event(keyboard, EV_SYN, SYN_REPORT, 0);
+ libinput_dispatch(li);
- event = libinput_get_event(li);
- litest_is_switch_event(event,
- LIBINPUT_SWITCH_LID,
- LIBINPUT_SWITCH_STATE_OFF);
+ event = libinput_get_event(li);
+ litest_is_switch_event(event,
+ LIBINPUT_SWITCH_LID,
+ LIBINPUT_SWITCH_STATE_OFF);
+ libinput_event_destroy(event);
- litest_assert_only_typed_events(li, LIBINPUT_EVENT_KEYBOARD_KEY);
+ litest_assert_only_typed_events(li, LIBINPUT_EVENT_KEYBOARD_KEY);
- litest_switch_action(sw,
- LIBINPUT_SWITCH_LID,
- LIBINPUT_SWITCH_STATE_OFF);
- litest_assert_empty_queue(li);
+ litest_switch_action(sw,
+ LIBINPUT_SWITCH_LID,
+ LIBINPUT_SWITCH_STATE_OFF);
+ litest_assert_empty_queue(li);
+ }
- libinput_event_destroy(event);
litest_delete_device(keyboard);
}
END_TEST