[PATCH v4 3/5] Add test for XIQueryPointer button mask when physical touch is active
Chase Douglas
chase.douglas at canonical.com
Thu May 24 10:27:58 PDT 2012
Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
---
.../recordings/ntrig_dell_xt2/device.prop | 32 +++++++++
.../recordings/ntrig_dell_xt2/touch_1_begin.record | 11 +++
.../recordings/ntrig_dell_xt2/touch_1_end.record | 3 +
test/integration/xi2.cpp | 76 ++++++++++++++++++++
4 files changed, 122 insertions(+)
create mode 100644 test/integration/recordings/ntrig_dell_xt2/device.prop
create mode 100644 test/integration/recordings/ntrig_dell_xt2/touch_1_begin.record
create mode 100644 test/integration/recordings/ntrig_dell_xt2/touch_1_end.record
diff --git a/test/integration/recordings/ntrig_dell_xt2/device.prop b/test/integration/recordings/ntrig_dell_xt2/device.prop
new file mode 100644
index 0000000..2738c04
--- /dev/null
+++ b/test/integration/recordings/ntrig_dell_xt2/device.prop
@@ -0,0 +1,32 @@
+N: N-Trig MultiTouch (Virtual Test Device)
+I: 0003 1b96 0001 0110
+P: 00 00 00 00 00 00 00 00
+B: 00 0b 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 04 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 01 00 00 00 00 00 00 00 00
+B: 02 00 00 00 00 00 00 00 00
+B: 03 03 00 00 00 00 01 73 00
+B: 04 00 00 00 00 00 00 00 00
+B: 05 00 00 00 00 00 00 00 00
+B: 11 00 00 00 00 00 00 00 00
+B: 12 00 00 00 00 00 00 00 00
+B: 15 00 00 00 00 00 00 00 00
+B: 15 00 00 00 00 00 00 00 00
+A: 00 0 9600 75 0
+A: 01 0 7200 78 0
+A: 28 0 255 0 0
+A: 30 0 9600 200 0
+A: 31 0 7200 150 0
+A: 34 0 1 0 0
+A: 35 0 9600 75 0
+A: 36 0 7200 78 0
diff --git a/test/integration/recordings/ntrig_dell_xt2/touch_1_begin.record b/test/integration/recordings/ntrig_dell_xt2/touch_1_begin.record
new file mode 100644
index 0000000..28a849b
--- /dev/null
+++ b/test/integration/recordings/ntrig_dell_xt2/touch_1_begin.record
@@ -0,0 +1,11 @@
+E: 1327542640.244087 0003 0000 2745
+E: 1327542640.244089 0003 0001 1639
+E: 1327542640.244090 0003 0035 2745
+E: 1327542640.244091 0003 0036 1639
+E: 1327542640.244092 0003 0034 0
+E: 1327542640.244093 0003 0030 468
+E: 1327542640.244094 0003 0031 306
+E: 1327542640.244095 0000 0002 0
+E: 1327542640.244251 0001 014d 1
+E: 1327542640.244251 0001 014a 1
+E: 1327542640.244253 0000 0000 0
diff --git a/test/integration/recordings/ntrig_dell_xt2/touch_1_end.record b/test/integration/recordings/ntrig_dell_xt2/touch_1_end.record
new file mode 100644
index 0000000..cd6a9d9
--- /dev/null
+++ b/test/integration/recordings/ntrig_dell_xt2/touch_1_end.record
@@ -0,0 +1,3 @@
+E: 1327542642.244253 0001 014d 0
+E: 1327542642.244253 0001 014a 0
+E: 1327542642.244253 0000 0000 0
diff --git a/test/integration/xi2.cpp b/test/integration/xi2.cpp
index d3c3a30..e6cd312 100644
--- a/test/integration/xi2.cpp
+++ b/test/integration/xi2.cpp
@@ -192,3 +192,79 @@ protected:
int xi2_opcode_;
};
+
+/**
+ * XIQueryPointer for XInput 2.1 and earlier should report the first button
+ * pressed if a touch is physically active. For XInput 2.2 and later clients,
+ * the first button should not be reported.
+ */
+TEST_P(XInput2Test, XIQueryPointerTouchscreen)
+{
+ XIEventMask mask;
+ mask.deviceid = XIAllDevices;
+ mask.mask_len = XIMaskLen(XI_HierarchyChanged);
+ 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_ButtonPress);
+
+ 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(WaitForDevice(Display(),
+ "N-Trig MultiTouch (Virtual Test Device)"));
+
+ device.Play(TEST_ROOT_DIR "recordings/ntrig_dell_xt2/touch_1_begin.record");
+
+ ASSERT_TRUE(WaitForEventOfType(Display(), GenericEvent, xi2_opcode_,
+ XI_ButtonPress));
+
+ 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);
+
+ Window root;
+ Window child;
+ double root_x;
+ double root_y;
+ double win_x;
+ double win_y;
+ XIButtonState buttons;
+ XIModifierState modifiers;
+ XIGroupState group;
+ ASSERT_TRUE(XIQueryPointer(Display(), device_event->deviceid,
+ DefaultRootWindow(Display()), &root, &child,
+ &root_x, &root_y, &win_x, &win_y, &buttons,
+ &modifiers, &group));
+
+ /* Test if button 1 is pressed */
+ ASSERT_GE(buttons.mask_len, XIMaskLen(1));
+ if (GetParam() < 2)
+ EXPECT_TRUE(XIMaskIsSet(buttons.mask, 0));
+ else
+ EXPECT_FALSE(XIMaskIsSet(buttons.mask, 0));
+
+ XFreeEventData(Display(), xcookie);
+}
+
+INSTANTIATE_TEST_CASE_P(, XInput2Test, ::testing::Range(0, 3));
--
1.7.9.5
More information about the xorg-devel
mailing list