mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 09:20:29 +01:00
test: add litest_is_button_event
Makes it easier from a caller to check for common things without all the other boilerplate code. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
a09476cdac
commit
88d1a52670
2 changed files with 23 additions and 7 deletions
|
|
@ -1321,16 +1321,13 @@ litest_create_uinput_device(const char *name, struct input_id *id, ...)
|
|||
return uinput;
|
||||
}
|
||||
|
||||
void
|
||||
litest_assert_button_event(struct libinput *li, unsigned int button,
|
||||
enum libinput_button_state state)
|
||||
struct libinput_event_pointer*
|
||||
litest_is_button_event(struct libinput_event *event,
|
||||
int button,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
struct libinput_event *event;
|
||||
struct libinput_event_pointer *ptrev;
|
||||
|
||||
litest_wait_for_event(li);
|
||||
event = libinput_get_event(li);
|
||||
|
||||
ck_assert(event != NULL);
|
||||
ck_assert_int_eq(libinput_event_get_type(event),
|
||||
LIBINPUT_EVENT_POINTER_BUTTON);
|
||||
|
|
@ -1339,6 +1336,21 @@ litest_assert_button_event(struct libinput *li, unsigned int button,
|
|||
button);
|
||||
ck_assert_int_eq(libinput_event_pointer_get_button_state(ptrev),
|
||||
state);
|
||||
|
||||
return ptrev;
|
||||
}
|
||||
|
||||
void
|
||||
litest_assert_button_event(struct libinput *li, unsigned int button,
|
||||
enum libinput_button_state state)
|
||||
{
|
||||
struct libinput_event *event;
|
||||
|
||||
litest_wait_for_event(li);
|
||||
event = libinput_get_event(li);
|
||||
|
||||
litest_is_button_event(event, button, state);
|
||||
|
||||
libinput_event_destroy(event);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -172,6 +172,10 @@ void litest_wait_for_event(struct libinput *li);
|
|||
void litest_wait_for_event_of_type(struct libinput *li, ...);
|
||||
void litest_drain_events(struct libinput *li);
|
||||
void litest_assert_empty_queue(struct libinput *li);
|
||||
struct libinput_event_pointer * litest_is_button_event(
|
||||
struct libinput_event *event,
|
||||
int button,
|
||||
enum libinput_button_state state);
|
||||
void litest_assert_button_event(struct libinput *li,
|
||||
unsigned int button,
|
||||
enum libinput_button_state state);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue