0416b301b2
- New ServicioExportImport owns the v2 backup envelope, pretty JSON encode and graceful decode; byte-compatible with existing exports, locked by a round-trip test - pantalla_ajustes delegates backup serialization to the service (inline jsonDecode/jsonEncode removed) - New EstadoEcualizador ChangeNotifier owns all EQ state and persistence (principal/current/per-station presets, active flag), exposed via its own provider so EQ changes no longer rebuild EstadoRadio consumers - EstadoRadio slims down ~210 lines and keeps 15 delegating compat members marked TODO(S4b) for the next slice to remove - Player EQ toggle rewired to the new provider to avoid going stale - 4 new tests (103 total green), flutter analyze clean
52 lines
1.6 KiB
Dart
52 lines
1.6 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pluriwave/estado/estado_ecualizador.dart';
|
|
import 'package:pluriwave/estado/estado_radio.dart';
|
|
import 'package:pluriwave/modelos/preset_ecualizador.dart';
|
|
|
|
import '../helpers/fakes.dart';
|
|
|
|
void main() {
|
|
group('EstadoEcualizador (S4-R1)', () {
|
|
test(
|
|
'cambiarPreset notifies EstadoEcualizador listeners (S4-R1-A)',
|
|
() async {
|
|
final audio = FakeServicioAudio();
|
|
final eq = EstadoEcualizador(
|
|
audio: audio,
|
|
servicio: FakeServicioEcualizador(),
|
|
);
|
|
var avisos = 0;
|
|
eq.addListener(() => avisos++);
|
|
|
|
await eq.cambiarPreset(PresetEcualizador.jazz);
|
|
|
|
expect(avisos, greaterThanOrEqualTo(1));
|
|
expect(eq.presetActual, PresetEcualizador.jazz);
|
|
expect(audio.presetsAplicados, contains(PresetEcualizador.jazz));
|
|
eq.dispose();
|
|
},
|
|
);
|
|
|
|
test('EQ preset change does NOT rebuild EstadoRadio listeners '
|
|
'(S4-R1-A, S4-R5)', () async {
|
|
final estado = EstadoRadio(
|
|
audio: FakeServicioAudio(),
|
|
favoritos: FakeServicioFavoritos(),
|
|
radio: FakeServicioRadio(),
|
|
servicioEcualizador: FakeServicioEcualizador(),
|
|
iniciarAutomaticamente: false,
|
|
);
|
|
var avisosRadio = 0;
|
|
var avisosEq = 0;
|
|
estado.addListener(() => avisosRadio++);
|
|
estado.ecualizador.addListener(() => avisosEq++);
|
|
|
|
await estado.ecualizador.cambiarPreset(PresetEcualizador.jazz);
|
|
|
|
expect(avisosEq, greaterThanOrEqualTo(1));
|
|
expect(avisosRadio, 0);
|
|
estado.dispose();
|
|
});
|
|
});
|
|
}
|