fix(library): sync track playback controls

This commit is contained in:
zarzet
2026-08-30 00:43:13 +07:00
parent d5465e9768
commit 7141ca980f
7 changed files with 150 additions and 38 deletions
+38
View File
@@ -0,0 +1,38 @@
import 'package:audio_service/audio_service.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:spotiflac_android/providers/music_player_provider.dart';
void main() {
test('Library playback state follows only the current media item', () async {
final container = ProviderContainer(
overrides: [
currentMediaItemProvider.overrideWith(
(ref) =>
Stream.value(const MediaItem(id: 'track-1', title: 'Track 1')),
),
playbackPlayingProvider.overrideWith((ref) => true),
playbackLoadingProvider.overrideWith((ref) => false),
],
);
addTearDown(container.dispose);
final currentMediaSubscription = container.listen(
currentMediaItemProvider,
(_, _) {},
);
addTearDown(currentMediaSubscription.close);
await container.read(currentMediaItemProvider.future);
expect(container.read(mediaItemPlaybackUiProvider('track-1')), (
isCurrent: true,
isPlaying: true,
isLoading: false,
));
expect(container.read(mediaItemPlaybackUiProvider('track-2')), (
isCurrent: false,
isPlaying: false,
isLoading: false,
));
});
}
+3 -2
View File
@@ -407,12 +407,13 @@ void main() {
expect(gridSource, contains('CompletionBridgePlayableStatus.checking'));
expect(gridSource, contains('semanticsLabel:'));
expect(gridSource, contains('queueCheckingDownloadedFile'));
expect(gridSource, contains('TrackGridPlayButton('));
expect(gridSource, contains('_LibraryPlaybackButton('));
expect(gridSource, contains('grid: true'));
expect(listSource, contains('resolveCompletionBridgePlayablePath('));
expect(listSource, contains('_completionBridgePlayableProbe.listenable('));
expect(listSource, contains('CompletionBridgePlayableStatus.checking'));
expect(listSource, contains('semanticsLabel:'));
expect(listSource, contains('queueCheckingDownloadedFile'));
expect(listSource, contains('Icons.play_arrow'));
expect(listSource, contains('_LibraryPlaybackButton('));
});
}