[PATCH v5 3/5] Add test for XIQueryPointer button mask when physical touch is active
Chase Douglas
chase.douglas at canonical.com
Thu Jun 7 14:05:13 PDT 2012
On 06/04/2012 09:41 PM, Peter Hutterer wrote:
> On Fri, May 25, 2012 at 09:06:10AM -0700, Chase Douglas wrote:
>> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
>> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
>> ---
>> Changes since v4:
>> * Allocate XI event mask using mask length
>> * Skip test if evemu device creation fails
>>
>> .../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 | 83 ++++++++++++++++++++
>> 4 files changed, 129 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..896d34a 100644
>> --- a/test/integration/xi2.cpp
>> +++ b/test/integration/xi2.cpp
>> @@ -192,3 +192,86 @@ 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(mask.mask_len, 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());
>> +
>> + std::auto_ptr<xorg::testing::evemu::Device> device;
>> + try {
>> + device = std::auto_ptr<xorg::testing::evemu::Device>(
>> + new xorg::testing::evemu::Device(
>> + TEST_ROOT_DIR "recordings/ntrig_dell_xt2/device.prop"));
>> + } catch (std::runtime_error &error) {
>> + std::cerr << "Failed to create evemu device, skipping test.\n";
>> + return;
>> + }
>> +
>> + 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));
>
> I finally found why this test fails for me on XI 2.0 and 2.1. You're
> checking the button mask for button 0 here which is never set (protocol
> defines the mask as (1 << button number)).
>
> please change this to 1. Also, I'm curious how this test would have
> succeeded on your box. did you have a different version of
> ee542b85590814ee25369babce1ad14feeb137af (Report touch emulated buttons
> in XIQueryPointer for XI 2.1 and earlier) in your tree?
I think my original version of the fix for the bug would report it as
button 0 instead of button 1. To be honest, I haven't run these tests
against a "fixed" server for a while because these fixes aren't
updateable for Ubuntu 12.04 LTS (no one has actually hit them and
complained). I was assuming the tests were still correct.
I have updated this test with the fix you noted. I also bumped the
assertion for the mask length to at least 2 bits. I built a version of
the Ubuntu server with the bug fix, and I can verify that this fails
without the bug fix and passes with it.
-- Chase
More information about the xorg-devel
mailing list