[PATCH libinput 4/7] test: add litest_is_motion_event() helper
Peter Hutterer
peter.hutterer at who-t.net
Mon May 4 22:43:06 PDT 2015
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
test/litest.c | 23 +++++++++++++++++++++++
test/litest.h | 2 ++
test/pointer.c | 14 ++------------
3 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/test/litest.c b/test/litest.c
index 563ee39..e7cf477 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -1366,6 +1366,29 @@ litest_is_axis_event(struct libinput_event *event,
return ptrev;
}
+struct libinput_event_pointer *
+litest_is_motion_event(struct libinput_event *event)
+{
+ struct libinput_event_pointer *ptrev;
+ enum libinput_event_type type = LIBINPUT_EVENT_POINTER_MOTION;
+ double x, y, ux, uy;
+
+ ck_assert(event != NULL);
+ ck_assert_int_eq(libinput_event_get_type(event), type);
+ ptrev = libinput_event_get_pointer_event(event);
+
+ x = libinput_event_pointer_get_dx(ptrev);
+ y = libinput_event_pointer_get_dy(ptrev);
+ ux = libinput_event_pointer_get_dx_unaccelerated(ptrev);
+ uy = libinput_event_pointer_get_dy_unaccelerated(ptrev);
+
+ /* No 0 delta motion events */
+ ck_assert(x != 0.0 || y != 0.0 ||
+ ux != 0.0 || uy != 0.0);
+
+ return ptrev;
+}
+
void
litest_assert_button_event(struct libinput *li, unsigned int button,
enum libinput_button_state state)
diff --git a/test/litest.h b/test/litest.h
index f2d267f..8f58ad2 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -182,6 +182,8 @@ struct libinput_event_pointer * litest_is_axis_event(
struct libinput_event *event,
enum libinput_pointer_axis axis,
enum libinput_pointer_axis_source source);
+struct libinput_event_pointer * litest_is_motion_event(
+ struct libinput_event *event);
void litest_assert_button_event(struct libinput *li,
unsigned int button,
enum libinput_button_state state);
diff --git a/test/pointer.c b/test/pointer.c
index 7784941..43c21ba 100644
--- a/test/pointer.c
+++ b/test/pointer.c
@@ -42,12 +42,7 @@ get_accelerated_motion_event(struct libinput *li)
while (1) {
event = libinput_get_event(li);
- ck_assert_notnull(event);
- ck_assert_int_eq(libinput_event_get_type(event),
- LIBINPUT_EVENT_POINTER_MOTION);
-
- ptrev = libinput_event_get_pointer_event(event);
- ck_assert_notnull(ptrev);
+ ptrev = litest_is_motion_event(event);
if (fabs(libinput_event_pointer_get_dx(ptrev)) < DBL_MIN &&
fabs(libinput_event_pointer_get_dy(ptrev)) < DBL_MIN) {
@@ -190,12 +185,7 @@ test_unaccel_event(struct litest_device *dev, int dx, int dy)
libinput_dispatch(li);
event = libinput_get_event(li);
- ck_assert_notnull(event);
- ck_assert_int_eq(libinput_event_get_type(event),
- LIBINPUT_EVENT_POINTER_MOTION);
-
- ptrev = libinput_event_get_pointer_event(event);
- ck_assert(ptrev != NULL);
+ ptrev = litest_is_motion_event(event);
ev_dx = libinput_event_pointer_get_dx_unaccelerated(ptrev);
ev_dy = libinput_event_pointer_get_dy_unaccelerated(ptrev);
--
2.3.5
More information about the wayland-devel
mailing list