mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-04 05:50:26 +01:00
test: add litest_push/pop_event_frame() helpers
For some tests we need to string multiple event sequences together into one event frame. Use a push/pop frame approach that stops litest from sending any EV_SYN/SYN_REPORT events, so we can merge two touches together by e.g. litest_push_event_frame(d); litest_touch_down(d, 0, 10, 10); litest_touch_down(d, 1, 20, 50); litest_pop_event_frame(d); Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
parent
e4adbff919
commit
4dce0648f6
2 changed files with 26 additions and 1 deletions
|
|
@ -634,7 +634,12 @@ void
|
|||
litest_event(struct litest_device *d, unsigned int type,
|
||||
unsigned int code, int value)
|
||||
{
|
||||
int ret = libevdev_uinput_write_event(d->uinput, type, code, value);
|
||||
int ret;
|
||||
|
||||
if (d->skip_ev_syn && type == EV_SYN && code == SYN_REPORT)
|
||||
return;
|
||||
|
||||
ret = libevdev_uinput_write_event(d->uinput, type, code, value);
|
||||
ck_assert_int_eq(ret, 0);
|
||||
}
|
||||
|
||||
|
|
@ -1135,3 +1140,18 @@ litest_timeout_softbuttons(void)
|
|||
{
|
||||
msleep(300);
|
||||
}
|
||||
|
||||
void
|
||||
litest_push_event_frame(struct litest_device *dev)
|
||||
{
|
||||
assert(!dev->skip_ev_syn);
|
||||
dev->skip_ev_syn = true;
|
||||
}
|
||||
|
||||
void
|
||||
litest_pop_event_frame(struct litest_device *dev)
|
||||
{
|
||||
assert(dev->skip_ev_syn);
|
||||
dev->skip_ev_syn = false;
|
||||
litest_event(dev, EV_SYN, SYN_REPORT, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,8 @@ struct litest_device {
|
|||
struct litest_device_interface *interface;
|
||||
|
||||
int ntouches_down;
|
||||
bool skip_ev_syn;
|
||||
|
||||
void *private; /* device-specific data */
|
||||
};
|
||||
|
||||
|
|
@ -161,6 +163,9 @@ struct libevdev_uinput * litest_create_uinput_abs_device(const char *name,
|
|||
void litest_timeout_tap(void);
|
||||
void litest_timeout_softbuttons(void);
|
||||
|
||||
void litest_push_event_frame(struct litest_device *dev);
|
||||
void litest_pop_event_frame(struct litest_device *dev);
|
||||
|
||||
#ifndef ck_assert_notnull
|
||||
#define ck_assert_notnull(ptr) ck_assert_ptr_ne(ptr, NULL)
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue