fix(auto): preserve phone-chosen station order in Android Auto folders
Android Auto's Favoritos/Todas/Mis emisoras folders always re-sorted by a hardcoded quality criterion in ConstructorArbolAuto.hijos/hijosGrupo, discarding whatever order the caller passed in. EstadoRadio now pushes already-ordered snapshots (listaFavoritosManual for Favoritos, and the ordenListas-sorted populares/emisorasCustom getters for Todas/Mis emisoras, re-pushed immediately on cambiarOrdenListas), and hijos/ hijosGrupo stop re-sorting so that order survives into the car.
This commit is contained in:
@@ -607,6 +607,136 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
test(
|
||||
'fix android-auto-orden: el snapshot de favoritos es EXACTAMENTE '
|
||||
'listaFavoritosManual (el orden manual que la pantalla Favoritos '
|
||||
'muestra y reordena), nunca la lista cruda ni un getter reordenado',
|
||||
() async {
|
||||
final favoritosServicio = FakeServicioFavoritos();
|
||||
// Agregados en orden Z, A: si el push usara un getter reordenado
|
||||
// (p. ej. alfabético), 'alfa' iría primero. El orden manual conserva
|
||||
// el orden de inserción/persistencia: Z, A.
|
||||
await favoritosServicio.agregar(
|
||||
emisoraDemo(uuid: 'zulu', nombre: 'Zulu Fav'),
|
||||
);
|
||||
await favoritosServicio.agregar(
|
||||
emisoraDemo(uuid: 'alfa', nombre: 'Alfa Fav'),
|
||||
);
|
||||
final fuenteAuto = _FuenteEmisorasAutoEspia();
|
||||
final estado = EstadoRadio(
|
||||
audio: FakeServicioAudio(),
|
||||
favoritos: favoritosServicio,
|
||||
radio: FakeServicioRadio(),
|
||||
servicioEcualizador: FakeServicioEcualizador(),
|
||||
resolverArchivoCustom: _archivoCustomVacio,
|
||||
fuenteAuto: fuenteAuto,
|
||||
iniciarAutomaticamente: false,
|
||||
);
|
||||
|
||||
await estado.inicializar();
|
||||
|
||||
expect(fuenteAuto.ultimoFavoritos?.map((e) => e.uuid).toList(), [
|
||||
'zulu',
|
||||
'alfa',
|
||||
]);
|
||||
expect(fuenteAuto.ultimoFavoritos, equals(estado.listaFavoritosManual));
|
||||
},
|
||||
);
|
||||
|
||||
test('fix android-auto-orden: el snapshot de "Todas" honra el orden '
|
||||
'global (ordenListas) igual que "Tendencias" en el teléfono, no el '
|
||||
'orden crudo de llegada de la API', () async {
|
||||
SharedPreferences.setMockInitialValues({
|
||||
'orden_listas_emisoras_v1': 'nombre',
|
||||
});
|
||||
final fuenteAuto = _FuenteEmisorasAutoEspia();
|
||||
final estado = EstadoRadio(
|
||||
audio: FakeServicioAudio(),
|
||||
favoritos: FakeServicioFavoritos(),
|
||||
radio: FakeServicioRadio(
|
||||
populares: [
|
||||
emisoraDemo(uuid: 'zulu-pop', nombre: 'Zulu Pop'),
|
||||
emisoraDemo(uuid: 'alfa-pop', nombre: 'Alfa Pop'),
|
||||
],
|
||||
),
|
||||
servicioEcualizador: FakeServicioEcualizador(),
|
||||
resolverArchivoCustom: _archivoCustomVacio,
|
||||
fuenteAuto: fuenteAuto,
|
||||
iniciarAutomaticamente: false,
|
||||
);
|
||||
|
||||
await estado.inicializar();
|
||||
|
||||
expect(fuenteAuto.ultimoTodas?.map((e) => e.uuid).toList(), [
|
||||
'alfa-pop',
|
||||
'zulu-pop',
|
||||
]);
|
||||
});
|
||||
|
||||
test('fix android-auto-orden: el snapshot de "Mis emisoras" honra el '
|
||||
'orden global (ordenListas), no el orden crudo del archivo', () async {
|
||||
SharedPreferences.setMockInitialValues({
|
||||
'orden_listas_emisoras_v1': 'nombre',
|
||||
});
|
||||
final archivo = await _crearArchivoCustom([
|
||||
emisoraDemo(uuid: 'zulu-custom', nombre: 'Zulu Custom'),
|
||||
emisoraDemo(uuid: 'alfa-custom', nombre: 'Alfa Custom'),
|
||||
]);
|
||||
final fuenteAuto = _FuenteEmisorasAutoEspia();
|
||||
final estado = EstadoRadio(
|
||||
audio: FakeServicioAudio(),
|
||||
favoritos: FakeServicioFavoritos(),
|
||||
radio: FakeServicioRadio(),
|
||||
servicioEcualizador: FakeServicioEcualizador(),
|
||||
resolverArchivoCustom: () async => archivo,
|
||||
fuenteAuto: fuenteAuto,
|
||||
iniciarAutomaticamente: false,
|
||||
);
|
||||
|
||||
await estado.inicializar();
|
||||
|
||||
expect(fuenteAuto.ultimoMisEmisoras?.map((e) => e.uuid).toList(), [
|
||||
'alfa-custom',
|
||||
'zulu-custom',
|
||||
]);
|
||||
});
|
||||
|
||||
test('fix android-auto-orden: cambiarOrdenListas re-empuja de inmediato '
|
||||
'los snapshots de "Todas" y "Mis emisoras" con el nuevo orden, sin '
|
||||
'esperar a la próxima recarga completa', () async {
|
||||
final archivo = await _crearArchivoCustom([
|
||||
emisoraDemo(uuid: 'zulu-custom', nombre: 'Zulu Custom'),
|
||||
emisoraDemo(uuid: 'alfa-custom', nombre: 'Alfa Custom'),
|
||||
]);
|
||||
final fuenteAuto = _FuenteEmisorasAutoEspia();
|
||||
final estado = EstadoRadio(
|
||||
audio: FakeServicioAudio(),
|
||||
favoritos: FakeServicioFavoritos(),
|
||||
radio: FakeServicioRadio(
|
||||
populares: [
|
||||
emisoraDemo(uuid: 'zulu-pop', nombre: 'Zulu Pop'),
|
||||
emisoraDemo(uuid: 'alfa-pop', nombre: 'Alfa Pop'),
|
||||
],
|
||||
),
|
||||
servicioEcualizador: FakeServicioEcualizador(),
|
||||
resolverArchivoCustom: () async => archivo,
|
||||
fuenteAuto: fuenteAuto,
|
||||
iniciarAutomaticamente: false,
|
||||
);
|
||||
|
||||
await estado.inicializar();
|
||||
await estado.cambiarOrdenListas(OrdenEmisoras.nombre);
|
||||
|
||||
expect(fuenteAuto.ultimoTodas?.map((e) => e.uuid).toList(), [
|
||||
'alfa-pop',
|
||||
'zulu-pop',
|
||||
]);
|
||||
expect(fuenteAuto.ultimoMisEmisoras?.map((e) => e.uuid).toList(), [
|
||||
'alfa-custom',
|
||||
'zulu-custom',
|
||||
]);
|
||||
});
|
||||
|
||||
test('reconcilia _emisoraSeleccionada cuando la selección viene desde '
|
||||
'el auto (no via reproducir())', () async {
|
||||
final audio = _AudioControlado();
|
||||
|
||||
Reference in New Issue
Block a user