Files
SpotiFLAC-Mobile/test/mornye_loading_and_chrome_test.dart
T
zarzet 63e1a9b9c8 feat(ui): add Mornye glass theme and adaptive music player
Add a selectable Mornye theme with shared glass controls, dialogs, sheets, notifications, and collection headers while retaining Material components.

Update player artwork, lyrics transitions and highlighting, synchronized rolling time labels, volume controls, and compact navigation. Unify metadata, Library, search, and extension surfaces; preserve restored artwork and report extension load failures.

Validation: full Flutter analyzer clean; 713 tests passed and 4 skipped; pinned Dart formatting and diff checks passed; signed ARM64 and ARM32 release APKs built and verified.
2026-09-19 12:10:10 +07:00

116 lines
4.4 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:spotiflac_android/services/shell_navigation_service.dart';
import 'package:spotiflac_android/theme/mornye_theme.dart';
import 'package:spotiflac_android/widgets/animation_utils.dart';
import 'package:spotiflac_android/widgets/mornye_artist_header.dart';
void main() {
for (final brightness in Brightness.values) {
testWidgets('Mornye loading layouts fit a narrow screen in $brightness', (
tester,
) async {
tester.view.physicalSize = const Size(320, 640);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
for (final skeleton in const [
ArtistScreenSkeleton(showCoverHeader: false),
AlbumTrackListSkeleton(showCoverHeader: true),
TrackListSkeleton(showCoverHeader: true),
]) {
await tester.pumpWidget(
MaterialApp(
theme: MornyeTheme.build(brightness),
home: Scaffold(body: skeleton),
),
);
await tester.pump(const Duration(milliseconds: 100));
expect(tester.takeException(), isNull);
await tester.drag(
find.byType(SingleChildScrollView).first,
const Offset(0, -350),
);
await tester.pump(const Duration(milliseconds: 100));
expect(tester.takeException(), isNull);
}
await tester.pumpWidget(const SizedBox.shrink());
});
}
testWidgets(
'chrome follows the visible artist and restores for albums and tabs',
(tester) async {
final key = ShellNavigationService.homeTabNavigatorKey;
final observer = ShellChromeObserver(key);
ShellNavigationService.syncState(currentTabIndex: 0, showRepoTab: true);
addTearDown(observer.detach);
await tester.pumpWidget(
MaterialApp(
theme: MornyeTheme.build(Brightness.light),
home: Navigator(
key: key,
observers: [observer],
onGenerateRoute: (_) => MaterialPageRoute<void>(
builder: (_) => const Scaffold(body: Text('Home')),
),
),
),
);
await tester.pumpAndSettle();
expect(ShellNavigationService.chromeBrightness.value, isNull);
key.currentState!.push(
MaterialPageRoute<void>(
builder: (_) => const MornyeArtistSurface(
imageSource: null,
child: Scaffold(body: Text('Artist')),
),
),
);
await tester.pumpAndSettle();
expect(ShellNavigationService.chromeBrightness.value, Brightness.dark);
final artistSurface = Theme.of(
tester.element(find.text('Artist')),
).colorScheme.surface;
expect(ShellNavigationService.chromeSurface.value, artistSurface);
// Menus do not turn the bars light over a dark artist.
showDialog<void>(
context: tester.element(find.text('Artist')),
useRootNavigator: false,
builder: (_) => const AlertDialog(title: Text('Options')),
);
await tester.pumpAndSettle();
expect(ShellNavigationService.chromeBrightness.value, Brightness.dark);
key.currentState!.pop();
await tester.pumpAndSettle();
// The mounted artist under a pushed album must not keep a stale override.
key.currentState!.push(
MaterialPageRoute<void>(
builder: (_) => const Scaffold(body: Text('Album')),
),
);
await tester.pumpAndSettle();
expect(ShellNavigationService.chromeBrightness.value, isNull);
expect(ShellNavigationService.chromeSurface.value, isNull);
key.currentState!.pop();
await tester.pumpAndSettle();
expect(ShellNavigationService.chromeBrightness.value, Brightness.dark);
expect(ShellNavigationService.chromeSurface.value, artistSurface);
ShellNavigationService.syncState(currentTabIndex: 3, showRepoTab: true);
await tester.pumpAndSettle();
expect(ShellNavigationService.chromeBrightness.value, isNull);
expect(ShellNavigationService.chromeSurface.value, isNull);
ShellNavigationService.syncState(currentTabIndex: 0, showRepoTab: true);
await tester.pumpAndSettle();
expect(ShellNavigationService.chromeBrightness.value, Brightness.dark);
key.currentState!.pop();
await tester.pumpAndSettle();
expect(ShellNavigationService.chromeBrightness.value, isNull);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox.shrink());
},
);
}