Both functions accept a series of event types/codes tuples, terminated by -1.
For the even type INPUT_PROP_MAX (an invalid type otherwise) the code is used
as a property to enable.

The _abs function als takes an array of absinfo, with absinfo.value
determining the axis to change. If none are given, abs axes are initialized
with default settings.

Both functions abort on failure, so the caller does not need to check the
return value.

Example code for creating a rel device:

struct libevdev_uinput *uinput;
struct input_id id = { ... };
uinput = litest_create_uinput_device("foo", &id,
                                     EV_REL, REL_X,
                                     EV_REL, REL_Y,
                                     EV_KEY, BTN_LEFT,
                                     INPUT_PROP_MAX, INPUT_PROP_BUTTONPAD,
                                     -1);
libevdev_uinput_write_event(uinput, EV_REL, REL_X, -1);
libevdev_uinput_write_event(uinput, EV_SYN, SYN_REPORT, 0);
..
libevdev_uinput_destroy(uinput);

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
 test/litest-bcm5974.c               |  43 +++-----
 test/litest-generic-highres-touch.c |  34 +++---
 test/litest-synaptics-st.c          |  37 +++----
 test/litest-synaptics.c             |  43 +++-----
 test/litest-trackpoint.c            |  32 +++---
 test/litest-wacom-touch.c           |  33 ++----
 test/litest.c                       |  89 ++++++++++++++++
 test/litest.h                       |   9 ++
 test/path.c                         | 207 ++++++++++++------------------------
 9 files changed, 244 insertions(+), 283 deletions(-)

