test(android-e2e): wait for the foreground to leave the fixture after Home
Summary
Closes #4990.
assertHomeAndRecentsRestoration read the foreground once after home, so the smoke lane failed when that read landed while WindowManager was still resuming the launcher. All three reported runs show one ordering: home finished after 55-121 ms (one injected keyevent), the next appstate read started 90-193 ms later, answered in 193-443 ms, and still named com.callstack.agentdevicelab/MainActivity. Run 45068801264's failed-step evidence shows topResumedActivity=NexusLauncherActivity about 1.5 s after the keyevent, so Home did happen; the read was early. #4716 bounded the pixel transition and kept this single read. The lane now waits at that owner with waitForForegroundLeaves — the same deadline, poll and per-attempt bound as waitForSurfaceChange — and reads pixels only once the device reports the foreground left the fixture. A foreground that never leaves fails at the deadline with its last observation. Test harness only.
Before / after
The scenario through runScenario, scripted to answer the first appstate reads after Home with the fixture package:
- Before: rejects with
notStrictEqual, actual = expected =com.callstack.agentdevicelab— the hosted signature. - After: fulfills after four
read Android Home foreground state (attempt N)steps. A foreground that never transitions rejects at the deadline, before any Home-surface capture.
Validation
Head ae8463ae7c on origin/0.22 (80678b6823). pnpm install --frozen-lockfile, pnpm build, typecheck, format, oxlint, and the five android-emulator-e2e suites passed: 39/39, 7 new tests. pnpm check:affected --run --base origin/0.22 --head ae8463ae7c passed exactCommit=true (receipt .tmp/validation/run-gaUrUm). Hosted Smoke Tests runs the live Android lane; no local device was allocated here.
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.