Skip to content

Commit e72b471

Browse files
authored
Use Material3 in the 2D viewport tests (flutter#128155)
Set `useMaterial3: true' for the MaterialApp used in the 2D tests to enable making `useMaterial3: true' the default for ThemeData in a future PR.
1 parent d095f10 commit e72b471

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

packages/flutter/test/widgets/two_dimensional_utils.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ Widget simpleListTest({
283283
Clip? clipBehavior,
284284
}) {
285285
return MaterialApp(
286+
theme: ThemeData(useMaterial3: true),
286287
home: Scaffold(
287288
body: SimpleListTableView(
288289
mainAxis: mainAxis,

packages/flutter/test/widgets/two_dimensional_viewport_test.dart

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,27 @@ void main() {
161161
));
162162
await tester.pumpAndSettle();
163163

164+
// In the tests below the number of RepaintBoundary widgets depends on:
165+
// ModalRoute - builds 2
166+
// GlowingOverscrollIndicator - builds 2
167+
// TwoDimensionalChildListDelegate - builds 1 unless addRepaintBoundaries is false
168+
169+
void expectModalRoute() {
170+
expect(ModalRoute.of(tester.element(find.byType(SimpleListTableViewport))), isA<MaterialPageRoute<void>>());
171+
}
172+
164173
switch (defaultTargetPlatform) {
165-
case TargetPlatform.android:
166174
case TargetPlatform.fuchsia:
175+
expectModalRoute();
176+
expect(find.byType(GlowingOverscrollIndicator), findsNWidgets(2));
167177
expect(find.byType(RepaintBoundary), findsNWidgets(7));
178+
179+
case TargetPlatform.android:
168180
case TargetPlatform.iOS:
169181
case TargetPlatform.linux:
170182
case TargetPlatform.macOS:
171183
case TargetPlatform.windows:
184+
expectModalRoute();
172185
expect(find.byType(RepaintBoundary), findsNWidgets(3));
173186
}
174187

@@ -183,13 +196,17 @@ void main() {
183196
await tester.pumpAndSettle();
184197

185198
switch (defaultTargetPlatform) {
186-
case TargetPlatform.android:
187199
case TargetPlatform.fuchsia:
200+
expectModalRoute();
201+
expect(find.byType(GlowingOverscrollIndicator), findsNWidgets(2));
188202
expect(find.byType(RepaintBoundary), findsNWidgets(6));
203+
204+
case TargetPlatform.android:
189205
case TargetPlatform.iOS:
190206
case TargetPlatform.linux:
191207
case TargetPlatform.macOS:
192208
case TargetPlatform.windows:
209+
expectModalRoute();
193210
expect(find.byType(RepaintBoundary), findsNWidgets(2));
194211
}
195212
}, variant: TargetPlatformVariant.all());

0 commit comments

Comments
 (0)