import 'package:flutter_test/flutter_test.dart'; import 'package:pluriwave/estado/estado_grabacion.dart'; import 'package:pluriwave/modelos/emisora.dart'; /// Reported: recording a station stopped working, with this on screen — /// /// No se pudo iniciar la grabación: Invalid argument(s): Unsupported scheme /// 'content' in URI content://com.android.externalstorage.documents/tree/ /// primary%3AMusic/document/primary%3AMusic%2F...%2FNew Limit - Smile.mp3 /// /// The URI in the message is a LOCAL MP3, not a station. /// `PluriWaveAudioHandler._cambiarFuente` sets `emisoraActual` for every /// source it plays, so a local track becomes an `Emisora` whose `url` is the /// SAF `content://` document URI it was opened from. The recorder then tried /// to open that as an HTTP stream. /// /// "It used to work" is accurate: before local music playback existed, /// whatever was playing was always a real station, so this could not happen. void main() { Emisora conUrl(String url) => Emisora(uuid: 'u', nombre: 'n', url: url); test('un stream de red es grabable', () { expect(esEmisoraGrabable(conUrl('http://stream.example.com/live')), isTrue); expect( esEmisoraGrabable(conUrl('https://stream.example.com/live')), isTrue, ); expect( esEmisoraGrabable(conUrl('HTTPS://STREAM.EXAMPLE.COM/live')), isTrue, reason: 'el esquema no distingue mayúsculas', ); }); test('la URI content:// de una pista local NO es grabable — el caso ' 'exacto del reporte', () { expect( esEmisoraGrabable( conUrl( 'content://com.android.externalstorage.documents/tree/' 'primary%3AMusic/document/primary%3AMusic%2FNew%20Limit%20-%20' 'Smile.mp3', ), ), isFalse, ); }); test('ni un fichero local, ni una url vacía o rota', () { expect( esEmisoraGrabable(conUrl('file:///storage/emulated/0/a.mp3')), isFalse, ); expect(esEmisoraGrabable(conUrl('')), isFalse); expect(esEmisoraGrabable(conUrl('no es una uri')), isFalse); }); }