import 'package:flutter_test/flutter_test.dart'; /// Reported: playing a song stored on the phone and pressing NEXT jumped to a /// radio station — "at least the first time". /// /// Self-inflicted, by 3398d02. That commit taught `skipToNext`/`skipToPrevious` /// to fall back to station-to-station skipping when there is no local queue, /// so the car's transport buttons would not be dead for radio. But a /// queue-less state does NOT mean "radio is playing": tapping ONE local track /// goes through `reproducirPistaLocal`, which never builds a queue. Only /// folder playback sets `_colaLocal` — which is exactly why the report said /// "at least the first time". /// /// `emisoraActual` cannot tell them apart either: `_cambiarFuente` fills it in /// for every source, so a local MP3 arrives as an `Emisora` whose `url` is its /// `content://` document URI. The media id's SCHEME is the real /// discriminator, and this asserts on that rule — the same one /// `esEmisoraGrabable` uses to keep the recorder off local files. /// /// `PluriWaveAudioHandler` needs platform MethodChannels and cannot be built /// in a unit test, so this pins the predicate rather than the private getter. void main() { bool esRadio(String? id) { if (id == null) return false; final esquema = Uri.tryParse(id)?.scheme.toLowerCase(); return esquema == 'http' || esquema == 'https'; } test('un stream de radio SÍ permite saltar de emisora', () { expect(esRadio('http://stream.example.com/live'), isTrue); expect(esRadio('https://stream.example.com/live'), isTrue); }); test('una pista local NO: es el caso exacto del reporte', () { expect( esRadio( 'content://com.android.externalstorage.documents/tree/' 'primary%3AMusic/document/primary%3AMusic%2FNew%20Limit%20-%20Smile.mp3', ), isFalse, reason: 'con una pista suelta no hay cola, y antes de esto el boton ' 'siguiente se iba a una emisora de radio', ); expect(esRadio('file:///storage/emulated/0/musica/a.mp3'), isFalse); }); test('sin nada sonando tampoco se salta', () { expect(esRadio(null), isFalse); expect(esRadio(''), isFalse); }); }