diff --git a/examples/api/test/painting/linear_gradient.0_test.dart b/examples/api/test/painting/linear_gradient.0_test.dart index 966efcd1e2..12f0ed011f 100644 --- a/examples/api/test/painting/linear_gradient.0_test.dart +++ b/examples/api/test/painting/linear_gradient.0_test.dart @@ -21,7 +21,7 @@ void main() { testWidgets('gradient matches golden', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( - theme: ThemeData(useMaterial3: false), + theme: ThemeData(useMaterial3: true), home: const SizedBox( width: 800, height: 600, diff --git a/packages/flutter/test/cupertino/dialog_test.dart b/packages/flutter/test/cupertino/dialog_test.dart index fb906561e8..64b15d38ca 100644 --- a/packages/flutter/test/cupertino/dialog_test.dart +++ b/packages/flutter/test/cupertino/dialog_test.dart @@ -1180,7 +1180,7 @@ void main() { expect(tester.getRect(find.byType(Placeholder)), placeholderRectWithoutInsets.translate(10, 10)); }); - testWidgets('Default cupertino dialog golden', (WidgetTester tester) async { + testWidgets('Material2 - Default cupertino dialog golden', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( useMaterial3: false, @@ -1207,7 +1207,38 @@ void main() { await expectLater( find.byType(CupertinoAlertDialog), - matchesGoldenFile('dialog_test.cupertino.default.png'), + matchesGoldenFile('m2_dialog_test.cupertino.default.png'), + ); + }); + + testWidgets('Material3 - Default cupertino dialog golden', (WidgetTester tester) async { + await tester.pumpWidget( + createAppWithButtonThatLaunchesDialog( + useMaterial3: true, + dialogBuilder: (BuildContext context) { + return MediaQuery( + data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0), + child: const RepaintBoundary( + child: CupertinoAlertDialog( + title: Text('Title'), + content: Text('text'), + actions: [ + CupertinoDialogAction(child: Text('No')), + CupertinoDialogAction(child: Text('OK')), + ], + ), + ), + ); + }, + ), + ); + + await tester.tap(find.text('Go')); + await tester.pumpAndSettle(); + + await expectLater( + find.byType(CupertinoAlertDialog), + matchesGoldenFile('m3_dialog_test.cupertino.default.png'), ); }); diff --git a/packages/flutter/test/rendering/localized_fonts_test.dart b/packages/flutter/test/rendering/localized_fonts_test.dart index 79e9c7cd79..b7ff7be2c5 100644 --- a/packages/flutter/test/rendering/localized_fonts_test.dart +++ b/packages/flutter/test/rendering/localized_fonts_test.dart @@ -15,7 +15,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets( - 'RichText TextSpan styles with different locales', + 'Material2 - RichText TextSpan styles with different locales', (WidgetTester tester) async { await tester.pumpWidget( @@ -55,13 +55,59 @@ void main() { await expectLater( find.byType(RichText), - matchesGoldenFile('localized_fonts.rich_text.styled_text_span.png'), + matchesGoldenFile('m2_localized_fonts.rich_text.styled_text_span.png'), ); }, ); testWidgets( - 'Text with locale-specific glyphs, ambient locale', + 'Material3 - RichText TextSpan styles with different locales', + (WidgetTester tester) async { + + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(useMaterial3: true), + supportedLocales: const [ + Locale('en', 'US'), + Locale('ja'), + Locale('zh'), + ], + home: Builder( + builder: (BuildContext context) { + const String character = '骨'; + final TextStyle style = Theme.of(context).textTheme.displayMedium!; + return Scaffold( + body: Container( + padding: const EdgeInsets.all(48.0), + alignment: Alignment.center, + child: RepaintBoundary( + // Expected result can be seen here: + // https://user-images.githubusercontent.com/1377460/40503473-faad6f34-5f42-11e8-972b-d83b727c9d0e.png + child: RichText( + text: TextSpan( + children: [ + TextSpan(text: character, style: style.copyWith(locale: const Locale('ja'))), + TextSpan(text: character, style: style.copyWith(locale: const Locale('zh'))), + ], + ), + ), + ), + ), + ); + }, + ), + ), + ); + + await expectLater( + find.byType(RichText), + matchesGoldenFile('m3_localized_fonts.rich_text.styled_text_span.png'), + ); + }, + ); + + testWidgets( + 'Material2 - Text with locale-specific glyphs, ambient locale', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( @@ -113,7 +159,59 @@ void main() { ); testWidgets( - 'Text with locale-specific glyphs, explicit locale', + 'Material3 - Text with locale-specific glyphs, ambient locale', + (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(useMaterial3: true), + supportedLocales: const [ + Locale('en', 'US'), + Locale('ja'), + Locale('zh'), + ], + home: Builder( + builder: (BuildContext context) { + const String character = '骨'; + final TextStyle style = Theme.of(context).textTheme.displayMedium!; + return Scaffold( + body: Container( + padding: const EdgeInsets.all(48.0), + alignment: Alignment.center, + child: RepaintBoundary( + // Expected result can be seen here: + // https://user-images.githubusercontent.com/1377460/40503473-faad6f34-5f42-11e8-972b-d83b727c9d0e.png + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Localizations.override( + context: context, + locale: const Locale('ja'), + child: Text(character, style: style), + ), + Localizations.override( + context: context, + locale: const Locale('zh'), + child: Text(character, style: style), + ), + ], + ), + ), + ), + ); + }, + ), + ), + ); + + await expectLater( + find.byType(Row), + matchesGoldenFile('m3_localized_fonts.text_ambient_locale.chars.png'), + ); + }, + ); + + testWidgets( + 'Material2 - Text with locale-specific glyphs, explicit locale', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( @@ -151,9 +249,52 @@ void main() { await expectLater( find.byType(Row), - matchesGoldenFile('localized_fonts.text_explicit_locale.chars.png'), + matchesGoldenFile('m2_localized_fonts.text_explicit_locale.chars.png'), ); }, ); + testWidgets( + 'Material3 - Text with locale-specific glyphs, explicit locale', + (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(useMaterial3: true), + supportedLocales: const [ + Locale('en', 'US'), + Locale('ja'), + Locale('zh'), + ], + home: Builder( + builder: (BuildContext context) { + const String character = '骨'; + final TextStyle style = Theme.of(context).textTheme.displayMedium!; + return Scaffold( + body: Container( + padding: const EdgeInsets.all(48.0), + alignment: Alignment.center, + child: RepaintBoundary( + // Expected result can be seen here: + // https://user-images.githubusercontent.com/1377460/40503473-faad6f34-5f42-11e8-972b-d83b727c9d0e.png + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + Text(character, style: style, locale: const Locale('ja')), + Text(character, style: style, locale: const Locale('zh')), + ], + ), + ), + ), + ); + }, + ), + ), + ); + + await expectLater( + find.byType(Row), + matchesGoldenFile('m3_localized_fonts.text_explicit_locale.chars.png'), + ); + }, + ); } diff --git a/packages/flutter/test/widgets/backdrop_filter_test.dart b/packages/flutter/test/widgets/backdrop_filter_test.dart index 7cafc612e2..a112fe9e66 100644 --- a/packages/flutter/test/widgets/backdrop_filter_test.dart +++ b/packages/flutter/test/widgets/backdrop_filter_test.dart @@ -13,7 +13,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - testWidgets("BackdropFilter's cull rect does not shrink", (WidgetTester tester) async { + testWidgets("Material2 - BackdropFilter's cull rect does not shrink", (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( theme: ThemeData(useMaterial3: false), @@ -47,11 +47,49 @@ void main() { ); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('backdrop_filter_test.cull_rect.png'), + matchesGoldenFile('m2_backdrop_filter_test.cull_rect.png'), ); }); - testWidgets('BackdropFilter blendMode on saveLayer', (WidgetTester tester) async { + testWidgets("Material3 - BackdropFilter's cull rect does not shrink", (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(useMaterial3: true), + home: Scaffold( + body: Stack( + fit: StackFit.expand, + children: [ + Text('0 0 ' * 10000), + Center( + // ClipRect needed for filtering the 200x200 area instead of the + // whole screen. + child: ClipRect( + child: BackdropFilter( + filter: ImageFilter.blur( + sigmaX: 5.0, + sigmaY: 5.0, + ), + child: Container( + alignment: Alignment.center, + width: 200.0, + height: 200.0, + child: const Text('Hello World'), + ), + ), + ), + ), + ], + ), + ), + ), + ); + await expectLater( + find.byType(RepaintBoundary).first, + matchesGoldenFile('m3_backdrop_filter_test.cull_rect.png'), + ); + }); + + testWidgets('Material2 - BackdropFilter blendMode on saveLayer', (WidgetTester tester) async { await tester.pumpWidget( MaterialApp( theme: ThemeData(useMaterial3: false), @@ -106,7 +144,66 @@ void main() { ); await expectLater( find.byType(RepaintBoundary).first, - matchesGoldenFile('backdrop_filter_test.saveLayer.blendMode.png'), + matchesGoldenFile('m2_backdrop_filter_test.saveLayer.blendMode.png'), + ); + }); + + testWidgets('Material3 - BackdropFilter blendMode on saveLayer', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData(useMaterial3: true), + home: Scaffold( + body: Opacity( + opacity: 0.9, + child: Stack( + fit: StackFit.expand, + children: [ + Text('0 0 ' * 10000), + Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + // ClipRect needed for filtering the 200x200 area instead of the + // whole screen. + children: [ + ClipRect( + child: BackdropFilter( + filter: ImageFilter.blur( + sigmaX: 5.0, + sigmaY: 5.0, + ), + child: Container( + alignment: Alignment.center, + width: 200.0, + height: 200.0, + color: Colors.yellow.withAlpha(0x7), + ), + ), + ), + ClipRect( + child: BackdropFilter( + filter: ImageFilter.blur( + sigmaX: 5.0, + sigmaY: 5.0, + ), + blendMode: BlendMode.src, + child: Container( + alignment: Alignment.center, + width: 200.0, + height: 200.0, + color: Colors.yellow.withAlpha(0x7), + ), + ), + ), + ], + ), + ], + ), + ), + ), + ), + ); + await expectLater( + find.byType(RepaintBoundary).first, + matchesGoldenFile('m3_backdrop_filter_test.saveLayer.blendMode.png'), ); }); } diff --git a/packages/flutter/test/widgets/page_route_builder_test.dart b/packages/flutter/test/widgets/page_route_builder_test.dart index 9e73e10445..3e6090fa80 100644 --- a/packages/flutter/test/widgets/page_route_builder_test.dart +++ b/packages/flutter/test/widgets/page_route_builder_test.dart @@ -11,14 +11,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; class TestPage extends StatelessWidget { - const TestPage({super.key}); + const TestPage({ super.key, this.useMaterial3 }); + + final bool? useMaterial3; @override Widget build(BuildContext context) { return MaterialApp( title: 'Test', theme: ThemeData( - useMaterial3: false, + useMaterial3: useMaterial3, primarySwatch: Colors.blue, ), home: const HomePage(), @@ -91,13 +93,23 @@ class ModalPage extends StatelessWidget { } void main() { - testWidgets('Barriers show when using PageRouteBuilder', (WidgetTester tester) async { - await tester.pumpWidget(const TestPage()); + testWidgets('Material2 - Barriers show when using PageRouteBuilder', (WidgetTester tester) async { + await tester.pumpWidget(const TestPage(useMaterial3: false)); await tester.tap(find.byType(FloatingActionButton)); await tester.pumpAndSettle(); await expectLater( find.byType(TestPage), - matchesGoldenFile('page_route_builder.barrier.png'), + matchesGoldenFile('m2_page_route_builder.barrier.png'), + ); + }); + + testWidgets('Material3 - Barriers show when using PageRouteBuilder', (WidgetTester tester) async { + await tester.pumpWidget(const TestPage(useMaterial3: true)); + await tester.tap(find.byType(FloatingActionButton)); + await tester.pumpAndSettle(); + await expectLater( + find.byType(TestPage), + matchesGoldenFile('m3_page_route_builder.barrier.png'), ); }); }