screen-locker/stronglift_replacement/workout_app/test/ui/motion_test.dart
Krzysztof kuhy Rudnicki 5f2925a550 Move workout_app to Flutter 3.50 material_ui
Flutter 3.50 deprecates package:flutter/material.dart, which made
flutter-analyze report 27 deprecated_member_use infos and blocked the
gate. workout_app now imports material_ui 1.11.0, with crdt_sync_dart
0.14.1 and sync_settings_ui 0.8.2 (both on material_ui).

material_ui's MaterialApp ships its own MaterialLocalizations, so a
package that still calls the framework showDialog threw a null check.
WorkoutApp now adds the framework delegate, and a widget test opens a
material_ui and a framework dialog through the real app root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
2026-11-16 08:54:33 +01:00

58 lines
1.6 KiB
Dart

import 'package:material_ui/material_ui.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:workout_app/ui/theme.dart';
Future<Duration> _resolved(
WidgetTester tester, {
required bool disableAnimations,
Duration wanted = AppDuration.base,
}) async {
late Duration out;
await tester.pumpWidget(
MediaQuery(
data: MediaQueryData(disableAnimations: disableAnimations),
child: Builder(
builder: (context) {
out = motionDuration(context, wanted);
return const SizedBox();
},
),
),
);
return out;
}
void main() {
test('the duration scale is the frozen four-step one', () {
expect(AppDuration.instant, Duration.zero);
expect(AppDuration.fast, const Duration(milliseconds: 120));
expect(AppDuration.base, const Duration(milliseconds: 200));
expect(AppDuration.slow, const Duration(milliseconds: 320));
});
test('the easing curves are the frozen cubic-beziers', () {
expect(AppCurve.standard, const Cubic(0.2, 0, 0, 1));
expect(AppCurve.decelerate, const Cubic(0, 0, 0, 1));
expect(AppCurve.accelerate, const Cubic(0.3, 0, 1, 1));
});
testWidgets('motionDuration keeps the token when animations are on', (
tester,
) async {
expect(await _resolved(tester, disableAnimations: false), AppDuration.base);
});
testWidgets('motionDuration collapses to zero when the OS removes motion', (
tester,
) async {
expect(
await _resolved(
tester,
disableAnimations: true,
wanted: AppDuration.slow,
),
Duration.zero,
);
});
}