diff --git a/test/litest-bcm5974.c b/test/litest-bcm5974.c
index 5a8ce8a..c76a892 100644
--- a/test/litest-bcm5974.c
+++ b/test/litest-bcm5974.c
@@ -95,7 +95,6 @@ static struct litest_device_interface interface = {
 void
 litest_create_bcm5974(struct litest_device *d)
 {
-       struct libevdev *dev;
        struct input_absinfo abs[] = {
                { ABS_X, 1472, 5472, 75 },
                { ABS_Y, 1408, 4448, 129 },
@@ -107,34 +106,24 @@ litest_create_bcm5974(struct litest_device *d)
                { ABS_MT_TRACKING_ID, 0, 65535, 0 },
                { ABS_MT_PRESSURE, 0, 255, 0 }
        };
-       struct input_absinfo *a;
-       int rc;
+       struct input_id id = {
+               .bustype = 0x3,
+               .vendor = 0x5ac,
+               .product = 0x249,
+       };
 
        d->interface = &interface;
-
-       dev = libevdev_new();
-       ck_assert(dev != NULL);
-
-       libevdev_set_name(dev, "bcm5974");
-       libevdev_set_id_bustype(dev, 0x3);
-       libevdev_set_id_vendor(dev, 0x5ac);
-       libevdev_set_id_product(dev, 0x249);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_LEFT, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_FINGER, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_QUINTTAP, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOUCH, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_DOUBLETAP, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_TRIPLETAP, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_QUADTAP, NULL);
-
-       ARRAY_FOR_EACH(abs, a)
-               libevdev_enable_event_code(dev, EV_ABS, a->value, a);
-
-       rc = libevdev_uinput_create_from_device(dev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &d->uinput);
-       ck_assert_int_eq(rc, 0);
-       libevdev_free(dev);
+       d->uinput = litest_create_uinput_abs_device("bcm5974", &id,
+                                                   ARRAY_LENGTH(abs),
+                                                   abs,
+                                                   EV_KEY, BTN_LEFT,
+                                                   EV_KEY, BTN_TOOL_FINGER,
+                                                   EV_KEY, BTN_TOOL_QUINTTAP,
+                                                   EV_KEY, BTN_TOUCH,
+                                                   EV_KEY, BTN_TOOL_DOUBLETAP,
+                                                   EV_KEY, BTN_TOOL_TRIPLETAP,
+                                                   EV_KEY, BTN_TOOL_QUADTAP,
+                                                   -1, -1);
 }
 
 struct litest_test_device litest_bcm5974_device = {
diff --git a/test/litest-generic-highres-touch.c 
b/test/litest-generic-highres-touch.c
index 68615c3..0d239fd 100644
--- a/test/litest-generic-highres-touch.c
+++ b/test/litest-generic-highres-touch.c
@@ -94,9 +94,6 @@ static struct litest_device_interface interface = {
 void
 litest_create_generic_highres_touch(struct litest_device *d)
 {
-       struct libevdev *dev;
-       int rc;
-       struct input_absinfo *a;
        struct input_absinfo abs[] = {
                { ABS_X, 0, 32767, 75 },
                { ABS_Y, 0, 32767, 129 },
@@ -105,27 +102,20 @@ litest_create_generic_highres_touch(struct litest_device 
*d)
                { ABS_MT_POSITION_Y, 0, 32767, 0, 0, 9 },
                { ABS_MT_TRACKING_ID, 0, 65535, 0 },
        };
+       struct input_id id = {
+               .bustype = 0x3,
+               .vendor = 0xabcd, /* Some random vendor. */
+               .product = 0x1234, /* Some random product id. */
+       };
 
        d->interface = &interface;
-
-       dev = libevdev_new();
-       ck_assert(dev != NULL);
-
-       libevdev_set_name(dev, "Generic emulated highres touch device");
-       libevdev_set_id_bustype(dev, 0x3);
-       libevdev_set_id_vendor(dev, 0xabcd); /* Some random vendor. */
-       libevdev_set_id_product(dev, 0x1234); /* Some random product id. */
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOUCH, NULL);
-       libevdev_enable_property(dev, INPUT_PROP_DIRECT);
-
-       ARRAY_FOR_EACH(abs, a)
-               libevdev_enable_event_code(dev, EV_ABS, a->value, a);
-
-       rc = libevdev_uinput_create_from_device(dev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &d->uinput);
-       ck_assert_int_eq(rc, 0);
-       libevdev_free(dev);
+       d->uinput = litest_create_uinput_abs_device("Generic emulated highres 
touch device",
+                                                   &id,
+                                                   ARRAY_LENGTH(abs),
+                                                   abs,
+                                                   EV_KEY, BTN_TOUCH,
+                                                   INPUT_PROP_MAX, 
INPUT_PROP_DIRECT,
+                                                   -1, -1);
 }
 
 struct litest_test_device litest_generic_highres_touch_device = {
diff --git a/test/litest-synaptics-st.c b/test/litest-synaptics-st.c
index 2c7d371..bb9e7d9 100644
--- a/test/litest-synaptics-st.c
+++ b/test/litest-synaptics-st.c
@@ -98,38 +98,27 @@ static struct litest_device_interface interface = {
 void
 litest_create_synaptics_touchpad(struct litest_device *d)
 {
-       struct libevdev *dev;
        struct input_absinfo abs[] = {
                { ABS_X, 1472, 5472, 75 },
                { ABS_Y, 1408, 4448, 129 },
                { ABS_PRESSURE, 0, 255, 0 },
                { ABS_TOOL_WIDTH, 0, 15, 0 },
        };
-       struct input_absinfo *a;
-       int rc;
+       struct input_id id = {
+               .bustype = 0x11,
+               .vendor = 0x2,
+               .product = 0x7,
+       };
 
        d->interface = &interface;
-
-       dev = libevdev_new();
-       ck_assert(dev != NULL);
-
-       libevdev_set_name(dev, "SynPS/2 Synaptics TouchPad");
-       libevdev_set_id_bustype(dev, 0x11);
-       libevdev_set_id_vendor(dev, 0x2);
-       libevdev_set_id_product(dev, 0x7);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_LEFT, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_RIGHT, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_FINGER, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOUCH, NULL);
-
-       ARRAY_FOR_EACH(abs, a)
-               libevdev_enable_event_code(dev, EV_ABS, a->value, a);
-
-       rc = libevdev_uinput_create_from_device(dev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &d->uinput);
-       ck_assert_int_eq(rc, 0);
-       libevdev_free(dev);
+       d->uinput = litest_create_uinput_abs_device("SynPS/2 Synaptics 
TouchPad", &id,
+                                                   ARRAY_LENGTH(abs),
+                                                   abs,
+                                                   EV_KEY, BTN_LEFT,
+                                                   EV_KEY, BTN_RIGHT,
+                                                   EV_KEY, BTN_TOOL_FINGER,
+                                                   EV_KEY, BTN_TOUCH,
+                                                   -1, -1);
 }
 
 struct litest_test_device litest_synaptics_touchpad_device = {
diff --git a/test/litest-synaptics.c b/test/litest-synaptics.c
index e4a4783..d6aecc4 100644
--- a/test/litest-synaptics.c
+++ b/test/litest-synaptics.c
@@ -97,7 +97,6 @@ static struct litest_device_interface interface = {
 void
 litest_create_synaptics_clickpad(struct litest_device *d)
 {
-       struct libevdev *dev;
        struct input_absinfo abs[] = {
                { ABS_X, 1472, 5472, 75 },
                { ABS_Y, 1408, 4448, 129 },
@@ -109,34 +108,24 @@ litest_create_synaptics_clickpad(struct litest_device *d)
                { ABS_MT_TRACKING_ID, 0, 65535, 0 },
                { ABS_MT_PRESSURE, 0, 255, 0 }
        };
-       struct input_absinfo *a;
-       int rc;
+       struct input_id id = {
+               .bustype = 0x11,
+               .vendor = 0x2,
+               .product = 0x11,
+       };
 
        d->interface = &interface;
-
-       dev = libevdev_new();
-       ck_assert(dev != NULL);
-
-       libevdev_set_name(dev, "SynPS/2 Synaptics TouchPad");
-       libevdev_set_id_bustype(dev, 0x11);
-       libevdev_set_id_vendor(dev, 0x2);
-       libevdev_set_id_product(dev, 0x11);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_LEFT, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_FINGER, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_QUINTTAP, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOUCH, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_DOUBLETAP, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_TRIPLETAP, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOOL_QUADTAP, NULL);
-
-       ARRAY_FOR_EACH(abs, a)
-               libevdev_enable_event_code(dev, EV_ABS, a->value, a);
-
-       rc = libevdev_uinput_create_from_device(dev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &d->uinput);
-       ck_assert_int_eq(rc, 0);
-       libevdev_free(dev);
+       d->uinput = litest_create_uinput_abs_device("SynPS/2 Synaptics 
TouchPad", &id,
+                                                   ARRAY_LENGTH(abs),
+                                                   abs,
+                                                   EV_KEY, BTN_LEFT,
+                                                   EV_KEY, BTN_TOOL_FINGER,
+                                                   EV_KEY, BTN_TOOL_QUINTTAP,
+                                                   EV_KEY, BTN_TOUCH,
+                                                   EV_KEY, BTN_TOOL_DOUBLETAP,
+                                                   EV_KEY, BTN_TOOL_TRIPLETAP,
+                                                   EV_KEY, BTN_TOOL_QUADTAP,
+                                                   -1, -1);
 }
 
 struct litest_test_device litest_synaptics_clickpad_device = {
diff --git a/test/litest-trackpoint.c b/test/litest-trackpoint.c
index 68d5834..e0b79c5 100644
--- a/test/litest-trackpoint.c
+++ b/test/litest-trackpoint.c
@@ -40,28 +40,20 @@ static struct litest_device_interface interface = {
 static void
 litest_create_trackpoint(struct litest_device *d)
 {
-       struct libevdev *dev;
-       int rc;
+       struct input_id id = {
+               .bustype = 0x11,
+               .vendor = 0x2,
+               .product = 0xa,
+       };
 
        d->interface = &interface;
-       dev = libevdev_new();
-       ck_assert(dev != NULL);
-
-       libevdev_set_name(dev, "TPPS/2 IBM TrackPoint");
-       libevdev_set_id_bustype(dev, 0x11);
-       libevdev_set_id_vendor(dev, 0x2);
-       libevdev_set_id_product(dev, 0xa);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_LEFT, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_RIGHT, NULL);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_MIDDLE, NULL);
-       libevdev_enable_event_code(dev, EV_REL, REL_X, NULL);
-       libevdev_enable_event_code(dev, EV_REL, REL_Y, NULL);
-
-       rc = libevdev_uinput_create_from_device(dev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &d->uinput);
-       ck_assert_int_eq(rc, 0);
-       libevdev_free(dev);
+       d->uinput = litest_create_uinput_device("TPPS/2 IBM TrackPoint", &id,
+                                               EV_KEY, BTN_LEFT,
+                                               EV_KEY, BTN_RIGHT,
+                                               EV_KEY, BTN_MIDDLE,
+                                               EV_REL, REL_X,
+                                               EV_REL, REL_Y,
+                                               -1, -1);
 }
 
 struct litest_test_device litest_trackpoint_device = {
diff --git a/test/litest-wacom-touch.c b/test/litest-wacom-touch.c
index 464d541..180fde2 100644
--- a/test/litest-wacom-touch.c
+++ b/test/litest-wacom-touch.c
@@ -94,7 +94,6 @@ static struct litest_device_interface interface = {
 void
 litest_create_wacom_touch(struct litest_device *d)
 {
-       struct libevdev *dev;
        struct input_absinfo abs[] = {
                { ABS_X, 0, 2776, 75 },
                { ABS_Y, 0, 1569, 129 },
@@ -103,29 +102,19 @@ litest_create_wacom_touch(struct litest_device *d)
                { ABS_MT_POSITION_Y, 0, 1569, 0, 0, 9 },
                { ABS_MT_TRACKING_ID, 0, 65535, 0 },
        };
-       struct input_absinfo *a;
-       int rc;
+       struct input_id id = {
+               .bustype = 0x3,
+               .vendor = 0x56a,
+               .product = 0xe6,
+       };
 
        d->interface = &interface;
-
-       dev = libevdev_new();
-       ck_assert(dev != NULL);
-
-       libevdev_set_name(dev, "Wacom ISDv4 E6 Finger");
-       libevdev_set_id_bustype(dev, 0x3);
-       libevdev_set_id_vendor(dev, 0x56a);
-       libevdev_set_id_product(dev, 0xe6);
-       libevdev_enable_event_code(dev, EV_KEY, BTN_TOUCH, NULL);
-       libevdev_enable_property(dev, INPUT_PROP_DIRECT);
-
-       ARRAY_FOR_EACH(abs, a)
-               libevdev_enable_event_code(dev, EV_ABS, a->value, a);
-
-       rc = libevdev_uinput_create_from_device(dev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &d->uinput);
-       ck_assert_int_eq(rc, 0);
-       libevdev_free(dev);
+       d->uinput = litest_create_uinput_abs_device("Wacom ISDv4 E6 Finger", 
&id,
+                                                   ARRAY_LENGTH(abs),
+                                                   abs,
+                                                   EV_KEY, BTN_TOUCH,
+                                                   INPUT_PROP_MAX, 
INPUT_PROP_DIRECT,
+                                                   -1, -1);
 }
 
 struct litest_test_device litest_wacom_touch_device = {
diff --git a/test/litest.c b/test/litest.c
index 9241623..65d557b 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -490,3 +490,92 @@ litest_drain_events(struct libinput *li)
                libinput_dispatch(li);
        }
 }
+
+static struct libevdev_uinput *
+litest_create_uinput_abs_device_v(const char *name,
+                                 struct input_id *id,
+                                 size_t nabs,
+                                 const struct input_absinfo *abs,
+                                 va_list args)
+{
+       struct libevdev_uinput *uinput;
+       struct libevdev *dev;
+       int type, code;
+       int rc, i;
+       const struct input_absinfo default_abs = {
+               .value = 0,
+               .minimum = 0,
+               .maximum = 0xffff,
+               .fuzz = 0,
+               .flat = 0,
+               .resolution = 100
+       };
+
+       dev = libevdev_new();
+       ck_assert(dev != NULL);
+
+       libevdev_set_name(dev, name);
+       if (id) {
+               libevdev_set_id_bustype(dev, id->bustype);
+               libevdev_set_id_vendor(dev, id->vendor);
+               libevdev_set_id_product(dev, id->product);
+       }
+
+       for (i = 0; i < nabs; i++) {
+               rc = libevdev_enable_event_code(dev, EV_ABS,
+                                               abs[i].value, &abs[i]);
+               ck_assert_int_eq(rc, 0);
+       }
+
+       while ((type = va_arg(args, int)) != -1 &&
+              (code = va_arg(args, int)) != -1) {
+               if (type == INPUT_PROP_MAX) {
+                       rc = libevdev_enable_property(dev, code);
+               } else {
+                       if (type != EV_SYN)
+                               ck_assert(!libevdev_has_event_code(dev, type, 
code));
+                       rc = libevdev_enable_event_code(dev, type, code,
+                                                       type == EV_ABS ? 
&default_abs : NULL);
+               }
+               ck_assert_int_eq(rc, 0);
+       }
+
+       rc = libevdev_uinput_create_from_device(dev,
+                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
+                                               &uinput);
+       ck_assert_int_eq(rc, 0);
+
+       libevdev_free(dev);
+
+       return uinput;
+}
+
+struct libevdev_uinput *
+litest_create_uinput_abs_device(const char *name,
+                               struct input_id *id,
+                               size_t nabs,
+                               const struct input_absinfo *abs,
+                               ...)
+{
+       struct libevdev_uinput *uinput;
+       va_list args;
+
+       va_start(args, abs);
+       uinput = litest_create_uinput_abs_device_v(name, id, nabs, abs, args);
+       va_end(args);
+
+       return uinput;
+}
+
+struct libevdev_uinput *
+litest_create_uinput_device(const char *name, struct input_id *id, ...)
+{
+       struct libevdev_uinput *uinput;
+       va_list args;
+
+       va_start(args, id);
+       uinput = litest_create_uinput_abs_device_v(name, id, 0, NULL, args);
+       va_end(args);
+
+       return uinput;
+}
diff --git a/test/litest.h b/test/litest.h
index 9f0f614..256b76b 100644
--- a/test/litest.h
+++ b/test/litest.h
@@ -100,4 +100,13 @@ void litest_button_click(struct litest_device *d,
                         bool is_press);
 void litest_drain_events(struct libinput *li);
 
+struct libevdev_uinput * litest_create_uinput_device(const char *name,
+                                                    struct input_id *id,
+                                                    ...);
+struct libevdev_uinput * litest_create_uinput_abs_device(const char *name,
+                                                        struct input_id *id,
+                                                        size_t nabs,
+                                                        const struct 
input_absinfo *abs,
+                                                        ...);
+
 #endif /* LITEST_H */
diff --git a/test/path.c b/test/path.c
index 41ee5c6..e9f80cb 100644
--- a/test/path.c
+++ b/test/path.c
@@ -105,25 +105,16 @@ START_TEST(path_create_destroy)
 {
        struct libinput *li;
        struct libinput_device *device;
-       struct libevdev *evdev;
        struct libevdev_uinput *uinput;
        int rc;
        void *userdata = &rc;
 
-       evdev = libevdev_new();
-       ck_assert(evdev != NULL);
-
-       libevdev_set_name(evdev, "test device");
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_LEFT, NULL);
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_RIGHT, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_X, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_Y, NULL);
-
-       rc = libevdev_uinput_create_from_device(evdev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &uinput);
-       ck_assert_int_eq(rc, 0);
-       libevdev_free(evdev);
+       uinput = litest_create_uinput_device("test device", NULL,
+                                            EV_KEY, BTN_LEFT,
+                                            EV_KEY, BTN_RIGHT,
+                                            EV_REL, REL_X,
+                                            EV_REL, REL_Y,
+                                            -1);
 
        li = libinput_path_create_context(&simple_interface, userdata);
        ck_assert(li != NULL);
@@ -360,25 +351,16 @@ START_TEST(path_suspend)
 {
        struct libinput *li;
        struct libinput_device *device;
-       struct libevdev *evdev;
        struct libevdev_uinput *uinput;
        int rc;
        void *userdata = &rc;
 
-       evdev = libevdev_new();
-       ck_assert(evdev != NULL);
-
-       libevdev_set_name(evdev, "test device");
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_LEFT, NULL);
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_RIGHT, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_X, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_Y, NULL);
-
-       rc = libevdev_uinput_create_from_device(evdev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &uinput);
-       ck_assert_int_eq(rc, 0);
-       libevdev_free(evdev);
+       uinput = litest_create_uinput_device("test device", NULL,
+                                            EV_KEY, BTN_LEFT,
+                                            EV_KEY, BTN_RIGHT,
+                                            EV_REL, REL_X,
+                                            EV_REL, REL_Y,
+                                            -1);
 
        li = libinput_path_create_context(&simple_interface, userdata);
        ck_assert(li != NULL);
@@ -402,25 +384,16 @@ START_TEST(path_double_suspend)
 {
        struct libinput *li;
        struct libinput_device *device;
-       struct libevdev *evdev;
        struct libevdev_uinput *uinput;
        int rc;
        void *userdata = &rc;
 
-       evdev = libevdev_new();
-       ck_assert(evdev != NULL);
-
-       libevdev_set_name(evdev, "test device");
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_LEFT, NULL);
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_RIGHT, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_X, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_Y, NULL);
-
-       rc = libevdev_uinput_create_from_device(evdev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &uinput);
-       ck_assert_int_eq(rc, 0);
-       libevdev_free(evdev);
+       uinput = litest_create_uinput_device("test device", NULL,
+                                            EV_KEY, BTN_LEFT,
+                                            EV_KEY, BTN_RIGHT,
+                                            EV_REL, REL_X,
+                                            EV_REL, REL_Y,
+                                            -1);
 
        li = libinput_path_create_context(&simple_interface, userdata);
        ck_assert(li != NULL);
@@ -445,25 +418,16 @@ START_TEST(path_double_resume)
 {
        struct libinput *li;
        struct libinput_device *device;
-       struct libevdev *evdev;
        struct libevdev_uinput *uinput;
        int rc;
        void *userdata = &rc;
 
-       evdev = libevdev_new();
-       ck_assert(evdev != NULL);
-
-       libevdev_set_name(evdev, "test device");
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_LEFT, NULL);
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_RIGHT, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_X, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_Y, NULL);
-
-       rc = libevdev_uinput_create_from_device(evdev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &uinput);
-       ck_assert_int_eq(rc, 0);
-       libevdev_free(evdev);
+       uinput = litest_create_uinput_device("test device", NULL,
+                                            EV_KEY, BTN_LEFT,
+                                            EV_KEY, BTN_RIGHT,
+                                            EV_REL, REL_X,
+                                            EV_REL, REL_Y,
+                                            -1);
 
        li = libinput_path_create_context(&simple_interface, userdata);
        ck_assert(li != NULL);
