- Meine Musik als Startbildschirm ohne Topbar: Kopfzeile (Einstellungen, Suche, Musikerkennung), Schnellzugriffe, Shuffle + Sortieren, Liederliste - Sortierung nach Zuletzt hinzugefuegt / Name (A-Z-#) / Wie oft abgespielt, auf- und absteigend, pro Liste gespeichert (SortStore) - Favoriten als eigener Tab mit gleicher Shuffle-/Sortier-Leiste - Download-Tab uebernimmt den Navidrome-Server-Browser - DB-Schema 3: playCount, gezaehlt beim Titelstart - Theme auf #0B0B10 / #c0392b - Scan-Aktionen aus der entfallenen Topbar jetzt in den Einstellungen Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011snPXPafPC5i87o68H14W7
114 lines
3.0 KiB
Dart
114 lines
3.0 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:melo/library/database.dart';
|
|
import 'package:melo/library/song_grouping.dart';
|
|
|
|
Song _song({
|
|
required String id,
|
|
required String title,
|
|
String? artist,
|
|
String? album,
|
|
}) {
|
|
return Song(
|
|
id: id,
|
|
path: '/$id.mp3',
|
|
title: title,
|
|
artist: artist,
|
|
album: album,
|
|
dateAddedMs: 0,
|
|
updatedAtMs: 0,
|
|
deleted: false,
|
|
playCount: 0,
|
|
);
|
|
}
|
|
|
|
void main() {
|
|
group('groupByArtist', () {
|
|
test('gruppiert mehrere Künstler getrennt', () {
|
|
final songs = [
|
|
_song(id: '1', title: 'A', artist: 'Bob'),
|
|
_song(id: '2', title: 'B', artist: 'Alice'),
|
|
_song(id: '3', title: 'C', artist: 'Alice'),
|
|
];
|
|
|
|
final grouped = groupByArtist(songs);
|
|
|
|
expect(grouped.keys, ['Alice', 'Bob']);
|
|
expect(grouped['Alice']!.length, 2);
|
|
expect(grouped['Bob']!.length, 1);
|
|
});
|
|
|
|
test('gruppiert Songs ohne Künstler unter "Unbekannt"', () {
|
|
final songs = [
|
|
_song(id: '1', title: 'A', artist: null),
|
|
_song(id: '2', title: 'B', artist: null),
|
|
];
|
|
|
|
final grouped = groupByArtist(songs);
|
|
|
|
expect(grouped.keys, [unbekannterKuenstler]);
|
|
expect(grouped[unbekannterKuenstler]!.length, 2);
|
|
});
|
|
|
|
test('sortiert Künstlernamen alphabetisch', () {
|
|
final songs = [
|
|
_song(id: '1', title: 'A', artist: 'Zebra'),
|
|
_song(id: '2', title: 'B', artist: 'Anton'),
|
|
_song(id: '3', title: 'C', artist: 'Mitte'),
|
|
];
|
|
|
|
final grouped = groupByArtist(songs);
|
|
|
|
expect(grouped.keys.toList(), ['Anton', 'Mitte', 'Zebra']);
|
|
});
|
|
|
|
test('leere Liste ergibt leere Map', () {
|
|
expect(groupByArtist(const []), isEmpty);
|
|
});
|
|
});
|
|
|
|
group('groupByAlbum', () {
|
|
test('gruppiert mehrere Alben getrennt', () {
|
|
final songs = [
|
|
_song(id: '1', title: 'A', album: 'Best Of'),
|
|
_song(id: '2', title: 'B', album: 'Anthology'),
|
|
];
|
|
|
|
final grouped = groupByAlbum(songs);
|
|
|
|
expect(grouped.keys.toList(), ['Anthology', 'Best Of']);
|
|
});
|
|
|
|
test('gruppiert Songs ohne Album unter "Unbekanntes Album"', () {
|
|
final songs = [_song(id: '1', title: 'A', album: null)];
|
|
|
|
final grouped = groupByAlbum(songs);
|
|
|
|
expect(grouped.keys, [unbekanntesAlbum]);
|
|
});
|
|
|
|
test('leere Liste ergibt leere Map', () {
|
|
expect(groupByAlbum(const []), isEmpty);
|
|
});
|
|
});
|
|
|
|
group('albumArtistLabel', () {
|
|
test('zeigt gemeinsamen Künstler, wenn alle Songs von ihm stammen', () {
|
|
final songs = [
|
|
_song(id: '1', title: 'A', artist: 'Alice', album: 'X'),
|
|
_song(id: '2', title: 'B', artist: 'Alice', album: 'X'),
|
|
];
|
|
|
|
expect(albumArtistLabel(songs), 'Alice');
|
|
});
|
|
|
|
test('zeigt "Verschiedene Interpreten" bei unterschiedlichen Künstlern', () {
|
|
final songs = [
|
|
_song(id: '1', title: 'A', artist: 'Alice', album: 'X'),
|
|
_song(id: '2', title: 'B', artist: 'Bob', album: 'X'),
|
|
];
|
|
|
|
expect(albumArtistLabel(songs), 'Verschiedene Interpreten');
|
|
});
|
|
});
|
|
}
|