summaryrefslogtreecommitdiff
path: root/test/litest-int.h
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-12-06 15:02:11 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-01-15 11:59:27 +1000
commit3a344169bb2db9976655062f90b21d046780a2c5 (patch)
tree9e860ab5d70b1f3115fcb58411f4dd8f5f41c568 /test/litest-int.h
parent86a50bccea0a757cbfddd0040acb6ec3d169fbc8 (diff)
downloadlibinput-3a344169bb2db9976655062f90b21d046780a2c5.tar.gz
Add a device test suite
A rather large commit, copied from a similar (almost identical) suite in libtouchpad and ported for libinput. The goal here is to make testing for various devices easy, so the litest ("libinput test") wrappers do that. The idea is that each device has some features, and tests are likely to exercise some features or won't work with other features. Each test case takes a list of required features and a list of excluded features. The test suite will create a new test case for each device in the suite that matches that set. For example, the set of required LITEST_TOUCHPAD, excluded LITEST_BUTTON would run on clickpads only, not on touchpads with buttons. check supports suites and test cases, both named. We wrap that so that each named set of cases we add are a test suite, with the set of devices being the test cases. i.e. litest_add("foo:bar", some_test_function, LITEST_ANY, LITEST_ANY); adds a suite named "foo:bar" and test cases for both devices given, with their shortnames as test case name, resulting in: "foo:bar", "trackpoint" "foo:bar", "clickpad" ... Multiple test functions can be added to a suite. For tests without a device requirement there is litest_add_no_device_test(...). The environment variables CK_RUN_SUITE and CK_RUN_CASE can be used to narrow the set of test cases. The test suite detects when run inside a debugger and disables fork mode (the default). Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test/litest-int.h')
-rw-r--r--test/litest-int.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/test/litest-int.h b/test/litest-int.h
new file mode 100644
index 00000000..dd48d16c
--- /dev/null
+++ b/test/litest-int.h
@@ -0,0 +1,53 @@
+/*
+ * 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
+
+#ifndef LITEST_INT_H
+#define LITEST_INT_H
+#include "litest.h"
+
+struct litest_test_device {
+ enum litest_device_type type;
+ enum litest_device_feature features;
+ const char *shortname;
+ void (*setup)(void); /* test fixture, used by check */
+ void (*teardown)(void); /* test fixture, used by check */
+
+ void (*create)(struct litest_device *d);
+};
+
+struct litest_device_interface {
+ void (*touch_down)(struct litest_device *d, unsigned int slot, int x, int y);
+ void (*touch_move)(struct litest_device *d, unsigned int slot, int x, int y);
+
+ int min[2];
+ int max[2];
+};
+
+void litest_set_current_device(struct litest_device *device);
+int litest_scale(const struct litest_device *d, unsigned int axis, int val);
+void litest_generic_device_teardown(void);
+
+#endif