Skip to content

Commit

Permalink
Update golden tests for material (#128839)
Browse files Browse the repository at this point in the history
  • Loading branch information
QuncCccccc authored Jun 14, 2023
1 parent ed3d463 commit 7d95086
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 37 deletions.
11 changes: 6 additions & 5 deletions packages/flutter/lib/src/material/snack_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -842,11 +842,12 @@ class _SnackbarDefaultsM2 extends SnackBarThemeData {

@override
TextStyle? get contentTextStyle => ThemeData(
brightness: _theme.brightness == Brightness.light
? Brightness.dark
: Brightness.light)
.textTheme
.titleMedium;
useMaterial3: _theme.useMaterial3,
brightness: _theme.brightness == Brightness.light
? Brightness.dark
: Brightness.light)
.textTheme
.titleMedium;

@override
SnackBarBehavior get behavior => SnackBarBehavior.fixed;
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/material/dropdown_menu_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void main() {
testWidgets('The width of the text field should always be the same as the menu view',
(WidgetTester tester) async {

final ThemeData themeData = ThemeData();
final ThemeData themeData = ThemeData(useMaterial3: false);
final bool useMaterial3 = themeData.useMaterial3;
await tester.pumpWidget(
MaterialApp(
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/material/icon_button_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ void main() {

await tester.pumpWidget(
wrap(
useMaterial3: theme.useMaterial3,
useMaterial3: false,
child: Column(
children: <Widget>[
IconButton(
Expand Down
1 change: 1 addition & 0 deletions packages/flutter/test/material/ink_sparkle_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ Future<void> _runTest(WidgetTester tester, String positionName, double distanceF
final Key buttonKey = UniqueKey();

await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold(
body: Center(
child: RepaintBoundary(
Expand Down
2 changes: 2 additions & 0 deletions packages/flutter/test/material/input_decorator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4488,6 +4488,7 @@ void main() {
// This is a regression test for https://github.com/flutter/flutter/issues/82321
Widget buildFrame(TextDirection textDirection) {
return MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold(
body: Container(
padding: const EdgeInsets.all(16.0),
Expand Down Expand Up @@ -4536,6 +4537,7 @@ void main() {

Widget buildFrame(TextDirection textDirection) {
return MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold(
body: Container(
padding: const EdgeInsets.all(16.0),
Expand Down
2 changes: 2 additions & 0 deletions packages/flutter/test/material/material_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ void main() {
final Key painterKey = UniqueKey();

await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold(
body: RepaintBoundary(
key: painterKey,
Expand Down Expand Up @@ -962,6 +963,7 @@ void main() {
final Key painterKey = UniqueKey();

await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold(
body: RepaintBoundary(
key: painterKey,
Expand Down
1 change: 1 addition & 0 deletions packages/flutter/test/material/page_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ void main() {
RepaintBoundary(
key: key,
child: MaterialApp(
theme: ThemeData(useMaterial3: false),
onGenerateRoute: (RouteSettings settings) {
return MaterialPageRoute<void>(
builder: (BuildContext context) {
Expand Down
18 changes: 12 additions & 6 deletions packages/flutter/test/material/progress_indicator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,10 @@ void main() {
final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(50, 50));

await tester.pumpFrames(animationSheet.record(
const _RefreshProgressIndicatorGolden(),
Theme(
data: ThemeData(useMaterial3: false),
child: const _RefreshProgressIndicatorGolden()
),
), const Duration(seconds: 3));

await expectLater(
Expand Down Expand Up @@ -1001,11 +1004,14 @@ void main() {
final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(40, 40));

await tester.pumpFrames(animationSheet.record(
const Directionality(
textDirection: TextDirection.ltr,
child: Padding(
padding: EdgeInsets.all(4),
child: CircularProgressIndicator(),
Theme(
data: ThemeData(useMaterial3: false),
child: const Directionality(
textDirection: TextDirection.ltr,
child: Padding(
padding: EdgeInsets.all(4),
child: CircularProgressIndicator(),
),
),
),
), const Duration(seconds: 2));
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/test/material/radio_list_tile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,7 @@ void main() {
return null;
}

final ThemeData theme = ThemeData();
final ThemeData theme = ThemeData(useMaterial3: false);
final bool material3 = theme.useMaterial3;
Widget buildRadio({bool active = false, bool useOverlay = true}) {
return wrap(
Expand Down
41 changes: 25 additions & 16 deletions packages/flutter/test/material/snack_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2155,8 +2155,9 @@ void main() {
});

testWidgets('SnackBars should be shown above the bottomSheet', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(
home: Scaffold(
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox(
width: 200,
height: 50,
Expand Down Expand Up @@ -2238,6 +2239,7 @@ void main() {

testWidgets('ScaffoldMessenger presents SnackBars to only the root Scaffold when Scaffolds are nested.', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold(
body: const Scaffold(),
floatingActionButton: FloatingActionButton(onPressed: () {}),
Expand Down Expand Up @@ -2439,6 +2441,7 @@ void main() {
testWidgets('Snackbar by default clips BackdropFilter', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/98205
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold(
body: const Scaffold(),
floatingActionButton: FloatingActionButton(onPressed: () {}),
Expand Down Expand Up @@ -2469,8 +2472,9 @@ void main() {
});

testWidgets('Floating snackbar can display optional icon', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(
home: Scaffold(
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox(
width: 200,
height: 50,
Expand Down Expand Up @@ -2500,8 +2504,9 @@ void main() {
});

testWidgets('Fixed width snackbar can display optional icon', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(
home: Scaffold(
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox(
width: 200,
height: 50,
Expand All @@ -2526,8 +2531,9 @@ void main() {
});

testWidgets('Fixed snackbar can display optional icon without action', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(
home: Scaffold(
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox(
width: 200,
height: 50,
Expand All @@ -2554,8 +2560,9 @@ void main() {

testWidgets(
'Floating width snackbar can display optional icon without action', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(
home: Scaffold(
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox(
width: 200,
height: 50,
Expand All @@ -2580,8 +2587,9 @@ void main() {
});

testWidgets('Floating multi-line snackbar with icon is aligned correctly', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(
home: Scaffold(
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox(
width: 200,
height: 50,
Expand All @@ -2607,8 +2615,9 @@ void main() {
});

testWidgets('Floating multi-line snackbar with icon and actionOverflowThreshold=1 is aligned correctly', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(
home: Scaffold(
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox(
width: 200,
height: 50,
Expand All @@ -2627,10 +2636,10 @@ void main() {
behavior: SnackBarBehavior.floating,
actionOverflowThreshold: 1,
));
await tester.pumpAndSettle(); // Have the SnackBar fully animate out.
await tester.pumpAndSettle(); // Have the SnackBar fully animate in.

await expectLater(find.byType(MaterialApp),
matchesGoldenFile('snack_bar.goldenTest.multiLineWithIconWithZeroActionOverflowThreshold.png'));
matchesGoldenFile('snack_bar.goldenTest.multiLineWithIconWithZeroActionOverflowThreshold.png'));
});

testWidgets(
Expand Down
19 changes: 12 additions & 7 deletions packages/flutter/test/material/text_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -918,13 +918,16 @@ void main() {
});

testWidgets('Material cursor golden', (WidgetTester tester) async {
final Widget widget = overlay(
child: const RepaintBoundary(
key: ValueKey<int>(1),
child: TextField(
cursorColor: Colors.blue,
cursorWidth: 15,
cursorRadius: Radius.circular(3.0),
final Widget widget = Theme(
data: ThemeData(useMaterial3: false),
child: overlay(
child: const RepaintBoundary(
key: ValueKey<int>(1),
child: TextField(
cursorColor: Colors.blue,
cursorWidth: 15,
cursorRadius: Radius.circular(3.0),
),
),
),
);
Expand Down Expand Up @@ -1095,6 +1098,7 @@ void main() {
);
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Material(
child: Center(
child: RepaintBoundary(
Expand Down Expand Up @@ -1143,6 +1147,7 @@ void main() {
);
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Material(
child: Center(
child: RepaintBoundary(
Expand Down

0 comments on commit 7d95086

Please sign in to comment.