feat: confirm playback from the media session, and stop demoting the top row
Phase 3 DoD reached end to end: `artemis run spotify_play query="Rolling Stones Honky Tonk"` played the right song in 13 steps / 35.3s, with playback paused first so the pass proves the row tap started it. Two things stopped it before that, both found on the real phone: - The playback check asserted on an on-screen "Pause" label that Spotify never shows: its transport button keeps the label "Play" while music is playing. The recipe now ends with a `playing` step that reads the app's media session (state PLAYING) and confirms the track title contains the query words. A failure reports the state and the track it found. - tap_row pressed the wrong row. Once a track is loaded its row carries a `Paused` state indicator, and counting that content description as row text dropped the top hit below an identical duplicate further down, so the tap went to y=1443 instead of y=878. Rows are now scored on their title and subtitle only (state lives in content descriptions), and scores within rowScoreTolerance are treated as equal so the higher row wins, because Spotify already ranks by relevance. internal/ui/rows_test.go reproduces that results screen, including the state indicator and the duplicate row. docs/phase-3-spotify-recipe.md records the successful run, the independent media-session and audio-output reads, and the failure that preceded it.
This commit is contained in:
@@ -215,6 +215,38 @@ func executeStep(r *adb.Runner, rec *Recipe, step Step, index int, params map[st
|
||||
sr.Detail = "found " + node.Label()
|
||||
return nil
|
||||
|
||||
case "playing":
|
||||
// The screen is not a trustworthy place to read playback: Spotify's
|
||||
// transport button keeps the label "Play" while music is playing.
|
||||
// Ask the media session instead, and confirm the track title.
|
||||
pkg := rec.App
|
||||
if len(args) == 2 {
|
||||
pkg = args[1]
|
||||
}
|
||||
if pkg == "" {
|
||||
return fmt.Errorf("playing needs an app: add an \"app:\" setting")
|
||||
}
|
||||
checkDeadline := time.Now().Add(timeout)
|
||||
var last *ui.Playback
|
||||
for {
|
||||
state, err := ui.PlaybackState(r, pkg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
last = state
|
||||
if state.Playing() && state.Title != "" {
|
||||
matched, total := ui.MatchesText(state.Title, args[0])
|
||||
if total > 0 && matched*2 >= total {
|
||||
sr.Detail = fmt.Sprintf("%s is playing %q", pkg, state.Title)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
if time.Now().After(checkDeadline) {
|
||||
return fmt.Errorf("%s is not playing %q within %s (%s)", pkg, args[0], timeout, last)
|
||||
}
|
||||
time.Sleep(ui.PollInterval)
|
||||
}
|
||||
|
||||
case "wait_gone":
|
||||
if err := ui.WaitForNoText(r, args[0], step.Exact, timeout); err != nil {
|
||||
return describeFailure(r, rec, err)
|
||||
|
||||
Reference in New Issue
Block a user