mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
fix(runner): restore scrollBounds doc; cover destination clamp and screenBounds
Review fixes: move the scrollBounds doc comment back onto scrollBounds (it was stranded above screenBounds by an insertion). Extend the clamp test to assert an off-screen destination is clamped onto the screen and that the origin lands exactly on the margin.
This commit is contained in:
1 parent
c48b13f304
commit
896cfc2cb5
2 files changed
+13
-8
No files matched your search
@@ -719,8 +719,6 @@ func scrollEndpoints(action verifier.Action, tree *hierarchy.Tree) (fromX, fromY
|
|||||||
return cx, cy, toX, toY
|
return cx, cy, toX, toY
|
||||||
}
|
}
|
||||||
|
|
||||||
// scrollBounds returns the container bounds for an authored Scroll: the node
|
|
||||||
// named by On when it resolves, otherwise the root (whole-screen) bounds.
|
|
||||||
// screenBounds returns the device screen rectangle as the maximum extent across
|
// screenBounds returns the device screen rectangle as the maximum extent across
|
||||||
// all elements. The hierarchy root often reports zero bounds on Android, so the
|
// all elements. The hierarchy root often reports zero bounds on Android, so the
|
||||||
// extent (driven by full-screen containers and the navigation bar) is the
|
// extent (driven by full-screen containers and the navigation bar) is the
|
||||||
@@ -773,6 +771,8 @@ func clampGestureToSafeArea(fromX, fromY, toX, toY int, screen hierarchy.Bounds)
|
|||||||
return fromX, fromY, toX, toY
|
return fromX, fromY, toX, toY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// scrollBounds returns the container bounds for an authored Scroll: the node
|
||||||
|
// named by On when it resolves, otherwise the root (whole-screen) bounds.
|
||||||
func scrollBounds(action verifier.Action, tree *hierarchy.Tree) hierarchy.Bounds {
|
func scrollBounds(action verifier.Action, tree *hierarchy.Tree) hierarchy.Bounds {
|
||||||
if tree == nil {
|
if tree == nil {
|
||||||
return hierarchy.Bounds{}
|
return hierarchy.Bounds{}
|
||||||
|
|||||||
@@ -1813,13 +1813,11 @@ func TestClampGestureToSafeArea_KeepsOriginOutOfGestureZones(t *testing.T) {
|
|||||||
screen := hierarchy.Bounds{Left: 0, Top: 0, Right: 1080, Bottom: 2400}
|
screen := hierarchy.Bounds{Left: 0, Top: 0, Right: 1080, Bottom: 2400}
|
||||||
// marginX = 1080/20 = 54, marginY = 2400/12 = 200.
|
// marginX = 1080/20 = 54, marginY = 2400/12 = 200.
|
||||||
|
|
||||||
// The real shade-opening swipe captured on device: origin y=62.
|
// The real shade-opening swipe captured on device: origin y=62 is pulled to
|
||||||
|
// the top margin (200); the in-range destination is untouched.
|
||||||
fromX, fromY, toX, toY := clampGestureToSafeArea(802, 62, 802, 447, screen)
|
fromX, fromY, toX, toY := clampGestureToSafeArea(802, 62, 802, 447, screen)
|
||||||
if fromY < 200 {
|
if fromX != 802 || fromY != 200 || toX != 802 || toY != 447 {
|
||||||
t.Errorf("origin Y %d still inside the status-bar strip (need >= 200)", fromY)
|
t.Errorf("origin not clamped to the safe area: from=(%d,%d) to=(%d,%d), want from=(802,200) to=(802,447)", fromX, fromY, toX, toY)
|
||||||
}
|
|
||||||
if fromX != 802 || toX != 802 || toY != 447 {
|
|
||||||
t.Errorf("unexpected clamp of in-range coords: from=(%d,%d) to=(%d,%d)", fromX, fromY, toX, toY)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Top-left corner origin pulled inside both margins.
|
// Top-left corner origin pulled inside both margins.
|
||||||
@@ -1828,6 +1826,13 @@ func TestClampGestureToSafeArea_KeepsOriginOutOfGestureZones(t *testing.T) {
|
|||||||
t.Errorf("corner origin not clamped to (54,200), got (%d,%d)", fromX, fromY)
|
t.Errorf("corner origin not clamped to (54,200), got (%d,%d)", fromX, fromY)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// An off-screen destination is clamped onto the screen (the destination only
|
||||||
|
// needs to stay on screen, not inside the gesture margins).
|
||||||
|
_, _, toX, toY = clampGestureToSafeArea(540, 1200, -50, 9999, screen)
|
||||||
|
if toX != 0 || toY != 2400 {
|
||||||
|
t.Errorf("off-screen destination not clamped to screen edges: got (%d,%d), want (0,2400)", toX, toY)
|
||||||
|
}
|
||||||
|
|
||||||
// Unknown screen size leaves coordinates untouched.
|
// Unknown screen size leaves coordinates untouched.
|
||||||
fromX, fromY, toX, toY = clampGestureToSafeArea(802, 62, 802, 447, hierarchy.Bounds{})
|
fromX, fromY, toX, toY = clampGestureToSafeArea(802, 62, 802, 447, hierarchy.Bounds{})
|
||||||
if fromX != 802 || fromY != 62 || toX != 802 || toY != 447 {
|
if fromX != 802 || fromY != 62 || toX != 802 || toY != 447 {
|
||||||
|
|||||||
Reference in new issue
Block a user