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
...@@ -15,7 +15,7 @@ import '../foundation/leak_tracking.dart'; ...@@ -15,7 +15,7 @@ import '../foundation/leak_tracking.dart';
import '../rendering/mock_canvas.dart'; import '../rendering/mock_canvas.dart';
void main() { void main() {
testWidgetsWithLeakTracking('shadow effect is not doubled', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - Shadow effect is not doubled', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/123064 // Regression test for https://github.com/flutter/flutter/issues/123064
debugDisableShadows = false; debugDisableShadows = false;
...@@ -41,7 +41,7 @@ void main() { ...@@ -41,7 +41,7 @@ void main() {
debugDisableShadows = true; debugDisableShadows = true;
}); });
testWidgetsWithLeakTracking('only one layer with `color` is painted', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - Only one layer with `color` is painted', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/122667 // Regression test for https://github.com/flutter/flutter/issues/122667
const Color bottomAppBarColor = Colors.black45; const Color bottomAppBarColor = Colors.black45;
...@@ -51,7 +51,6 @@ void main() { ...@@ -51,7 +51,6 @@ void main() {
home: const Scaffold( home: const Scaffold(
bottomNavigationBar: BottomAppBar( bottomNavigationBar: BottomAppBar(
color: bottomAppBarColor, color: bottomAppBarColor,
// Avoid getting a surface tint color, to keep the color check below simple // Avoid getting a surface tint color, to keep the color check below simple
elevation: 0, elevation: 0,
), ),
...@@ -80,7 +79,7 @@ void main() { ...@@ -80,7 +79,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('no overlap with floating action button', (WidgetTester tester) async { testWidgetsWithLeakTracking('No overlap with floating action button', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: Scaffold( home: Scaffold(
...@@ -111,7 +110,7 @@ void main() { ...@@ -111,7 +110,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('custom shape', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - Custom shape', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
Future<void> pump(FloatingActionButtonLocation location) async { Future<void> pump(FloatingActionButtonLocation location) async {
await tester.pumpWidget( await tester.pumpWidget(
...@@ -145,53 +144,65 @@ void main() { ...@@ -145,53 +144,65 @@ void main() {
await pump(FloatingActionButtonLocation.endDocked); await pump(FloatingActionButtonLocation.endDocked);
await expectLater( await expectLater(
find.byKey(key), find.byKey(key),
matchesGoldenFile('bottom_app_bar.custom_shape.1.png'), matchesGoldenFile('m2_bottom_app_bar.custom_shape.1.png'),
); );
await pump(FloatingActionButtonLocation.centerDocked); await pump(FloatingActionButtonLocation.centerDocked);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
await expectLater( await expectLater(
find.byKey(key), find.byKey(key),
matchesGoldenFile('bottom_app_bar.custom_shape.2.png'), matchesGoldenFile('m2_bottom_app_bar.custom_shape.2.png'),
); );
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44572 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/44572
testWidgetsWithLeakTracking('Custom Padding', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - Custom shape', (WidgetTester tester) async {
const EdgeInsets customPadding = EdgeInsets.all(10); final Key key = UniqueKey();
Future<void> pump(FloatingActionButtonLocation location) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( SizedBox(
theme: ThemeData.from(colorScheme: const ColorScheme.light()), width: 200,
home: Builder( height: 200,
builder: (BuildContext context) { child: RepaintBoundary(
return const Scaffold( key: key,
body: Align( child: MaterialApp(
alignment: Alignment.bottomCenter, theme: ThemeData(useMaterial3: true),
child: BottomAppBar( home: Scaffold(
padding: customPadding, floatingActionButton: FloatingActionButton(
child: ColoredBox( onPressed: () { },
),
floatingActionButtonLocation: location,
bottomNavigationBar: const BottomAppBar(
shape: AutomaticNotchedShape(
BeveledRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(50.0))),
ContinuousRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(30.0))),
),
notchMargin: 10.0,
color: Colors.green, color: Colors.green,
child: SizedBox(width: 300, height: 60), child: SizedBox(height: 100.0),
), ),
), ),
), ),
);
},
), ),
), ),
); );
}
await pump(FloatingActionButtonLocation.endDocked);
await expectLater(
find.byKey(key),
matchesGoldenFile('m3_bottom_app_bar.custom_shape.1.png'),
);
await pump(FloatingActionButtonLocation.centerDocked);
await tester.pumpAndSettle();
await expectLater(
find.byKey(key),
matchesGoldenFile('m3_bottom_app_bar.custom_shape.2.png'),
);
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44572
final BottomAppBar bottomAppBar = tester.widget(find.byType(BottomAppBar)); testWidgetsWithLeakTracking('Custom Padding', (WidgetTester tester) async {
expect(bottomAppBar.padding, customPadding);
final Rect babRect = tester.getRect(find.byType(BottomAppBar));
final Rect childRect = tester.getRect(find.byType(ColoredBox));
expect(childRect, const Rect.fromLTRB(250, 530, 550, 590));
expect(babRect, const Rect.fromLTRB(240, 520, 560, 600));
});
testWidgetsWithLeakTracking('Custom Padding in Material 3', (WidgetTester tester) async {
const EdgeInsets customPadding = EdgeInsets.all(10); const EdgeInsets customPadding = EdgeInsets.all(10);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: true), theme: ThemeData.from(colorScheme: const ColorScheme.light()),
home: Builder( home: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return const Scaffold( return const Scaffold(
...@@ -219,7 +230,7 @@ void main() { ...@@ -219,7 +230,7 @@ void main() {
expect(babRect, const Rect.fromLTRB(240, 520, 560, 600)); expect(babRect, const Rect.fromLTRB(240, 520, 560, 600));
}); });
testWidgetsWithLeakTracking('color defaults to Theme.bottomAppBarColor in M2', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - Color defaults to Theme.bottomAppBarColor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
...@@ -245,7 +256,7 @@ void main() { ...@@ -245,7 +256,7 @@ void main() {
expect(physicalShape.color, const Color(0xffffff00)); expect(physicalShape.color, const Color(0xffffff00));
}); });
testWidgetsWithLeakTracking('color overrides theme color', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - Color overrides theme color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
...@@ -276,11 +287,12 @@ void main() { ...@@ -276,11 +287,12 @@ void main() {
}); });
testWidgetsWithLeakTracking('color overrides theme color with Material 3', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - Color overrides theme color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData.light(useMaterial3: true).copyWith( theme: ThemeData.light(useMaterial3: true).copyWith(
bottomAppBarColor: const Color(0xffffff00)), bottomAppBarColor: const Color(0xffffff00),
),
home: Builder( home: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return const Scaffold( return const Scaffold(
...@@ -303,7 +315,7 @@ void main() { ...@@ -303,7 +315,7 @@ void main() {
expect(physicalShape.color, const Color(0xff0000ff)); expect(physicalShape.color, const Color(0xff0000ff));
}); });
testWidgetsWithLeakTracking('Shadow color is transparent in Material 3', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - Shadow color is transparent', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: true, theme: ThemeData(useMaterial3: true,
...@@ -325,7 +337,7 @@ void main() { ...@@ -325,7 +337,7 @@ void main() {
expect(physicalShape.shadowColor, Colors.transparent); expect(physicalShape.shadowColor, Colors.transparent);
}); });
testWidgetsWithLeakTracking('dark theme applies an elevation overlay color', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - Dark theme applies an elevation overlay color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData.from(useMaterial3: false, colorScheme: const ColorScheme.dark()), theme: ThemeData.from(useMaterial3: false, colorScheme: const ColorScheme.dark()),
...@@ -343,6 +355,26 @@ void main() { ...@@ -343,6 +355,26 @@ void main() {
expect(physicalShape.color, const Color(0xFF2D2D2D)); expect(physicalShape.color, const Color(0xFF2D2D2D));
}); });
testWidgetsWithLeakTracking('Material3 - Dark theme applies an elevation overlay color', (WidgetTester tester) async {
const ColorScheme colorScheme = ColorScheme.dark();
await tester.pumpWidget(
MaterialApp(
theme: ThemeData.from(useMaterial3: true, colorScheme: colorScheme),
home: Scaffold(
bottomNavigationBar: BottomAppBar(
color: colorScheme.surface,
),
),
),
);
final PhysicalShape physicalShape = tester.widget(find.byType(PhysicalShape).at(0));
const double elevation = 3.0; // Default for M3.
final Color overlayColor = ElevationOverlay.applySurfaceTint(colorScheme.surface, colorScheme.surfaceTint, elevation);
expect(physicalShape.color, overlayColor);
});
// This is a regression test for a bug we had where toggling the notch on/off // This is a regression test for a bug we had where toggling the notch on/off
// would crash, as the shouldReclip method of ShapeBorderClipper or // would crash, as the shouldReclip method of ShapeBorderClipper or
// _BottomAppBarClipper would try an illegal downcast. // _BottomAppBarClipper would try an illegal downcast.
...@@ -510,7 +542,7 @@ void main() { ...@@ -510,7 +542,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('observes safe area', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - Observes safe area', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
...@@ -535,6 +567,37 @@ void main() { ...@@ -535,6 +567,37 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material3 - Observes safe area', (WidgetTester tester) async {
const double safeAreaPadding = 50.0;
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
home: const MediaQuery(
data: MediaQueryData(
padding: EdgeInsets.all(safeAreaPadding),
),
child: Scaffold(
bottomNavigationBar: BottomAppBar(
child: Center(
child: Text('safe'),
),
),
),
),
),
);
const double appBarVerticalPadding = 12.0;
const double appBarHorizontalPadding = 16.0;
expect(
tester.getBottomLeft(find.widgetWithText(Center, 'safe')),
const Offset(
safeAreaPadding + appBarHorizontalPadding,
600 - safeAreaPadding - appBarVerticalPadding,
),
);
});
testWidgetsWithLeakTracking('clipBehavior is propagated', (WidgetTester tester) async { testWidgetsWithLeakTracking('clipBehavior is propagated', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
...@@ -569,9 +632,45 @@ void main() { ...@@ -569,9 +632,45 @@ void main() {
expect(physicalShape.clipBehavior, Clip.antiAliasWithSaveLayer); expect(physicalShape.clipBehavior, Clip.antiAliasWithSaveLayer);
}); });
testWidgetsWithLeakTracking('BottomAppBar with shape when Scaffold.bottomNavigationBar == null', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material2 - BottomAppBar with shape when Scaffold.bottomNavigationBar == null', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/80878
final ThemeData theme = ThemeData(useMaterial3: false);
await tester.pumpWidget(
MaterialApp(
theme: theme,
home: Scaffold(
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: FloatingActionButton(
backgroundColor: Colors.green,
child: const Icon(Icons.home),
onPressed: () {},
),
body: Stack(
children: <Widget>[
Container(
color: Colors.amber,
),
Container(
alignment: Alignment.bottomCenter,
child: BottomAppBar(
color: Colors.green,
shape: const CircularNotchedRectangle(),
child: Container(height: 50),
),
),
],
),
),
),
);
expect(tester.getRect(find.byType(FloatingActionButton)), const Rect.fromLTRB(372, 528, 428, 584));
expect(tester.getSize(find.byType(BottomAppBar)), const Size(800, 50));
});
testWidgetsWithLeakTracking('Material3 - BottomAppBar with shape when Scaffold.bottomNavigationBar == null', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/80878 // Regression test for https://github.com/flutter/flutter/issues/80878
final ThemeData theme = ThemeData(); final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: theme, theme: theme,
...@@ -602,7 +701,7 @@ void main() { ...@@ -602,7 +701,7 @@ void main() {
); );
expect(tester.getRect(find.byType(FloatingActionButton)), const Rect.fromLTRB(372, 528, 428, 584)); expect(tester.getRect(find.byType(FloatingActionButton)), const Rect.fromLTRB(372, 528, 428, 584));
expect(tester.getSize(find.byType(BottomAppBar)), theme.useMaterial3 ? const Size(800, 80) : const Size(800, 50)); expect(tester.getSize(find.byType(BottomAppBar)), const Size(800, 80));
}); });
testWidgetsWithLeakTracking('notch with margin and top padding, home safe area', (WidgetTester tester) async { testWidgetsWithLeakTracking('notch with margin and top padding, home safe area', (WidgetTester tester) async {
...@@ -691,7 +790,7 @@ void main() { ...@@ -691,7 +790,7 @@ void main() {
expect(physicalShape.clipper.toString(), 'ShapeBorderClipper'); expect(physicalShape.clipper.toString(), 'ShapeBorderClipper');
}); });
testWidgetsWithLeakTracking('BottomAppBar adds bottom padding to height', (WidgetTester tester) async { testWidgetsWithLeakTracking('Material3 - BottomAppBar adds bottom padding to height', (WidgetTester tester) async {
const double bottomPadding = 35.0; const double bottomPadding = 35.0;
await tester.pumpWidget( await tester.pumpWidget(
......
...@@ -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