Skip to content

Commit 6a568d5

Browse files
committed
Bring back the original ‘Heroes animation is fastOutSlowIn’ test.
1 parent fdd9db6 commit 6a568d5

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

‎packages/flutter/test/widgets/heroes_test.dart‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,49 @@ Future<void> main() async {
620620
await tester.pump(const Duration(seconds: 1));
621621
});
622622

623+
testWidgets('Default Hero animation is fastOutSlowIn', (WidgetTester tester) async {
624+
final observer = TransitionDurationObserver();
625+
await tester.pumpWidget(
626+
MaterialApp(navigatorObservers: <NavigatorObserver>[observer], routes: routes),
627+
);
628+
await tester.tap(find.text('two'));
629+
await tester.pump(); // begin navigation
630+
631+
// Expect the height of the secondKey Hero to vary from 100 to 150
632+
// over duration and according to curve.
633+
634+
final Duration duration = observer.transitionDuration;
635+
const Curve curve = Curves.fastOutSlowIn;
636+
final double initialHeight = tester.getSize(find.byKey(firstKey, skipOffstage: false)).height;
637+
final double finalHeight = tester.getSize(find.byKey(secondKey, skipOffstage: false)).height;
638+
final double deltaHeight = finalHeight - initialHeight;
639+
const epsilon = 0.001;
640+
641+
await tester.pump(duration * 0.25);
642+
expect(
643+
tester.getSize(find.byKey(secondKey)).height,
644+
moreOrLessEquals(curve.transform(0.25) * deltaHeight + initialHeight, epsilon: epsilon),
645+
);
646+
647+
await tester.pump(duration * 0.25);
648+
expect(
649+
tester.getSize(find.byKey(secondKey)).height,
650+
moreOrLessEquals(curve.transform(0.50) * deltaHeight + initialHeight, epsilon: epsilon),
651+
);
652+
653+
await tester.pump(duration * 0.25);
654+
expect(
655+
tester.getSize(find.byKey(secondKey)).height,
656+
moreOrLessEquals(curve.transform(0.75) * deltaHeight + initialHeight, epsilon: epsilon),
657+
);
658+
659+
await tester.pump(duration * 0.25);
660+
expect(
661+
tester.getSize(find.byKey(secondKey)).height,
662+
moreOrLessEquals(curve.transform(1.0) * deltaHeight + initialHeight, epsilon: epsilon),
663+
);
664+
});
665+
623666
testWidgets('Heroes animation curve is customizable', (WidgetTester tester) async {
624667
final testCurvesList = <Curve>[
625668
Curves.linear,

0 commit comments

Comments
 (0)