Re: [PATCH libinput] test: Add seat slot tests
On Mon, Feb 24, 2014 at 10:52:38AM +1000, Peter Hutterer wrote: On Sat, Feb 22, 2014 at 03:38:28PM +0100, Jonas Ådahl wrote: Add one test that checks uniqueness of seat slots when having multiple devices with active touch points. Add one test that checks that libinput drops touch points when it could not represent them with a seat wide slot. This commit also adds support for from a test case add test devices to an existing libinput context. Only litest-wacom-touch supports this so far. Signed-off-by: Jonas Ådahl jad...@gmail.com --- Needs to be applied after 'Split up the touch event into the different touch types'. test/litest-wacom-touch.c | 24 ++- test/litest.c | 30 - test/litest.h | 13 +++- test/touch.c | 156 ++ 4 files changed, 217 insertions(+), 6 deletions(-) diff --git a/test/litest-wacom-touch.c b/test/litest-wacom-touch.c index 464d541..a6c22ef 100644 --- a/test/litest-wacom-touch.c +++ b/test/litest-wacom-touch.c @@ -24,11 +24,22 @@ #include config.h #endif +#include stdio.h + #include litest.h #include litest-int.h #include libinput-util.h -void litest_wacom_touch_setup(void) +static int device_ids = 0; + +static void +litest_wacom_touch_destroy(struct litest_device *dev) +{ + device_ids = ~dev-device_id; +} + +void +litest_wacom_touch_setup(void) { struct litest_device *d = litest_create_device(LITEST_WACOM_TOUCH); litest_set_current_device(d); @@ -104,14 +115,23 @@ litest_create_wacom_touch(struct litest_device *d) { ABS_MT_TRACKING_ID, 0, 65535, 0 }, }; struct input_absinfo *a; + char name[256]; + int device_id; int rc; d-interface = interface; + d-destroy = litest_wacom_touch_destroy; dev = libevdev_new(); ck_assert(dev != NULL); - libevdev_set_name(dev, Wacom ISDv4 E6 Finger); + device_id = ffs(~device_ids) - 1; + ck_assert_int_ge(device_id, 0); + device_ids |= 1 device_id; + d-device_id = device_id; + snprintf(name, sizeof name, Wacom ISDv4 E6 Finger (%d), device_id); + libevdev_set_name(dev, name); + IMO the actual devices should stay as close to the real thing as possible. That leaves us, for this test, with two options: put a 1.5s sleep in to avoid the uinput duplicate issue, or push this code into the generic touch device that you created for the scaling overflow issue. with that we have more freedom of messing around with the device name. Moving to the generic touch device seems like the better way, so I'll do that. Thanks. Jonas libevdev_set_id_bustype(dev, 0x3); libevdev_set_id_vendor(dev, 0x56a); libevdev_set_id_product(dev, 0xe6); diff --git a/test/litest.c b/test/litest.c index 78a0472..e69f354 100644 --- a/test/litest.c +++ b/test/litest.c @@ -325,8 +325,15 @@ const struct libinput_interface interface = { .close_restricted = close_restricted, }; +const struct libinput_interface * +litest_get_libinput_interface() +{ + return interface; +} + struct litest_device * -litest_create_device(enum litest_device_type which) +litest_create_device_for(struct libinput *libinput, +enum litest_device_type which) { struct litest_device *d = zalloc(sizeof(*d)); int fd; @@ -358,7 +365,7 @@ litest_create_device(enum litest_device_type which) rc = libevdev_new_from_fd(fd, d-evdev); ck_assert_int_eq(rc, 0); - d-libinput = libinput_path_create_context(interface, NULL); + d-libinput = libinput; ck_assert(d-libinput != NULL); d-libinput_device = libinput_path_add_device(d-libinput, path); @@ -372,6 +379,19 @@ litest_create_device(enum litest_device_type which) return d; } +struct litest_device * +litest_create_device(enum litest_device_type which) +{ + struct libinput *libinput; + struct litest_device *d; + + libinput = libinput_path_create_context(interface, NULL); + d = litest_create_device_for(libinput, which); + d-owns_context = true; + + return d; +} + int litest_handle_events(struct litest_device *d) { @@ -392,8 +412,12 @@ litest_delete_device(struct litest_device *d) if (!d) return; + if (d-destroy) + d-destroy(d); + libinput_device_unref(d-libinput_device); - libinput_destroy(d-libinput); + if (d-owns_context) + libinput_destroy(d-libinput); libevdev_free(d-evdev); libevdev_uinput_destroy(d-uinput); memset(d,0, sizeof(*d)); diff --git a/test/litest.h b/test/litest.h index 9cc0ff5..fef051d 100644 --- a/test/litest.h +++ b/test/litest.h @@ -60,8 +60,11 @@ struct litest_device { struct libevdev *evdev; struct libevdev_uinput *uinput;
Re: [PATCH libinput] test: Add seat slot tests
On Sat, Feb 22, 2014 at 03:38:28PM +0100, Jonas Ådahl wrote: Add one test that checks uniqueness of seat slots when having multiple devices with active touch points. Add one test that checks that libinput drops touch points when it could not represent them with a seat wide slot. This commit also adds support for from a test case add test devices to an existing libinput context. Only litest-wacom-touch supports this so far. Signed-off-by: Jonas Ådahl jad...@gmail.com --- Needs to be applied after 'Split up the touch event into the different touch types'. test/litest-wacom-touch.c | 24 ++- test/litest.c | 30 - test/litest.h | 13 +++- test/touch.c | 156 ++ 4 files changed, 217 insertions(+), 6 deletions(-) diff --git a/test/litest-wacom-touch.c b/test/litest-wacom-touch.c index 464d541..a6c22ef 100644 --- a/test/litest-wacom-touch.c +++ b/test/litest-wacom-touch.c @@ -24,11 +24,22 @@ #include config.h #endif +#include stdio.h + #include litest.h #include litest-int.h #include libinput-util.h -void litest_wacom_touch_setup(void) +static int device_ids = 0; + +static void +litest_wacom_touch_destroy(struct litest_device *dev) +{ + device_ids = ~dev-device_id; +} + +void +litest_wacom_touch_setup(void) { struct litest_device *d = litest_create_device(LITEST_WACOM_TOUCH); litest_set_current_device(d); @@ -104,14 +115,23 @@ litest_create_wacom_touch(struct litest_device *d) { ABS_MT_TRACKING_ID, 0, 65535, 0 }, }; struct input_absinfo *a; + char name[256]; + int device_id; int rc; d-interface = interface; + d-destroy = litest_wacom_touch_destroy; dev = libevdev_new(); ck_assert(dev != NULL); - libevdev_set_name(dev, Wacom ISDv4 E6 Finger); + device_id = ffs(~device_ids) - 1; + ck_assert_int_ge(device_id, 0); + device_ids |= 1 device_id; + d-device_id = device_id; + snprintf(name, sizeof name, Wacom ISDv4 E6 Finger (%d), device_id); + libevdev_set_name(dev, name); + IMO the actual devices should stay as close to the real thing as possible. That leaves us, for this test, with two options: put a 1.5s sleep in to avoid the uinput duplicate issue, or push this code into the generic touch device that you created for the scaling overflow issue. with that we have more freedom of messing around with the device name. libevdev_set_id_bustype(dev, 0x3); libevdev_set_id_vendor(dev, 0x56a); libevdev_set_id_product(dev, 0xe6); diff --git a/test/litest.c b/test/litest.c index 78a0472..e69f354 100644 --- a/test/litest.c +++ b/test/litest.c @@ -325,8 +325,15 @@ const struct libinput_interface interface = { .close_restricted = close_restricted, }; +const struct libinput_interface * +litest_get_libinput_interface() +{ + return interface; +} + struct litest_device * -litest_create_device(enum litest_device_type which) +litest_create_device_for(struct libinput *libinput, + enum litest_device_type which) { struct litest_device *d = zalloc(sizeof(*d)); int fd; @@ -358,7 +365,7 @@ litest_create_device(enum litest_device_type which) rc = libevdev_new_from_fd(fd, d-evdev); ck_assert_int_eq(rc, 0); - d-libinput = libinput_path_create_context(interface, NULL); + d-libinput = libinput; ck_assert(d-libinput != NULL); d-libinput_device = libinput_path_add_device(d-libinput, path); @@ -372,6 +379,19 @@ litest_create_device(enum litest_device_type which) return d; } +struct litest_device * +litest_create_device(enum litest_device_type which) +{ + struct libinput *libinput; + struct litest_device *d; + + libinput = libinput_path_create_context(interface, NULL); + d = litest_create_device_for(libinput, which); + d-owns_context = true; + + return d; +} + int litest_handle_events(struct litest_device *d) { @@ -392,8 +412,12 @@ litest_delete_device(struct litest_device *d) if (!d) return; + if (d-destroy) + d-destroy(d); + libinput_device_unref(d-libinput_device); - libinput_destroy(d-libinput); + if (d-owns_context) + libinput_destroy(d-libinput); libevdev_free(d-evdev); libevdev_uinput_destroy(d-uinput); memset(d,0, sizeof(*d)); diff --git a/test/litest.h b/test/litest.h index 9cc0ff5..fef051d 100644 --- a/test/litest.h +++ b/test/litest.h @@ -60,8 +60,11 @@ struct litest_device { struct libevdev *evdev; struct libevdev_uinput *uinput; struct libinput *libinput; + void (*destroy)(struct litest_device *d); + bool owns_context; struct libinput_device *libinput_device; struct litest_device_interface *interface; + int
[PATCH libinput] test: Add seat slot tests
Add one test that checks uniqueness of seat slots when having multiple devices with active touch points. Add one test that checks that libinput drops touch points when it could not represent them with a seat wide slot. This commit also adds support for from a test case add test devices to an existing libinput context. Only litest-wacom-touch supports this so far. Signed-off-by: Jonas Ådahl jad...@gmail.com --- Needs to be applied after 'Split up the touch event into the different touch types'. test/litest-wacom-touch.c | 24 ++- test/litest.c | 30 - test/litest.h | 13 +++- test/touch.c | 156 ++ 4 files changed, 217 insertions(+), 6 deletions(-) diff --git a/test/litest-wacom-touch.c b/test/litest-wacom-touch.c index 464d541..a6c22ef 100644 --- a/test/litest-wacom-touch.c +++ b/test/litest-wacom-touch.c @@ -24,11 +24,22 @@ #include config.h #endif +#include stdio.h + #include litest.h #include litest-int.h #include libinput-util.h -void litest_wacom_touch_setup(void) +static int device_ids = 0; + +static void +litest_wacom_touch_destroy(struct litest_device *dev) +{ + device_ids = ~dev-device_id; +} + +void +litest_wacom_touch_setup(void) { struct litest_device *d = litest_create_device(LITEST_WACOM_TOUCH); litest_set_current_device(d); @@ -104,14 +115,23 @@ litest_create_wacom_touch(struct litest_device *d) { ABS_MT_TRACKING_ID, 0, 65535, 0 }, }; struct input_absinfo *a; + char name[256]; + int device_id; int rc; d-interface = interface; + d-destroy = litest_wacom_touch_destroy; dev = libevdev_new(); ck_assert(dev != NULL); - libevdev_set_name(dev, Wacom ISDv4 E6 Finger); + device_id = ffs(~device_ids) - 1; + ck_assert_int_ge(device_id, 0); + device_ids |= 1 device_id; + d-device_id = device_id; + snprintf(name, sizeof name, Wacom ISDv4 E6 Finger (%d), device_id); + libevdev_set_name(dev, name); + libevdev_set_id_bustype(dev, 0x3); libevdev_set_id_vendor(dev, 0x56a); libevdev_set_id_product(dev, 0xe6); diff --git a/test/litest.c b/test/litest.c index 78a0472..e69f354 100644 --- a/test/litest.c +++ b/test/litest.c @@ -325,8 +325,15 @@ const struct libinput_interface interface = { .close_restricted = close_restricted, }; +const struct libinput_interface * +litest_get_libinput_interface() +{ + return interface; +} + struct litest_device * -litest_create_device(enum litest_device_type which) +litest_create_device_for(struct libinput *libinput, +enum litest_device_type which) { struct litest_device *d = zalloc(sizeof(*d)); int fd; @@ -358,7 +365,7 @@ litest_create_device(enum litest_device_type which) rc = libevdev_new_from_fd(fd, d-evdev); ck_assert_int_eq(rc, 0); - d-libinput = libinput_path_create_context(interface, NULL); + d-libinput = libinput; ck_assert(d-libinput != NULL); d-libinput_device = libinput_path_add_device(d-libinput, path); @@ -372,6 +379,19 @@ litest_create_device(enum litest_device_type which) return d; } +struct litest_device * +litest_create_device(enum litest_device_type which) +{ + struct libinput *libinput; + struct litest_device *d; + + libinput = libinput_path_create_context(interface, NULL); + d = litest_create_device_for(libinput, which); + d-owns_context = true; + + return d; +} + int litest_handle_events(struct litest_device *d) { @@ -392,8 +412,12 @@ litest_delete_device(struct litest_device *d) if (!d) return; + if (d-destroy) + d-destroy(d); + libinput_device_unref(d-libinput_device); - libinput_destroy(d-libinput); + if (d-owns_context) + libinput_destroy(d-libinput); libevdev_free(d-evdev); libevdev_uinput_destroy(d-uinput); memset(d,0, sizeof(*d)); diff --git a/test/litest.h b/test/litest.h index 9cc0ff5..fef051d 100644 --- a/test/litest.h +++ b/test/litest.h @@ -60,8 +60,11 @@ struct litest_device { struct libevdev *evdev; struct libevdev_uinput *uinput; struct libinput *libinput; + void (*destroy)(struct litest_device *d); + bool owns_context; struct libinput_device *libinput_device; struct litest_device_interface *interface; + int device_id; }; void litest_add(const char *name, void *func, @@ -70,7 +73,11 @@ void litest_add(const char *name, void *func, void litest_add_no_device(const char *name, void *func); int litest_run(int argc, char **argv); -struct litest_device * litest_create_device(enum litest_device_type which); + +const struct libinput_interface *litest_get_libinput_interface(void); +struct litest_device *litest_create_device(enum litest_device_type