Files
SpotiFLAC-Mobile/test/loading_layout_regression_test.dart
T
zarzet 962e582acc chore(flutter): move to Flutter 3.50.0 and the material_ui packages
Flutter 3.50 deprecates its built-in Material and Cupertino libraries in
favour of the material_ui and cupertino_ui packages. The imports move
with the official fix (dart fix, migrate_design_widgets); the app's old
two-library theme bridge collapses into one Theme type.

- MaterialExpressiveScope keeps the complete host theme nearest its
  child. The reduced copy made for the expressive widgets now shares the
  app's Theme type and would hide component themes and extensions.
- LegacyThemeBrightness hands the brightness to the glass package, which
  still reads Flutter's built-in theme.
- appLocalizationsDelegates lists the material_ui localization delegates;
  the generated list still names the built-in ones.
- Tests: findByTooltip and pageBack replace the flutter_test helpers that
  only know the built-in widgets, and several tests that had gone stale
  against earlier app changes are repaired.
2026-11-15 23:33:29 +07:00

90 lines
3.1 KiB
Dart

import 'package:material_ui/material_ui.dart';
import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mornye/l10n/l10n.dart';
import 'package:mornye/providers/repo_provider.dart';
import 'package:mornye/screens/repo_tab.dart';
import 'package:mornye/theme/app_theme.dart';
import 'package:mornye/theme/mornye_theme.dart';
import 'package:mornye/widgets/animation_utils.dart';
import 'package:mornye/widgets/extension_row.dart';
class _LoadingRepo extends RepoNotifier {
@override
RepoState build() => const RepoState(
isLoading: true,
isInitialized: true,
registryUrls: ['https://example.invalid/registry.json'],
);
@override
Future<void> initialize(String cacheDir) async {}
}
void main() {
for (final width in [320.0, 1024.0]) {
for (final brightness in Brightness.values) {
testWidgets('Material loading rows fit at $width in $brightness', (
tester,
) async {
tester.view.physicalSize = Size(width, 1200);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
for (final skeleton in const [
TrackListSkeleton(itemCount: 3),
AlbumTrackListSkeleton(itemCount: 3),
HomeSearchSkeleton(),
]) {
await tester.pumpWidget(
MaterialApp(
theme: brightness == Brightness.light
? AppTheme.light()
: AppTheme.dark(),
home: Scaffold(body: skeleton),
),
);
await tester.pump(const Duration(milliseconds: 100));
expect(tester.takeException(), isNull);
}
await tester.pumpWidget(const SizedBox.shrink());
});
}
for (final mornye in [false, true]) {
testWidgets('store skeleton fits at $width with Mornye=$mornye', (
tester,
) async {
tester.view.physicalSize = Size(width, 1200);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
const paths = MethodChannel('plugins.flutter.io/path_provider');
final messenger =
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger;
messenger.setMockMethodCallHandler(
paths,
(_) async => '/tmp/mornye-loading-test',
);
addTearDown(() => messenger.setMockMethodCallHandler(paths, null));
await tester.pumpWidget(
ProviderScope(
overrides: [repoProvider.overrideWith(_LoadingRepo.new)],
child: MaterialApp(
theme: mornye
? MornyeTheme.build(Brightness.dark)
: AppTheme.light(),
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: AppLocalizations.supportedLocales,
home: const RepoTab(),
),
),
);
await tester.pump(const Duration(milliseconds: 100));
expect(find.byType(ExtensionRow), findsWidgets);
expect(tester.takeException(), isNull);
await tester.pumpWidget(const SizedBox.shrink());
});
}
}
}