mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
refactor(hierarchy): one Tree.Transitional, drop the duplicated cross-fade check
This commit is contained in:
1 parent
1a893c570d
commit
b82a27df4e
5 files changed
+52
-71
No files matched your search
@@ -878,7 +878,7 @@ retryLoop:
|
||||
tree, err = hierarchy.Parse(hierarchyJSON)
|
||||
pngBytes = image.PNG
|
||||
}
|
||||
if err != nil || !isTransitionalHierarchy(tree) {
|
||||
if err != nil || !tree.Transitional() {
|
||||
break
|
||||
}
|
||||
// A tree unchanged since the previous attempt is a settled state
|
||||
@@ -909,27 +909,6 @@ retryLoop:
|
||||
return tree, pngBytes, transitional, err
|
||||
}
|
||||
|
||||
// isTransitionalHierarchy returns true when the tree carries more than one
|
||||
// resource-id ending in "Screen" - the marker of a Compose NavHost mid
|
||||
// cross-fade where both source and destination route composables are alive.
|
||||
// Mirrors the sidecar's stabilitySnapshot heuristic so runner-side rejection
|
||||
// stays consistent with the settle poll.
|
||||
func isTransitionalHierarchy(tree *hierarchy.Tree) bool {
|
||||
if tree == nil {
|
||||
return false
|
||||
}
|
||||
screens := 0
|
||||
for _, element := range tree.Elements {
|
||||
if strings.HasSuffix(element.ResourceID, "Screen") {
|
||||
screens++
|
||||
if screens > 1 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func traceActionFor(action verifier.Action, tree *hierarchy.Tree) *trace.Action {
|
||||
traceAction := &trace.Action{Kind: string(action.Kind), X: action.X, Y: action.Y}
|
||||
switch action.Kind {
|
||||
|
||||
@@ -1118,34 +1118,6 @@ func TestRunner_OneScreenshotPerStep(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestIsTransitionalHierarchy_DetectsMultipleScreens covers the runner-side
|
||||
// guard that re-fetches when the hierarchy still carries two route-level
|
||||
// *Screen ids - the NavHost cross-fade signature.
|
||||
func TestIsTransitionalHierarchy_DetectsMultipleScreens(t *testing.T) {
|
||||
multi, err := hierarchy.Parse(`{"attributes":{"resource-id":"root"},"children":[
|
||||
{"attributes":{"resource-id":"AddAccountScreen"},"children":[]},
|
||||
{"attributes":{"resource-id":"HomeScreen"},"children":[]}
|
||||
]}`)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !isTransitionalHierarchy(multi) {
|
||||
t.Error("expected multi-screen tree to be flagged as transitional")
|
||||
}
|
||||
|
||||
single, err := hierarchy.Parse(`{"attributes":{"resource-id":"HomeScreen"},"children":[]}`)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if isTransitionalHierarchy(single) {
|
||||
t.Error("single-screen tree must not be flagged as transitional")
|
||||
}
|
||||
|
||||
if isTransitionalHierarchy(nil) {
|
||||
t.Error("nil tree must not be flagged as transitional")
|
||||
}
|
||||
}
|
||||
|
||||
// TestRunner_StableTransitionalTreeIsVerified feeds a driver whose hierarchy
|
||||
// constantly carries two route-level *Screen ids but never changes between
|
||||
// retry attempts. Such a tree is a settled state that merely matches the
|
||||
|
||||
Reference in new issue
Block a user