test(e2e): SpeechToText @TestInstallIn swap + FakeSpeechToText#462
Merged
Conversation
## Priority 5: Refactor / Quality Mirrors #460's TTS swap pattern for the STT boundary so future E2E tests can drive `voicePipeline.startListening()` from a programmatic SttResult source instead of needing an emulator microphone. Production refactor (minimal): - Extract `provideSpeechToText` from `VoiceModule` into a new `SttModule`. No behavioural change — same `DelegatingSttProvider` singleton, same constructor. Test additions: - `FakeSpeechToText`: Channel-backed `SpeechToText` impl. Tests call `queue(SttResult.Final("..."))` to push results; the next `startListening()` collector receives them in order. `Final` / `Error` close the channel so the Flow completes (matching how the real `AndroidSttProvider` ends a session). - `FakeSttTestModule`: `@TestInstallIn(replaces = [SttModule::class])` registering the same singleton against both `SpeechToText` and the concrete fake type. - `FakeSttPipelineE2ETest`: 4 cases proving the swap works: * the interface and the concrete fake resolve to the same Hilt singleton (regression guard against accidentally creating two instances) * queued partials + a final emit in order and complete the Flow * an `Error` result terminates the session * `reset()` allows a second listening session within one test Scope note: full wake→STT→tool→TTS pipeline E2E is left to a follow-up because `VoicePipeline.startListening()` touches `VoiceService`, `AudioFocus`, and a beep player that need either a service test rule or further extraction. This PR ships the swap pattern; the chain hookup PR can build on it. Verification: - ./gradlew assembleStandardDebugAndroidTest — green - ./gradlew assembleStandardDebug testStandardDebugUnitTest — green
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Priority 5: Refactor / Quality
Mirrors #460's TTS swap pattern for the STT boundary so future E2E tests can drive `voicePipeline.startListening()` from a programmatic `SttResult` source instead of needing an emulator microphone.
What changed
Production refactor (minimal, no behavioural change)
Tests (`app/src/androidTest/...`)
Scope note
Full wake→STT→tool→TTS pipeline E2E is left to a follow-up because `VoicePipeline.startListening()` touches `VoiceService`, `AudioFocus`, and a beep player that need either a service test rule or further extraction. This PR ships the swap pattern; the chain hookup PR can build on it.
Test plan