Unverified Commit 26ad4a4a authored by Hans Muller's avatar Hans Muller Committed by GitHub

Updated some golden image tests for M2/M3 (#129794)

Updated some of the golden image tests that were temporarily changed in https://github.com/flutter/flutter/pull/128914 to have M2 and M3 versions. 

Updated the linear_gradient_0 example to M3 (which will require updating its golden image as well).

More info in https://github.com/flutter/flutter/issues/127064
parent 34c092f2
......@@ -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,
......
......@@ -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: <Widget>[
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'),
);
});
......
......@@ -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>[
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>[
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>[
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: <Widget>[
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>[
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: <Widget>[
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'),
);
},
);
}
......@@ -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: <Widget>[
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: <Widget>[
Text('0 0 ' * 10000),
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
// ClipRect needed for filtering the 200x200 area instead of the
// whole screen.
children: <Widget>[
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'),
);
});
}
......@@ -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('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('page_route_builder.barrier.png'),
matchesGoldenFile('m3_page_route_builder.barrier.png'),
);
});
}
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