[PATCH 2/2] test: add a simple test to verify device axis intialization.
Peter Hutterer
peter.hutterer at who-t.net
Sun Apr 19 17:55:49 PDT 2009
---
test/Makefile.am | 2 +-
test/input.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+), 1 deletions(-)
create mode 100644 test/input.c
diff --git a/test/Makefile.am b/test/Makefile.am
index 2accb99..8fb774d 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -1,4 +1,4 @@
-check_PROGRAMS = xkb
+check_PROGRAMS = xkb input
check_LTLIBRARIES = libxservertest.la libxservertest_t.la
TESTS=$(check_PROGRAMS)
diff --git a/test/input.c b/test/input.c
new file mode 100644
index 0000000..4c1f9b2
--- /dev/null
+++ b/test/input.c
@@ -0,0 +1,82 @@
+/**
+ * Copyright © 2009 Red Hat, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <X11/X.h>
+#include "misc.h"
+#include "resource.h"
+#include <X11/Xproto.h>
+#include <X11/Xatom.h>
+#include "windowstr.h"
+#include "inputstr.h"
+
+#include "xserver-testing.h"
+
+static int dix_init_valuators(void)
+{
+ DeviceIntRec dev;
+ ValuatorClassPtr val;
+ const int num_axes = 2;
+ int i;
+
+ test_explain("Init a device with axes.\n"
+ "Verify values set on the device.\n");
+ test_expected("All axes set to default values (usually 0).");
+
+
+ memset(&dev, 0, sizeof(DeviceIntRec));
+ dev.isMaster = TRUE; /* claim it's a master to stop ptracccel */
+
+ test_test(InitValuatorClassDeviceStruct(NULL, 0, 0, 0) == FALSE);
+ test_test(InitValuatorClassDeviceStruct(&dev, num_axes, 0, Absolute));
+
+ val = dev.valuator;
+ test_test(val);
+ test_test(val->numAxes == num_axes);
+ test_test(val->numMotionEvents == 0);
+ test_test(val->mode == Absolute);
+ test_test(val->axisVal);
+
+ for (i = 0; i < num_axes; i++)
+ {
+ test_test(val->axisVal[i] == 0);
+ test_test(val->axes->min_value == NO_AXIS_LIMITS);
+ test_test(val->axes->max_value == NO_AXIS_LIMITS);
+ }
+
+ test_test(dev.last.numValuators == num_axes);
+
+ return 0;
+}
+
+int main(int argc, char** argv)
+{
+ test_init(argc, argv);
+
+ test_call(dix_init_valuators);
+
+ return 0;
+}
--
1.6.2.2.447.g4afa7
More information about the xorg-devel
mailing list