diff options
author | Povilas Kanapickas <povilas@radix.lt> | 2021-02-08 05:24:10 +0200 |
---|---|---|
committer | Povilas Kanapickas <povilas@radix.lt> | 2021-02-15 11:29:58 +0000 |
commit | 4488c0a1e4617e53ec63920d21ef53c287be3546 (patch) | |
tree | 59b00a067fd1491b0a6c1ac37fb4c86bd7441bc4 | |
parent | 83f097af344ef361418b18440300107927c0396d (diff) |
grab: Test active pointer grab without button events after implicit grab
-rw-r--r-- | tests/server/grab.cpp | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/tests/server/grab.cpp b/tests/server/grab.cpp index 6bfac0a..6535954 100644 --- a/tests/server/grab.cpp +++ b/tests/server/grab.cpp @@ -247,6 +247,70 @@ TEST_F(PointerGrabTest, ImplicitGrabToActiveGrab) ASSERT_EQ(server.GetState(), xorg::testing::Process::RUNNING); } +TEST_F(PointerGrabTest, ImplicitGrabToActiveGrabReleaseEventNotInMask) +{ + XORG_TESTCASE("Create a window with the button masks set.\n" + "Create a pointer device\n" + "Activate implicit pointer grab by clicking into the window.\n" + "While the implicit grab is active, grab the pointer, but without release mask\n" + "Release the button, check event is received\n"); + + ::Display *dpy = Display(); + Window win = CreateWindow(dpy, DefaultRootWindow(dpy)); + XSelectInput(dpy, win, ButtonPressMask|ButtonReleaseMask); + XSync(dpy, False); + + Dev(0).ButtonDown(1); + + ASSERT_EVENT(XEvent, e_press, dpy, ButtonPress); + + ASSERT_EQ(Success, XGrabPointer(dpy, win, True, EnterWindowMask, + GrabModeAsync, GrabModeAsync, None, None, CurrentTime)); + XSync(dpy, False); + + Dev(0).ButtonUp(1); + + ASSERT_EVENT(XEvent, e_release, dpy, ButtonRelease); + + ASSERT_TRUE(NoEventPending(dpy)); +} + +TEST_F(PointerGrabTest, XiImplicitGrabToActiveGrabReleaseEventNotInMask) +{ + XORG_TESTCASE("Create a window with the button masks set.\n" + "Create a pointer device\n" + "Activate implicit pointer grab by clicking into the window.\n" + "While the implicit grab is active, grab the pointer, but without release mask\n" + "Release the button, check event is not received\n" + "Note the difference to the core grab case in which the event is received.\n"); + + ::Display *dpy = Display(); + + Window win = CreateWindow(dpy, DefaultRootWindow(dpy)); + + SelectXI2Events(dpy, XIAllMasterDevices, win, + { XI_ButtonPress, XI_ButtonRelease }); + XSync(dpy, False); + + Dev(0).ButtonDown(1); + + ASSERT_EVENT(XIDeviceEvent, press, dpy, GenericEvent, xi2_opcode, XI_ButtonPress); + + ASSERT_TRUE(NoEventPending(dpy)); + + EventMaskBuilder mask{VIRTUAL_CORE_POINTER_ID, { XI_Enter }}; + ASSERT_EQ(Success, XIGrabDevice(dpy, VIRTUAL_CORE_POINTER_ID, + win, CurrentTime, None, + GrabModeAsync, GrabModeAsync, + False, mask.GetMask())); + + XSync(dpy, False); + + Dev(0).ButtonUp(1); + + ASSERT_TRUE(NoEventPending(dpy)); +} + TEST_F(PointerGrabTest, ImplicitGrabToActiveGrabDeactivated) { XORG_TESTCASE("Create a window with the button masks set.\n" @@ -893,6 +957,74 @@ TEST_F(TouchGrabTest, ActivePointerGrabOverPointerSelection) XCloseDisplay(dpy2); } +TEST_F(TouchGrabTest, CoreImplicitGrabToActiveGrabReleaseEventNotInMask) +{ + XORG_TESTCASE("Create a window with the button masks set.\n" + "Activate implicit pointer grab by touching on the window.\n" + "While the implicit grab is active, grab the pointer, but without release mask\n" + "End the touch, check button release event is received\n"); + + ::Display *dpy = Display(); + + Window win = CreateWindow(dpy, DefaultRootWindow(dpy)); + + XSelectInput(dpy, win, ButtonPressMask|ButtonReleaseMask); + XSync(dpy, False); + + TouchDev().TouchBegin(200, 200, 0); + ASSERT_EVENT(XEvent, e_press, dpy, ButtonPress); + + ASSERT_TRUE(NoEventPending(dpy)); + + ASSERT_EQ(Success, XGrabPointer(dpy, win, True, EnterWindowMask, + GrabModeAsync, GrabModeAsync, None, None, CurrentTime)); + XSync(dpy, False); + + TouchDev().TouchUpdate(282, 282, 0); + ASSERT_TRUE(NoEventPending(dpy)); + + TouchDev().TouchEnd(282, 282, 0); + + ASSERT_EVENT(XEvent, e_release, dpy, ButtonRelease); + ASSERT_TRUE(NoEventPending(dpy)); +} + +TEST_F(TouchGrabTest, ImplicitGrabToActiveGrabReleaseEventNotInMask) +{ + XORG_TESTCASE("Create a window with the button masks set.\n" + "Activate implicit pointer grab by touching on the window.\n" + "While the implicit grab is active, grab the pointer, but without release mask\n" + "End the touch, check button release event is not received\n" + "Note the difference to the core grab case in which the event is received.\n"); + + ::Display *dpy = Display(); + + Window win = CreateWindow(dpy, DefaultRootWindow(dpy)); + + SelectXI2Events(dpy, XIAllMasterDevices, win, + { XI_ButtonPress, XI_ButtonRelease }); + XSync(dpy, False); + + TouchDev().TouchBegin(200, 200, 0); + + ASSERT_EVENT(XIDeviceEvent, press, dpy, GenericEvent, xi2_opcode, XI_ButtonPress); + + ASSERT_TRUE(NoEventPending(dpy)); + + EventMaskBuilder mask{VIRTUAL_CORE_POINTER_ID, { XI_Enter }}; + ASSERT_EQ(Success, XIGrabDevice(dpy, VIRTUAL_CORE_POINTER_ID, + win, CurrentTime, None, + GrabModeAsync, GrabModeAsync, + False, mask.GetMask())); + + XSync(dpy, False); + + TouchDev().TouchUpdate(282, 282, 0); + TouchDev().TouchEnd(282, 282, 0); + + ASSERT_TRUE(NoEventPending(dpy)); +} + TEST_F(TouchGrabTest, PassiveTouchGrabPassedToTouchClient) { XORG_TESTCASE("Client 1: register for passive touch grab on roow window\n" |