@@ -489,33 +453,23 @@ START_TEST(path_add_device_suspend_resume)
        struct libinput *li;
        struct libinput_device *device;
        struct libinput_event *event;
-       struct libevdev *evdev;
        struct libevdev_uinput *uinput1, *uinput2;
        int rc;
        int nevents;
        void *userdata = &rc;
 
-       evdev = libevdev_new();
-       ck_assert(evdev != NULL);
-
-       libevdev_set_name(evdev, "test device");
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_LEFT, NULL);
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_RIGHT, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_X, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_Y, NULL);
-
-       rc = libevdev_uinput_create_from_device(evdev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &uinput1);
-       ck_assert_int_eq(rc, 0);
-
-       libevdev_set_name(evdev, "test device 2");
-       rc = libevdev_uinput_create_from_device(evdev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &uinput2);
-       ck_assert_int_eq(rc, 0);
-
-       libevdev_free(evdev);
+       uinput1 = litest_create_uinput_device("test device", NULL,
+                                             EV_KEY, BTN_LEFT,
+                                             EV_KEY, BTN_RIGHT,
+                                             EV_REL, REL_X,
+                                             EV_REL, REL_Y,
+                                             -1);
+       uinput2 = litest_create_uinput_device("test device 2", NULL,
+                                             EV_KEY, BTN_LEFT,
+                                             EV_KEY, BTN_RIGHT,
+                                             EV_REL, REL_X,
+                                             EV_REL, REL_Y,
+                                             -1);
 
        li = libinput_path_create_context(&simple_interface, userdata);
        ck_assert(li != NULL);
