mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-01-07 21:40:36 +01:00
test: make litest_wait_for_event_of_type auto-terminating
Wrap this in a macro so we cannot forget to pass -1 Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1048>
This commit is contained in:
parent
d0bec3843a
commit
0ec0a4212a
7 changed files with 20 additions and 31 deletions
|
|
@ -2991,7 +2991,7 @@ litest_wait_for_event(struct libinput *li)
|
|||
}
|
||||
|
||||
void
|
||||
litest_wait_for_event_of_type(struct libinput *li, ...)
|
||||
_litest_wait_for_event_of_type(struct libinput *li, ...)
|
||||
{
|
||||
va_list args;
|
||||
enum libinput_event_type types[32] = {LIBINPUT_EVENT_NONE};
|
||||
|
|
|
|||
|
|
@ -764,7 +764,10 @@ void
|
|||
litest_wait_for_event(struct libinput *li);
|
||||
|
||||
void
|
||||
litest_wait_for_event_of_type(struct libinput *li, ...);
|
||||
_litest_wait_for_event_of_type(struct libinput *li, ...);
|
||||
|
||||
#define litest_wait_for_event_of_type(li_, ...) \
|
||||
_litest_wait_for_event_of_type(li_, __VA_ARGS__, -1)
|
||||
|
||||
void
|
||||
litest_drain_events(struct libinput *li);
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ START_TEST(switch_down_on_init)
|
|||
libevdev_uinput_get_devnode(dev->uinput));
|
||||
libinput_dispatch(li);
|
||||
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_SWITCH_TOGGLE, -1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_SWITCH_TOGGLE);
|
||||
event = libinput_get_event(li);
|
||||
litest_is_switch_event(event, sw, LIBINPUT_SWITCH_STATE_ON);
|
||||
libinput_event_destroy(event);
|
||||
|
|
|
|||
|
|
@ -156,9 +156,7 @@ START_TEST(totem_proximity_in_on_init)
|
|||
libinput_path_add_device(li, devnode);
|
||||
libinput_dispatch(li);
|
||||
|
||||
litest_wait_for_event_of_type(li,
|
||||
LIBINPUT_EVENT_DEVICE_ADDED,
|
||||
-1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_DEVICE_ADDED);
|
||||
event = libinput_get_event(li);
|
||||
libinput_event_destroy(event);
|
||||
|
||||
|
|
@ -417,9 +415,7 @@ START_TEST(totem_button_down_on_init)
|
|||
libinput_path_add_device(li, devnode);
|
||||
libinput_dispatch(li);
|
||||
|
||||
litest_wait_for_event_of_type(li,
|
||||
LIBINPUT_EVENT_DEVICE_ADDED,
|
||||
-1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_DEVICE_ADDED);
|
||||
event = libinput_get_event(li);
|
||||
libinput_event_destroy(event);
|
||||
|
||||
|
|
|
|||
|
|
@ -201,9 +201,7 @@ START_TEST(touchpad_2fg_scroll_initially_diagonal)
|
|||
ydelta = 15 * ratio;
|
||||
litest_touch_move_two_touches(dev, 45, 30, 55, 30, 15, ydelta, 10);
|
||||
libinput_dispatch(li);
|
||||
litest_wait_for_event_of_type(li,
|
||||
LIBINPUT_EVENT_POINTER_AXIS,
|
||||
-1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_POINTER_AXIS);
|
||||
litest_drain_events(li);
|
||||
|
||||
/* get rid of any touch history still adding x deltas sideways */
|
||||
|
|
@ -351,9 +349,7 @@ START_TEST(touchpad_2fg_scroll_axis_lock_switch)
|
|||
/* Move roughly straight horizontally for >100ms to set axis lock */
|
||||
litest_touch_move_two_touches(dev, 20, 20, 25, 20, 55, 10, 15);
|
||||
libinput_dispatch(li);
|
||||
litest_wait_for_event_of_type(li,
|
||||
LIBINPUT_EVENT_POINTER_AXIS,
|
||||
-1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_POINTER_AXIS);
|
||||
|
||||
axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
|
||||
ck_assert(is_single_axis_2fg_scroll(dev, axis));
|
||||
|
|
@ -368,17 +364,13 @@ START_TEST(touchpad_2fg_scroll_axis_lock_switch)
|
|||
*/
|
||||
litest_touch_move_two_touches(dev, 75, 30, 80, 30, 2, 20, 15);
|
||||
libinput_dispatch(li);
|
||||
litest_wait_for_event_of_type(li,
|
||||
LIBINPUT_EVENT_POINTER_AXIS,
|
||||
-1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_POINTER_AXIS);
|
||||
litest_drain_events(li);
|
||||
|
||||
/* Move some more, roughly vertically, and check new axis lock */
|
||||
litest_touch_move_two_touches(dev, 77, 50, 82, 50, 1, 40, 15);
|
||||
libinput_dispatch(li);
|
||||
litest_wait_for_event_of_type(li,
|
||||
LIBINPUT_EVENT_POINTER_AXIS,
|
||||
-1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_POINTER_AXIS);
|
||||
|
||||
axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
|
||||
ck_assert(is_single_axis_2fg_scroll(dev, axis));
|
||||
|
|
@ -387,9 +379,7 @@ START_TEST(touchpad_2fg_scroll_axis_lock_switch)
|
|||
/* Move in a clear diagonal direction to ensure the lock releases */
|
||||
litest_touch_move_two_touches(dev, 78, 90, 83, 90, -60, -60, 20);
|
||||
libinput_dispatch(li);
|
||||
litest_wait_for_event_of_type(li,
|
||||
LIBINPUT_EVENT_POINTER_AXIS,
|
||||
-1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_POINTER_AXIS);
|
||||
|
||||
axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
|
||||
ck_assert(!is_single_axis_2fg_scroll(dev, axis));
|
||||
|
|
@ -488,7 +478,7 @@ START_TEST(touchpad_2fg_scroll_source)
|
|||
litest_drain_events(li);
|
||||
|
||||
test_2fg_scroll(dev, 0, 30, false);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_POINTER_AXIS, -1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_POINTER_AXIS);
|
||||
|
||||
while ((event = libinput_get_event(li))) {
|
||||
litest_is_axis_event(event,
|
||||
|
|
@ -938,7 +928,7 @@ START_TEST(touchpad_edge_scroll_timeout)
|
|||
litest_touch_up(dev, 0);
|
||||
libinput_dispatch(li);
|
||||
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_POINTER_AXIS, -1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_POINTER_AXIS);
|
||||
|
||||
while ((event = libinput_get_event(li))) {
|
||||
struct libinput_event_pointer *ptrev;
|
||||
|
|
@ -1022,7 +1012,7 @@ START_TEST(touchpad_edge_scroll_source)
|
|||
litest_touch_move_to(dev, 0, 99, 20, 99, 80, 10);
|
||||
litest_touch_up(dev, 0);
|
||||
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_POINTER_AXIS, -1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_POINTER_AXIS);
|
||||
|
||||
while ((event = libinput_get_event(li))) {
|
||||
struct libinput_event_pointer *ptrev;
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ START_TEST(trackpoint_scroll_source)
|
|||
litest_drain_events(li);
|
||||
|
||||
litest_button_scroll(dev, BTN_MIDDLE, 0, 6);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_POINTER_AXIS, -1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_POINTER_AXIS);
|
||||
|
||||
while ((event = libinput_get_event(li))) {
|
||||
ptrev = libinput_event_get_pointer_event(event);
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ START_TEST(udev_added_seat_default)
|
|||
* logical seat. This test may fail if there is a local rule changing
|
||||
* that, but it'll be fine for the 99% case. */
|
||||
dev = litest_create(LITEST_MOUSE, NULL, NULL, NULL, NULL);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_DEVICE_ADDED, -1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_DEVICE_ADDED);
|
||||
event = libinput_get_event(li);
|
||||
device = libinput_event_get_device(event);
|
||||
seat = libinput_device_get_seat(device);
|
||||
|
|
@ -244,7 +244,7 @@ START_TEST(udev_change_seat)
|
|||
* logical seat. This test may fail if there is a local rule changing
|
||||
* that, but it'll be fine for the 99% case. */
|
||||
dev = litest_create(LITEST_MOUSE, NULL, NULL, NULL, NULL);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_DEVICE_ADDED, -1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_DEVICE_ADDED);
|
||||
event = libinput_get_event(li);
|
||||
device = libinput_event_get_device(event);
|
||||
libinput_device_ref(device);
|
||||
|
|
@ -610,7 +610,7 @@ START_TEST(udev_path_remove_device)
|
|||
ck_assert_int_eq(libinput_udev_assign_seat(li, "seat0"), 0);
|
||||
libinput_dispatch(li);
|
||||
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_DEVICE_ADDED, -1);
|
||||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_DEVICE_ADDED);
|
||||
event = libinput_get_event(li);
|
||||
device = libinput_event_get_device(event);
|
||||
ck_assert_notnull(device);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue