home_media_state_test.dart 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import 'package:cardash_launcher/core/app_identity.dart';
  2. import 'package:cardash_launcher/data/models/media_playback.dart';
  3. import 'package:cardash_launcher/features/home/home_media_state.dart';
  4. import 'package:flutter_test/flutter_test.dart';
  5. const _carDashPlaying = MediaPlayback(
  6. hasAccess: true,
  7. hasSession: true,
  8. playing: true,
  9. packageName: appPackageName,
  10. );
  11. const _chromePlaying = MediaPlayback(
  12. hasAccess: true,
  13. hasSession: true,
  14. playing: true,
  15. packageName: 'com.android.chrome',
  16. );
  17. void main() {
  18. group('shouldShowMusicEqualizer', () {
  19. test(
  20. 'stays quiet while the stale session is CarDash after a Jellyfin pause',
  21. () {
  22. expect(
  23. shouldShowMusicEqualizer(
  24. systemMusicPlaying: true,
  25. jellyfinPlaying: false,
  26. systemMedia: _carDashPlaying,
  27. ),
  28. isFalse,
  29. );
  30. },
  31. );
  32. test('animates for another app', () {
  33. expect(
  34. shouldShowMusicEqualizer(
  35. systemMusicPlaying: true,
  36. jellyfinPlaying: false,
  37. systemMedia: _chromePlaying,
  38. ),
  39. isTrue,
  40. );
  41. });
  42. test('stays quiet while Jellyfin is playing', () {
  43. expect(
  44. shouldShowMusicEqualizer(
  45. systemMusicPlaying: true,
  46. jellyfinPlaying: true,
  47. systemMedia: _carDashPlaying,
  48. ),
  49. isFalse,
  50. );
  51. });
  52. test('falls back to system music with no media session', () {
  53. expect(
  54. shouldShowMusicEqualizer(
  55. systemMusicPlaying: true,
  56. jellyfinPlaying: false,
  57. systemMedia: const MediaPlayback(),
  58. ),
  59. isTrue,
  60. );
  61. });
  62. });
  63. test('detects CarDash versus external media sessions', () {
  64. expect(isExternalSystemMedia(_carDashPlaying), isFalse);
  65. expect(isExternalSystemMedia(_chromePlaying), isTrue);
  66. expect(isExternalSystemMedia(const MediaPlayback()), isTrue);
  67. });
  68. }