summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-07-15 15:35:20 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-07-21 08:56:12 +1000
commite1484cb7f820ae8284140d3a5ece43b564f19b45 (patch)
treee48b843b4a9cc5663d2faf140bc5192fbb481cf2
parent475665efdf21641d5f18c02c3862138197c33466 (diff)
downloadlibinput-e1484cb7f820ae8284140d3a5ece43b564f19b45.tar.gz
test: set the abs resolution after creating the device
Until uinput gets that capability (likely not before 3.17) all we can do is a racy approach of setting it after creating it. That won't work well for anything test where libinput is already listening to udev when the device is created, but it does work for those cases where libinput is started after the device was initialized. And it's a better alternative than not testing anything dependent on resolution settings. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--test/litest.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/test/litest.c b/test/litest.c
index 452cb770..1ffbd53d 100644
--- a/test/litest.c
+++ b/test/litest.c
@@ -811,13 +811,14 @@ litest_assert_empty_queue(struct libinput *li)
struct libevdev_uinput *
litest_create_uinput_device_from_description(const char *name,
const struct input_id *id,
- const struct input_absinfo *abs,
+ const struct input_absinfo *abs_info,
const int *events)
{
struct libevdev_uinput *uinput;
struct libevdev *dev;
int type, code;
- int rc;
+ int rc, fd;
+ const struct input_absinfo *abs;
const struct input_absinfo default_abs = {
.value = 0,
.minimum = 0,
@@ -827,6 +828,7 @@ litest_create_uinput_device_from_description(const char *name,
.resolution = 100
};
char buf[512];
+ const char *devnode;
dev = libevdev_new();
ck_assert(dev != NULL);
@@ -839,6 +841,7 @@ litest_create_uinput_device_from_description(const char *name,
libevdev_set_id_product(dev, id->product);
}
+ abs = abs_info;
while (abs && abs->value != -1) {
rc = libevdev_enable_event_code(dev, EV_ABS,
abs->value, abs);
@@ -867,6 +870,31 @@ litest_create_uinput_device_from_description(const char *name,
libevdev_free(dev);
+ /* uinput does not yet support setting the resolution, so we set it
+ * afterwards. This is of course racy as hell but the way we
+ * _generally_ use this function by the time libinput uses the
+ * device, we're finished here */
+
+ devnode = libevdev_uinput_get_devnode(uinput);
+ ck_assert_notnull(devnode);
+ fd = open(devnode, O_RDONLY);
+ ck_assert_int_gt(fd, -1);
+ rc = libevdev_new_from_fd(fd, &dev);
+ ck_assert_int_eq(rc, 0);
+
+ abs = abs_info;
+ while (abs && abs->value != -1) {
+ if (abs->resolution != 0) {
+ rc = libevdev_kernel_set_abs_info(dev,
+ abs->value,
+ abs);
+ ck_assert_int_eq(rc, 0);
+ }
+ abs++;
+ }
+ close(fd);
+ libevdev_free(dev);
+
return uinput;
}