Skip to content

Commit

Permalink
test: add helper functions for checking proximity events
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
whot committed Feb 2, 2020
1 parent 736de2f commit 8705aba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
21 changes: 15 additions & 6 deletions test/litest.c
Original file line number Diff line number Diff line change
Expand Up @@ -3505,21 +3505,30 @@ litest_assert_tablet_button_event(struct libinput *li, unsigned int button,
libinput_event_destroy(event);
}

void litest_assert_tablet_proximity_event(struct libinput *li,
enum libinput_tablet_tool_proximity_state state)

struct libinput_event_tablet_tool *
litest_is_proximity_event(struct libinput_event *event,
enum libinput_tablet_tool_proximity_state state)
{
struct libinput_event *event;
struct libinput_event_tablet_tool *tev;
enum libinput_event_type type = LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY;

litest_wait_for_event(li);
event = libinput_get_event(li);

litest_assert_notnull(event);
litest_assert_event_type(event, type);
tev = libinput_event_get_tablet_tool_event(event);
litest_assert_int_eq(libinput_event_tablet_tool_get_proximity_state(tev),
state);
return tev;
}

void litest_assert_tablet_proximity_event(struct libinput *li,
enum libinput_tablet_tool_proximity_state state)
{
struct libinput_event *event;

litest_wait_for_event(li);
event = libinput_get_event(li);
litest_is_proximity_event(event, state);
libinput_event_destroy(event);
}

Expand Down
4 changes: 4 additions & 0 deletions test/litest.h
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,10 @@ litest_is_switch_event(struct libinput_event *event,
enum libinput_switch sw,
enum libinput_switch_state state);

struct libinput_event_tablet_tool *
litest_is_proximity_event(struct libinput_event *event,
enum libinput_tablet_tool_proximity_state state);

void
litest_assert_key_event(struct libinput *li, unsigned int key,
enum libinput_key_state state);
Expand Down

0 comments on commit 8705aba

Please sign in to comment.