@@ -582,33 +536,23 @@ START_TEST(path_add_device_suspend_resume_fail)
        struct libinput *li;
        struct libinput_device *device;
        struct libinput_event *event;
-       struct libevdev *evdev;
        struct libevdev_uinput *uinput1, *uinput2;
        int rc;
        int nevents;
        void *userdata = &rc;
 
-       evdev = libevdev_new();
-       ck_assert(evdev != NULL);
-
-       libevdev_set_name(evdev, "test device");
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_LEFT, NULL);
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_RIGHT, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_X, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_Y, NULL);
-
-       rc = libevdev_uinput_create_from_device(evdev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &uinput1);
-       ck_assert_int_eq(rc, 0);
-
-       libevdev_set_name(evdev, "test device 2");
-       rc = libevdev_uinput_create_from_device(evdev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &uinput2);
-       ck_assert_int_eq(rc, 0);
-
-       libevdev_free(evdev);
+       uinput1 = litest_create_uinput_device("test device", NULL,
+                                             EV_KEY, BTN_LEFT,
+                                             EV_KEY, BTN_RIGHT,
+                                             EV_REL, REL_X,
+                                             EV_REL, REL_Y,
+                                             -1);
+       uinput2 = litest_create_uinput_device("test device 2", NULL,
+                                             EV_KEY, BTN_LEFT,
+                                             EV_KEY, BTN_RIGHT,
+                                             EV_REL, REL_X,
+                                             EV_REL, REL_Y,
+                                             -1);
 
        li = libinput_path_create_context(&simple_interface, userdata);
        ck_assert(li != NULL);
