mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
feat(ios): derive scrollable from the snapshot's tree depth
the companion now emits each node's depth, so the hierarchy mapper can find the containers that clip content reaching past their own frame and mark them scrollable:true, the same fact android reads off uiautomator and the web driver derives from overflow. a dump without depth makes every element a root and roots are never marked, so the legacy bridge reports no scroll rather than a guessed one.
This commit is contained in:
1 parent
0ab5c305e3
commit
1b01bdbaf1
6 files changed
+234
-10
No files matched your search
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -331,3 +332,59 @@ func TestDumpIsCollapsed(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func scrollableBounds(tree *hierarchy.Tree) []hierarchy.Bounds {
|
||||
var bounds []hierarchy.Bounds
|
||||
for _, element := range tree.FindAllNodes("scrollable:true") {
|
||||
bounds = append(bounds, element.Bounds)
|
||||
}
|
||||
return bounds
|
||||
}
|
||||
|
||||
func TestScrollableMarksTheContainerThatClipsOverflowingContent(t *testing.T) {
|
||||
tree := mapAndParse(
|
||||
t,
|
||||
readDump(t, "home-scrolling-describe.json"),
|
||||
402,
|
||||
874,
|
||||
)
|
||||
got := scrollableBounds(tree)
|
||||
want := []hierarchy.Bounds{{Left: 0, Top: 122, Right: 402, Bottom: 699}}
|
||||
if !slices.Equal(got, want) {
|
||||
t.Fatalf("scrollable containers = %+v, want %+v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestScrollableIsAbsentWhenNothingOverflows(t *testing.T) {
|
||||
tree := mapAndParse(t, readDump(t, "home-fixed-describe.json"), 402, 874)
|
||||
if got := scrollableBounds(tree); len(got) != 0 {
|
||||
t.Fatalf(
|
||||
"scrollable containers = %+v, want none on a screen that does not scroll",
|
||||
got,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func TestScrollableIsAbsentWithoutTreeDepth(t *testing.T) {
|
||||
tree := mapAndParse(t, readDump(t, "accounts-describe.json"), 402, 874)
|
||||
if got := scrollableBounds(tree); len(got) != 0 {
|
||||
t.Fatalf(
|
||||
"scrollable containers = %+v, want none from a dump that carries no depth",
|
||||
got,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func TestScrollableIgnoresAContainerOffTheScreen(t *testing.T) {
|
||||
// The dismissed keyboard is reported below the screen, and its prediction
|
||||
// bar clips a much taller child, so it satisfies every other condition.
|
||||
dump := `[
|
||||
{"type":"Application","depth":0,"frame":{"x":0,"y":0,"width":402,"height":874},"enabled":true},
|
||||
{"type":"Other","depth":1,"frame":{"x":0,"y":874,"width":402,"height":54},"enabled":true},
|
||||
{"type":"Other","depth":2,"frame":{"x":0,"y":274,"width":402,"height":1254},"enabled":true}
|
||||
]`
|
||||
tree := mapAndParse(t, []byte(dump), 402, 874)
|
||||
if got := scrollableBounds(tree); len(got) != 0 {
|
||||
t.Fatalf("scrollable containers = %+v, want none off the screen", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user