screen-locker/stronglift_replacement/workout_app/test/ui/motion_test.dart
Krzysztof kuhy Rudnicki 5d0aa9b57a Add set haptics, finish chime, sound switch
dopamine-ux 05: selectionClick on recording a set or warmup,
mediumImpact + generated chime (music_theory, pinned tag) on
finish, dialog arrival on the slow motion token, AppDuration /
AppCurve in theme.dart, streak card counts up, all of it
collapsing under the OS reduced-motion flag. One Settings
"Sound" switch silences the chime and the break-end cue
(foreground service included, via a silent channel); haptics
stay. Removes the finished dopamine-ux-05 prompt.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WzxdWYdwRAtMg7ki6TKxuU
2026-11-01 21:46:09 +01:00

58 lines
1.6 KiB
Dart

import 'package:flutter/material.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,
);
});
}