Unverified Commit eb489122 authored by Bruno Leroux's avatar Bruno Leroux Committed by GitHub

Update BottomAppBar and BottomAppBarTheme tests for M3 (#130983)

This PR updates `BottomAppBar` and `BottomAppBarTheme` tests for M3 migration.

More info in https://github.com/flutter/flutter/issues/127064

- Some tests are M2 or M3 only.
- Added several M3 tests.
- One golden change.
parent 147e12d1
...@@ -20,17 +20,17 @@ void main() { ...@@ -20,17 +20,17 @@ void main() {
}); });
group('Material 2 tests', () { group('Material 2 tests', () {
testWidgetsWithLeakTracking('BAB theme overrides color', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - BAB theme overrides color', (WidgetTester tester) async {
const Color themedColor = Colors.black87; const Color themedColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme(color: themedColor); const BottomAppBarTheme theme = BottomAppBarTheme(color: themedColor);
await tester.pumpWidget(_withTheme(theme)); await tester.pumpWidget(_withTheme(theme, useMaterial3: false));
final PhysicalShape widget = _getBabRenderObject(tester); final PhysicalShape widget = _getBabRenderObject(tester);
expect(widget.color, themedColor); expect(widget.color, themedColor);
}); });
testWidgetsWithLeakTracking('BAB color - Widget', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - BAB color - Widget', (WidgetTester tester) async {
const Color themeColor = Colors.white10; const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87; const Color babThemeColor = Colors.black87;
const Color babColor = Colors.pink; const Color babColor = Colors.pink;
...@@ -49,7 +49,7 @@ void main() { ...@@ -49,7 +49,7 @@ void main() {
expect(widget.color, babColor); expect(widget.color, babColor);
}); });
testWidgetsWithLeakTracking('BAB color - BabTheme', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - BAB color - BabTheme', (WidgetTester tester) async {
const Color themeColor = Colors.white10; const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87; const Color babThemeColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme(color: babThemeColor); const BottomAppBarTheme theme = BottomAppBarTheme(color: babThemeColor);
...@@ -67,7 +67,7 @@ void main() { ...@@ -67,7 +67,7 @@ void main() {
expect(widget.color, babThemeColor); expect(widget.color, babThemeColor);
}); });
testWidgetsWithLeakTracking('BAB color - Theme', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - BAB color - Theme', (WidgetTester tester) async {
const Color themeColor = Colors.white10; const Color themeColor = Colors.white10;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
...@@ -79,7 +79,7 @@ void main() { ...@@ -79,7 +79,7 @@ void main() {
expect(widget.color, themeColor); expect(widget.color, themeColor);
}); });
testWidgetsWithLeakTracking('BAB color - Default', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - BAB color - Default', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
home: const Scaffold(body: BottomAppBar()), home: const Scaffold(body: BottomAppBar()),
...@@ -90,14 +90,14 @@ void main() { ...@@ -90,14 +90,14 @@ void main() {
expect(widget.color, Colors.white); expect(widget.color, Colors.white);
}); });
testWidgetsWithLeakTracking('BAB theme customizes shape', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - BAB theme customizes shape', (WidgetTester tester) async {
const BottomAppBarTheme theme = BottomAppBarTheme( const BottomAppBarTheme theme = BottomAppBarTheme(
color: Colors.white30, color: Colors.white30,
shape: CircularNotchedRectangle(), shape: CircularNotchedRectangle(),
elevation: 1.0, elevation: 1.0,
); );
await tester.pumpWidget(_withTheme(theme)); await tester.pumpWidget(_withTheme(theme, useMaterial3: false));
await expectLater( await expectLater(
find.byKey(_painterKey), find.byKey(_painterKey),
...@@ -105,7 +105,7 @@ void main() { ...@@ -105,7 +105,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('BAB theme does not affect defaults', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - BAB theme does not affect defaults', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
home: const Scaffold(body: BottomAppBar()), home: const Scaffold(body: BottomAppBar()),
...@@ -119,19 +119,19 @@ void main() { ...@@ -119,19 +119,19 @@ void main() {
}); });
group('Material 3 tests', () { group('Material 3 tests', () {
testWidgetsWithLeakTracking('BAB theme overrides color - M3', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - BAB theme overrides color', (WidgetTester tester) async {
const Color themedColor = Colors.black87; const Color themedColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme( const BottomAppBarTheme theme = BottomAppBarTheme(
color: themedColor, color: themedColor,
elevation: 0 elevation: 0
); );
await tester.pumpWidget(_withTheme(theme, true)); await tester.pumpWidget(_withTheme(theme, useMaterial3: true));
final PhysicalShape widget = _getBabRenderObject(tester); final PhysicalShape widget = _getBabRenderObject(tester);
expect(widget.color, themedColor); expect(widget.color, themedColor);
}); });
testWidgetsWithLeakTracking('BAB color - Widget - M3', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - BAB color - Widget', (WidgetTester tester) async {
const Color themeColor = Colors.white10; const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87; const Color babThemeColor = Colors.black87;
const Color babColor = Colors.pink; const Color babColor = Colors.pink;
...@@ -150,7 +150,7 @@ void main() { ...@@ -150,7 +150,7 @@ void main() {
expect(widget.color, babColor); expect(widget.color, babColor);
}); });
testWidgetsWithLeakTracking('BAB color - BabTheme - M3', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - BAB color - BabTheme', (WidgetTester tester) async {
const Color themeColor = Colors.white10; const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87; const Color babThemeColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme(color: babThemeColor); const BottomAppBarTheme theme = BottomAppBarTheme(color: babThemeColor);
...@@ -168,7 +168,7 @@ void main() { ...@@ -168,7 +168,7 @@ void main() {
expect(widget.color, babThemeColor); expect(widget.color, babThemeColor);
}); });
testWidgetsWithLeakTracking('BAB theme does not affect defaults - M3', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - BAB theme does not affect defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: theme, theme: theme,
...@@ -181,30 +181,30 @@ void main() { ...@@ -181,30 +181,30 @@ void main() {
expect(widget.elevation, equals(3.0)); expect(widget.elevation, equals(3.0));
}); });
testWidgetsWithLeakTracking('BAB theme overrides surfaceTintColor - M3', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - BAB theme overrides surfaceTintColor', (WidgetTester tester) async {
const Color color = Colors.blue; // base color that the surface tint will be applied to const Color color = Colors.blue; // base color that the surface tint will be applied to
const Color babThemeSurfaceTintColor = Colors.black87; const Color babThemeSurfaceTintColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme( const BottomAppBarTheme theme = BottomAppBarTheme(
color: color, surfaceTintColor: babThemeSurfaceTintColor, elevation: 0, color: color, surfaceTintColor: babThemeSurfaceTintColor, elevation: 0,
); );
await tester.pumpWidget(_withTheme(theme, true)); await tester.pumpWidget(_withTheme(theme, useMaterial3: true));
final PhysicalShape widget = _getBabRenderObject(tester); final PhysicalShape widget = _getBabRenderObject(tester);
expect(widget.color, ElevationOverlay.applySurfaceTint(color, babThemeSurfaceTintColor, 0)); expect(widget.color, ElevationOverlay.applySurfaceTint(color, babThemeSurfaceTintColor, 0));
}); });
testWidgetsWithLeakTracking('BAB theme overrides shadowColor - M3', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - BAB theme overrides shadowColor', (WidgetTester tester) async {
const Color babThemeShadowColor = Colors.yellow; const Color babThemeShadowColor = Colors.yellow;
const BottomAppBarTheme theme = BottomAppBarTheme( const BottomAppBarTheme theme = BottomAppBarTheme(
shadowColor: babThemeShadowColor, elevation: 0 shadowColor: babThemeShadowColor, elevation: 0
); );
await tester.pumpWidget(_withTheme(theme, true)); await tester.pumpWidget(_withTheme(theme, useMaterial3: true));
final PhysicalShape widget = _getBabRenderObject(tester); final PhysicalShape widget = _getBabRenderObject(tester);
expect(widget.shadowColor, babThemeShadowColor); expect(widget.shadowColor, babThemeShadowColor);
}); });
testWidgetsWithLeakTracking('BAB surfaceTintColor - Widget - M3', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - BAB surfaceTintColor - Widget', (WidgetTester tester) async {
const Color color = Colors.white10; // base color that the surface tint will be applied to const Color color = Colors.white10; // base color that the surface tint will be applied to
const Color themeSurfaceTintColor = Colors.white10; const Color themeSurfaceTintColor = Colors.white10;
const Color babThemeSurfaceTintColor = Colors.black87; const Color babThemeSurfaceTintColor = Colors.black87;
...@@ -227,7 +227,7 @@ void main() { ...@@ -227,7 +227,7 @@ void main() {
expect(widget.color, ElevationOverlay.applySurfaceTint(color, babSurfaceTintColor, 3.0)); expect(widget.color, ElevationOverlay.applySurfaceTint(color, babSurfaceTintColor, 3.0));
}); });
testWidgetsWithLeakTracking('BAB surfaceTintColor - BabTheme - M3', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - BAB surfaceTintColor - BabTheme', (WidgetTester tester) async {
const Color color = Colors.blue; // base color that the surface tint will be applied to const Color color = Colors.blue; // base color that the surface tint will be applied to
const Color themeColor = Colors.white10; const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87; const Color babThemeColor = Colors.black87;
...@@ -261,7 +261,7 @@ PhysicalShape _getBabRenderObject(WidgetTester tester) { ...@@ -261,7 +261,7 @@ PhysicalShape _getBabRenderObject(WidgetTester tester) {
final Key _painterKey = UniqueKey(); final Key _painterKey = UniqueKey();
Widget _withTheme(BottomAppBarTheme theme, [bool useMaterial3 = false]) { Widget _withTheme(BottomAppBarTheme theme, {required bool useMaterial3}) {
return MaterialApp( return MaterialApp(
theme: ThemeData(useMaterial3: useMaterial3, bottomAppBarTheme: theme), theme: ThemeData(useMaterial3: useMaterial3, bottomAppBarTheme: theme),
home: Scaffold( home: Scaffold(
......
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