feat: bounded retry for a dropped tap, and poll the screen more gently
Running spotify_play against the real phone showed a tap can be delivered to the app and then never acted on (the dispatcher lists the Spotify window as the touch target, and the screen does not move). The run log also showed step durations were printed as 0s while the recorded ones were correct. - wait steps accept "retry N": on timeout, re-run the step above and wait again, up to N extra times. Only a wait may use it, it needs a step above it, and it can only press something already matched by text. spotify_play uses it on the search box and on the playback check. - The success log line printed the duration before the deferred assignment ran. It now records the duration first. - uiautomator dump starts a JVM on the phone, and the wait helpers polled every 400ms. ui.PollInterval is now 1500ms, which cuts that load on a phone that is already short of memory. docs/phase-3-spotify-recipe.md logs attempts 7-10: the recipe now reaches tap_row and picks "Honky Tonk Women" at (540,878), but the app stops acting on input on this loaded phone, so the end-to-end run is still outstanding.
This commit is contained in:
@@ -172,6 +172,9 @@ func TestSpotifyRecipeIsValid(t *testing.T) {
|
||||
if last.Verb != "wait" || last.Args[0] != "Pause" {
|
||||
t.Fatalf("the last step must confirm playback, got %+v", last)
|
||||
}
|
||||
if last.Retry < 1 {
|
||||
t.Fatal("the playback check must be allowed to press the row again")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadAndList(t *testing.T) {
|
||||
@@ -205,6 +208,38 @@ func TestLoadAndList(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRetryOnWait(t *testing.T) {
|
||||
rec, err := Parse("steps:\n - tap_row \"{query}\" 40s\n - wait exact \"Pause\" 45s retry 3\n")
|
||||
if err != nil {
|
||||
t.Fatalf("Parse: %v", err)
|
||||
}
|
||||
wait := rec.Steps[1]
|
||||
if wait.Retry != 3 || wait.Timeout != 45*time.Second || !wait.Exact || wait.Args[0] != "Pause" {
|
||||
t.Fatalf("retry wait step = %+v", wait)
|
||||
}
|
||||
// retry without a duration still works.
|
||||
rec, err = Parse("steps:\n - tap_row \"x\"\n - wait \"Pause\" retry 2\n")
|
||||
if err != nil {
|
||||
t.Fatalf("Parse: %v", err)
|
||||
}
|
||||
if rec.Steps[1].Retry != 2 || rec.Steps[1].Timeout != 0 {
|
||||
t.Fatalf("retry step = %+v", rec.Steps[1])
|
||||
}
|
||||
}
|
||||
|
||||
func TestRetryRejectsBadUse(t *testing.T) {
|
||||
for name, src := range map[string]string{
|
||||
"on a tap": "steps:\n - tap \"x\" retry 3\n",
|
||||
"no number": "steps:\n - tap_row \"x\"\n - wait \"y\" retry\n",
|
||||
"zero": "steps:\n - tap_row \"x\"\n - wait \"y\" retry 0\n",
|
||||
"not a number": "steps:\n - tap_row \"x\"\n - wait \"y\" retry soon\n",
|
||||
} {
|
||||
if _, err := Parse(src); err == nil {
|
||||
t.Errorf("%s: expected a parse error", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestForegroundStep(t *testing.T) {
|
||||
rec, err := Parse("app: com.spotify.music\nsteps:\n - launch\n - foreground 30s\n")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user