diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-02-14 09:17:31 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2013-02-14 10:36:08 +1000 |
commit | 14dbc8cb7eb672ebe7cfb34c63859edadc43164a (patch) | |
tree | 02e20c46420d815076498a3290bf657ba4efedea | |
parent | f356d316ec2c7a849f9dc631a6ac26f50813e974 (diff) |
server/grab: add test for touch grab passing on to core button grab
Possibly the test for:
https://bugs.freedesktop.org/show_bug.cgi?id=56578
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r-- | tests/server/grab.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/server/grab.cpp b/tests/server/grab.cpp index ad1dc47..6c2d23a 100644 --- a/tests/server/grab.cpp +++ b/tests/server/grab.cpp @@ -480,6 +480,62 @@ public: } }; +TEST_F(TouchGrabTest, TouchGrabPassedToCoreGrab) +{ + XORG_TESTCASE("Client 1: Register for passive touch grab on root window\n" + "Client 2: Register for passive button grab on client window\n" + "Trigger touch begin/end\n" + "Client 1: reject after TouchEnd\n" + "Client 2: verify button event is received\n" + "Repeat 10 times\n"); + + ::Display *dpy1 = Display(); + ::Display *dpy2 = XOpenDisplay(server.GetDisplayString().c_str()); + XSynchronize(dpy2, True); + + Window root = DefaultRootWindow(dpy1); + Window win = CreateWindow(dpy2, None); + + XIEventMask mask; + mask.deviceid = VIRTUAL_CORE_POINTER_ID; + mask.mask_len = XIMaskLen(XI_TouchEnd); + mask.mask = new unsigned char[mask.mask_len](); + XISetMask(mask.mask, XI_TouchBegin); + XISetMask(mask.mask, XI_TouchUpdate); + XISetMask(mask.mask, XI_TouchEnd); + + XIGrabModifiers mods = {}; + mods.modifiers = XIAnyModifier; + ASSERT_EQ(Success, XIGrabTouchBegin(dpy1, VIRTUAL_CORE_POINTER_ID, + root, False, &mask, 1, &mods)); + delete[] mask.mask; + + XGrabButton(dpy2, AnyButton, XIAnyModifier, win, False, + ButtonPressMask|ButtonReleaseMask, + GrabModeAsync, GrabModeAsync, None, None); + + for (int i = 0; i < 10; i++) { + dev->Play(RECORDINGS_DIR "tablets/N-Trig-MultiTouch.touch_1_begin.events"); + dev->Play(RECORDINGS_DIR "tablets/N-Trig-MultiTouch.touch_1_end.events"); + + ASSERT_EVENT(XIDeviceEvent, tbegin, dpy1, GenericEvent, xi2_opcode, XI_TouchBegin); + ASSERT_EVENT(XIDeviceEvent, tend, dpy1, GenericEvent, xi2_opcode, XI_TouchEnd); + XIAllowTouchEvents(dpy1, tbegin->deviceid, tbegin->detail, root, XIRejectTouch); + + ASSERT_EVENT(XEvent, press, dpy2, ButtonPress); + ASSERT_EVENT(XEvent, release, dpy2, ButtonRelease); + ASSERT_TRUE(NoEventPending(dpy2)); + ASSERT_TRUE(NoEventPending(dpy1)); + + Window r, c; + int rx, ry, wx, wy; + unsigned int state; + + XQueryPointer(dpy2, root, &r, &c, &rx, &ry, &wx, &wy, &state); + ASSERT_FALSE(state & Button1Mask); + } +} + class TouchGrabTestMultipleModes : public TouchGrabTest, public ::testing::WithParamInterface<int> { |