[PATCH 1/2] Add test for touch end on device disable
Chase Douglas
chase.douglas at canonical.com
Tue May 15 13:21:54 PDT 2012
When a device is disabled, all physically active touches must end.
Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
---
test/integration/xi2.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 71 insertions(+)
diff --git a/test/integration/xi2.cpp b/test/integration/xi2.cpp
index 21305d3..b864e8b 100644
--- a/test/integration/xi2.cpp
+++ b/test/integration/xi2.cpp
@@ -2,6 +2,7 @@
#include <xorg/gtest/xorg-gtest.h>
+#include <X11/extensions/XInput.h>
#include <X11/extensions/XInput2.h>
namespace {
@@ -267,4 +268,74 @@ TEST_P(XInput2Test, XIQueryPointerTouchscreen)
XFreeEventData(Display(), xcookie);
}
+/**
+ * When a device is disabled, any physically active touches should end.
+ */
+TEST_P(XInput2Test, DisableDeviceEndTouches)
+{
+ /* This is an XInput 2.2 and later test only */
+ if (GetParam() < 2)
+ return;
+
+ XIEventMask mask;
+ mask.deviceid = XIAllDevices;
+ mask.mask_len = XIMaskLen(XI_TouchEnd);
+ mask.mask = reinterpret_cast<unsigned char*>(
+ calloc(XIMaskLen(XI_HierarchyChanged), 1));
+ XISetMask(mask.mask, XI_HierarchyChanged);
+
+ ASSERT_EQ(Success,
+ XISelectEvents(Display(), DefaultRootWindow(Display()), &mask,
+ 1));
+
+ mask.deviceid = XIAllMasterDevices;
+ XIClearMask(mask.mask, XI_HierarchyChanged);
+ XISetMask(mask.mask, XI_TouchBegin);
+ XISetMask(mask.mask, XI_TouchUpdate);
+ XISetMask(mask.mask, XI_TouchEnd);
+
+ ASSERT_EQ(Success,
+ XISelectEvents(Display(), DefaultRootWindow(Display()), &mask,
+ 1));
+
+ free(mask.mask);
+
+ XFlush(Display());
+
+ xorg::testing::evemu::Device device(
+ TEST_ROOT_DIR "recordings/ntrig_dell_xt2/device.prop");
+
+ ASSERT_TRUE(wait_for_device(Display(),
+ "N-Trig MultiTouch (Virtual Test Device)"));
+
+ device.Play(TEST_ROOT_DIR "recordings/ntrig_dell_xt2/touch_1_begin.record");
+
+ ASSERT_TRUE(wait_for_event_of_type(Display(), GenericEvent, xi2_opcode_,
+ XI_TouchBegin));
+
+ XEvent event;
+ ASSERT_EQ(Success, XNextEvent(Display(), &event));
+
+ XGenericEventCookie *xcookie = &event.xcookie;
+ ASSERT_TRUE(XGetEventData(Display(), xcookie));
+
+ XIDeviceEvent *device_event =
+ reinterpret_cast<XIDeviceEvent*>(xcookie->data);
+
+ XDevice *xdevice = XOpenDevice(Display(), device_event->sourceid);
+ XFreeEventData(Display(), xcookie);
+ ASSERT_TRUE(xdevice != NULL);
+
+ XDeviceEnableControl enable_control;
+ enable_control.enable = false;
+ XDeviceControl *control = reinterpret_cast<XDeviceControl*>(&control);
+ ASSERT_TRUE(XChangeDeviceControl(Display(), xdevice, DEVICE_ENABLE,
+ control));
+ XCloseDevice(Display(), xdevice);
+ XFlush(Display());
+
+ ASSERT_TRUE(wait_for_event_of_type(Display(), GenericEvent, xi2_opcode_,
+ XI_TouchEnd));
+}
+
INSTANTIATE_TEST_CASE_P(, XInput2Test, ::testing::Range(0, 3));
--
1.7.9.5
More information about the xorg-devel
mailing list