From: Peter Hutterer Date: Tue, 21 Jan 2014 05:18:09 +0000 (+1000) Subject: test: Add a basic mouse test device X-Git-Tag: 0.1.0~56 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=404a0ea14e2a31decf6ee7c6434e5919930ddc72;p=platform%2Fupstream%2Flibinput.git test: Add a basic mouse test device Signed-off-by: Peter Hutterer --- diff --git a/test/Makefile.am b/test/Makefile.am index 75b14122..82f5e538 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -10,6 +10,7 @@ liblitest_la_SOURCES = \ litest-int.h \ litest-bcm5974.c \ litest-keyboard.c \ + litest-mouse.c \ litest-synaptics.c \ litest-trackpoint.c \ litest.c diff --git a/test/litest-mouse.c b/test/litest-mouse.c new file mode 100644 index 00000000..2fde0950 --- /dev/null +++ b/test/litest-mouse.c @@ -0,0 +1,75 @@ +/* + * Copyright © 2013 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include "litest.h" +#include "litest-int.h" +#include "libinput-util.h" + +static void litest_mouse_setup(void) +{ + struct litest_device *d = litest_create_device(LITEST_MOUSE); + litest_set_current_device(d); +} + +static struct litest_device_interface interface = { +}; + +static void +litest_create_mouse(struct litest_device *d) +{ + struct libevdev *dev; + int rc; + + d->interface = &interface; + dev = libevdev_new(); + ck_assert(dev != NULL); + + libevdev_set_name(dev, "Lenovo Optical USB Mouse"); + libevdev_set_id_bustype(dev, 0x3); + libevdev_set_id_vendor(dev, 0x17ef); + libevdev_set_id_product(dev, 0x6019); + 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); + libevdev_enable_event_code(dev, EV_REL, REL_WHEEL, NULL); + + rc = libevdev_uinput_create_from_device(dev, + LIBEVDEV_UINPUT_OPEN_MANAGED, + &d->uinput); + ck_assert_int_eq(rc, 0); + libevdev_free(dev); +} + +struct litest_test_device litest_mouse_device = { + .type = LITEST_MOUSE, + .features = LITEST_POINTER | LITEST_BUTTON | LITEST_WHEEL, + .shortname = "mouse", + .setup = litest_mouse_setup, + .teardown = litest_generic_device_teardown, + .create = litest_create_mouse, +}; diff --git a/test/litest.c b/test/litest.c index 79d19a27..efab26c7 100644 --- a/test/litest.c +++ b/test/litest.c @@ -79,12 +79,14 @@ extern struct litest_test_device litest_keyboard_device; extern struct litest_test_device litest_synaptics_clickpad_device; extern struct litest_test_device litest_trackpoint_device; extern struct litest_test_device litest_bcm5974_device; +extern struct litest_test_device litest_mouse_device; struct litest_test_device* devices[] = { &litest_synaptics_clickpad_device, &litest_keyboard_device, &litest_trackpoint_device, &litest_bcm5974_device, + &litest_mouse_device, NULL, }; diff --git a/test/litest.h b/test/litest.h index 7de2d393..5dbc0daf 100644 --- a/test/litest.h +++ b/test/litest.h @@ -39,6 +39,7 @@ enum litest_device_type { LITEST_BCM5974, LITEST_KEYBOARD, LITEST_TRACKPOINT, + LITEST_MOUSE, }; enum litest_device_feature { @@ -49,6 +50,7 @@ enum litest_device_feature { LITEST_BUTTON = 1 << 2, LITEST_KEYS = 1 << 3, LITEST_POINTER = 1 << 4, + LITEST_WHEEL = 1 << 5, }; struct litest_device {