[PATCH v5 4/5] Add test for touch end on device disable

Chase Douglas chase.douglas at canonical.com
Thu Jun 7 14:06:53 PDT 2012


On 06/04/2012 09:41 PM, Peter Hutterer wrote:
> On Fri, May 25, 2012 at 09:06:11AM -0700, Chase Douglas wrote:
>> When a device is disabled, all physically active touches must end.
>>
>> 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
>>
>>  test/integration/xi2.cpp |   78 ++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 78 insertions(+)
>>
>> diff --git a/test/integration/xi2.cpp b/test/integration/xi2.cpp
>> index 896d34a..2429339 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 {
>> @@ -274,4 +275,81 @@ 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(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_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());
>> +
>> +    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_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);
> 
> this should be reinterpret_cast...(&enable_control). that explains why this
> test kept failing here.

I know that this passed at one point in a fixed server, and fails in a
non-fixed server. Maybe I didn't commit this "fix" and it got cleaned
away at some point? Either way, I've implemented the requested change
and verified that the test fails on a server without the bug fix and
passes on a server with the bug fix.

-- Chase


More information about the xorg-devel mailing list