diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-12-11 14:10:07 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-12-11 14:10:07 +1000 |
commit | d56558d48926825d5b477716d9824458f8ae15dd (patch) | |
tree | 616845889a94a8987cbfe16308304eeb06980acf | |
parent | 0f646d12715903bc83c8b104cc91fda6a569d3d6 (diff) | |
parent | 6d4b278572c12d117725668227eb92b38ef10590 (diff) |
Merge remote-tracking branch 'magcius/barriers' into barriers
-rw-r--r-- | tests/server/barriers-notify.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/server/barriers-notify.cpp b/tests/server/barriers-notify.cpp index ac004bd..7aaf252 100644 --- a/tests/server/barriers-notify.cpp +++ b/tests/server/barriers-notify.cpp @@ -675,3 +675,80 @@ TEST_F(BarrierNotify, BarrierRandREventsVertical) ASSERT_EQ(event.ev->root_x, w - 20 - 1); ASSERT_LT(event.ev->root_y, h); } + +TEST_F(BarrierNotify, ReceivesLeaveOnDestroyWhenInsideHitbox) +{ + XORG_TESTCASE("Set up pointer barrier.\n" + "Move the pointer into the barrier hitbox.\n" + "Destroy the barrier.\n" + "Ensure that we receive an event."); + + ::Display *dpy = Display(); + Window root = DefaultRootWindow(dpy); + Window win = CreateWindow(dpy, root); + + XIWarpPointer(dpy, VIRTUAL_CORE_POINTER_ID, None, root, 0, 0, 0, 0, 30, 30); + + PointerBarrier barrier = XFixesCreatePointerBarrier(dpy, win, 20, 20, 20, 40, 0, 0, NULL); + XSync(dpy, False); + + XIEventMask mask; + mask.deviceid = XIAllMasterDevices; + mask.mask_len = XIMaskLen(XI_LASTEVENT); + mask.mask = reinterpret_cast<unsigned char*>(calloc(mask.mask_len, 1)); + XISetMask(mask.mask, XI_BarrierHit); + XISetMask(mask.mask, XI_BarrierLeave); + XISelectEvents(dpy, win, &mask, 1); + free(mask.mask); + XSync(dpy, False); + + dev->PlayOne(EV_REL, REL_X, -40, True); + + /* Ensure we have a BarrierHit on our hands. */ + { + XITEvent<XIBarrierEvent> event(dpy, GenericEvent, xi2_opcode, XI_BarrierHit); + } + + XFixesDestroyPointerBarrier(dpy, barrier); + + { + XITEvent<XIBarrierEvent> event(dpy, GenericEvent, xi2_opcode, XI_BarrierLeave); + ASSERT_EQ(0, event.ev->dx); + ASSERT_EQ(0, event.ev->dy); + ASSERT_TRUE(event.ev->flags & XIBarrierPointerReleased); + } +} + +TEST_F(BarrierNotify, DoesntReceiveLeaveOnDestroyWhenOutsideHitbox) +{ + XORG_TESTCASE("Set up pointer barrier.\n" + "Move the pointer a bit, but don't make it touch the barrier.\n" + "Destroy the barrier.\n" + "Ensure that we didn't receive an event."); + + ::Display *dpy = Display(); + Window root = DefaultRootWindow(dpy); + Window win = CreateWindow(dpy, root); + + XIWarpPointer(dpy, VIRTUAL_CORE_POINTER_ID, None, root, 0, 0, 0, 0, 30, 30); + + PointerBarrier barrier = XFixesCreatePointerBarrier(dpy, win, 20, 20, 20, 40, 0, 0, NULL); + XSync(dpy, False); + + XIEventMask mask; + mask.deviceid = XIAllMasterDevices; + mask.mask_len = XIMaskLen(XI_LASTEVENT); + mask.mask = reinterpret_cast<unsigned char*>(calloc(mask.mask_len, 1)); + XISetMask(mask.mask, XI_BarrierHit); + XISetMask(mask.mask, XI_BarrierLeave); + XISelectEvents(dpy, win, &mask, 1); + free(mask.mask); + XSync(dpy, False); + + /* Move the pointer, but don't hit the barrier. */ + dev->PlayOne(EV_REL, REL_X, -5, True); + + XIWarpPointer(dpy, VIRTUAL_CORE_POINTER_ID, None, root, 0, 0, 0, 0, 30, 30); + XFixesDestroyPointerBarrier(dpy, barrier); + ASSERT_FALSE(xorg::testing::XServer::WaitForEvent(dpy, 500)); +} |