From bfa272ac3ef942e549a2c17ac971728a1de07d82 Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Fri, 25 Mar 2022 14:54:21 -0700 Subject: [PATCH] =?UTF-8?q?Revert=20"=E2=9C=A8=20Android=20Q=20transition?= =?UTF-8?q?=20by=20default=20(#98559)"=20(#100799)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit c82ddd39e54fed2401e8b89dd82960d6ac9717d3. --- packages/flutter/lib/src/material/page.dart | 17 ++-- .../src/material/page_transitions_theme.dart | 89 +++++++++---------- .../bottom_navigation_bar_theme_test.dart | 60 ++++--------- .../test/material/data_table_test.dart | 18 +--- .../material/flexible_space_bar_test.dart | 7 +- packages/flutter/test/material/page_test.dart | 85 +----------------- .../material/page_transitions_theme_test.dart | 47 ++++------ .../user_accounts_drawer_header_test.dart | 20 ++--- .../flutter/test/widgets/heroes_test.dart | 9 +- 9 files changed, 99 insertions(+), 253 deletions(-) diff --git a/packages/flutter/lib/src/material/page.dart b/packages/flutter/lib/src/material/page.dart index 7cd5cec9365..2a0e2791f39 100644 --- a/packages/flutter/lib/src/material/page.dart +++ b/packages/flutter/lib/src/material/page.dart @@ -63,24 +63,19 @@ class MaterialPageRoute extends PageRoute with MaterialRouteTransitionMixi /// A mixin that provides platform-adaptive transitions for a [PageRoute]. /// /// {@template flutter.material.materialRouteTransitionMixin} -/// For Android, the entrance transition for the page zooms in and fades in -/// while the exiting page zooms out and fades out. The exit transition is similar, -/// but in reverse. +/// For Android, the entrance transition for the page slides the route upwards +/// and fades it in. The exit transition is the same, but in reverse. /// -/// For iOS, the page slides in from the right and exits in reverse. The page -/// also shifts to the left in parallax when another page enters to cover it. -/// (These directions are flipped in environments with a right-to-left reading -/// direction.) +/// The transition is adaptive to the platform and on iOS, the route slides in +/// from the right and exits in reverse. The route also shifts to the left in +/// parallax when another page enters to cover it. (These directions are flipped +/// in environments with a right-to-left reading direction.) /// {@endtemplate} /// /// See also: /// /// * [PageTransitionsTheme], which defines the default page transitions used /// by the [MaterialRouteTransitionMixin.buildTransitions]. -/// * [ZoomPageTransitionsBuilder], which is the default page transition used -/// by the [PageTransitionsTheme]. -/// * [CupertinoPageTransitionsBuilder], which is the default page transition -/// for iOS and macOS. mixin MaterialRouteTransitionMixin on PageRoute { /// Builds the primary contents of the route. @protected diff --git a/packages/flutter/lib/src/material/page_transitions_theme.dart b/packages/flutter/lib/src/material/page_transitions_theme.dart index 39e81d95fec..5a02d525974 100644 --- a/packages/flutter/lib/src/material/page_transitions_theme.dart +++ b/packages/flutter/lib/src/material/page_transitions_theme.dart @@ -9,8 +9,7 @@ import 'colors.dart'; import 'theme.dart'; // Slides the page upwards and fades it in, starting from 1/4 screen -// below the top. The transition is intended to match the default for -// Android O. +// below the top. class _FadeUpwardsPageTransition extends StatelessWidget { _FadeUpwardsPageTransition({ Key? key, @@ -147,7 +146,7 @@ class _OpenUpwardsPageTransition extends StatelessWidget { } // Zooms and fades a new page in, zooming out the previous page. This transition -// is designed to match the Android Q activity transition. +// is designed to match the Android 10 activity transition. class _ZoomPageTransition extends StatelessWidget { /// Creates a [_ZoomPageTransition]. /// @@ -292,16 +291,16 @@ class _ZoomEnterTransition extends StatelessWidget { @override Widget build(BuildContext context) { double opacity = 0; - // The transition's scrim opacity only increases on the forward transition. - // In the reverse transition, the opacity should always be 0.0. + // The transition's scrim opacity only increases on the forward transition. In the reverse + // transition, the opacity should always be 0.0. // - // Therefore, we need to only apply the scrim opacity animation when - // the transition is running forwards. + // Therefore, we need to only apply the scrim opacity animation when the transition + // is running forwards. // - // The reason that we check that the animation's status is not `completed` - // instead of checking that it is `forward` is that this allows - // the interrupted reversal of the forward transition to smoothly fade - // the scrim away. This prevents a disjointed removal of the scrim. + // The reason that we check that the animation's status is not `completed` instead + // of checking that it is `forward` is that this allows the interrupted reversal of the + // forward transition to smoothly fade the scrim away. This prevents a disjointed + // removal of the scrim. if (!reverse && animation.status != AnimationStatus.completed) { opacity = _scrimOpacityTween.evaluate(animation)!; } @@ -318,14 +317,17 @@ class _ZoomEnterTransition extends StatelessWidget { return AnimatedBuilder( animation: animation, builder: (BuildContext context, Widget? child) { - return ColoredBox( + return Container( color: Colors.black.withOpacity(opacity), child: child, ); }, child: FadeTransition( opacity: fadeTransition, - child: ScaleTransition(scale: scaleTransition, child: child), + child: ScaleTransition( + scale: scaleTransition, + child: child, + ), ), ); } @@ -372,7 +374,10 @@ class _ZoomExitTransition extends StatelessWidget { return FadeTransition( opacity: fadeTransition, - child: ScaleTransition(scale: scaleTransition, child: child), + child: ScaleTransition( + scale: scaleTransition, + child: child, + ), ); } } @@ -386,12 +391,11 @@ class _ZoomExitTransition extends StatelessWidget { /// /// See also: /// -/// * [FadeUpwardsPageTransitionsBuilder], which defines a page transition -/// that's similar to the one provided by Android O. +/// * [FadeUpwardsPageTransitionsBuilder], which defines a default page transition. /// * [OpenUpwardsPageTransitionsBuilder], which defines a page transition /// that's similar to the one provided by Android P. -/// * [ZoomPageTransitionsBuilder], which defines the default page transition -/// that's similar to the one provided in Android Q. +/// * [ZoomPageTransitionsBuilder], which defines a page transition similar +/// to the one provided in Android 10. /// * [CupertinoPageTransitionsBuilder], which defines a horizontal page /// transition that matches native iOS page transitions. abstract class PageTransitionsBuilder { @@ -415,19 +419,18 @@ abstract class PageTransitionsBuilder { ); } -/// Used by [PageTransitionsTheme] to define a vertically fading -/// [MaterialPageRoute] page transition animation that looks like -/// the default page transition used on Android O. +/// Used by [PageTransitionsTheme] to define a default [MaterialPageRoute] page +/// transition animation. /// -/// The animation fades the new page in while translating it upwards, +/// The default animation fades the new page in while translating it upwards, /// starting from about 25% below the top of the screen. /// /// See also: /// /// * [OpenUpwardsPageTransitionsBuilder], which defines a page transition /// that's similar to the one provided by Android P. -/// * [ZoomPageTransitionsBuilder], which defines the default page transition -/// that's similar to the one provided in Android Q. +/// * [ZoomPageTransitionsBuilder], which defines a page transition similar +/// to the one provided in Android 10. /// * [CupertinoPageTransitionsBuilder], which defines a horizontal page /// transition that matches native iOS page transitions. class FadeUpwardsPageTransitionsBuilder extends PageTransitionsBuilder { @@ -452,10 +455,9 @@ class FadeUpwardsPageTransitionsBuilder extends PageTransitionsBuilder { /// /// See also: /// -/// * [FadeUpwardsPageTransitionsBuilder], which defines a page transition -/// that's similar to the one provided by Android O. -/// * [ZoomPageTransitionsBuilder], which defines the default page transition -/// that's similar to the one provided in Android Q. +/// * [FadeUpwardsPageTransitionsBuilder], which defines a default page transition. +/// * [ZoomPageTransitionsBuilder], which defines a page transition similar +/// to the one provided in Android 10. /// * [CupertinoPageTransitionsBuilder], which defines a horizontal page /// transition that matches native iOS page transitions. class OpenUpwardsPageTransitionsBuilder extends PageTransitionsBuilder { @@ -481,19 +483,18 @@ class OpenUpwardsPageTransitionsBuilder extends PageTransitionsBuilder { /// Used by [PageTransitionsTheme] to define a zooming [MaterialPageRoute] page /// transition animation that looks like the default page transition used on -/// Android Q. +/// Android 10. /// /// See also: /// -/// * [FadeUpwardsPageTransitionsBuilder], which defines a page transition -/// that's similar to the one provided by Android O. +/// * [FadeUpwardsPageTransitionsBuilder], which defines a default page transition. /// * [OpenUpwardsPageTransitionsBuilder], which defines a page transition -/// that's similar to the one provided by Android P. +/// similar to the one provided by Android P. /// * [CupertinoPageTransitionsBuilder], which defines a horizontal page /// transition that matches native iOS page transitions. class ZoomPageTransitionsBuilder extends PageTransitionsBuilder { /// Constructs a page transition animation that matches the transition used on - /// Android Q. + /// Android 10. const ZoomPageTransitionsBuilder(); @override @@ -517,12 +518,11 @@ class ZoomPageTransitionsBuilder extends PageTransitionsBuilder { /// /// See also: /// -/// * [FadeUpwardsPageTransitionsBuilder], which defines a page transition -/// that's similar to the one provided by Android O. +/// * [FadeUpwardsPageTransitionsBuilder], which defines a default page transition. /// * [OpenUpwardsPageTransitionsBuilder], which defines a page transition /// that's similar to the one provided by Android P. -/// * [ZoomPageTransitionsBuilder], which defines the default page transition -/// that's similar to the one provided in Android Q. +/// * [ZoomPageTransitionsBuilder], which defines a page transition similar +/// to the one provided in Android 10. class CupertinoPageTransitionsBuilder extends PageTransitionsBuilder { /// Constructs a page transition animation that matches the iOS transition. const CupertinoPageTransitionsBuilder(); @@ -553,27 +553,26 @@ class CupertinoPageTransitionsBuilder extends PageTransitionsBuilder { /// /// * [ThemeData.pageTransitionsTheme], which defines the default page /// transitions for the overall theme. -/// * [FadeUpwardsPageTransitionsBuilder], which defines a page transition -/// that's similar to the one provided by Android O. +/// * [FadeUpwardsPageTransitionsBuilder], which defines a default page transition. /// * [OpenUpwardsPageTransitionsBuilder], which defines a page transition /// that's similar to the one provided by Android P. -/// * [ZoomPageTransitionsBuilder], which defines the default page transition -/// that's similar to the one provided by Android Q. /// * [CupertinoPageTransitionsBuilder], which defines a horizontal page /// transition that matches native iOS page transitions. @immutable class PageTransitionsTheme with Diagnosticable { /// Constructs an object that selects a transition based on the platform. /// - /// By default the list of builders is: [ZoomPageTransitionsBuilder] + /// By default the list of builders is: [FadeUpwardsPageTransitionsBuilder] /// for [TargetPlatform.android], and [CupertinoPageTransitionsBuilder] for /// [TargetPlatform.iOS] and [TargetPlatform.macOS]. const PageTransitionsTheme({ Map builders = _defaultBuilders }) : _builders = builders; static const Map _defaultBuilders = { - TargetPlatform.android: ZoomPageTransitionsBuilder(), + TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(), TargetPlatform.iOS: CupertinoPageTransitionsBuilder(), + TargetPlatform.linux: FadeUpwardsPageTransitionsBuilder(), TargetPlatform.macOS: CupertinoPageTransitionsBuilder(), + TargetPlatform.windows: FadeUpwardsPageTransitionsBuilder(), }; /// The [PageTransitionsBuilder]s supported by this theme. @@ -581,7 +580,7 @@ class PageTransitionsTheme with Diagnosticable { final Map _builders; /// Delegates to the builder for the current [ThemeData.platform] - /// or [ZoomPageTransitionsBuilder]. + /// or [FadeUpwardsPageTransitionsBuilder]. /// /// [MaterialPageRoute.buildTransitions] delegates to this method. Widget buildTransitions( @@ -597,7 +596,7 @@ class PageTransitionsTheme with Diagnosticable { platform = TargetPlatform.iOS; final PageTransitionsBuilder matchingBuilder = - builders[platform] ?? const ZoomPageTransitionsBuilder(); + builders[platform] ?? const FadeUpwardsPageTransitionsBuilder(); return matchingBuilder.buildTransitions(route, context, animation, secondaryAnimation, child); } diff --git a/packages/flutter/test/material/bottom_navigation_bar_theme_test.dart b/packages/flutter/test/material/bottom_navigation_bar_theme_test.dart index f9279b9d6fa..110fd3cc28a 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_theme_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_theme_test.dart @@ -151,27 +151,13 @@ void main() { ), ); - final Finder findACTransform = find.descendant( - of: find.byType(BottomNavigationBar), - matching: find.ancestor( - of: find.text('AC'), - matching: find.byType(Transform), - ), - ); - final Finder findAlarmTransform = find.descendant( - of: find.byType(BottomNavigationBar), - matching: find.ancestor( - of: find.text('Alarm'), - matching: find.byType(Transform), - ), - ); final TextStyle selectedFontStyle = tester.renderObject(find.text('AC')).text.style!; final TextStyle selectedIcon = _iconStyle(tester, Icons.ac_unit); final TextStyle unselectedIcon = _iconStyle(tester, Icons.access_alarm); expect(selectedFontStyle.fontSize, selectedFontStyle.fontSize); // Unselected label has a font size of 22 but is scaled down to be font size 21. expect( - tester.firstWidget(findAlarmTransform).transform, + tester.firstWidget(find.ancestor(of: find.text('Alarm'), matching: find.byType(Transform))).transform, equals(Matrix4.diagonal3(Vector3.all(unselectedTextStyle.fontSize! / selectedTextStyle.fontSize!))), ); expect(selectedIcon.color, equals(selectedItemColor)); @@ -193,8 +179,14 @@ void main() { expect(_material(tester).elevation, equals(elevation)); expect(_material(tester).color, equals(backgroundColor)); - final Offset selectedBarItem = tester.getCenter(findACTransform); - final Offset unselectedBarItem = tester.getCenter(findAlarmTransform); + final Offset selectedBarItem = tester.getCenter( + find.ancestor(of: find.text('AC'), + matching: find.byType(Transform)) + ); + final Offset unselectedBarItem = tester.getCenter( + find.ancestor(of: find.text('Alarm'), + matching: find.byType(Transform)) + ); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); await gesture.addPointer(); addTearDown(gesture.removePointer); @@ -278,27 +270,13 @@ void main() { ), ); - Finder findDescendantOfBottomNavigationBar(Finder finder) { - return find.descendant( - of: find.byType(BottomNavigationBar), - matching: finder, - ); - } - final TextStyle selectedFontStyle = tester.renderObject(find.text('AC')).text.style!; final TextStyle selectedIcon = _iconStyle(tester, Icons.ac_unit); final TextStyle unselectedIcon = _iconStyle(tester, Icons.access_alarm); expect(selectedFontStyle.fontSize, selectedFontStyle.fontSize); // Unselected label has a font size of 22 but is scaled down to be font size 21. expect( - tester.firstWidget( - findDescendantOfBottomNavigationBar( - find.ancestor( - of: find.text('Alarm'), - matching: find.byType(Transform), - ), - ), - ).transform, + tester.firstWidget(find.ancestor(of: find.text('Alarm'), matching: find.byType(Transform))).transform, equals(Matrix4.diagonal3(Vector3.all(unselectedTextStyle.fontSize! / selectedTextStyle.fontSize!))), ); expect(selectedIcon.color, equals(selectedItemColor)); @@ -307,11 +285,13 @@ void main() { expect(unselectedIcon.fontSize, equals(unselectedIconTheme.size)); // There should not be any [Opacity] or [FadeTransition] widgets // since showUnselectedLabels and showSelectedLabels are true. - final Finder findOpacity = findDescendantOfBottomNavigationBar( - find.byType(Opacity), + final Finder findOpacity = find.descendant( + of: find.byType(BottomNavigationBar), + matching: find.byType(Opacity), ); - final Finder findFadeTransition = findDescendantOfBottomNavigationBar( - find.byType(FadeTransition), + final Finder findFadeTransition = find.descendant( + of: find.byType(BottomNavigationBar), + matching: find.byType(FadeTransition), ); expect(findOpacity, findsNothing); expect(findFadeTransition, findsNothing); @@ -319,12 +299,8 @@ void main() { expect(_material(tester).color, equals(backgroundColor)); final Offset barItem = tester.getCenter( - findDescendantOfBottomNavigationBar( - find.ancestor( - of: find.text('AC'), - matching: find.byType(Transform), - ), - ), + find.ancestor(of: find.text('AC'), + matching: find.byType(Transform)) ); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); await gesture.addPointer(); diff --git a/packages/flutter/test/material/data_table_test.dart b/packages/flutter/test/material/data_table_test.dart index 64e9c1251be..f1eb9defc92 100644 --- a/packages/flutter/test/material/data_table_test.dart +++ b/packages/flutter/test/material/data_table_test.dart @@ -467,11 +467,7 @@ void main() { home: Material(child: buildTable()), )); // The `tester.widget` ensures that there is exactly one upward arrow. - final Finder iconFinder = find.descendant( - of: find.byType(DataTable), - matching: find.widgetWithIcon(Transform, Icons.arrow_upward), - ); - Transform transformOfArrow = tester.widget(iconFinder); + Transform transformOfArrow = tester.widget(find.widgetWithIcon(Transform, Icons.arrow_upward)); expect( transformOfArrow.transform.getRotation(), equals(Matrix3.identity()), @@ -483,7 +479,7 @@ void main() { )); await tester.pumpAndSettle(); // The `tester.widget` ensures that there is exactly one upward arrow. - transformOfArrow = tester.widget(iconFinder); + transformOfArrow = tester.widget(find.widgetWithIcon(Transform, Icons.arrow_upward)); expect( transformOfArrow.transform.getRotation(), equals(Matrix3.rotationZ(math.pi)), @@ -519,10 +515,7 @@ void main() { home: Material(child: buildTable()), )); // The `tester.widget` ensures that there is exactly one upward arrow. - final Finder iconFinder = find.descendant( - of: find.byType(DataTable), - matching: find.widgetWithIcon(Transform, Icons.arrow_upward), - ); + final Finder iconFinder = find.widgetWithIcon(Transform, Icons.arrow_upward); Transform transformOfArrow = tester.widget(iconFinder); expect( transformOfArrow.transform.getRotation(), @@ -572,10 +565,7 @@ void main() { home: Material(child: buildTable()), )); // The `tester.widget` ensures that there is exactly one upward arrow. - final Finder iconFinder = find.descendant( - of: find.byType(DataTable), - matching: find.widgetWithIcon(Transform, Icons.arrow_upward), - ); + final Finder iconFinder = find.widgetWithIcon(Transform, Icons.arrow_upward); Transform transformOfArrow = tester.widget(iconFinder); expect( transformOfArrow.transform.getRotation(), diff --git a/packages/flutter/test/material/flexible_space_bar_test.dart b/packages/flutter/test/material/flexible_space_bar_test.dart index 51368236461..0e1e93bcea2 100644 --- a/packages/flutter/test/material/flexible_space_bar_test.dart +++ b/packages/flutter/test/material/flexible_space_bar_test.dart @@ -102,12 +102,7 @@ void main() { ); final RenderBox clipRect = tester.renderObject(find.byType(ClipRect).first); - final Transform transform = tester.firstWidget( - find.descendant( - of: find.byType(FlexibleSpaceBar), - matching: find.byType(Transform), - ), - ); + final Transform transform = tester.firstWidget(find.byType(Transform)); // The current (200) is half way between the min (100) and max (300) and the // lerp values used to calculate the scale are 1 and 1.5, so we check for 1.25. diff --git a/packages/flutter/test/material/page_test.dart b/packages/flutter/test/material/page_test.dart index be17fe0a62d..edbfb366981 100644 --- a/packages/flutter/test/material/page_test.dart +++ b/packages/flutter/test/material/page_test.dart @@ -10,17 +10,10 @@ import 'package:flutter_test/flutter_test.dart'; import '../rendering/mock_canvas.dart'; void main() { - testWidgets('test page transition (_FadeUpwardsPageTransition)', (WidgetTester tester) async { + testWidgets('test page transition', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( home: const Material(child: Text('Page 1')), - theme: ThemeData( - pageTransitionsTheme: const PageTransitionsTheme( - builders: { - TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(), - }, - ), - ), routes: { '/next': (BuildContext context) { return const Material(child: Text('Page 2')); @@ -74,7 +67,7 @@ void main() { expect(find.text('Page 2'), findsNothing); }, variant: TargetPlatformVariant.only(TargetPlatform.android)); - testWidgets('test page transition (CupertinoPageTransition)', (WidgetTester tester) async { + testWidgets('test page transition', (WidgetTester tester) async { final Key page2Key = UniqueKey(); await tester.pumpWidget( MaterialApp( @@ -155,80 +148,6 @@ void main() { expect(widget1InitialTopLeft == widget1TransientTopLeft, true); }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); - testWidgets('test page transition (_ZoomPageTransition)', (WidgetTester tester) async { - Iterable _findWidgets(Finder of) { - return tester.widgetList( - find.ancestor(of: of, matching: find.byType(T)), - ); - } - - FadeTransition _findForwardFadeTransition(Finder of) { - return _findWidgets(of).where( - (FadeTransition t) => t.opacity.status == AnimationStatus.forward, - ).first; - } - - ScaleTransition _findForwardScaleTransition(Finder of) { - return _findWidgets(of).where( - (ScaleTransition t) => t.scale.status == AnimationStatus.forward, - ).first; - } - - await tester.pumpWidget( - MaterialApp( - home: const Material(child: Text('Page 1')), - routes: { - '/next': (BuildContext context) { - return const Material(child: Text('Page 2')); - }, - }, - ), - ); - - tester.state(find.byType(Navigator)).pushNamed('/next'); - await tester.pump(); - await tester.pump(const Duration(milliseconds: 50)); - - ScaleTransition widget1Scale = _findForwardScaleTransition(find.text('Page 1')); - ScaleTransition widget2Scale = _findForwardScaleTransition(find.text('Page 2')); - FadeTransition widget2Opacity = _findForwardFadeTransition(find.text('Page 2')); - - // Page 1 is enlarging, starts from 1.0. - expect(widget1Scale.scale.value, greaterThan(1.0)); - // Page 2 is enlarging from the value less than 1.0. - expect(widget2Scale.scale.value, lessThan(1.0)); - // Page 2 is becoming none transparent. - expect(widget2Opacity.opacity.value, lessThan(1.0)); - - await tester.pump(const Duration(milliseconds: 250)); - await tester.pump(const Duration(milliseconds: 1)); - - // Page 2 covers page 1. - expect(find.text('Page 1'), findsNothing); - expect(find.text('Page 2'), isOnstage); - - tester.state(find.byType(Navigator)).pop(); - await tester.pump(); - await tester.pump(const Duration(milliseconds: 100)); - - widget1Scale = _findForwardScaleTransition(find.text('Page 1')); - widget2Scale = _findForwardScaleTransition(find.text('Page 2')); - widget2Opacity = _findForwardFadeTransition(find.text('Page 2')); - - // Page 1 is narrowing down, but still larger than 1.0. - expect(widget1Scale.scale.value, greaterThan(1.0)); - // Page 2 is smaller than 1.0. - expect(widget2Scale.scale.value, lessThan(1.0)); - // Page 2 is becoming transparent. - expect(widget2Opacity.opacity.value, lessThan(1.0)); - - await tester.pump(const Duration(milliseconds: 200)); - await tester.pump(const Duration(milliseconds: 1)); - - expect(find.text('Page 1'), isOnstage); - expect(find.text('Page 2'), findsNothing); - }, variant: TargetPlatformVariant.only(TargetPlatform.android)); - testWidgets('test fullscreen dialog transition', (WidgetTester tester) async { await tester.pumpWidget( const MaterialApp( diff --git a/packages/flutter/test/material/page_transitions_theme_test.dart b/packages/flutter/test/material/page_transitions_theme_test.dart index 749588c6f51..2db3f43e7c3 100644 --- a/packages/flutter/test/material/page_transitions_theme_test.dart +++ b/packages/flutter/test/material/page_transitions_theme_test.dart @@ -13,30 +13,15 @@ void main() { final PageTransitionsTheme theme = Theme.of(tester.element(find.text('home'))).pageTransitionsTheme; expect(theme.builders, isNotNull); for (final TargetPlatform platform in TargetPlatform.values) { - switch (platform) { - case TargetPlatform.android: - case TargetPlatform.iOS: - case TargetPlatform.macOS: - expect( - theme.builders[platform], - isNotNull, - reason: 'theme builder for $platform is null', - ); - break; - case TargetPlatform.fuchsia: - case TargetPlatform.linux: - case TargetPlatform.windows: - expect( - theme.builders[platform], - isNull, - reason: 'theme builder for $platform is not null', - ); - break; + if (platform == TargetPlatform.fuchsia) { + // No builder on Fuchsia. + continue; } + expect(theme.builders[platform], isNotNull, reason: 'theme builder for $platform is null'); } }); - testWidgets('Default PageTransitionsTheme builds a CupertinoPageTransition', (WidgetTester tester) async { + testWidgets('Default PageTransitionsTheme builds a CupertionPageTransition', (WidgetTester tester) async { final Map routes = { '/': (BuildContext context) => Material( child: TextButton( @@ -62,7 +47,7 @@ void main() { expect(find.byType(CupertinoPageTransition), findsOneWidget); }, variant: const TargetPlatformVariant({ TargetPlatform.iOS, TargetPlatform.macOS })); - testWidgets('Default PageTransitionsTheme builds a _ZoomPageTransition for android', (WidgetTester tester) async { + testWidgets('Default PageTransitionsTheme builds a _FadeUpwardsPageTransition for android', (WidgetTester tester) async { final Map routes = { '/': (BuildContext context) => Material( child: TextButton( @@ -79,20 +64,20 @@ void main() { ), ); - Finder findZoomPageTransition() { + Finder findFadeUpwardsPageTransition() { return find.descendant( of: find.byType(MaterialApp), - matching: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_ZoomPageTransition'), + matching: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_FadeUpwardsPageTransition'), ); } expect(Theme.of(tester.element(find.text('push'))).platform, debugDefaultTargetPlatformOverride); - expect(findZoomPageTransition(), findsOneWidget); + expect(findFadeUpwardsPageTransition(), findsOneWidget); await tester.tap(find.text('push')); await tester.pumpAndSettle(); expect(find.text('page b'), findsOneWidget); - expect(findZoomPageTransition(), findsOneWidget); + expect(findFadeUpwardsPageTransition(), findsOneWidget); }, variant: TargetPlatformVariant.only(TargetPlatform.android)); testWidgets('PageTransitionsTheme override builds a _OpenUpwardsPageTransition', (WidgetTester tester) async { @@ -135,7 +120,7 @@ void main() { expect(findOpenUpwardsPageTransition(), findsOneWidget); }, variant: TargetPlatformVariant.only(TargetPlatform.android)); - testWidgets('PageTransitionsTheme override builds a _FadeUpwardsTransition', (WidgetTester tester) async { + testWidgets('PageTransitionsTheme override builds a _ZoomPageTransition', (WidgetTester tester) async { final Map routes = { '/': (BuildContext context) => Material( child: TextButton( @@ -151,7 +136,7 @@ void main() { theme: ThemeData( pageTransitionsTheme: const PageTransitionsTheme( builders: { - TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(), // creates a _FadeUpwardsTransition + TargetPlatform.android: ZoomPageTransitionsBuilder(), // creates a _ZoomPageTransition }, ), ), @@ -159,20 +144,20 @@ void main() { ), ); - Finder findFadeUpwardsPageTransition() { + Finder findZoomPageTransition() { return find.descendant( of: find.byType(MaterialApp), - matching: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_FadeUpwardsPageTransition'), + matching: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_ZoomPageTransition'), ); } expect(Theme.of(tester.element(find.text('push'))).platform, debugDefaultTargetPlatformOverride); - expect(findFadeUpwardsPageTransition(), findsOneWidget); + expect(findZoomPageTransition(), findsOneWidget); await tester.tap(find.text('push')); await tester.pumpAndSettle(); expect(find.text('page b'), findsOneWidget); - expect(findFadeUpwardsPageTransition(), findsOneWidget); + expect(findZoomPageTransition(), findsOneWidget); }, variant: TargetPlatformVariant.only(TargetPlatform.android)); testWidgets('_ZoomPageTransition only cause child widget built once', (WidgetTester tester) async { diff --git a/packages/flutter/test/material/user_accounts_drawer_header_test.dart b/packages/flutter/test/material/user_accounts_drawer_header_test.dart index 3ff35a392d4..9f6c5f07f27 100644 --- a/packages/flutter/test/material/user_accounts_drawer_header_test.dart +++ b/packages/flutter/test/material/user_accounts_drawer_header_test.dart @@ -70,12 +70,6 @@ Future pumpTestWidget( } void main() { - // Find the exact transform which is the descendant of [UserAccountsDrawerHeader]. - final Finder findTransform = find.descendant( - of: find.byType(UserAccountsDrawerHeader), - matching: find.byType(Transform), - ); - testWidgets('UserAccountsDrawerHeader test', (WidgetTester tester) async { await pumpTestWidget(tester); @@ -133,7 +127,7 @@ void main() { testWidgets('UserAccountsDrawerHeader icon rotation test', (WidgetTester tester) async { await pumpTestWidget(tester); - Transform transformWidget = tester.firstWidget(findTransform); + Transform transformWidget = tester.firstWidget(find.byType(Transform)); // Icon is right side up. expect(transformWidget.transform.getRotation()[0], 1.0); @@ -146,7 +140,7 @@ void main() { await tester.pumpAndSettle(); await tester.pump(); - transformWidget = tester.firstWidget(findTransform); + transformWidget = tester.firstWidget(find.byType(Transform)); // Icon has rotated 180 degrees. expect(transformWidget.transform.getRotation()[0], -1.0); @@ -159,7 +153,7 @@ void main() { await tester.pumpAndSettle(); await tester.pump(); - transformWidget = tester.firstWidget(findTransform); + transformWidget = tester.firstWidget(find.byType(Transform)); // Icon has rotated 180 degrees back to the original position. expect(transformWidget.transform.getRotation()[0], 1.0); @@ -184,7 +178,7 @@ void main() { ), )); - Transform transformWidget = tester.firstWidget(findTransform); + Transform transformWidget = tester.firstWidget(find.byType(Transform)); // Icon is right side up. expect(transformWidget.transform.getRotation()[0], 1.0); @@ -195,7 +189,7 @@ void main() { expect(tester.hasRunningAnimations, isFalse); expect(await tester.pumpAndSettle(), 1); - transformWidget = tester.firstWidget(findTransform); + transformWidget = tester.firstWidget(find.byType(Transform)); // Icon has not rotated. expect(transformWidget.transform.getRotation()[0], 1.0); @@ -204,7 +198,7 @@ void main() { testWidgets('UserAccountsDrawerHeader icon rotation test speeeeeedy', (WidgetTester tester) async { await pumpTestWidget(tester); - Transform transformWidget = tester.firstWidget(findTransform); + Transform transformWidget = tester.firstWidget(find.byType(Transform)); // Icon is right side up. expect(transformWidget.transform.getRotation()[0], 1.0); @@ -236,7 +230,7 @@ void main() { await tester.pumpAndSettle(); await tester.pump(); - transformWidget = tester.firstWidget(findTransform); + transformWidget = tester.firstWidget(find.byType(Transform)); // Icon has rotated 180 degrees back to the original position. expect(transformWidget.transform.getRotation()[0], 1.0); diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index 4514593b4d5..d60ad87827d 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -728,14 +728,7 @@ Future main() async { testWidgets('Hero pop transition interrupted by a push', (WidgetTester tester) async { await tester.pumpWidget( - MaterialApp( - routes: routes, - theme: ThemeData(pageTransitionsTheme: const PageTransitionsTheme( - builders: { - TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(), - }, - )), - ), + MaterialApp(routes: routes), ); // Pushes MaterialPageRoute '/two'.