From 8b660cd307297c13771996fa77fe366f98162305 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 9 Jul 2013 11:57:02 +1000 Subject: server/grab: add test case for ungrab during second touch This currently crashes the server, the listener is removed and triggers a bug, replaying the event after the ungrab means accessing dangling pointers. Signed-off-by: Peter Hutterer --- tests/server/grab.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/server/grab.cpp b/tests/server/grab.cpp index a883bae..c7147b7 100644 --- a/tests/server/grab.cpp +++ b/tests/server/grab.cpp @@ -1015,6 +1015,55 @@ class TouchGrabTestOnLegacyClient : public TouchGrabTest { } }; +TEST_F(TouchGrabTestOnLegacyClient, ActivePointerGrabUngrabDuringTouch) +{ + XORG_TESTCASE("Create window\n" + "Select for button events on XIAllMasterDevices.\n" + "Touch begin\n" + "Activate async active grab on the window\n" + "Touch end, second touch begin\n" + "Ungrab device\n" + "https://bugs.freedesktop.org/show_bug.cgi?id=66720"); + + ::Display *dpy = Display(); /* XI 2.0 client */ + + int deviceid; + FindInputDeviceByName(dpy, "--device--", &deviceid); + + Window win = CreateWindow(dpy, DefaultRootWindow(dpy)); + + SelectXI2Events(dpy, XIAllMasterDevices, win, + XI_ButtonPress, + XI_ButtonRelease, + XI_Enter, + XI_Leave, + XI_Motion, + -1); + + TouchBegin(200, 200); + TouchUpdate(202, 202); + + EXPECT_EVENT(XIDeviceEvent, m1, dpy, GenericEvent, xi2_opcode, XI_Motion); + EXPECT_EVENT(XIDeviceEvent, p1, dpy, GenericEvent, xi2_opcode, XI_ButtonPress); + ASSERT_TRUE(NoEventPending(dpy)); + + GrabPointer(dpy, VIRTUAL_CORE_POINTER_ID, win); + TouchEnd(); + + EXPECT_EVENT(XIDeviceEvent, r1, dpy, GenericEvent, xi2_opcode, XI_ButtonRelease); + + TouchBegin(200, 200); + TouchUpdate(202, 202); + EXPECT_EVENT(XIDeviceEvent, m2, dpy, GenericEvent, xi2_opcode, XI_Motion); + EXPECT_EVENT(XIDeviceEvent, p2, dpy, GenericEvent, xi2_opcode, XI_ButtonPress); + XIUngrabDevice(dpy, VIRTUAL_CORE_POINTER_ID, CurrentTime); + + TouchEnd(); + + ASSERT_TRUE(NoEventPending(dpy)); +} + + TEST_F(TouchGrabTestOnLegacyClient, ActivePointerGrabOverPointerSelection) { XORG_TESTCASE("Create window\n" -- cgit v1.2.3