Skip to content

Commit

Permalink
Make pumpWidget's arguments named (#141728)
Browse files Browse the repository at this point in the history
Much nicer calling API and simplifies evolving this API in the future.

I wish we could write a dart fix for this, but that's blocked on dart-lang/sdk#54668.
  • Loading branch information
goderbauer authored Jan 19, 2024
1 parent 9e024fd commit cc54416
Show file tree
Hide file tree
Showing 20 changed files with 80 additions and 97 deletions.
10 changes: 5 additions & 5 deletions packages/flutter/test/cupertino/segmented_control_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ void main() {
);
},
),
const Duration(milliseconds: 40),
duration: const Duration(milliseconds: 40),
);
expect(getBackgroundColor(tester, 0), const Color(0xff3d9aff));
expect(getBackgroundColor(tester, 1), const Color(0x64007aff));
Expand All @@ -1127,7 +1127,7 @@ void main() {
);
},
),
const Duration(milliseconds: 40),
duration: const Duration(milliseconds: 40),
);
expect(getBackgroundColor(tester, 0), const Color(0xff7bbaff));
expect(getBackgroundColor(tester, 1), const Color(0x95007aff));
Expand All @@ -1148,7 +1148,7 @@ void main() {
);
},
),
const Duration(milliseconds: 40),
duration: const Duration(milliseconds: 40),
);
expect(getBackgroundColor(tester, 0), const Color(0xffb9daff));
expect(getBackgroundColor(tester, 1), const Color(0xc7007aff));
Expand All @@ -1169,7 +1169,7 @@ void main() {
);
},
),
const Duration(milliseconds: 40),
duration: const Duration(milliseconds: 40),
);
expect(getBackgroundColor(tester, 0), const Color(0xfff7faff));
expect(getBackgroundColor(tester, 1), const Color(0xf8007aff));
Expand All @@ -1190,7 +1190,7 @@ void main() {
);
},
),
const Duration(milliseconds: 40),
duration: const Duration(milliseconds: 40),
);
expect(getBackgroundColor(tester, 0), isSameColorAs(CupertinoColors.white));
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/test/material/button_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,8 @@ void main() {
testWidgets('_RenderButtonBarRow.constraints does not work before layout', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(home: ButtonBar()),
Duration.zero,
EnginePhase.build,
duration: Duration.zero,
phase: EnginePhase.build,
);

final Finder buttonBar = find.byWidgetPredicate((Widget w) => '${w.runtimeType}' == '_ButtonBarRow');
Expand Down
3 changes: 1 addition & 2 deletions packages/flutter/test/material/input_decorator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6570,8 +6570,7 @@ testWidgets('OutlineInputBorder with BorderRadius.zero should draw a rectangular
),
),
),
null,
EnginePhase.layout,
phase: EnginePhase.layout,
);
} finally {
FlutterError.onError = oldHandler;
Expand Down
3 changes: 1 addition & 2 deletions packages/flutter/test/material/scaffold_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,7 @@ void main() {

await tester.pumpWidget(
buildFrame(const EdgeInsets.only(bottom: 400)),
null,
EnginePhase.build,
phase: EnginePhase.build,
);

expect(renderBox.debugNeedsLayout, true);
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/material/tabs_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void main() {
indicatorPadding: indicatorPadding + const EdgeInsets.all(7.0),
),
),
), Duration.zero, EnginePhase.build);
), duration: Duration.zero, phase: EnginePhase.build);