@@ -683,33 +627,23 @@ START_TEST(path_add_device_suspend_resume_remove_device)
        struct libinput *li;
        struct libinput_device *device;
        struct libinput_event *event;
-       struct libevdev *evdev;
        struct libevdev_uinput *uinput1, *uinput2;
        int rc;
        int nevents;
        void *userdata = &rc;
 
-       evdev = libevdev_new();
-       ck_assert(evdev != NULL);
-
-       libevdev_set_name(evdev, "test device");
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_LEFT, NULL);
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_RIGHT, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_X, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_Y, NULL);
-
-       rc = libevdev_uinput_create_from_device(evdev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &uinput1);
-       ck_assert_int_eq(rc, 0);
-
-       libevdev_set_name(evdev, "test device 2");
-       rc = libevdev_uinput_create_from_device(evdev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &uinput2);
-       ck_assert_int_eq(rc, 0);
-
-       libevdev_free(evdev);
+       uinput1 = litest_create_uinput_device("test device", NULL,
+                                             EV_KEY, BTN_LEFT,
+                                             EV_KEY, BTN_RIGHT,
+                                             EV_REL, REL_X,
+                                             EV_REL, REL_Y,
+                                             -1);
+       uinput2 = litest_create_uinput_device("test device 2", NULL,
+                                             EV_KEY, BTN_LEFT,
+                                             EV_KEY, BTN_RIGHT,
+                                             EV_REL, REL_X,
+                                             EV_REL, REL_Y,
+                                             -1);
 
        li = libinput_path_create_context(&simple_interface, userdata);
        ck_assert(li != NULL);
