summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2013-05-21 14:56:07 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2013-05-21 15:06:34 +1000
commitaf9ae20fd9f51381e0d16d0e6e4617ec4c543bc2 (patch)
tree4aa1ecf133f34dcd795a5e20cef7490d6c500e63
parent19b48b948c33137951e2b52f884b30af2c9068b8 (diff)
lib/libXi: add test for serial number
incomplete, but at least it picks up some events Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--tests/lib/libXi.cpp65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/lib/libXi.cpp b/tests/lib/libXi.cpp
index c897991..918406f 100644
--- a/tests/lib/libXi.cpp
+++ b/tests/lib/libXi.cpp
@@ -34,6 +34,7 @@
#include <X11/extensions/XInput2.h>
#include <xit-server-input-test.h>
+#include <xit-property.h>
#include <device-interface.h>
#include "helpers.h"
@@ -63,6 +64,7 @@ public:
config.AddDefaultScreenWithDriver();
config.AddInputSection("evdev", "--device--",
"Option \"CorePointer\" \"on\"\n"
+ "Option \"GrabDevice\" \"on\"\n"
"Option \"Device\" \"" + dev->GetDeviceNode() + "\"");
/* add default keyboard device to avoid server adding our device again */
config.AddInputSection("kbd", "keyboard-device",
@@ -110,6 +112,69 @@ TEST_F(libXiTest, DisplayNotGarbage)
XFreeEventData(dpy, &ev.xcookie);
}
+TEST_F(libXiTest, SerialNumberNotGarbage)
+{
+ XORG_TESTCASE("https://bugs.fredesktop.org/id=64687");
+
+ ::Display *dpy = Display();
+
+
+ /* XIDeviceEvent */
+ SelectXI2Events(dpy, VIRTUAL_CORE_POINTER_ID, DefaultRootWindow(dpy),
+ XI_Motion, -1);
+ dev->PlayOne(EV_REL, REL_X, -1, true);
+ dev->PlayOne(EV_REL, REL_X, -1, true);
+
+ ASSERT_EVENT(XIDeviceEvent, motion1, dpy, GenericEvent, xi2_opcode, XI_Motion);
+ ASSERT_EVENT(XIDeviceEvent, motion2, dpy, GenericEvent, xi2_opcode, XI_Motion);
+ EXPECT_EQ(motion1->serial, motion2->serial);
+
+ XSync(dpy, True);
+
+ dev->PlayOne(EV_REL, REL_X, -1, true);
+ ASSERT_EVENT(XIDeviceEvent, motion3, dpy, GenericEvent, xi2_opcode, XI_Motion);
+ EXPECT_LT(motion2->serial, motion3->serial);
+
+ /* XIRawEvent */
+ XSync(dpy, True);
+ SelectXI2Events(dpy, VIRTUAL_CORE_POINTER_ID, DefaultRootWindow(dpy),
+ XI_RawMotion, -1);
+ dev->PlayOne(EV_REL, REL_X, -1, true);
+ dev->PlayOne(EV_REL, REL_X, -1, true);
+ ASSERT_EVENT(XIDeviceEvent, raw1, dpy, GenericEvent, xi2_opcode, XI_RawMotion);
+ ASSERT_EVENT(XIDeviceEvent, raw2, dpy, GenericEvent, xi2_opcode, XI_RawMotion);
+ EXPECT_GT(raw2->serial, motion3->serial);
+ EXPECT_EQ(raw2->serial, raw2->serial);
+
+ XSync(dpy, True);
+
+ dev->PlayOne(EV_REL, REL_X, -1, true);
+ ASSERT_EVENT(XIDeviceEvent, raw3, dpy, GenericEvent, xi2_opcode, XI_RawMotion);
+ EXPECT_LT(raw2->serial, raw3->serial);
+
+ /* XIPropertyEvent, XIHierarchyEvent */
+ XSync(dpy, True);
+ SelectXI2Events(dpy, XIAllDevices, DefaultRootWindow(dpy),
+ XI_HierarchyChanged, XI_PropertyEvent, -1);
+
+ int deviceid;
+ FindInputDeviceByName(dpy, "--device--", &deviceid);
+ XITProperty<int> prop(dpy, deviceid, "Device Enabled");
+ prop.data[0] = 0;
+ prop.Update();
+
+ ASSERT_EVENT(XIPropertyEvent, propev, dpy, GenericEvent, xi2_opcode, XI_PropertyEvent);
+ ASSERT_EVENT(XIHierarchyEvent, hierarchy, dpy, GenericEvent, xi2_opcode, XI_HierarchyChanged);
+ EXPECT_GT(propev->serial, raw3->serial);
+ EXPECT_EQ(hierarchy->serial, propev->serial);
+
+ prop.data[0] = 1;
+ prop.Update();
+ XSync(dpy, True);
+
+ /* FIXME: should check other events too */
+}
+
#if HAVE_XI22
class libXiTouchTest : public libXiTest {
public: