@@ -350,140 +350,4 @@ void main() {
350350 await tester.pumpAndSettle ();
351351 expect (builtCount, 1 );
352352 }, variant: TargetPlatformVariant .only (TargetPlatform .android));
353-
354- testWidgets ('android can use CupertinoPageTransitionsBuilder' , (WidgetTester tester) async {
355- int builtCount = 0 ;
356-
357- final Map <String , WidgetBuilder > routes = < String , WidgetBuilder > {
358- '/' : (BuildContext context) => Material (
359- child: TextButton (
360- child: const Text ('push' ),
361- onPressed: () { Navigator .of (context).pushNamed ('/b' ); },
362- ),
363- ),
364- '/b' : (BuildContext context) => StatefulBuilder (
365- builder: (BuildContext context, StateSetter setState) {
366- builtCount++ ;
367- return TextButton (
368- child: const Text ('pop' ),
369- onPressed: () { Navigator .pop (context); },
370- );
371- },
372- ),
373- };
374-
375- await tester.pumpWidget (
376- MaterialApp (
377- theme: ThemeData (
378- pageTransitionsTheme: const PageTransitionsTheme (
379- builders: < TargetPlatform , PageTransitionsBuilder > {
380- TargetPlatform .android: CupertinoPageTransitionsBuilder (),
381- // iOS uses different PageTransitionsBuilder
382- TargetPlatform .iOS: FadeUpwardsPageTransitionsBuilder (),
383- },
384- ),
385- ),
386- routes: routes,
387- ),
388- );
389-
390- // No matter push or pop was called, the child widget should built only once.
391- await tester.tap (find.text ('push' ));
392- await tester.pumpAndSettle ();
393- expect (builtCount, 1 );
394-
395- final Size size = tester.getSize (find.byType (MaterialApp ));
396- await tester.flingFrom (Offset (0 , size.height / 2 ), Offset (size.width * 2 / 3 , 0 ), 500 );
397-
398- await tester.pumpAndSettle ();
399- expect (find.text ('push' ), findsOneWidget);
400- expect (builtCount, 1 );
401- }, variant: TargetPlatformVariant .only (TargetPlatform .android));
402-
403- testWidgets ('back gesture while TargetPlatform changes' , (WidgetTester tester) async {
404- final Map <String , WidgetBuilder > routes = < String , WidgetBuilder > {
405- '/' : (BuildContext context) => Material (
406- child: TextButton (
407- child: const Text ('PUSH' ),
408- onPressed: () { Navigator .of (context).pushNamed ('/b' ); },
409- ),
410- ),
411- '/b' : (BuildContext context) => const Text ('HELLO' ),
412- };
413- const PageTransitionsTheme pageTransitionsTheme = PageTransitionsTheme (
414- builders: < TargetPlatform , PageTransitionsBuilder > {
415- TargetPlatform .android: CupertinoPageTransitionsBuilder (),
416- // iOS uses different PageTransitionsBuilder
417- TargetPlatform .iOS: FadeUpwardsPageTransitionsBuilder (),
418- },
419- );
420- await tester.pumpWidget (
421- MaterialApp (
422- theme: ThemeData (
423- platform: TargetPlatform .android,
424- pageTransitionsTheme: pageTransitionsTheme,
425- ),
426- routes: routes,
427- ),
428- );
429- await tester.tap (find.text ('PUSH' ));
430- expect (await tester.pumpAndSettle (const Duration (minutes: 1 )), 2 );
431- expect (find.text ('PUSH' ), findsNothing);
432- expect (find.text ('HELLO' ), findsOneWidget);
433-
434- final Offset helloPosition1 = tester.getCenter (find.text ('HELLO' ));
435- final TestGesture gesture = await tester.startGesture (const Offset (2.5 , 300.0 ));
436- await tester.pump (const Duration (milliseconds: 20 ));
437- await gesture.moveBy (const Offset (100.0 , 0.0 ));
438- expect (find.text ('PUSH' ), findsNothing);
439- expect (find.text ('HELLO' ), findsOneWidget);
440- await tester.pump (const Duration (milliseconds: 20 ));
441- expect (find.text ('PUSH' ), findsOneWidget);
442- expect (find.text ('HELLO' ), findsOneWidget);
443- final Offset helloPosition2 = tester.getCenter (find.text ('HELLO' ));
444- expect (helloPosition1.dx, lessThan (helloPosition2.dx));
445- expect (helloPosition1.dy, helloPosition2.dy);
446- expect (Theme .of (tester.element (find.text ('HELLO' ))).platform, TargetPlatform .android);
447-
448- await tester.pumpWidget (
449- MaterialApp (
450- theme: ThemeData (
451- platform: TargetPlatform .iOS,
452- pageTransitionsTheme: pageTransitionsTheme,
453- ),
454- routes: routes,
455- ),
456- );
457- // Now, let the theme animation run through.
458- // This takes three frames (including the first one above):
459- // 1. Start the Theme animation. It's at t=0 so everything else is identical.
460- // 2. Start any animations that are informed by the Theme, for example, the
461- // DefaultTextStyle, on the first frame that the theme is not at t=0. In
462- // this case, it's at t=1.0 of the theme animation, so this is also the
463- // frame in which the theme animation ends.
464- // 3. End all the other animations.
465- expect (await tester.pumpAndSettle (const Duration (minutes: 1 )), 2 );
466- expect (Theme .of (tester.element (find.text ('HELLO' ))).platform, TargetPlatform .iOS);
467- final Offset helloPosition3 = tester.getCenter (find.text ('HELLO' ));
468- expect (helloPosition3, helloPosition2);
469- expect (find.text ('PUSH' ), findsOneWidget);
470- expect (find.text ('HELLO' ), findsOneWidget);
471- await gesture.moveBy (const Offset (100.0 , 0.0 ));
472- await tester.pump (const Duration (milliseconds: 20 ));
473- expect (find.text ('PUSH' ), findsOneWidget);
474- expect (find.text ('HELLO' ), findsOneWidget);
475- final Offset helloPosition4 = tester.getCenter (find.text ('HELLO' ));
476- expect (helloPosition3.dx, lessThan (helloPosition4.dx));
477- expect (helloPosition3.dy, helloPosition4.dy);
478- await gesture.moveBy (const Offset (500.0 , 0.0 ));
479- await gesture.up ();
480- expect (await tester.pumpAndSettle (const Duration (minutes: 1 )), 3 );
481- expect (find.text ('PUSH' ), findsOneWidget);
482- expect (find.text ('HELLO' ), findsNothing);
483-
484- await tester.tap (find.text ('PUSH' ));
485- expect (await tester.pumpAndSettle (const Duration (minutes: 1 )), 2 );
486- expect (find.text ('PUSH' ), findsNothing);
487- expect (find.text ('HELLO' ), findsOneWidget);
488- });
489353}
0 commit comments