feat(settings): Settings-Tab mit Bibliotheks-Statistik, Berechtigungen, Über Melo
- Bibliotheks-Statistik: Song-Anzahl + Gesamtspieldauer via watchSongs() (reine Summier-/Format-Funktion in lib/settings/library_stats.dart, unabhängig von Flutter/Plattform testbar) - Berechtigungen: Musik-Berechtigung öffnet Systemeinstellungen über das bereits vorhandene openMusicPermissionSettings() - Über Melo: kurzer Name + Slogan, keine erfundene Versionsnummer (package_info_plus ist keine Dependency) - Keine Platzhalter für Profil/Cloud-Sync/Geräte-Verwaltung, da es noch kein Account-/Cloud-System gibt (Phase 2) - HomeShell nutzt SettingsScreen statt des Settings-Placeholders, toter _Placeholder-Widget-Code entfernt Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
3fc52327c9
commit
23a1e7838d
@@ -0,0 +1,60 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:melo/library/database.dart';
|
||||
import 'package:melo/settings/library_stats.dart';
|
||||
|
||||
Song _song({required String id, int? durationMs}) {
|
||||
return Song(
|
||||
id: id,
|
||||
path: '/$id.mp3',
|
||||
title: id,
|
||||
durationMs: durationMs,
|
||||
dateAddedMs: 0,
|
||||
updatedAtMs: 0,
|
||||
deleted: false,
|
||||
);
|
||||
}
|
||||
|
||||
void main() {
|
||||
group('totalDuration', () {
|
||||
test('leere Liste ergibt Duration.zero', () {
|
||||
expect(totalDuration([]), Duration.zero);
|
||||
});
|
||||
|
||||
test('überspringt Songs ohne bekannte Dauer', () {
|
||||
final songs = [
|
||||
_song(id: 'a', durationMs: 200000),
|
||||
_song(id: 'b', durationMs: 185000),
|
||||
_song(id: 'c', durationMs: null),
|
||||
];
|
||||
expect(totalDuration(songs), const Duration(milliseconds: 385000));
|
||||
});
|
||||
});
|
||||
|
||||
group('formatTotalDuration', () {
|
||||
test('leere Liste ergibt "0m"', () {
|
||||
expect(formatTotalDuration([]), '0m');
|
||||
});
|
||||
|
||||
test('formatiert unter einer Stunde ohne Stunden-Anteil', () {
|
||||
final songs = [_song(id: 'a', durationMs: 6 * 60 * 1000)];
|
||||
expect(formatTotalDuration(songs), '6m');
|
||||
});
|
||||
|
||||
test('formatiert Stunden und Minuten korrekt', () {
|
||||
// 200000ms + 185000ms = 385000ms = 6min 25s -> aufgerundet auf 6 Minuten
|
||||
final songs = [
|
||||
_song(id: 'a', durationMs: 200000),
|
||||
_song(id: 'b', durationMs: 185000),
|
||||
_song(id: 'c', durationMs: null),
|
||||
];
|
||||
expect(formatTotalDuration(songs), '6m');
|
||||
});
|
||||
|
||||
test('formatiert mehr als eine Stunde mit Stunden-Anteil', () {
|
||||
final songs = [
|
||||
_song(id: 'a', durationMs: const Duration(hours: 2, minutes: 15).inMilliseconds),
|
||||
];
|
||||
expect(formatTotalDuration(songs), '2h 15m');
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user