You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How is Cup's native Android playback tested on the emulator and the Pixel? #426
How is Cup's native Android playback tested? Which behavior the mobile E2E suite (ADR 0018, loopback exempt from the network cut and freezer) covers on the emulator, which plugin logic gets unit tests, and what the physical-device protocol checks on the operator's Pixel 10 Pro.
Carried over for the protocol: a Pixel Bud out and back in (HCI snoop log shows the pause reaching Cup's session), a headphone disconnect, a call (also adb emu gsm call), another app taking focus, a ducking prompt (now a pause), a notification or earbud Play after the 10-minute grace, a call longer than the grace, swiping Cup from recents. New: a locked listen longer than an hour with positions saved, and the stop when the track URL expires.
Written by @patricktree's agent (Claude Code, Claude Opus 5.5).
Decided with the operator on 2026-11-16. The rule: automate everything the emulator can show, and leave only what needs real hardware or production networking to a manual check on the Pixel 10 Pro.
Emulator: Android mobile E2E suite (deploy gate)
These run against the test Worker. Each is a case in qa/mobile-e2e/test/android/ and extends what draft PR #401's media-session.test.ts already does.
Play and the session. No notification exists before the first Play. After it, the service runs in the foreground with type mediaPlayback. dumpsys media_session shows Cup's session PLAYING, with the title, artwork present and the whole duration. The shade's progress text matches the position.
System controls.KEYCODE_MEDIA_PAUSE and KEYCODE_MEDIA_PLAY, tapping the notification's back 15 and forward 15 buttons, and dragging the shade's seek bar all change the position. Each pause or seek saves it, which the Worker logs as a PUT /api/audiobooks/{id}/position?token=….
Locked listen. Turn the screen off (KEYCODE_POWER, keyguard without PIN) and press HOME, then wait about 120 s, past the freezer's 60 to 90 s. Then check:
Cup's process has isFrozen=false.
The service is still in the foreground.
The position advanced.
Saves arrived at the save interval.
Audio focus.
During adb emu gsm call, playback pauses, and it resumes after gsm cancel.
A transient focus request pauses and then resumes playback.
A duck request pauses playback.
Failure paths.
Dropping adb reverse while playing pauses playback and shows "Press Play to try again".
A track URL that has expired or returns 403 stops the service and removes the notification. The next Play renews the URL and plays.
Lifecycle.
Swiping Cup from recents keeps a playing session.
A relaunch adopts that session and shows the plugin's position.
Sign-out runs close("save"), which saves the position and stops the service.
With the shortened grace (seam c), the session leaves the foreground after the grace and the notification stays.
A notification Play after the grace works.
A call longer than the grace is covered.
Debug-only test seams are passed the same way as cupTestApiOrigin:
(a) The test Worker issues short-lived track and position URLs, the way the sign-in test shortens the token lifetime.
(b) A debug-source-set FocusProbePlugin requests transient, duck or full audio focus on an adb command.
(c) A shortened Media3 foreground grace of about 10 s. If Media3 doesn't expose that timeout, the grace cases in item 6 move to the manual protocol.
The suite can't reproduce the background network cut, because loopback is exempt. It only shows the unfrozen process state that keeps network access. If ExoPlayer doesn't advance under the emulator's -no-audio, the Android emulator starts with audio enabled, as the #373 probe did.
The added runtime of about 3 to 5 minutes on Android is accepted. Android runs in parallel with iOS, and Turbo replays passes.
Native unit tests (review gate)
The plugin's decision logic lives in plain Java classes with no Android imports:
position conversion (listeningPositionAt, mirroring the web player's cases)
the save rules and PlaybackSession's retry and ordering, with an injected clock
whether the track URL has expired
These classes are tested with JUnit 4 on the JVM, without Robolectric. ExoPlayer and MediaSessionService wiring is left to the E2E suite.
apps/mobile-app gets a turbo:test that runs ./gradlew testDebugUnitTest, so the tests run in the review gate. The review gate therefore checks JDK 21 and the Android SDK as prerequisites, which only the deploy gate checks today.
Web-side tests (Vitest, apps/web-app)
The navigator.mediaSession handlers and position state, for every platform.
Both createPlayer implementations behind the Player port. The native-backed one is tested against a fake plugin that emits state events and answers getState().
The page adopting or closing a running session at startup.
The save-rule tests in player-host.test.ts go through the Player port, so the browser implementation keeps the coverage it has today.
Manual Pixel protocol
The protocol is a checked-in checklist in qa/mobile-e2e/ (for example physical-device-protocol.md), linked from the README, so CUP-44 can grow it. During a run, the agent drives everything it can over adb: dumpsys, process state, the HCI snoop log, and the saved positions and Workers Logs. The operator does only the physical actions. The checks:
A Pixel Bud taken out and put back in. The HCI snoop log shows the AVRCP pause reaching Cup's session.
Both Buds put in the case, or a wired disconnect (AUDIO_BECOMING_NOISY).
Another real app taking focus.
An earbud Play after the grace.
A locked listen longer than an hour against production. The evidence is the position the server saved at the end compared with the elapsed time, a spot check of the Workers Logs for regular writes, and dumpsys showing the service still in the foreground.
A visual check of the lock screen's media controls and cover image.
A real incoming call is dropped; the emulator's gsm call covers calls.
The protocol runs once, as CUP-41's acceptance check before it moves to production QA. It runs again only when the plugin's native code, its Media3 version or the target Android version changes. Each run's result goes in that Linear comment. It is not a gate step.
Written by @patricktree's agent (Claude Code, Claude Opus 5.5).
Activity
patricktree commentedon Nov 16, 2026
Resolution
Decided with the operator on 2026-11-16. The rule: automate everything the emulator can show, and leave only what needs real hardware or production networking to a manual check on the Pixel 10 Pro.
Emulator: Android mobile E2E suite (deploy gate)
These run against the test Worker. Each is a case in
qa/mobile-e2e/test/android/and extends what draft PR #401'smedia-session.test.tsalready does.mediaPlayback.dumpsys media_sessionshows Cup's sessionPLAYING, with the title, artwork present and the whole duration. The shade's progress text matches the position.KEYCODE_MEDIA_PAUSEandKEYCODE_MEDIA_PLAY, tapping the notification's back 15 and forward 15 buttons, and dragging the shade's seek bar all change the position. Each pause or seek saves it, which the Worker logs as aPUT /api/audiobooks/{id}/position?token=….KEYCODE_POWER, keyguard without PIN) and press HOME, then wait about 120 s, past the freezer's 60 to 90 s. Then check:isFrozen=false.adb emu gsm call, playback pauses, and it resumes aftergsm cancel.adb reversewhile playing pauses playback and shows "Press Play to try again".403stops the service and removes the notification. The next Play renews the URL and plays.close("save"), which saves the position and stops the service.Debug-only test seams are passed the same way as
cupTestApiOrigin:FocusProbePluginrequests transient, duck or full audio focus on an adb command.The suite can't reproduce the background network cut, because loopback is exempt. It only shows the unfrozen process state that keeps network access. If ExoPlayer doesn't advance under the emulator's
-no-audio, the Android emulator starts with audio enabled, as the #373 probe did.The added runtime of about 3 to 5 minutes on Android is accepted. Android runs in parallel with iOS, and Turbo replays passes.
Native unit tests (review gate)
listeningPositionAt, mirroring the web player's cases)PlaybackSession's retry and ordering, with an injected clockMediaSessionServicewiring is left to the E2E suite.apps/mobile-appgets aturbo:testthat runs./gradlew testDebugUnitTest, so the tests run in the review gate. The review gate therefore checks JDK 21 and the Android SDK as prerequisites, which only the deploy gate checks today.Web-side tests (Vitest,
apps/web-app)navigator.mediaSessionhandlers and position state, for every platform.createPlayerimplementations behind thePlayerport. The native-backed one is tested against a fake plugin that emitsstateevents and answersgetState().player-host.test.tsgo through thePlayerport, so the browser implementation keeps the coverage it has today.Manual Pixel protocol
The protocol is a checked-in checklist in
qa/mobile-e2e/(for examplephysical-device-protocol.md), linked from the README, so CUP-44 can grow it. During a run, the agent drives everything it can over adb:dumpsys, process state, the HCI snoop log, and the saved positions and Workers Logs. The operator does only the physical actions. The checks:AUDIO_BECOMING_NOISY).dumpsysshowing the service still in the foreground.A real incoming call is dropped; the emulator's
gsm callcovers calls.The protocol runs once, as CUP-41's acceptance check before it moves to production QA. It runs again only when the plugin's native code, its Media3 version or the target Android version changes. Each run's result goes in that Linear comment. It is not a gate step.
Written by @patricktree's agent (Claude Code, Claude Opus 5.5).