mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Update unit tests
This commit is contained in:
parent
f74318f11a
commit
c91c18ebc5
@ -218,7 +218,7 @@ void main() {
|
||||
final BottomAppBar bottomAppBar = tester.widget(find.byType(BottomAppBar));
|
||||
expect(bottomAppBar.padding, customPadding);
|
||||
final Rect babRect = tester.getRect(find.byType(BottomAppBar));
|
||||
final Rect childRect = tester.getRect(find.byType(ColoredBox));
|
||||
final Rect childRect = tester.getRect(find.byType(ColoredBox).last);
|
||||
expect(childRect, const Rect.fromLTRB(250, 530, 550, 590));
|
||||
expect(babRect, const Rect.fromLTRB(240, 520, 560, 600));
|
||||
});
|
||||
|
||||
@ -1567,7 +1567,12 @@ void main() {
|
||||
));
|
||||
|
||||
final Size materialAppSize = tester.getSize(find.byType(MaterialApp));
|
||||
final Size titleSize = tester.getSize(find.byType(ColoredBox));
|
||||
final Size titleSize = tester.getSize(
|
||||
find.descendant(
|
||||
of: find.byType(ExpansionTile),
|
||||
matching: find.byType(ColoredBox)
|
||||
)
|
||||
);
|
||||
|
||||
expect(titleSize.width, materialAppSize.width);
|
||||
});
|
||||
@ -1585,7 +1590,12 @@ void main() {
|
||||
));
|
||||
|
||||
final Size materialAppSize = tester.getSize(find.byType(MaterialApp));
|
||||
final Size titleSize = tester.getSize(find.byType(ColoredBox));
|
||||
final Size titleSize = tester.getSize(
|
||||
find.descendant(
|
||||
of: find.byType(ExpansionTile),
|
||||
matching: find.byType(ColoredBox)
|
||||
)
|
||||
);
|
||||
|
||||
expect(titleSize.width, materialAppSize.width - 32.0);
|
||||
});
|
||||
|
||||
@ -3017,7 +3017,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
final Offset topLeft = tester.getTopLeft(find.byType(ColoredBox));
|
||||
final Offset topLeft = tester.getTopLeft(find.byType(ColoredBox).last);
|
||||
final TestGesture gesture = await tester.createGesture(
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
|
||||
@ -128,7 +128,7 @@ void main() {
|
||||
await tester.tap(find.text('push'));
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
|
||||
final Finder coloredBoxFinder = find.byType(ColoredBox);
|
||||
final Finder coloredBoxFinder = find.byType(ColoredBox).last;
|
||||
expect(coloredBoxFinder, findsOneWidget);
|
||||
final ColoredBox coloredBox = tester.widget<ColoredBox>(coloredBoxFinder);
|
||||
expect(coloredBox.color, Colors.pink);
|
||||
@ -176,7 +176,7 @@ void main() {
|
||||
await tester.tap(find.text('push'));
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
|
||||
final Finder coloredBoxFinder = find.byType(ColoredBox);
|
||||
final Finder coloredBoxFinder = find.byType(ColoredBox).last;
|
||||
expect(coloredBoxFinder, findsOneWidget);
|
||||
final ColoredBox coloredBox = tester.widget<ColoredBox>(coloredBoxFinder);
|
||||
expect(coloredBox.color, Colors.lightGreen);
|
||||
@ -214,11 +214,13 @@ void main() {
|
||||
await tester.tap(find.text('push'));
|
||||
await tester.pump(const Duration(milliseconds: 799));
|
||||
expect(find.text('page b'), findsNothing);
|
||||
expect(find.byType(ColoredBox), findsOneWidget); // ColoredBox only exists during animation.
|
||||
ColoredBox coloredBox = tester.widget(find.byType(ColoredBox).last);
|
||||
expect(coloredBox.color, isNot(Colors.transparent)); // Color is not transparent during animation.
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 801));
|
||||
expect(find.text('page b'), findsOneWidget);
|
||||
expect(find.byType(ColoredBox), findsNothing);
|
||||
coloredBox = tester.widget(find.byType(ColoredBox).last);
|
||||
expect(coloredBox.color, Colors.transparent); // Color is transparent during animation.
|
||||
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
|
||||
|
||||
testWidgets('Animation duration changes accordingly when page transition builder changes', (WidgetTester tester) async {
|
||||
@ -269,22 +271,29 @@ void main() {
|
||||
await tester.tap(find.text('push'));
|
||||
await tester.pump(const Duration(milliseconds: 799));
|
||||
expect(find.text('page b'), findsNothing);
|
||||
expect(find.byType(ColoredBox), findsOneWidget); // ColoredBox only exists during animation.
|
||||
ColoredBox coloredBox = tester.widget(find.byType(ColoredBox).last);
|
||||
expect(coloredBox.color, isNot(Colors.transparent)); // The color is not transparent during animation.
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 801));
|
||||
expect(find.text('page b'), findsOneWidget);
|
||||
expect(find.byType(ColoredBox), findsNothing);
|
||||
coloredBox = tester.widget(find.byType(ColoredBox).last);
|
||||
expect(coloredBox.color, Colors.transparent); // The color is transparent during animation.
|
||||
|
||||
await tester.pumpWidget(buildApp(const CupertinoPageTransitionsBuilder()));
|
||||
await tester.pumpWidget(buildApp(const FadeUpwardsPageTransitionsBuilder()));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.descendant(
|
||||
of: find.byType(MaterialApp),
|
||||
matching: find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_FadeUpwardsPageTransition'),
|
||||
), findsOneWidget);
|
||||
await tester.tap(find.text('pop'));
|
||||
await tester.pump(const Duration(milliseconds: 299));
|
||||
expect(find.text('page b'), findsOneWidget);
|
||||
expect(find.byType(ColoredBox), findsNothing); // ColoredBox doesn't exist in CupertinoPageTransition.
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 301));
|
||||
expect(find.text('page b'), findsNothing);
|
||||
expect(find.text('push'), findsOneWidget); // The first page
|
||||
expect(find.byType(ColoredBox), findsNothing);
|
||||
|
||||
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user