Files
SpotiFLAC-Mobile/test/download_service_picker_drag_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

130 lines
4.5 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:spotiflac_android/l10n/app_localizations.dart';
import 'package:spotiflac_android/models/settings.dart';
import 'package:spotiflac_android/providers/extension_provider.dart';
import 'package:spotiflac_android/providers/settings_provider.dart';
import 'package:spotiflac_android/theme/mornye_theme.dart';
import 'package:spotiflac_android/widgets/download_service_picker.dart';
class _Extensions extends ExtensionNotifier {
_Extensions(this._qualityCount);
final int _qualityCount;
@override
ExtensionState build() => ExtensionState(
extensions: [
Extension(
id: 'example',
name: 'example',
displayName: 'Example',
version: '1.0.0',
description: '',
enabled: true,
status: 'loaded',
hasDownloadProvider: true,
qualityOptions: List.generate(
_qualityCount,
(index) => QualityOption(id: '$index', label: 'Quality $index'),
),
),
],
);
@override
void refreshEnabledExtensionHealth({bool force = false}) {}
}
class _Settings extends SettingsNotifier {
@override
AppSettings build() => const AppSettings();
}
void main() {
for (final (qualityCount, mornye) in [
(3, false),
(16, false),
(3, true),
(16, true),
]) {
testWidgets(
'picker fits $qualityCount options and dismisses (Mornye=$mornye)',
(tester) async {
tester.view.physicalSize = const Size(320, 780);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
(String, String)? selection;
await tester.pumpWidget(
ProviderScope(
overrides: [
extensionProvider.overrideWith(() => _Extensions(qualityCount)),
settingsProvider.overrideWith(_Settings.new),
],
child: MaterialApp(
theme: mornye
? MornyeTheme.build(Brightness.dark)
: ThemeData(platform: TargetPlatform.iOS),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: Scaffold(
body: Builder(
builder: (context) => TextButton(
onPressed: () => DownloadServicePicker.show(
context,
trackName: 'Example track',
onSelect: (quality, service) =>
selection = (quality, service),
),
child: const Text('Open'),
),
),
),
),
),
);
await tester.tap(find.text('Open'));
await tester.pumpAndSettle();
if (qualityCount == 3) {
final sheetBottom = tester.getBottomLeft(find.byType(BottomSheet)).dy;
final lastOptionBottom = tester
.getBottomLeft(find.text('Quality 2'))
.dy;
expect(sheetBottom - lastOptionBottom, lessThan(100));
}
if (qualityCount == 16) {
final scroll = find.descendant(
of: find.byType(DownloadServicePicker),
matching: find.byType(SingleChildScrollView),
);
await tester.drag(scroll, const Offset(0, -300));
await tester.pumpAndSettle();
expect(find.byType(DownloadServicePicker), findsOneWidget);
await tester.drag(scroll, const Offset(0, 1500));
await tester.pumpAndSettle();
}
final sheetTop = tester.getTopLeft(find.byType(BottomSheet));
final sheetWidth = tester.getSize(find.byType(BottomSheet)).width;
await tester.dragFrom(
sheetTop + Offset(sheetWidth / 2, 16),
const Offset(0, 600),
);
await tester.pumpAndSettle();
expect(find.byType(DownloadServicePicker), findsNothing);
expect(selection, isNull);
await tester.tap(find.text('Open'));
await tester.pumpAndSettle();
final lastQuality = find.text('Quality ${qualityCount - 1}');
await tester.ensureVisible(lastQuality);
await tester.pumpAndSettle();
await tester.tap(lastQuality);
await tester.pumpAndSettle();
expect(selection, ('${qualityCount - 1}', 'example'));
expect(find.byType(DownloadServicePicker), findsNothing);
expect(tester.takeException(), isNull);
},
);
}
}