fix(alarm): start the fade-in when pre-started audio is already playing
The ringing screen only confirmed the native-to-Flutter handoff from its playback-state listener, but app.dart pre-starts the station before pushing the screen, so `reproduciendo` could be emitted before the listener subscribed and no further event ever arrived. That branch only cancelled the fallback timer: the gated fade-in never started and the native alarm player was never told to stop, so the alarm blared at the alarm-stream volume with no 5%-to-target ramp. Previously this was a timing race the stream usually lost; gating the ramp on the confirmation made the failure deterministic. The already-playing branch now confirms the handoff explicitly (idempotent with the listener), and the ramp re-imposes its 5% start volume immediately instead of waiting for the first periodic tick. Adds the regression test mounting in the real pre-started path.
This commit is contained in:
@@ -229,6 +229,30 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
group('handoff con audio prearrancado ya reproduciendo (regresion)', () {
|
||||
testWidgets('si la radio ya esta reproduciendo al montar, la confirmacion '
|
||||
'del handoff y el fade-in arrancan igual', (tester) async {
|
||||
// Real production path: app.dart pre-starts the station BEFORE the
|
||||
// screen mounts, so `reproduciendo` is emitted before the state
|
||||
// listener subscribes and no further state event ever arrives. The
|
||||
// handoff confirmation (native stop) and the Dart ramp must not
|
||||
// depend on catching that already-missed event.
|
||||
final entorno = await _montarPantalla(tester);
|
||||
|
||||
expect(
|
||||
entorno.android.detenidas,
|
||||
contains('ring1'),
|
||||
reason: 'el nativo debe recibir el stop del handoff aunque '
|
||||
'"reproduciendo" haya llegado antes del mount',
|
||||
);
|
||||
expect(
|
||||
entorno.audio.volumenesAplicados,
|
||||
[0.05, 0.85],
|
||||
reason: 'el fade-in debe arrancar tambien en el camino ya-sonando',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('restore de volumen de medios con dispose como unico llamador', () {
|
||||
testWidgets('desmontar la pantalla sin detener ni posponer restaura el '
|
||||
'volumen exactamente una vez', (tester) async {
|
||||
|
||||
Reference in New Issue
Block a user