From e72b4717bfa6d3a975b3ccfdb2963191ff3ea654 Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Tue, 6 Jun 2023 09:28:31 -0700 Subject: [PATCH] Use Material3 in the 2D viewport tests (#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. --- .../test/widgets/two_dimensional_utils.dart | 1 + .../two_dimensional_viewport_test.dart | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/flutter/test/widgets/two_dimensional_utils.dart b/packages/flutter/test/widgets/two_dimensional_utils.dart index f510de5ed59..f9da5abf350 100644 --- a/packages/flutter/test/widgets/two_dimensional_utils.dart +++ b/packages/flutter/test/widgets/two_dimensional_utils.dart @@ -283,6 +283,7 @@ Widget simpleListTest({ Clip? clipBehavior, }) { return MaterialApp( + theme: ThemeData(useMaterial3: true), home: Scaffold( body: SimpleListTableView( mainAxis: mainAxis, diff --git a/packages/flutter/test/widgets/two_dimensional_viewport_test.dart b/packages/flutter/test/widgets/two_dimensional_viewport_test.dart index fa9c9072e64..01c05c92903 100644 --- a/packages/flutter/test/widgets/two_dimensional_viewport_test.dart +++ b/packages/flutter/test/widgets/two_dimensional_viewport_test.dart @@ -161,14 +161,27 @@ void main() { )); await tester.pumpAndSettle(); + // In the tests below the number of RepaintBoundary widgets depends on: + // ModalRoute - builds 2 + // GlowingOverscrollIndicator - builds 2 + // TwoDimensionalChildListDelegate - builds 1 unless addRepaintBoundaries is false + + void expectModalRoute() { + expect(ModalRoute.of(tester.element(find.byType(SimpleListTableViewport))), isA>()); + } + switch (defaultTargetPlatform) { - case TargetPlatform.android: case TargetPlatform.fuchsia: + expectModalRoute(); + expect(find.byType(GlowingOverscrollIndicator), findsNWidgets(2)); expect(find.byType(RepaintBoundary), findsNWidgets(7)); + + case TargetPlatform.android: case TargetPlatform.iOS: case TargetPlatform.linux: case TargetPlatform.macOS: case TargetPlatform.windows: + expectModalRoute(); expect(find.byType(RepaintBoundary), findsNWidgets(3)); } @@ -183,13 +196,17 @@ void main() { await tester.pumpAndSettle(); switch (defaultTargetPlatform) { - case TargetPlatform.android: case TargetPlatform.fuchsia: + expectModalRoute(); + expect(find.byType(GlowingOverscrollIndicator), findsNWidgets(2)); expect(find.byType(RepaintBoundary), findsNWidgets(6)); + + case TargetPlatform.android: case TargetPlatform.iOS: case TargetPlatform.linux: case TargetPlatform.macOS: case TargetPlatform.windows: + expectModalRoute(); expect(find.byType(RepaintBoundary), findsNWidgets(2)); } }, variant: TargetPlatformVariant.all());