[PATCH libinput 23/24] test: Add proximity tablet test
Carlos Garnacho
carlosg at gnome.org
Mon Apr 21 10:11:32 PDT 2014
Signed-off-by: Carlos Garnacho <carlosg at gnome.org>
---
test/Makefile.am | 6 +++++
test/tablet.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 88 insertions(+)
create mode 100644 test/tablet.c
diff --git a/test/Makefile.am b/test/Makefile.am
index 74d9a06..9c0f906 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -28,6 +28,7 @@ run_tests = \
test-pointer \
test-touch \
test-log \
+ test-tablet \
test-touchpad \
test-misc
build_tests = \
@@ -64,6 +65,11 @@ test_log_CFLAGS = $(TEST_CFLAGS)
test_log_LDADD = $(TEST_LIBS)
test_log_LDFLAGS = -static
+test_tablet_SOURCES = tablet.c
+test_tablet_CFLAGS = $(AM_CPPFLAGS)
+test_tablet_LDADD = $(TEST_LIBS)
+test_tablet_LDFLAGS = -static
+
test_touchpad_SOURCES = touchpad.c
test_touchpad_CFLAGS = $(AM_CPPFLAGS)
test_touchpad_LDADD = $(TEST_LIBS)
diff --git a/test/tablet.c b/test/tablet.c
new file mode 100644
index 0000000..591742a
--- /dev/null
+++ b/test/tablet.c
@@ -0,0 +1,82 @@
+/*
+ * Copyright © 2014 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.
+ */
+
+#include <config.h>
+
+#include <check.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <libinput.h>
+#include <unistd.h>
+
+#include "libinput-util.h"
+#include "litest.h"
+
+START_TEST(proximity_in_out)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+ struct libinput_event_pointer *pointer_event;
+ struct libinput_event *event;
+ int have_tool_update = 0;
+ struct axis_replacement axes[] = {
+ { ABS_DISTANCE, 10 },
+ { -1, -1 }
+ };
+
+ litest_drain_events(dev->libinput);
+
+ litest_tablet_proximity_in(dev, 10, 10, axes);
+ libinput_dispatch(li);
+
+ while ((event = libinput_get_event(li))) {
+ if (libinput_event_get_type(event) == LIBINPUT_EVENT_POINTER_TOOL_UPDATE) {
+ have_tool_update++;
+ pointer_event = libinput_event_get_pointer_event(event);
+ ck_assert_int_eq(libinput_event_pointer_get_tool(pointer_event), LIBINPUT_TOOL_PEN);
+ }
+ libinput_event_destroy(event);
+ }
+ ck_assert_int_eq(have_tool_update, 1);
+
+ litest_tablet_proximity_out(dev);
+ libinput_dispatch(li);
+
+ while ((event = libinput_get_event(li))) {
+ if (libinput_event_get_type(event) == LIBINPUT_EVENT_POINTER_TOOL_UPDATE) {
+ have_tool_update++;
+ pointer_event = libinput_event_get_pointer_event(event);
+ ck_assert_int_eq(libinput_event_pointer_get_tool(pointer_event), LIBINPUT_TOOL_NONE);
+ }
+ libinput_event_destroy(event);
+ }
+ ck_assert_int_eq(have_tool_update, 2);
+}
+END_TEST
+
+int
+main(int argc, char **argv)
+{
+ litest_add("tablet:proximity-in-out", proximity_in_out, LITEST_TABLET, LITEST_ANY);
+
+ return litest_run(argc, argv);
+}
--
1.9.0
More information about the wayland-devel
mailing list