Skip to content

Commit 5a2c1f9

Browse files
committed
Bring back the original ‘popped hero uses fastOutSlowIn curve’ test.
1 parent 9cf4b32 commit 5a2c1f9

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,6 +3289,82 @@ Future<void> main() async {
32893289
},
32903290
);
32913291

3292+
testWidgets('Default popped hero uses fastOutSlowIn curve', (WidgetTester tester) async {
3293+
final Key container1 = UniqueKey();
3294+
final Key container2 = UniqueKey();
3295+
final navigator = GlobalKey<NavigatorState>();
3296+
final observer = TransitionDurationObserver();
3297+
3298+
final Animatable<Size?> tween = SizeTween(
3299+
begin: const Size(200, 200),
3300+
end: const Size(100, 100),
3301+
).chain(CurveTween(curve: Curves.fastOutSlowIn));
3302+
3303+
await tester.pumpWidget(
3304+
MaterialApp(
3305+
navigatorKey: navigator,
3306+
navigatorObservers: <NavigatorObserver>[observer],
3307+
home: Scaffold(
3308+
body: Center(
3309+
child: Hero(
3310+
tag: 'test',
3311+
createRectTween: (Rect? begin, Rect? end) {
3312+
return RectTween(begin: begin, end: end);
3313+
},
3314+
child: SizedBox(key: container1, height: 100, width: 100),
3315+
),
3316+
),
3317+
),
3318+
),
3319+
);
3320+
final Size originalSize = tester.getSize(find.byKey(container1));
3321+
expect(originalSize, const Size(100, 100));
3322+
3323+
navigator.currentState!.push(
3324+
MaterialPageRoute<void>(
3325+
builder: (BuildContext context) {
3326+
return Scaffold(
3327+
body: Center(
3328+
child: Hero(
3329+
tag: 'test',
3330+
createRectTween: (Rect? begin, Rect? end) {
3331+
return RectTween(begin: begin, end: end);
3332+
},
3333+
child: SizedBox(key: container2, height: 200, width: 200),
3334+
),
3335+
),
3336+
);
3337+
},
3338+
),
3339+
);
3340+
await tester.pumpAndSettle();
3341+
final Size newSize = tester.getSize(find.byKey(container2));
3342+
expect(newSize, const Size(200, 200));
3343+
3344+
navigator.currentState!.pop();
3345+
await tester.pump();
3346+
3347+
// Jump 25% into the transition.
3348+
await tester.pump(observer.transitionDuration ~/ 4);
3349+
Size heroSize = tester.getSize(find.byKey(container1));
3350+
expect(heroSize, tween.transform(0.25));
3351+
3352+
// Jump to 50% into the transition.
3353+
await tester.pump(observer.transitionDuration ~/ 4);
3354+
heroSize = tester.getSize(find.byKey(container1));
3355+
expect(heroSize, tween.transform(0.50));
3356+
3357+
// Jump to 75% into the transition.
3358+
await tester.pump(observer.transitionDuration ~/ 4);
3359+
heroSize = tester.getSize(find.byKey(container1));
3360+
expect(heroSize, tween.transform(0.75));
3361+
3362+
// Jump to 100% into the transition.
3363+
await tester.pump(observer.transitionDuration ~/ 4);
3364+
heroSize = tester.getSize(find.byKey(container1));
3365+
expect(heroSize, tween.transform(1.0));
3366+
});
3367+
32923368
Future<void> verifyPoppedHeroCurve({
32933369
required WidgetTester tester,
32943370
required Curve curve,

0 commit comments

Comments
 (0)