expect(tester.renderObject(find.byType(CustomPaint)).debugNeedsPaint, true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Foo extends SingleChildRenderObjectWidget {

void main() {
testWidgets('Stack parsing in non-normalized constraints error', (WidgetTester tester) async {
await tester.pumpWidget(const Foo(child: Placeholder()), Duration.zero, EnginePhase.layout);
await tester.pumpWidget(const Foo(child: Placeholder()), duration: Duration.zero, phase: EnginePhase.layout);
final Object? exception = tester.takeException();
final String text = exception.toString();
expect(text, contains('BoxConstraints has non-normalized width constraints.'));
Expand Down
6 changes: 2 additions & 4 deletions packages/flutter/test/semantics/semantics_update_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ void main() {
await tester.pumpWidget(
const Placeholder(),
// Stops right after the warm up frame.
null,
EnginePhase.build,
phase: EnginePhase.build,
);
// The warm up frame will send update for an empty semantics tree. We
// ignore this one time update.
Expand Down Expand Up @@ -91,8 +90,7 @@ void main() {
await tester.pumpWidget(
const Placeholder(),
// Stops right after the warm up frame.
null,
EnginePhase.build,
phase: EnginePhase.build,
);
// The warm up frame will send update for an empty semantics tree. We
// ignore this one time update.
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/widgets/animated_size_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ void main() {
),
),
),
duration,
duration: duration,
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/widgets/async_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void main() {
await tester.pumpWidget(FutureBuilder<String>(
future: completer.future,
builder: snapshotText,
), const Duration(seconds: 1));
), duration: const Duration(seconds: 1));
completer.completeError('bad');
}, (Object error, StackTrace stack) {
expectSync(error, equals('bad'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ void main() {
),
],
),
), null, EnginePhase.build);
), phase: EnginePhase.build);
expect(tester.takeException(), isAssertionError);
});

Expand Down
8 changes: 4 additions & 4 deletions packages/flutter/test/widgets/flex_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ void main() {
Column(),
],
),
Duration.zero,
EnginePhase.layout,
duration: Duration.zero,
phase: EnginePhase.layout,
);

// Turn off intrinsics checking, which also fails with the same exception.
Expand All @@ -125,8 +125,8 @@ void main() {
),
],
),
Duration.zero,
EnginePhase.layout,
duration: Duration.zero,
phase: EnginePhase.layout,
);
debugCheckIntrinsicSizes = true;
final String message = tester.takeException().toString();
Expand Down
4 changes: 1 addition & 3 deletions packages/flutter/test/widgets/image_resolution_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ RenderImage getRenderImage(WidgetTester tester, Key key) {
}

Future<void> pumpTreeToLayout(WidgetTester tester, Widget widget) {
const Duration pumpDuration = Duration.zero;
const EnginePhase pumpPhase = EnginePhase.layout;
return tester.pumpWidget(widget, pumpDuration, pumpPhase);
return tester.pumpWidget(widget, duration: Duration.zero, phase: EnginePhase.layout);
}

void main() {
Expand Down
72 changes: 36 additions & 36 deletions packages/flutter/test/widgets/image_rtl_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(Container), paints
..clipRect(rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 50.0))
Expand Down Expand Up @@ -95,8 +95,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(Container), paints
..clipRect(rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 50.0))
Expand Down Expand Up @@ -130,8 +130,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(Container), paints
..clipRect(rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 50.0))
Expand Down Expand Up @@ -165,8 +165,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(Container), paints
..clipRect(rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 50.0))
Expand Down Expand Up @@ -200,8 +200,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(Container), paints
..translate(x: 50.0, y: 0.0)
Expand Down Expand Up @@ -231,8 +231,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(Container), paints
..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)),
Expand All @@ -259,8 +259,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(Container), paints
..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)),
Expand All @@ -287,8 +287,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(Container), paints
..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)),
Expand All @@ -314,8 +314,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(SizedBox), paints
..clipRect(rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 50.0))
Expand Down Expand Up @@ -351,8 +351,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(SizedBox), paints
..clipRect(rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 50.0))
Expand Down Expand Up @@ -384,8 +384,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(SizedBox), paints
..clipRect(rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 50.0))
Expand Down Expand Up @@ -417,8 +417,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(SizedBox), paints
..clipRect(rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 50.0))
Expand Down Expand Up @@ -477,8 +477,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(SizedBox), paints
..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)),
Expand All @@ -503,8 +503,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(SizedBox), paints
..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)),
Expand All @@ -529,8 +529,8 @@ void main() {
),
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
expect(find.byType(SizedBox), paints
..drawImageRect(source: const Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: const Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)),
Expand All @@ -548,8 +548,8 @@ void main() {
alignment: Alignment.centerRight,
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
await tester.pumpWidget(
Directionality(
Expand All @@ -560,8 +560,8 @@ void main() {
matchTextDirection: true,
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
await tester.pumpWidget(
Directionality(
Expand All @@ -571,8 +571,8 @@ void main() {
alignment: Alignment.centerRight,
),
),
Duration.zero,
EnginePhase.layout, // so that we don't try to paint the fake images
duration: Duration.zero,
phase: EnginePhase.layout, // so that we don't try to paint the fake images
);
});
}
Loading

0 comments on commit cc54416

Please sign in to comment.