feat(radio): add nearby discovery and paged search
This commit is contained in:
@@ -197,7 +197,7 @@ void main() {
|
||||
expect(notificaciones, greaterThan(antes));
|
||||
});
|
||||
|
||||
test('reproducir la misma emisora mientras suena no reinicia el stream', () async {
|
||||
test('reproducir la misma emisora mientras suena fuerza recarga del stream', () async {
|
||||
final audio = FakeServicioAudio();
|
||||
final emisora = emisoraDemo(uuid: 'same-1', nombre: 'Misma');
|
||||
final estado = EstadoRadio(
|
||||
@@ -213,7 +213,7 @@ void main() {
|
||||
await estado.reproducir(emisora);
|
||||
await estado.reproducir(emisora);
|
||||
|
||||
expect(audio.emisorasReproducidas, hasLength(1));
|
||||
expect(audio.emisorasReproducidas, hasLength(2));
|
||||
});
|
||||
|
||||
test('reordenar favoritos reindexa de forma determinística', () async {
|
||||
@@ -229,6 +229,35 @@ void main() {
|
||||
expect(lista.map((e) => e.orden).toList(), equals([0, 1, 2]));
|
||||
});
|
||||
|
||||
|
||||
|
||||
test('cargarMasBusqueda pagina resultados y acota memoria', () async {
|
||||
final emisoras = List.generate(
|
||||
70,
|
||||
(i) => emisoraDemo(uuid: 'page-$i', nombre: 'Page $i'),
|
||||
);
|
||||
final estado = EstadoRadio(
|
||||
audio: FakeServicioAudio(),
|
||||
favoritos: FakeServicioFavoritos(),
|
||||
radio: FakeServicioRadio(busqueda: emisoras),
|
||||
servicioEcualizador: FakeServicioEcualizador(),
|
||||
resolverArchivoCustom: _archivoCustomVacio,
|
||||
iniciarAutomaticamente: false,
|
||||
);
|
||||
|
||||
await estado.inicializar();
|
||||
await estado.buscar(nombre: 'page');
|
||||
expect(estado.resultadosBusqueda, hasLength(30));
|
||||
expect(estado.hayMasBusqueda, isTrue);
|
||||
|
||||
await estado.cargarMasBusqueda();
|
||||
expect(estado.resultadosBusqueda, hasLength(60));
|
||||
|
||||
await estado.cargarMasBusqueda();
|
||||
expect(estado.resultadosBusqueda, hasLength(70));
|
||||
expect(estado.hayMasBusqueda, isFalse);
|
||||
});
|
||||
|
||||
test('toggleFavorito refresca lista global y evita estado stale', () async {
|
||||
final favoritos = FakeServicioFavoritos();
|
||||
final emisora = emisoraDemo(uuid: 'fav-sync', nombre: 'Sync');
|
||||
|
||||
@@ -147,7 +147,7 @@ class FakeServicioRadio extends ServicioRadio {
|
||||
error is Exception ? error : Exception(error.toString());
|
||||
|
||||
@override
|
||||
Future<List<Emisora>> obtenerPopulares({int limit = 30}) async {
|
||||
Future<List<Emisora>> obtenerPopulares({int limit = 30, int offset = 0}) async {
|
||||
final llamada = obtenerPopularesCalls++;
|
||||
if (llamada < _erroresPopularesPorLlamada.length) {
|
||||
throw _normalizarError(_erroresPopularesPorLlamada[llamada]);
|
||||
@@ -177,8 +177,9 @@ class FakeServicioRadio extends ServicioRadio {
|
||||
String? idioma,
|
||||
String? tag,
|
||||
int limit = 30,
|
||||
int offset = 0,
|
||||
}) async {
|
||||
return _busqueda.take(limit).toList();
|
||||
return _busqueda.skip(offset).take(limit).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user