mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 10:00:27 +01:00
test: add litest_is_touch_event() helper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
77eb2d5445
commit
cbfbede748
3 changed files with 34 additions and 10 deletions
|
|
@ -1531,6 +1531,33 @@ litest_assert_button_event(struct libinput *li, unsigned int button,
|
|||
libinput_event_destroy(event);
|
||||
}
|
||||
|
||||
struct libinput_event_touch *
|
||||
litest_is_touch_event(struct libinput_event *event,
|
||||
enum libinput_event_type type)
|
||||
{
|
||||
struct libinput_event_touch *touch;
|
||||
|
||||
ck_assert(event != NULL);
|
||||
|
||||
if (type == 0)
|
||||
type = libinput_event_get_type(event);
|
||||
|
||||
switch (type) {
|
||||
case LIBINPUT_EVENT_TOUCH_DOWN:
|
||||
case LIBINPUT_EVENT_TOUCH_UP:
|
||||
case LIBINPUT_EVENT_TOUCH_MOTION:
|
||||
case LIBINPUT_EVENT_TOUCH_FRAME:
|
||||
ck_assert_int_eq(libinput_event_get_type(event), type);
|
||||
break;
|
||||
default:
|
||||
ck_abort_msg("%s: invalid touch type %d\n", __func__, type);
|
||||
}
|
||||
|
||||
touch = libinput_event_get_touch_event(event);
|
||||
|
||||
return touch;
|
||||
}
|
||||
|
||||
void
|
||||
litest_assert_scroll(struct libinput *li,
|
||||
enum libinput_pointer_axis axis,
|
||||
|
|
|
|||
|
|
@ -206,6 +206,9 @@ struct libinput_event_pointer * litest_is_axis_event(
|
|||
enum libinput_pointer_axis_source source);
|
||||
struct libinput_event_pointer * litest_is_motion_event(
|
||||
struct libinput_event *event);
|
||||
struct libinput_event_touch * litest_is_touch_event(
|
||||
struct libinput_event *event,
|
||||
enum libinput_event_type type);
|
||||
void litest_assert_button_event(struct libinput *li,
|
||||
unsigned int button,
|
||||
enum libinput_button_state state);
|
||||
|
|
|
|||
14
test/touch.c
14
test/touch.c
|
|
@ -244,9 +244,7 @@ START_TEST(touch_calibration_scale)
|
|||
|
||||
litest_wait_for_event(li);
|
||||
ev = libinput_get_event(li);
|
||||
ck_assert_int_eq(libinput_event_get_type(ev),
|
||||
LIBINPUT_EVENT_TOUCH_DOWN);
|
||||
tev = libinput_event_get_touch_event(ev);
|
||||
tev = litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_DOWN);
|
||||
|
||||
x = libinput_event_touch_get_x_transformed(tev, width);
|
||||
y = libinput_event_touch_get_y_transformed(tev, height);
|
||||
|
|
@ -315,9 +313,7 @@ START_TEST(touch_calibration_rotation)
|
|||
litest_touch_up(dev, 0);
|
||||
litest_wait_for_event(li);
|
||||
ev = libinput_get_event(li);
|
||||
ck_assert_int_eq(libinput_event_get_type(ev),
|
||||
LIBINPUT_EVENT_TOUCH_DOWN);
|
||||
tev = libinput_event_get_touch_event(ev);
|
||||
tev = litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_DOWN);
|
||||
|
||||
x = libinput_event_touch_get_x_transformed(tev, width);
|
||||
y = libinput_event_touch_get_y_transformed(tev, height);
|
||||
|
|
@ -381,9 +377,7 @@ START_TEST(touch_calibration_translation)
|
|||
|
||||
litest_wait_for_event(li);
|
||||
ev = libinput_get_event(li);
|
||||
ck_assert_int_eq(libinput_event_get_type(ev),
|
||||
LIBINPUT_EVENT_TOUCH_DOWN);
|
||||
tev = libinput_event_get_touch_event(ev);
|
||||
tev = litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_DOWN);
|
||||
|
||||
x = libinput_event_touch_get_x_transformed(tev, width);
|
||||
y = libinput_event_touch_get_y_transformed(tev, height);
|
||||
|
|
@ -499,7 +493,7 @@ START_TEST(touch_protocol_a_touch)
|
|||
litest_wait_for_event_of_type(li, LIBINPUT_EVENT_TOUCH_DOWN, -1);
|
||||
|
||||
ev = libinput_get_event(li);
|
||||
tev = libinput_event_get_touch_event(ev);
|
||||
tev = litest_is_touch_event(ev, LIBINPUT_EVENT_TOUCH_DOWN);
|
||||
|
||||
oldx = libinput_event_touch_get_x(tev);
|
||||
oldy = libinput_event_touch_get_y(tev);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue