Restyle the Ecualizador settings screen to the new visual language while keeping the equalizer at 5 bands (spike-resolved, Engram id 2498 - band count is device-reported via just_audio's AndroidEqualizer, not app-chosen; the approved mockup's 7 sliders would silently no-op on typical hardware). - Restyle EcualizadorWidget in place: strip its internal title + preset chip row (the pushed screen's header now carries the title), add a habilitado parameter that greys/disables every slider when EQ is off. Widen PresetsEcualizadorWidget additively (personalizados param) so custom presets can join the chip row without a second implementation. - Add servicio_presets_personalizados.dart (new file, own SharedPreferences key eq_custom_presets_v1) for custom EQ preset persistence - kept out of servicio_ecualizador.dart, which has an empty-git-diff success criterion for this change. preset_ecualizador.dart is unchanged: a custom preset is just a PresetEcualizador with a user-supplied name. - Extend EstadoEcualizador with presetsPersonalizados, guardarPresetPersonalizado (validates non-empty name), eliminarPresetPersonalizado. The load is a new explicit cargarPresetsPersonalizados(), deliberately NOT folded into cargarPersistido(): that method is exercised ~30 times by estado_ecualizador_test.dart (protected, must stay unmodified) via Fakes only, with no SharedPreferences awareness in that file. - Build out the Ecualizador screen body: base-vs-per-station explainer banner, a "Salida activa" row surfaced on the main screen (previously Advanced-only), an "Emisoras con ajuste propio" drill-down sourced from the existing presetsPorEmisora map, and a "Guardar como preset" action. New coverage lives in new files rather than touching the three protected EQ test files: ecualizador_widget_test.dart (component-level, did not exist before this commit), servicio_presets_personalizados_test.dart, and estado_ecualizador_presets_personalizados_test.dart. servicio_ecualizador.dart, servicio_audio.dart and the three protected EQ test files keep an empty git diff. Full suite: 713/713 green (2 skipped, unchanged), up from 682. size:exception - realized 1,954 changed lines (25 files, plus this docs update) against the 400-550 forecast: lib/ + ARB alone is ~650 lines, near the top of the forecast band by itself since this WU also had to build out a screen body WU3a only stubbed; the rest is 4 test files (675 lines) and 11 new ARB keys regenerating 13 lib/l10n/gen files (~546 lines) - the same pattern every prior work unit in this branch has hit. Not splittable: WU14 reuses this unit's editor component by exact runtime type and cannot begin until this lands as a whole.
162 lines
5.1 KiB
Dart
162 lines
5.1 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pluriwave/estado/estado_ecualizador.dart';
|
|
import 'package:pluriwave/modelos/preset_ecualizador.dart';
|
|
|
|
import '../helpers/fakes.dart';
|
|
|
|
/// WU13 task 13.7 — `EstadoEcualizador`'s new custom-preset members
|
|
/// (`presetsPersonalizados`, `guardarPresetPersonalizado`,
|
|
/// `eliminarPresetPersonalizado`), reading/writing only through the new
|
|
/// `ServicioPresetsPersonalizados` (design ADR-5 hazard box).
|
|
///
|
|
/// **Correction found at apply time, deliberate**: this is a NEW file, not
|
|
/// an addition to `estado_ecualizador_test.dart`. That file is one of the
|
|
/// three EQ test files this change's master guard requires to pass
|
|
/// **unmodified** — it is exercised ~30 times via `cargarPersistido()`
|
|
/// using Fakes for `servicio`/`dispositivoAudio` ONLY, with no
|
|
/// SharedPreferences awareness anywhere in the file. Because of that,
|
|
/// `cargarPersistido()` itself is intentionally left untouched by this WU
|
|
/// (see `cargarPresetsPersonalizados` below) rather than folding a third,
|
|
/// always-real-by-default collaborator into a method exercised by a file
|
|
/// that must never change.
|
|
void main() {
|
|
EstadoEcualizador buildEq({FakeServicioPresetsPersonalizados? servicio}) {
|
|
return EstadoEcualizador(
|
|
audio: FakeServicioAudio(),
|
|
servicio: FakeServicioEcualizador(),
|
|
presetsPersonalizadosService:
|
|
servicio ?? FakeServicioPresetsPersonalizados(),
|
|
);
|
|
}
|
|
|
|
test('presetsPersonalizados starts empty before loading', () {
|
|
final eq = buildEq();
|
|
|
|
expect(eq.presetsPersonalizados, isEmpty);
|
|
eq.dispose();
|
|
});
|
|
|
|
test(
|
|
'cargarPresetsPersonalizados populates presetsPersonalizados from the service',
|
|
() async {
|
|
final fakeServicio = FakeServicioPresetsPersonalizados();
|
|
final preexistente = PresetEcualizador(
|
|
nombre: 'Ya guardado',
|
|
bandas: [1, 2, 3, 4, 5],
|
|
);
|
|
await fakeServicio.guardar(preexistente);
|
|
final eq = buildEq(servicio: fakeServicio);
|
|
|
|
await eq.cargarPresetsPersonalizados();
|
|
|
|
expect(eq.presetsPersonalizados, hasLength(1));
|
|
expect(eq.presetsPersonalizados.single.nombre, equals('Ya guardado'));
|
|
eq.dispose();
|
|
},
|
|
);
|
|
|
|
test(
|
|
'guardarPresetPersonalizado saves the CURRENT effective preset bands under the given name',
|
|
() async {
|
|
final eq = buildEq();
|
|
await eq.cambiarPreset(PresetEcualizador.jazz);
|
|
|
|
final guardado = await eq.guardarPresetPersonalizado('Mi preset');
|
|
|
|
expect(guardado, isTrue);
|
|
expect(eq.presetsPersonalizados, hasLength(1));
|
|
expect(eq.presetsPersonalizados.single.nombre, equals('Mi preset'));
|
|
expect(
|
|
eq.presetsPersonalizados.single.bandas,
|
|
equals(PresetEcualizador.jazz.bandas),
|
|
);
|
|
eq.dispose();
|
|
},
|
|
);
|
|
|
|
test('guardarPresetPersonalizado notifies listeners on success', () async {
|
|
final eq = buildEq();
|
|
var avisos = 0;
|
|
eq.addListener(() => avisos++);
|
|
|
|
await eq.guardarPresetPersonalizado('Preset con nombre');
|
|
|
|
expect(avisos, greaterThanOrEqualTo(1));
|
|
eq.dispose();
|
|
});
|
|
|
|
test(
|
|
'guardarPresetPersonalizado rejects an empty name: no save, returns false',
|
|
() async {
|
|
final eq = buildEq();
|
|
|
|
final guardado = await eq.guardarPresetPersonalizado('');
|
|
|
|
expect(guardado, isFalse);
|
|
expect(eq.presetsPersonalizados, isEmpty);
|
|
eq.dispose();
|
|
},
|
|
);
|
|
|
|
test(
|
|
'guardarPresetPersonalizado rejects a whitespace-only name: no save, returns false',
|
|
() async {
|
|
final eq = buildEq();
|
|
|
|
final guardado = await eq.guardarPresetPersonalizado(' ');
|
|
|
|
expect(guardado, isFalse);
|
|
expect(eq.presetsPersonalizados, isEmpty);
|
|
eq.dispose();
|
|
},
|
|
);
|
|
|
|
test(
|
|
'guardarPresetPersonalizado trims surrounding whitespace from a valid name',
|
|
() async {
|
|
final eq = buildEq();
|
|
|
|
final guardado = await eq.guardarPresetPersonalizado(' Con espacios ');
|
|
|
|
expect(guardado, isTrue);
|
|
expect(eq.presetsPersonalizados.single.nombre, equals('Con espacios'));
|
|
eq.dispose();
|
|
},
|
|
);
|
|
|
|
test(
|
|
'eliminarPresetPersonalizado removes a previously saved preset',
|
|
() async {
|
|
final eq = buildEq();
|
|
await eq.guardarPresetPersonalizado('Para borrar');
|
|
expect(eq.presetsPersonalizados, hasLength(1));
|
|
|
|
await eq.eliminarPresetPersonalizado('Para borrar');
|
|
|
|
expect(eq.presetsPersonalizados, isEmpty);
|
|
eq.dispose();
|
|
},
|
|
);
|
|
|
|
test(
|
|
'guardarPresetPersonalizado reads/writes only through the injected service '
|
|
'(never touches ServicioEcualizador)',
|
|
() async {
|
|
final fakeEcualizador = FakeServicioEcualizador();
|
|
final eq = EstadoEcualizador(
|
|
audio: FakeServicioAudio(),
|
|
servicio: fakeEcualizador,
|
|
presetsPersonalizadosService: FakeServicioPresetsPersonalizados(),
|
|
);
|
|
|
|
await eq.guardarPresetPersonalizado('Aislado');
|
|
|
|
// ServicioEcualizador's own config is completely untouched by the
|
|
// custom-preset save — it lives in a separate service (ADR-5 hazard
|
|
// box), not folded into servicio_ecualizador.dart's persistence.
|
|
expect(fakeEcualizador.config.porEmisora, isEmpty);
|
|
eq.dispose();
|
|
},
|
|
);
|
|
}
|