Unverified Commit bfa272ac authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

Revert " Android Q transition by default (#98559)" (#100799)

This reverts commit c82ddd39.
parent c82ddd39
...@@ -63,24 +63,19 @@ class MaterialPageRoute<T> extends PageRoute<T> with MaterialRouteTransitionMixi ...@@ -63,24 +63,19 @@ class MaterialPageRoute<T> extends PageRoute<T> with MaterialRouteTransitionMixi
/// A mixin that provides platform-adaptive transitions for a [PageRoute]. /// A mixin that provides platform-adaptive transitions for a [PageRoute].
/// ///
/// {@template flutter.material.materialRouteTransitionMixin} /// {@template flutter.material.materialRouteTransitionMixin}
/// For Android, the entrance transition for the page zooms in and fades in /// For Android, the entrance transition for the page slides the route upwards
/// while the exiting page zooms out and fades out. The exit transition is similar, /// and fades it in. The exit transition is the same, but in reverse.
/// but in reverse. ///
/// /// The transition is adaptive to the platform and on iOS, the route slides in
/// For iOS, the page slides in from the right and exits in reverse. The page /// from the right and exits in reverse. The route also shifts to the left in
/// also shifts to the left in parallax when another page enters to cover it. /// parallax when another page enters to cover it. (These directions are flipped
/// (These directions are flipped in environments with a right-to-left reading /// in environments with a right-to-left reading direction.)
/// direction.)
/// {@endtemplate} /// {@endtemplate}
/// ///
/// See also: /// See also:
/// ///
/// * [PageTransitionsTheme], which defines the default page transitions used /// * [PageTransitionsTheme], which defines the default page transitions used
/// by the [MaterialRouteTransitionMixin.buildTransitions]. /// 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<T> on PageRoute<T> { mixin MaterialRouteTransitionMixin<T> on PageRoute<T> {
/// Builds the primary contents of the route. /// Builds the primary contents of the route.
@protected @protected
......
...@@ -151,27 +151,13 @@ void main() { ...@@ -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<RenderParagraph>(find.text('AC')).text.style!; final TextStyle selectedFontStyle = tester.renderObject<RenderParagraph>(find.text('AC')).text.style!;
final TextStyle selectedIcon = _iconStyle(tester, Icons.ac_unit); final TextStyle selectedIcon = _iconStyle(tester, Icons.ac_unit);
final TextStyle unselectedIcon = _iconStyle(tester, Icons.access_alarm); final TextStyle unselectedIcon = _iconStyle(tester, Icons.access_alarm);
expect(selectedFontStyle.fontSize, selectedFontStyle.fontSize); expect(selectedFontStyle.fontSize, selectedFontStyle.fontSize);
// Unselected label has a font size of 22 but is scaled down to be font size 21. // Unselected label has a font size of 22 but is scaled down to be font size 21.
expect( expect(
tester.firstWidget<Transform>(findAlarmTransform).transform, tester.firstWidget<Transform>(find.ancestor(of: find.text('Alarm'), matching: find.byType(Transform))).transform,
equals(Matrix4.diagonal3(Vector3.all(unselectedTextStyle.fontSize! / selectedTextStyle.fontSize!))), equals(Matrix4.diagonal3(Vector3.all(unselectedTextStyle.fontSize! / selectedTextStyle.fontSize!))),
); );
expect(selectedIcon.color, equals(selectedItemColor)); expect(selectedIcon.color, equals(selectedItemColor));
...@@ -193,8 +179,14 @@ void main() { ...@@ -193,8 +179,14 @@ void main() {
expect(_material(tester).elevation, equals(elevation)); expect(_material(tester).elevation, equals(elevation));
expect(_material(tester).color, equals(backgroundColor)); expect(_material(tester).color, equals(backgroundColor));
final Offset selectedBarItem = tester.getCenter(findACTransform); final Offset selectedBarItem = tester.getCenter(
final Offset unselectedBarItem = tester.getCenter(findAlarmTransform); 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); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
addTearDown(gesture.removePointer); addTearDown(gesture.removePointer);
...@@ -278,27 +270,13 @@ void main() { ...@@ -278,27 +270,13 @@ void main() {
), ),
); );
Finder findDescendantOfBottomNavigationBar(Finder finder) {
return find.descendant(
of: find.byType(BottomNavigationBar),
matching: finder,
);
}
final TextStyle selectedFontStyle = tester.renderObject<RenderParagraph>(find.text('AC')).text.style!; final TextStyle selectedFontStyle = tester.renderObject<RenderParagraph>(find.text('AC')).text.style!;
final TextStyle selectedIcon = _iconStyle(tester, Icons.ac_unit); final TextStyle selectedIcon = _iconStyle(tester, Icons.ac_unit);
final TextStyle unselectedIcon = _iconStyle(tester, Icons.access_alarm); final TextStyle unselectedIcon = _iconStyle(tester, Icons.access_alarm);
expect(selectedFontStyle.fontSize, selectedFontStyle.fontSize); expect(selectedFontStyle.fontSize, selectedFontStyle.fontSize);
// Unselected label has a font size of 22 but is scaled down to be font size 21. // Unselected label has a font size of 22 but is scaled down to be font size 21.
expect( expect(
tester.firstWidget<Transform>( tester.firstWidget<Transform>(find.ancestor(of: find.text('Alarm'), matching: find.byType(Transform))).transform,
findDescendantOfBottomNavigationBar(
find.ancestor(
of: find.text('Alarm'),
matching: find.byType(Transform),
),
),
).transform,
equals(Matrix4.diagonal3(Vector3.all(unselectedTextStyle.fontSize! / selectedTextStyle.fontSize!))), equals(Matrix4.diagonal3(Vector3.all(unselectedTextStyle.fontSize! / selectedTextStyle.fontSize!))),
); );
expect(selectedIcon.color, equals(selectedItemColor)); expect(selectedIcon.color, equals(selectedItemColor));
...@@ -307,11 +285,13 @@ void main() { ...@@ -307,11 +285,13 @@ void main() {
expect(unselectedIcon.fontSize, equals(unselectedIconTheme.size)); expect(unselectedIcon.fontSize, equals(unselectedIconTheme.size));
// There should not be any [Opacity] or [FadeTransition] widgets // There should not be any [Opacity] or [FadeTransition] widgets
// since showUnselectedLabels and showSelectedLabels are true. // since showUnselectedLabels and showSelectedLabels are true.
final Finder findOpacity = findDescendantOfBottomNavigationBar( final Finder findOpacity = find.descendant(
find.byType(Opacity), of: find.byType(BottomNavigationBar),
matching: find.byType(Opacity),
); );
final Finder findFadeTransition = findDescendantOfBottomNavigationBar( final Finder findFadeTransition = find.descendant(
find.byType(FadeTransition), of: find.byType(BottomNavigationBar),
matching: find.byType(FadeTransition),
); );
expect(findOpacity, findsNothing); expect(findOpacity, findsNothing);
expect(findFadeTransition, findsNothing); expect(findFadeTransition, findsNothing);
...@@ -319,12 +299,8 @@ void main() { ...@@ -319,12 +299,8 @@ void main() {
expect(_material(tester).color, equals(backgroundColor)); expect(_material(tester).color, equals(backgroundColor));
final Offset barItem = tester.getCenter( final Offset barItem = tester.getCenter(
findDescendantOfBottomNavigationBar( find.ancestor(of: find.text('AC'),
find.ancestor( matching: find.byType(Transform))
of: find.text('AC'),
matching: find.byType(Transform),
),
),
); );
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
......
...@@ -467,11 +467,7 @@ void main() { ...@@ -467,11 +467,7 @@ void main() {
home: Material(child: buildTable()), home: Material(child: buildTable()),
)); ));
// The `tester.widget` ensures that there is exactly one upward arrow. // The `tester.widget` ensures that there is exactly one upward arrow.
final Finder iconFinder = find.descendant( Transform transformOfArrow = tester.widget<Transform>(find.widgetWithIcon(Transform, Icons.arrow_upward));
of: find.byType(DataTable),
matching: find.widgetWithIcon(Transform, Icons.arrow_upward),
);
Transform transformOfArrow = tester.widget<Transform>(iconFinder);
expect( expect(
transformOfArrow.transform.getRotation(), transformOfArrow.transform.getRotation(),
equals(Matrix3.identity()), equals(Matrix3.identity()),
...@@ -483,7 +479,7 @@ void main() { ...@@ -483,7 +479,7 @@ void main() {
)); ));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
// The `tester.widget` ensures that there is exactly one upward arrow. // The `tester.widget` ensures that there is exactly one upward arrow.
transformOfArrow = tester.widget<Transform>(iconFinder); transformOfArrow = tester.widget<Transform>(find.widgetWithIcon(Transform, Icons.arrow_upward));
expect( expect(
transformOfArrow.transform.getRotation(), transformOfArrow.transform.getRotation(),
equals(Matrix3.rotationZ(math.pi)), equals(Matrix3.rotationZ(math.pi)),
...@@ -519,10 +515,7 @@ void main() { ...@@ -519,10 +515,7 @@ void main() {
home: Material(child: buildTable()), home: Material(child: buildTable()),
)); ));
// The `tester.widget` ensures that there is exactly one upward arrow. // The `tester.widget` ensures that there is exactly one upward arrow.
final Finder iconFinder = find.descendant( final Finder iconFinder = find.widgetWithIcon(Transform, Icons.arrow_upward);
of: find.byType(DataTable),
matching: find.widgetWithIcon(Transform, Icons.arrow_upward),
);
Transform transformOfArrow = tester.widget<Transform>(iconFinder); Transform transformOfArrow = tester.widget<Transform>(iconFinder);
expect( expect(
transformOfArrow.transform.getRotation(), transformOfArrow.transform.getRotation(),
...@@ -572,10 +565,7 @@ void main() { ...@@ -572,10 +565,7 @@ void main() {
home: Material(child: buildTable()), home: Material(child: buildTable()),
)); ));
// The `tester.widget` ensures that there is exactly one upward arrow. // The `tester.widget` ensures that there is exactly one upward arrow.
final Finder iconFinder = find.descendant( final Finder iconFinder = find.widgetWithIcon(Transform, Icons.arrow_upward);
of: find.byType(DataTable),
matching: find.widgetWithIcon(Transform, Icons.arrow_upward),
);
Transform transformOfArrow = tester.widget<Transform>(iconFinder); Transform transformOfArrow = tester.widget<Transform>(iconFinder);
expect( expect(
transformOfArrow.transform.getRotation(), transformOfArrow.transform.getRotation(),
......
...@@ -102,12 +102,7 @@ void main() { ...@@ -102,12 +102,7 @@ void main() {
); );
final RenderBox clipRect = tester.renderObject(find.byType(ClipRect).first); final RenderBox clipRect = tester.renderObject(find.byType(ClipRect).first);
final Transform transform = tester.firstWidget( final Transform transform = tester.firstWidget(find.byType(Transform));
find.descendant(
of: find.byType(FlexibleSpaceBar),
matching: find.byType(Transform),
),
);
// The current (200) is half way between the min (100) and max (300) and the // 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. // lerp values used to calculate the scale are 1 and 1.5, so we check for 1.25.
......
...@@ -10,17 +10,10 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -10,17 +10,10 @@ import 'package:flutter_test/flutter_test.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
void main() { void main() {
testWidgets('test page transition (_FadeUpwardsPageTransition)', (WidgetTester tester) async { testWidgets('test page transition', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: const Material(child: Text('Page 1')), home: const Material(child: Text('Page 1')),
theme: ThemeData(
pageTransitionsTheme: const PageTransitionsTheme(
builders: <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
},
),
),
routes: <String, WidgetBuilder>{ routes: <String, WidgetBuilder>{
'/next': (BuildContext context) { '/next': (BuildContext context) {
return const Material(child: Text('Page 2')); return const Material(child: Text('Page 2'));
...@@ -74,7 +67,7 @@ void main() { ...@@ -74,7 +67,7 @@ void main() {
expect(find.text('Page 2'), findsNothing); expect(find.text('Page 2'), findsNothing);
}, variant: TargetPlatformVariant.only(TargetPlatform.android)); }, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgets('test page transition (CupertinoPageTransition)', (WidgetTester tester) async { testWidgets('test page transition', (WidgetTester tester) async {
final Key page2Key = UniqueKey(); final Key page2Key = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -155,80 +148,6 @@ void main() { ...@@ -155,80 +148,6 @@ void main() {
expect(widget1InitialTopLeft == widget1TransientTopLeft, true); expect(widget1InitialTopLeft == widget1TransientTopLeft, true);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgets('test page transition (_ZoomPageTransition)', (WidgetTester tester) async {
Iterable<T> _findWidgets<T extends Widget>(Finder of) {
return tester.widgetList<T>(
find.ancestor(of: of, matching: find.byType(T)),
);
}
FadeTransition _findForwardFadeTransition(Finder of) {
return _findWidgets<FadeTransition>(of).where(
(FadeTransition t) => t.opacity.status == AnimationStatus.forward,
).first;
}
ScaleTransition _findForwardScaleTransition(Finder of) {
return _findWidgets<ScaleTransition>(of).where(
(ScaleTransition t) => t.scale.status == AnimationStatus.forward,
).first;
}
await tester.pumpWidget(
MaterialApp(
home: const Material(child: Text('Page 1')),
routes: <String, WidgetBuilder>{
'/next': (BuildContext context) {
return const Material(child: Text('Page 2'));
},
},
),
);
tester.state<NavigatorState>(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<NavigatorState>(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 { testWidgets('test fullscreen dialog transition', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
......
...@@ -13,30 +13,15 @@ void main() { ...@@ -13,30 +13,15 @@ void main() {
final PageTransitionsTheme theme = Theme.of(tester.element(find.text('home'))).pageTransitionsTheme; final PageTransitionsTheme theme = Theme.of(tester.element(find.text('home'))).pageTransitionsTheme;
expect(theme.builders, isNotNull); expect(theme.builders, isNotNull);
for (final TargetPlatform platform in TargetPlatform.values) { for (final TargetPlatform platform in TargetPlatform.values) {
switch (platform) { if (platform == TargetPlatform.fuchsia) {
case TargetPlatform.android: // No builder on Fuchsia.
case TargetPlatform.iOS: continue;
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;
} }
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<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => Material( '/': (BuildContext context) => Material(
child: TextButton( child: TextButton(
...@@ -62,7 +47,7 @@ void main() { ...@@ -62,7 +47,7 @@ void main() {
expect(find.byType(CupertinoPageTransition), findsOneWidget); expect(find.byType(CupertinoPageTransition), findsOneWidget);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ 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<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => Material( '/': (BuildContext context) => Material(
child: TextButton( child: TextButton(
...@@ -79,20 +64,20 @@ void main() { ...@@ -79,20 +64,20 @@ void main() {
), ),
); );
Finder findZoomPageTransition() { Finder findFadeUpwardsPageTransition() {
return find.descendant( return find.descendant(
of: find.byType(MaterialApp), 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(Theme.of(tester.element(find.text('push'))).platform, debugDefaultTargetPlatformOverride);
expect(findZoomPageTransition(), findsOneWidget); expect(findFadeUpwardsPageTransition(), findsOneWidget);
await tester.tap(find.text('push')); await tester.tap(find.text('push'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('page b'), findsOneWidget); expect(find.text('page b'), findsOneWidget);
expect(findZoomPageTransition(), findsOneWidget); expect(findFadeUpwardsPageTransition(), findsOneWidget);
}, variant: TargetPlatformVariant.only(TargetPlatform.android)); }, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgets('PageTransitionsTheme override builds a _OpenUpwardsPageTransition', (WidgetTester tester) async { testWidgets('PageTransitionsTheme override builds a _OpenUpwardsPageTransition', (WidgetTester tester) async {
...@@ -135,7 +120,7 @@ void main() { ...@@ -135,7 +120,7 @@ void main() {
expect(findOpenUpwardsPageTransition(), findsOneWidget); expect(findOpenUpwardsPageTransition(), findsOneWidget);
}, variant: TargetPlatformVariant.only(TargetPlatform.android)); }, 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<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => Material( '/': (BuildContext context) => Material(
child: TextButton( child: TextButton(
...@@ -151,7 +136,7 @@ void main() { ...@@ -151,7 +136,7 @@ void main() {
theme: ThemeData( theme: ThemeData(
pageTransitionsTheme: const PageTransitionsTheme( pageTransitionsTheme: const PageTransitionsTheme(
builders: <TargetPlatform, PageTransitionsBuilder>{ builders: <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(), // creates a _FadeUpwardsTransition TargetPlatform.android: ZoomPageTransitionsBuilder(), // creates a _ZoomPageTransition
}, },
), ),
), ),
...@@ -159,20 +144,20 @@ void main() { ...@@ -159,20 +144,20 @@ void main() {
), ),
); );
Finder findFadeUpwardsPageTransition() { Finder findZoomPageTransition() {
return find.descendant( return find.descendant(
of: find.byType(MaterialApp), 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(Theme.of(tester.element(find.text('push'))).platform, debugDefaultTargetPlatformOverride);
expect(findFadeUpwardsPageTransition(), findsOneWidget); expect(findZoomPageTransition(), findsOneWidget);
await tester.tap(find.text('push')); await tester.tap(find.text('push'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('page b'), findsOneWidget); expect(find.text('page b'), findsOneWidget);
expect(findFadeUpwardsPageTransition(), findsOneWidget); expect(findZoomPageTransition(), findsOneWidget);
}, variant: TargetPlatformVariant.only(TargetPlatform.android)); }, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgets('_ZoomPageTransition only cause child widget built once', (WidgetTester tester) async { testWidgets('_ZoomPageTransition only cause child widget built once', (WidgetTester tester) async {
......
...@@ -70,12 +70,6 @@ Future<void> pumpTestWidget( ...@@ -70,12 +70,6 @@ Future<void> pumpTestWidget(
} }
void main() { 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 { testWidgets('UserAccountsDrawerHeader test', (WidgetTester tester) async {
await pumpTestWidget(tester); await pumpTestWidget(tester);
...@@ -133,7 +127,7 @@ void main() { ...@@ -133,7 +127,7 @@ void main() {
testWidgets('UserAccountsDrawerHeader icon rotation test', (WidgetTester tester) async { testWidgets('UserAccountsDrawerHeader icon rotation test', (WidgetTester tester) async {
await pumpTestWidget(tester); await pumpTestWidget(tester);
Transform transformWidget = tester.firstWidget(findTransform); Transform transformWidget = tester.firstWidget(find.byType(Transform));
// Icon is right side up. // Icon is right side up.
expect(transformWidget.transform.getRotation()[0], 1.0); expect(transformWidget.transform.getRotation()[0], 1.0);
...@@ -146,7 +140,7 @@ void main() { ...@@ -146,7 +140,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.pump(); await tester.pump();
transformWidget = tester.firstWidget(findTransform); transformWidget = tester.firstWidget(find.byType(Transform));
// Icon has rotated 180 degrees. // Icon has rotated 180 degrees.
expect(transformWidget.transform.getRotation()[0], -1.0); expect(transformWidget.transform.getRotation()[0], -1.0);
...@@ -159,7 +153,7 @@ void main() { ...@@ -159,7 +153,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.pump(); await tester.pump();
transformWidget = tester.firstWidget(findTransform); transformWidget = tester.firstWidget(find.byType(Transform));
// Icon has rotated 180 degrees back to the original position. // Icon has rotated 180 degrees back to the original position.
expect(transformWidget.transform.getRotation()[0], 1.0); expect(transformWidget.transform.getRotation()[0], 1.0);
...@@ -184,7 +178,7 @@ void main() { ...@@ -184,7 +178,7 @@ void main() {
), ),
)); ));
Transform transformWidget = tester.firstWidget(findTransform); Transform transformWidget = tester.firstWidget(find.byType(Transform));
// Icon is right side up. // Icon is right side up.
expect(transformWidget.transform.getRotation()[0], 1.0); expect(transformWidget.transform.getRotation()[0], 1.0);
...@@ -195,7 +189,7 @@ void main() { ...@@ -195,7 +189,7 @@ void main() {
expect(tester.hasRunningAnimations, isFalse); expect(tester.hasRunningAnimations, isFalse);
expect(await tester.pumpAndSettle(), 1); expect(await tester.pumpAndSettle(), 1);
transformWidget = tester.firstWidget(findTransform); transformWidget = tester.firstWidget(find.byType(Transform));
// Icon has not rotated. // Icon has not rotated.
expect(transformWidget.transform.getRotation()[0], 1.0); expect(transformWidget.transform.getRotation()[0], 1.0);
...@@ -204,7 +198,7 @@ void main() { ...@@ -204,7 +198,7 @@ void main() {
testWidgets('UserAccountsDrawerHeader icon rotation test speeeeeedy', (WidgetTester tester) async { testWidgets('UserAccountsDrawerHeader icon rotation test speeeeeedy', (WidgetTester tester) async {
await pumpTestWidget(tester); await pumpTestWidget(tester);
Transform transformWidget = tester.firstWidget(findTransform); Transform transformWidget = tester.firstWidget(find.byType(Transform));
// Icon is right side up. // Icon is right side up.
expect(transformWidget.transform.getRotation()[0], 1.0); expect(transformWidget.transform.getRotation()[0], 1.0);
...@@ -236,7 +230,7 @@ void main() { ...@@ -236,7 +230,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await tester.pump(); await tester.pump();
transformWidget = tester.firstWidget(findTransform); transformWidget = tester.firstWidget(find.byType(Transform));
// Icon has rotated 180 degrees back to the original position. // Icon has rotated 180 degrees back to the original position.
expect(transformWidget.transform.getRotation()[0], 1.0); expect(transformWidget.transform.getRotation()[0], 1.0);
......
...@@ -728,14 +728,7 @@ Future<void> main() async { ...@@ -728,14 +728,7 @@ Future<void> main() async {
testWidgets('Hero pop transition interrupted by a push', (WidgetTester tester) async { testWidgets('Hero pop transition interrupted by a push', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(routes: routes),
routes: routes,
theme: ThemeData(pageTransitionsTheme: const PageTransitionsTheme(
builders: <TargetPlatform, PageTransitionsBuilder>{
TargetPlatform.android: FadeUpwardsPageTransitionsBuilder(),
},
)),
),
); );
// Pushes MaterialPageRoute '/two'. // Pushes MaterialPageRoute '/two'.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment