test fix
This commit is contained in:
parent
2099d3d64d
commit
9728906556
2 changed files with 16 additions and 4 deletions
|
|
@ -141,13 +141,15 @@ class PlaybackController extends StateNotifier<PlaybackState>
|
||||||
required String? Function() serverKeyGetter,
|
required String? Function() serverKeyGetter,
|
||||||
required void Function(Uri artUri) onArt,
|
required void Function(Uri artUri) onArt,
|
||||||
required void Function(Song song) onPlay,
|
required void Function(Song song) onPlay,
|
||||||
|
@visibleForTesting bool? audioEnabled,
|
||||||
}) : _streamUriFor = streamUriFor,
|
}) : _streamUriFor = streamUriFor,
|
||||||
_coverArtUriFor = coverArtUriFor,
|
_coverArtUriFor = coverArtUriFor,
|
||||||
_serverKeyGetter = serverKeyGetter,
|
_serverKeyGetter = serverKeyGetter,
|
||||||
_onArt = onArt,
|
_onArt = onArt,
|
||||||
_onPlay = onPlay,
|
_onPlay = onPlay,
|
||||||
super(PlaybackState(supported: _audioSupported)) {
|
_audioEnabled = audioEnabled ?? _audioSupported,
|
||||||
if (_audioSupported) {
|
super(PlaybackState(supported: audioEnabled ?? _audioSupported)) {
|
||||||
|
if (_audioEnabled) {
|
||||||
_player = AudioPlayer();
|
_player = AudioPlayer();
|
||||||
_wireStreams();
|
_wireStreams();
|
||||||
}
|
}
|
||||||
|
|
@ -161,6 +163,12 @@ class PlaybackController extends StateNotifier<PlaybackState>
|
||||||
final void Function(Uri artUri) _onArt;
|
final void Function(Uri artUri) _onArt;
|
||||||
final void Function(Song song) _onPlay;
|
final void Function(Song song) _onPlay;
|
||||||
|
|
||||||
|
/// Whether a platform [AudioPlayer] was created. Defaults to [_audioSupported]
|
||||||
|
/// but tests force it false so a headless CI host (macOS/iOS, where
|
||||||
|
/// [_audioSupported] is true) doesn't touch uninitialized just_audio platform
|
||||||
|
/// channels. The queue/state logic runs identically either way.
|
||||||
|
final bool _audioEnabled;
|
||||||
|
|
||||||
AudioPlayer? _player;
|
AudioPlayer? _player;
|
||||||
|
|
||||||
final Random _random = Random();
|
final Random _random = Random();
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,17 @@ void main() {
|
||||||
final sessions = <RemoteSession>[];
|
final sessions = <RemoteSession>[];
|
||||||
|
|
||||||
PlaybackController buildController() => PlaybackController(
|
PlaybackController buildController() => PlaybackController(
|
||||||
// Non-null so songs count as streamable; no real player exists on the
|
// Non-null so songs count as streamable; no real player is created
|
||||||
// test host (audio unsupported), so this URI is never opened.
|
// (audioEnabled: false), so this URI is never opened. Forcing audio off
|
||||||
|
// keeps the test headless on any host — a macOS/iOS CI runner would
|
||||||
|
// otherwise build a just_audio AudioPlayer against uninitialized
|
||||||
|
// platform channels and throw.
|
||||||
streamUriFor: (s) => Uri.parse('http://host.local/stream/${s.id}'),
|
streamUriFor: (s) => Uri.parse('http://host.local/stream/${s.id}'),
|
||||||
coverArtUriFor: (_) => null,
|
coverArtUriFor: (_) => null,
|
||||||
serverKeyGetter: () => serverKey,
|
serverKeyGetter: () => serverKey,
|
||||||
onArt: (_) {},
|
onArt: (_) {},
|
||||||
onPlay: (_) {},
|
onPlay: (_) {},
|
||||||
|
audioEnabled: false,
|
||||||
);
|
);
|
||||||
|
|
||||||
RemoteSession newSession(
|
RemoteSession newSession(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue