GitLab will be down for maintenance this Sunday 13th June, from approx 7-11am UTC. This is for a PostgreSQL migration. See the tracker issue for more informations.

Commit 7d3f1e97 authored by Povilas Kanapickas's avatar Povilas Kanapickas
Browse files

grab: Add tests for a couple active grab scenarios after touch begins

parent bcb882cd
Pipeline #270815 passed with stages
in 1 minute and 42 seconds
......@@ -1301,6 +1301,103 @@ TEST_F(TouchGrabTest, DISABLED_DeviceUngrabDropsEmulatedEvents)
ASSERT_TRUE(NoEventPending(dpy2));
}
TEST_F(TouchGrabTest, AsyncGrabSameClientAfterTouchBegunNoTouchesInGrabMaskUngrabBeforeEnd)
{
XORG_TESTCASE("Clients C1 and C2 selects for touches.\n"
"The selection of C1 takes precedence over the selection of C2.\n"
"A touch begins.\n"
"Client C1 creates an active async grab without touch events in the mask\n"
"The touch end event is immediately sent to client C1."
"Touch is updated, but all events related to it should be discarded.\n"
"C2 does not get any events.\n");
::Display *dpy1 = Display();
::Display *dpy2 = NewClient();
Window root = DefaultRootWindow(dpy2);
Window win = CreateWindow(dpy2, root);
SelectXI2Events(dpy1, VIRTUAL_CORE_POINTER_ID, win,
{ XI_TouchBegin, XI_TouchUpdate, XI_TouchEnd });
SelectXI2Events(dpy2, VIRTUAL_CORE_POINTER_ID, root,
{ XI_TouchBegin, XI_TouchUpdate, XI_TouchEnd });
TouchDev().TouchBegin(100, 100, 0);
TouchDev().TouchUpdate(110, 100, 0);
EXPECT_EVENT(XIDeviceEvent, tbegin1, dpy1, GenericEvent, xi2_opcode, XI_TouchBegin);
EXPECT_EVENT(XIDeviceEvent, tupdate1, dpy1, GenericEvent, xi2_opcode, XI_TouchUpdate);
ASSERT_TRUE(NoEventPending(dpy1));
ASSERT_TRUE(NoEventPending(dpy2));
// grab event type that is not related to touches
EventMaskBuilder mask{VIRTUAL_CORE_POINTER_ID, { XI_Enter }};
ASSERT_EQ(Success, XIGrabDevice(dpy1, VIRTUAL_CORE_POINTER_ID, win, CurrentTime, None,
GrabModeAsync, GrabModeAsync, False, mask.GetMask()));
XSync(dpy1, False);
EXPECT_EVENT(XIDeviceEvent, tend1, dpy1, GenericEvent, xi2_opcode, XI_TouchEnd);
ASSERT_TRUE(NoEventPending(dpy1));
TouchDev().TouchUpdate(120, 100, 0);
TouchDev().TouchUpdate(130, 100, 0);
XIUngrabDevice(dpy1, VIRTUAL_CORE_POINTER_ID, CurrentTime);
TouchDev().TouchUpdate(140, 100, 0);
TouchDev().TouchEnd(150, 100, 0);
ASSERT_TRUE(NoEventPending(dpy1));
ASSERT_TRUE(NoEventPending(dpy2));
}
TEST_F(TouchGrabTest, AsyncGrabSameClientAfterTouchBegunNoTouchesInGrabMaskUngrabAfterEnd)
{
XORG_TESTCASE("Clients C1 and C2 selects for touches.\n"
"The selection of C1 takes precedence over the selection of C2.\n"
"A touch begins.\n"
"Client C1 creates an active async grab without touch events in the mask\n"
"The touch end event is immediately sent to client C1."
"Touch is updated, but all events related to it should be discarded.\n"
"C2 does not get any events.\n");
::Display *dpy1 = Display();
::Display *dpy2 = NewClient();
Window root = DefaultRootWindow(dpy2);
Window win = CreateWindow(dpy2, root);
SelectXI2Events(dpy1, VIRTUAL_CORE_POINTER_ID, win,
{ XI_TouchBegin, XI_TouchUpdate, XI_TouchEnd });
SelectXI2Events(dpy2, VIRTUAL_CORE_POINTER_ID, root,
{ XI_TouchBegin, XI_TouchUpdate, XI_TouchEnd });
TouchDev().TouchBegin(100, 100, 0);
TouchDev().TouchUpdate(110, 100, 0);
EXPECT_EVENT(XIDeviceEvent, tbegin1, dpy1, GenericEvent, xi2_opcode, XI_TouchBegin);
EXPECT_EVENT(XIDeviceEvent, tupdate1, dpy1, GenericEvent, xi2_opcode, XI_TouchUpdate);
ASSERT_TRUE(NoEventPending(dpy1));
ASSERT_TRUE(NoEventPending(dpy2));
// grab event type that is not related to touches
EventMaskBuilder mask{VIRTUAL_CORE_POINTER_ID, { XI_Enter }};
ASSERT_EQ(Success, XIGrabDevice(dpy1, VIRTUAL_CORE_POINTER_ID, win, CurrentTime, None,
GrabModeAsync, GrabModeAsync, False, mask.GetMask()));
XSync(dpy1, False);
EXPECT_EVENT(XIDeviceEvent, tend1, dpy1, GenericEvent, xi2_opcode, XI_TouchEnd);
ASSERT_TRUE(NoEventPending(dpy1));
TouchDev().TouchUpdate(120, 100, 0);
TouchDev().TouchUpdate(130, 100, 0);
TouchDev().TouchEnd(150, 100, 0);
XIUngrabDevice(dpy1, VIRTUAL_CORE_POINTER_ID, CurrentTime);
ASSERT_TRUE(NoEventPending(dpy1));
ASSERT_TRUE(NoEventPending(dpy2));
}
class TouchGrabTestOnLegacyClient : public TouchGrabTest {
void SetUp() override {
AddDevice(xorg::testing::inputtest::DeviceType::TOUCH);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment