Unverified Commit 7d950864 authored by Qun Cheng's avatar Qun Cheng Committed by GitHub

Update golden tests for material (#128839)

parent ed3d4630
...@@ -842,11 +842,12 @@ class _SnackbarDefaultsM2 extends SnackBarThemeData { ...@@ -842,11 +842,12 @@ class _SnackbarDefaultsM2 extends SnackBarThemeData {
@override @override
TextStyle? get contentTextStyle => ThemeData( TextStyle? get contentTextStyle => ThemeData(
brightness: _theme.brightness == Brightness.light useMaterial3: _theme.useMaterial3,
? Brightness.dark brightness: _theme.brightness == Brightness.light
: Brightness.light) ? Brightness.dark
.textTheme : Brightness.light)
.titleMedium; .textTheme
.titleMedium;
@override @override
SnackBarBehavior get behavior => SnackBarBehavior.fixed; SnackBarBehavior get behavior => SnackBarBehavior.fixed;
......
...@@ -112,7 +112,7 @@ void main() { ...@@ -112,7 +112,7 @@ void main() {
testWidgets('The width of the text field should always be the same as the menu view', testWidgets('The width of the text field should always be the same as the menu view',
(WidgetTester tester) async { (WidgetTester tester) async {
final ThemeData themeData = ThemeData(); final ThemeData themeData = ThemeData(useMaterial3: false);
final bool useMaterial3 = themeData.useMaterial3; final bool useMaterial3 = themeData.useMaterial3;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
......
...@@ -789,7 +789,7 @@ void main() { ...@@ -789,7 +789,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
useMaterial3: theme.useMaterial3, useMaterial3: false,
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
IconButton( IconButton(
......
...@@ -116,6 +116,7 @@ Future<void> _runTest(WidgetTester tester, String positionName, double distanceF ...@@ -116,6 +116,7 @@ Future<void> _runTest(WidgetTester tester, String positionName, double distanceF
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold( home: Scaffold(
body: Center( body: Center(
child: RepaintBoundary( child: RepaintBoundary(
......
...@@ -4488,6 +4488,7 @@ void main() { ...@@ -4488,6 +4488,7 @@ void main() {
// This is a regression test for https://github.com/flutter/flutter/issues/82321 // This is a regression test for https://github.com/flutter/flutter/issues/82321
Widget buildFrame(TextDirection textDirection) { Widget buildFrame(TextDirection textDirection) {
return MaterialApp( return MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold( home: Scaffold(
body: Container( body: Container(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
...@@ -4536,6 +4537,7 @@ void main() { ...@@ -4536,6 +4537,7 @@ void main() {
Widget buildFrame(TextDirection textDirection) { Widget buildFrame(TextDirection textDirection) {
return MaterialApp( return MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold( home: Scaffold(
body: Container( body: Container(
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
......
...@@ -924,6 +924,7 @@ void main() { ...@@ -924,6 +924,7 @@ void main() {
final Key painterKey = UniqueKey(); final Key painterKey = UniqueKey();
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold( home: Scaffold(
body: RepaintBoundary( body: RepaintBoundary(
key: painterKey, key: painterKey,
...@@ -962,6 +963,7 @@ void main() { ...@@ -962,6 +963,7 @@ void main() {
final Key painterKey = UniqueKey(); final Key painterKey = UniqueKey();
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold( home: Scaffold(
body: RepaintBoundary( body: RepaintBoundary(
key: painterKey, key: painterKey,
......
...@@ -252,6 +252,7 @@ void main() { ...@@ -252,6 +252,7 @@ void main() {
RepaintBoundary( RepaintBoundary(
key: key, key: key,
child: MaterialApp( child: MaterialApp(
theme: ThemeData(useMaterial3: false),
onGenerateRoute: (RouteSettings settings) { onGenerateRoute: (RouteSettings settings) {
return MaterialPageRoute<void>( return MaterialPageRoute<void>(
builder: (BuildContext context) { builder: (BuildContext context) {
......
...@@ -723,7 +723,10 @@ void main() { ...@@ -723,7 +723,10 @@ void main() {
final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(50, 50)); final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(50, 50));
await tester.pumpFrames(animationSheet.record( await tester.pumpFrames(animationSheet.record(
const _RefreshProgressIndicatorGolden(), Theme(
data: ThemeData(useMaterial3: false),
child: const _RefreshProgressIndicatorGolden()
),
), const Duration(seconds: 3)); ), const Duration(seconds: 3));
await expectLater( await expectLater(
...@@ -1001,11 +1004,14 @@ void main() { ...@@ -1001,11 +1004,14 @@ void main() {
final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(40, 40)); final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(40, 40));
await tester.pumpFrames(animationSheet.record( await tester.pumpFrames(animationSheet.record(
const Directionality( Theme(
textDirection: TextDirection.ltr, data: ThemeData(useMaterial3: false),
child: Padding( child: const Directionality(
padding: EdgeInsets.all(4), textDirection: TextDirection.ltr,
child: CircularProgressIndicator(), child: Padding(
padding: EdgeInsets.all(4),
child: CircularProgressIndicator(),
),
), ),
), ),
), const Duration(seconds: 2)); ), const Duration(seconds: 2));
......
...@@ -1101,7 +1101,7 @@ void main() { ...@@ -1101,7 +1101,7 @@ void main() {
return null; return null;
} }
final ThemeData theme = ThemeData(); final ThemeData theme = ThemeData(useMaterial3: false);
final bool material3 = theme.useMaterial3; final bool material3 = theme.useMaterial3;
Widget buildRadio({bool active = false, bool useOverlay = true}) { Widget buildRadio({bool active = false, bool useOverlay = true}) {
return wrap( return wrap(
......
...@@ -2155,8 +2155,9 @@ void main() { ...@@ -2155,8 +2155,9 @@ void main() {
}); });
testWidgets('SnackBars should be shown above the bottomSheet', (WidgetTester tester) async { testWidgets('SnackBars should be shown above the bottomSheet', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox( bottomSheet: SizedBox(
width: 200, width: 200,
height: 50, height: 50,
...@@ -2238,6 +2239,7 @@ void main() { ...@@ -2238,6 +2239,7 @@ void main() {
testWidgets('ScaffoldMessenger presents SnackBars to only the root Scaffold when Scaffolds are nested.', (WidgetTester tester) async { testWidgets('ScaffoldMessenger presents SnackBars to only the root Scaffold when Scaffolds are nested.', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold( home: Scaffold(
body: const Scaffold(), body: const Scaffold(),
floatingActionButton: FloatingActionButton(onPressed: () {}), floatingActionButton: FloatingActionButton(onPressed: () {}),
...@@ -2439,6 +2441,7 @@ void main() { ...@@ -2439,6 +2441,7 @@ void main() {
testWidgets('Snackbar by default clips BackdropFilter', (WidgetTester tester) async { testWidgets('Snackbar by default clips BackdropFilter', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/98205 // Regression test for https://github.com/flutter/flutter/issues/98205
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold( home: Scaffold(
body: const Scaffold(), body: const Scaffold(),
floatingActionButton: FloatingActionButton(onPressed: () {}), floatingActionButton: FloatingActionButton(onPressed: () {}),
...@@ -2469,8 +2472,9 @@ void main() { ...@@ -2469,8 +2472,9 @@ void main() {
}); });
testWidgets('Floating snackbar can display optional icon', (WidgetTester tester) async { testWidgets('Floating snackbar can display optional icon', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox( bottomSheet: SizedBox(
width: 200, width: 200,
height: 50, height: 50,
...@@ -2500,8 +2504,9 @@ void main() { ...@@ -2500,8 +2504,9 @@ void main() {
}); });
testWidgets('Fixed width snackbar can display optional icon', (WidgetTester tester) async { testWidgets('Fixed width snackbar can display optional icon', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox( bottomSheet: SizedBox(
width: 200, width: 200,
height: 50, height: 50,
...@@ -2526,8 +2531,9 @@ void main() { ...@@ -2526,8 +2531,9 @@ void main() {
}); });
testWidgets('Fixed snackbar can display optional icon without action', (WidgetTester tester) async { testWidgets('Fixed snackbar can display optional icon without action', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox( bottomSheet: SizedBox(
width: 200, width: 200,
height: 50, height: 50,
...@@ -2554,8 +2560,9 @@ void main() { ...@@ -2554,8 +2560,9 @@ void main() {
testWidgets( testWidgets(
'Floating width snackbar can display optional icon without action', (WidgetTester tester) async { 'Floating width snackbar can display optional icon without action', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox( bottomSheet: SizedBox(
width: 200, width: 200,
height: 50, height: 50,
...@@ -2580,8 +2587,9 @@ void main() { ...@@ -2580,8 +2587,9 @@ void main() {
}); });
testWidgets('Floating multi-line snackbar with icon is aligned correctly', (WidgetTester tester) async { testWidgets('Floating multi-line snackbar with icon is aligned correctly', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox( bottomSheet: SizedBox(
width: 200, width: 200,
height: 50, height: 50,
...@@ -2607,8 +2615,9 @@ void main() { ...@@ -2607,8 +2615,9 @@ void main() {
}); });
testWidgets('Floating multi-line snackbar with icon and actionOverflowThreshold=1 is aligned correctly', (WidgetTester tester) async { testWidgets('Floating multi-line snackbar with icon and actionOverflowThreshold=1 is aligned correctly', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( theme: ThemeData(useMaterial3: false),
home: const Scaffold(
bottomSheet: SizedBox( bottomSheet: SizedBox(
width: 200, width: 200,
height: 50, height: 50,
...@@ -2627,10 +2636,10 @@ void main() { ...@@ -2627,10 +2636,10 @@ void main() {
behavior: SnackBarBehavior.floating, behavior: SnackBarBehavior.floating,
actionOverflowThreshold: 1, 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), await expectLater(find.byType(MaterialApp),
matchesGoldenFile('snack_bar.goldenTest.multiLineWithIconWithZeroActionOverflowThreshold.png')); matchesGoldenFile('snack_bar.goldenTest.multiLineWithIconWithZeroActionOverflowThreshold.png'));
}); });
testWidgets( testWidgets(
......
...@@ -918,13 +918,16 @@ void main() { ...@@ -918,13 +918,16 @@ void main() {
}); });
testWidgets('Material cursor golden', (WidgetTester tester) async { testWidgets('Material cursor golden', (WidgetTester tester) async {
final Widget widget = overlay( final Widget widget = Theme(
child: const RepaintBoundary( data: ThemeData(useMaterial3: false),
key: ValueKey<int>(1), child: overlay(
child: TextField( child: const RepaintBoundary(
cursorColor: Colors.blue, key: ValueKey<int>(1),
cursorWidth: 15, child: TextField(
cursorRadius: Radius.circular(3.0), cursorColor: Colors.blue,
cursorWidth: 15,
cursorRadius: Radius.circular(3.0),
),
), ),
), ),
); );
...@@ -1095,6 +1098,7 @@ void main() { ...@@ -1095,6 +1098,7 @@ void main() {
); );
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Material( home: Material(
child: Center( child: Center(
child: RepaintBoundary( child: RepaintBoundary(
...@@ -1143,6 +1147,7 @@ void main() { ...@@ -1143,6 +1147,7 @@ void main() {
); );
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Material( home: Material(
child: Center( child: Center(
child: RepaintBoundary( child: RepaintBoundary(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment