[client] tests: update mouse cases for direct warping

Remove confinement handshake expectations now that Wayland advertises
functional warp support. Verify immediate viewport transitions and cursor
alignment when capture is released.
This commit is contained in:
Geoffrey McRae
2026-08-09 12:39:23 +10:00
parent 19a22ac8ca
commit 89f0311abc
2 changed files with 75 additions and 84 deletions

View File

@@ -69,14 +69,14 @@ target_link_libraries(mouse-tests
set(MOUSE_CASES set(MOUSE_CASES
inset-exit inset-exit
surface-exit surface-exit
exit-delay exit-immediate
exit-guest exit-guest
exit-cancel exit-reentry
confine-pending view-immediate
confine-guest
capture-pending capture-pending
capture-revoked capture-revoked
capture-release capture-release
capture-align
capture-fallback capture-fallback
rotate-scale rotate-scale
geometry geometry

View File

@@ -343,15 +343,13 @@ static void testInsetExit(void)
core_handleMouseNormal(-0.25, -0.25); core_handleMouseNormal(-0.25, -0.25);
const int drop = first(EV_UNGRAB); CHECK(count(EV_UNGRAB) == 0);
const int move = first(EV_WARP); CHECK(count(EV_WARP) == 0);
CHECK(drop >= 0); CHECK(near(g_cursor.exitPos.x, 9.75));
CHECK(count(EV_WARP) == 1); CHECK(near(g_cursor.exitPos.y, 19.75));
CHECK(move > drop); CHECK(g_cursor.exit);
CHECK(m.ev[move].x == 9);
CHECK(m.ev[move].y == 19);
CHECK(m.ev[move].exit);
CHECK(!g_cursor.inView); CHECK(!g_cursor.inView);
CHECK(!g_cursor.viewReq);
core_handleGuestMouseUpdate(); core_handleGuestMouseUpdate();
CHECK(count(EV_GUEST) == 0); CHECK(count(EV_GUEST) == 0);
@@ -444,36 +442,20 @@ static void startExit(void)
{ {
reset(); reset();
setLocal(109, 50); setLocal(109, 50);
m.conf.hold = true;
core_handleMouseNormal(2, 0); core_handleMouseNormal(2, 0);
} }
static void testExitWait(void) static void testExitImmediate(void)
{ {
startExit(); startExit();
const int drop = first(EV_UNGRAB); CHECK(count(EV_UNGRAB) == 0);
CHECK(drop >= 0);
CHECK(count(EV_WARP) == 0); CHECK(count(EV_WARP) == 0);
CHECK(g_cursor.inView); CHECK(near(g_cursor.exitPos.x, 111));
CHECK(near(g_cursor.exitPos.y, 50));
CHECK(!g_cursor.inView);
CHECK(!g_cursor.viewReq); CHECK(!g_cursor.viewReq);
CHECK(g_cursor.exit); CHECK(g_cursor.exit);
g_cursor.pos = (struct DoublePoint) { 111, 50 };
g_cursor.warpState = WARP_STATE_OFF;
setConf(false);
const int move = first(EV_WARP);
CHECK(move > drop);
CHECK(count(EV_WARP) == 1);
CHECK(m.ev[move].x == 111);
CHECK(m.ev[move].y == 50);
CHECK(m.ev[move].exit);
CHECK(!m.ev[move].conf);
CHECK(!g_cursor.inView);
CHECK(!g_cursor.exit);
setConf(false);
CHECK(count(EV_WARP) == 1);
} }
static void testExitGuest(void) static void testExitGuest(void)
@@ -484,35 +466,29 @@ static void testExitGuest(void)
CHECK(count(EV_GUEST) == 0); CHECK(count(EV_GUEST) == 0);
} }
static void testExitCancel(void) static void testExitReentry(void)
{ {
startExit(); startExit();
CHECK(g_cursor.exit); CHECK(g_cursor.exit);
CHECK(!g_cursor.inView);
core_handleMouseNormal(1, 0);
CHECK(g_cursor.exit);
CHECK(!g_cursor.viewReq); CHECK(!g_cursor.viewReq);
core_handleMouseNormal(-3, 0); setLocal(50, 50);
core_handleMouseNormal(0, 0);
CHECK(!g_cursor.exit); CHECK(!g_cursor.exit);
CHECK(g_cursor.viewReq); CHECK(g_cursor.viewReq);
CHECK(m.conf.req);
CHECK(count(EV_WARP) == 0);
setConf(false);
CHECK(count(EV_WARP) == 0);
setConf(true);
CHECK(g_cursor.inView); CHECK(g_cursor.inView);
CHECK(count(EV_GRAB) == 0);
CHECK(count(EV_UNGRAB) == 0);
CHECK(count(EV_WARP) == 0);
startExit(); startExit();
g_state.focused = false; g_state.focused = false;
core_setCursorInView(false); core_setCursorInView(false);
CHECK(!g_cursor.exit); CHECK(!g_cursor.exit);
setConf(false);
CHECK(count(EV_WARP) == 0);
} }
static void startConf(void) static void testViewImmediate(void)
{ {
reset(); reset();
setLocal(50, 50); setLocal(50, 50);
@@ -521,28 +497,14 @@ static void startConf(void)
g_cursor.inView = false; g_cursor.inView = false;
g_cursor.viewReq = false; g_cursor.viewReq = false;
core_handleMouseNormal(0, 0); core_setCursorInView(true);
} CHECK(!m.conf.req);
static void testConfWait(void)
{
startConf();
CHECK(m.conf.req);
CHECK(!m.conf.on); CHECK(!m.conf.on);
CHECK(!g_cursor.inView); CHECK(count(EV_GRAB) == 0);
CHECK(count(EV_UNGRAB) == 0);
setConf(true); CHECK(g_cursor.viewReq);
CHECK(g_cursor.inView); CHECK(g_cursor.inView);
}
static void testConfGuest(void)
{
startConf();
core_handleGuestMouseUpdate();
CHECK(m.conf.req);
CHECK(count(EV_GUEST) == 0);
setConf(true);
core_handleGuestMouseUpdate(); core_handleGuestMouseUpdate();
CHECK(count(EV_GUEST) == 1); CHECK(count(EV_GUEST) == 1);
} }
@@ -608,6 +570,28 @@ static void testCapRelease(void)
CHECK(count(EV_MOTION) == 1); CHECK(count(EV_MOTION) == 1);
} }
static void testCapAlign(void)
{
reset();
setLocal(50, 50);
g_params.hideMouse = true;
core_setGrabQuiet(true);
m.lock.on = true;
g_cursor.guest.x += 10;
g_cursor.warpState = WARP_STATE_ON;
m.count = 0;
core_setGrabQuiet(false);
const int drop = first(EV_UNCAPTURE);
const int warp = first(EV_WARP);
CHECK(drop >= 0);
CHECK(warp > drop);
CHECK(m.ev[warp].x == 60);
CHECK(m.ev[warp].y == 50);
CHECK(!m.ev[warp].exit);
}
static void testCapFallback(void) static void testCapFallback(void)
{ {
reset(); reset();
@@ -771,11 +755,13 @@ static void testEdges(void)
core_handleMouseNormal(input.x, input.y); core_handleMouseNormal(input.x, input.y);
const int index = first(EV_WARP); CHECK(count(EV_UNGRAB) == 0);
CHECK(index >= 0); CHECK(count(EV_WARP) == 0);
CHECK(m.ev[index].x == cases[i].target.x); CHECK(g_cursor.exit);
CHECK(m.ev[index].y == cases[i].target.y); CHECK(!g_cursor.inView);
CHECK(m.ev[index].exit); CHECK(!g_cursor.viewReq);
CHECK(near(g_cursor.exitPos.x, cases[i].target.x));
CHECK(near(g_cursor.exitPos.y, cases[i].target.y));
} }
} }
@@ -804,10 +790,13 @@ static void testScales(void)
core_handleMouseNormal(cases[i].delta, 0); core_handleMouseNormal(cases[i].delta, 0);
const int index = first(EV_WARP); CHECK(count(EV_UNGRAB) == 0);
CHECK(index >= 0); CHECK(count(EV_WARP) == 0);
CHECK(m.ev[index].x == cases[i].target); CHECK(g_cursor.exit);
CHECK(m.ev[index].y == 50); CHECK(!g_cursor.inView);
CHECK(!g_cursor.viewReq);
CHECK(near(g_cursor.exitPos.x, cases[i].target));
CHECK(near(g_cursor.exitPos.y, 50));
} }
} }
@@ -834,14 +823,16 @@ static void testBorderExit(void)
core_handleMouseNormal(2, 0); core_handleMouseNormal(2, 0);
const int check = first(EV_VALID); const int check = first(EV_VALID);
const int move = first(EV_WARP);
CHECK(check >= 0); CHECK(check >= 0);
CHECK(move > check);
CHECK(m.ev[check].x == cases[i].valid.x); CHECK(m.ev[check].x == cases[i].valid.x);
CHECK(m.ev[check].y == cases[i].valid.y); CHECK(m.ev[check].y == cases[i].valid.y);
CHECK(m.ev[move].x == 111); CHECK(count(EV_UNGRAB) == 0);
CHECK(m.ev[move].y == 50); CHECK(count(EV_WARP) == 0);
CHECK(m.ev[move].exit); CHECK(g_cursor.exit);
CHECK(!g_cursor.inView);
CHECK(!g_cursor.viewReq);
CHECK(near(g_cursor.exitPos.x, 111));
CHECK(near(g_cursor.exitPos.y, 50));
} }
} }
@@ -854,14 +845,14 @@ struct Test
static const struct Test tests[] = { static const struct Test tests[] = {
{ "inset-exit" , testInsetExit }, { "inset-exit" , testInsetExit },
{ "surface-exit" , testSurfaceExit }, { "surface-exit" , testSurfaceExit },
{ "exit-delay" , testExitWait }, { "exit-immediate" , testExitImmediate},
{ "exit-guest" , testExitGuest }, { "exit-guest" , testExitGuest },
{ "exit-cancel" , testExitCancel }, { "exit-reentry" , testExitReentry },
{ "confine-pending" , testConfWait }, { "view-immediate" , testViewImmediate},
{ "confine-guest" , testConfGuest },
{ "capture-pending" , testCapWait }, { "capture-pending" , testCapWait },
{ "capture-revoked" , testCapRevoke }, { "capture-revoked" , testCapRevoke },
{ "capture-release" , testCapRelease }, { "capture-release" , testCapRelease },
{ "capture-align" , testCapAlign },
{ "capture-fallback", testCapFallback }, { "capture-fallback", testCapFallback },
{ "rotate-scale" , testRotateScale }, { "rotate-scale" , testRotateScale },
{ "geometry" , testGeometry }, { "geometry" , testGeometry },