[PATCH v4 4/5] Add test for touch end on device disable
Peter Hutterer
peter.hutterer at who-t.net
Thu May 24 18:38:19 PDT 2012
On Thu, May 24, 2012 at 10:27:59AM -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 v3:
> * Fix wait_for_event functions to WaitForEvent functions
>
> test/integration/xi2.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 71 insertions(+)
>
> diff --git a/test/integration/xi2.cpp b/test/integration/xi2.cpp
> index e6cd312..42b973f 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));
this should be XI_TouchEnd here, btw.
a better way to avoid these errors is to use mask.mask_len as alloc size
instead of duplicating the XIMaskLen macro.
Cheers,
Peter
> + 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(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);
> + ASSERT_TRUE(XChangeDeviceControl(Display(), xdevice, DEVICE_ENABLE,
> + control));
> + XCloseDevice(Display(), xdevice);
> + XFlush(Display());
> +
> + ASSERT_TRUE(WaitForEventOfType(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