@@ -781,7 +715,6 @@ END_TEST
 START_TEST(path_seat_recycle)
 {
        struct libinput *li;
-       struct libevdev *evdev;
        struct libevdev_uinput *uinput;
        int rc;
        void *userdata = &rc;
@@ -793,20 +726,12 @@ START_TEST(path_seat_recycle)
        int found = 0;
        void *user_data;
 
-       evdev = libevdev_new();
-       ck_assert(evdev != NULL);
-
-       libevdev_set_name(evdev, "test device");
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_LEFT, NULL);
-       libevdev_enable_event_code(evdev, EV_KEY, BTN_RIGHT, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_X, NULL);
-       libevdev_enable_event_code(evdev, EV_REL, REL_Y, NULL);
-
-       rc = libevdev_uinput_create_from_device(evdev,
-                                               LIBEVDEV_UINPUT_OPEN_MANAGED,
-                                               &uinput);
-       ck_assert_int_eq(rc, 0);
-       libevdev_free(evdev);
+       uinput = litest_create_uinput_device("test device", NULL,
+                                            EV_KEY, BTN_LEFT,
+                                            EV_KEY, BTN_RIGHT,
+                                            EV_REL, REL_X,
+                                            EV_REL, REL_Y,
+                                            -1);
 
        li = libinput_path_create_context(&simple_interface, userdata);
        ck_assert(li != NULL);
-- 
1.8.5.3

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to