Update CircleAvatar
& DataTable
tests for Material 3 (#135901)
Updated unit tests for `CircleAvatar` & `DataTable` to have M2 and M3 versions. More info in #127064
This commit is contained in:
parent
c899ce3edd
commit
9ab091f92b
@ -146,8 +146,8 @@ void main() {
|
||||
expect(paragraph.text.style!.color, equals(foregroundColor));
|
||||
});
|
||||
|
||||
testWidgetsWithLeakTracking('CircleAvatar default colors', (WidgetTester tester) async {
|
||||
final ThemeData theme = ThemeData(useMaterial3: true);
|
||||
testWidgetsWithLeakTracking('Material3 - CircleAvatar default colors', (WidgetTester tester) async {
|
||||
final ThemeData theme = ThemeData();
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
child: Theme(
|
||||
@ -286,7 +286,7 @@ void main() {
|
||||
// support is deprecated and the APIs are removed, these tests
|
||||
// can be deleted.
|
||||
|
||||
testWidgetsWithLeakTracking('CircleAvatar default colors with light theme', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - CircleAvatar default colors with light theme', (WidgetTester tester) async {
|
||||
final ThemeData theme = ThemeData(useMaterial3: false, primaryColor: Colors.grey.shade100);
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
@ -308,7 +308,7 @@ void main() {
|
||||
expect(paragraph.text.style!.color, equals(theme.primaryTextTheme.titleLarge!.color));
|
||||
});
|
||||
|
||||
testWidgetsWithLeakTracking('CircleAvatar default colors with dark theme', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - CircleAvatar default colors with dark theme', (WidgetTester tester) async {
|
||||
final ThemeData theme = ThemeData(useMaterial3: false, primaryColor: Colors.grey.shade800);
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
|
@ -1651,7 +1651,7 @@ void main() {
|
||||
expect(lastTableRowBoxDecoration().color, disabledColor);
|
||||
});
|
||||
|
||||
testWidgetsWithLeakTracking('DataRow renders custom colors when pressed', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Material2 - DataRow renders custom colors when pressed', (WidgetTester tester) async {
|
||||
const Color pressedColor = Color(0xff4caf50);
|
||||
Widget buildTable() {
|
||||
return DataTable(
|
||||
@ -1691,6 +1691,53 @@ void main() {
|
||||
await gesture.up();
|
||||
});
|
||||
|
||||
testWidgetsWithLeakTracking('Material3 - DataRow renders custom colors when pressed', (WidgetTester tester) async {
|
||||
const Color pressedColor = Color(0xff4caf50);
|
||||
Widget buildTable() {
|
||||
return DataTable(
|
||||
columns: const <DataColumn>[
|
||||
DataColumn(
|
||||
label: Text('Column1'),
|
||||
),
|
||||
],
|
||||
rows: <DataRow>[
|
||||
DataRow(
|
||||
color: MaterialStateProperty.resolveWith<Color>(
|
||||
(Set<MaterialState> states) {
|
||||
if (states.contains(MaterialState.pressed)) {
|
||||
return pressedColor;
|
||||
}
|
||||
return Colors.transparent;
|
||||
},
|
||||
),
|
||||
onSelectChanged: (bool? value) {},
|
||||
cells: const <DataCell>[
|
||||
DataCell(Text('Content1')),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
theme: ThemeData(),
|
||||
home: Material(child: buildTable()),
|
||||
));
|
||||
|
||||
final TestGesture gesture = await tester.startGesture(tester.getCenter(find.text('Content1')));
|
||||
await tester.pump(const Duration(milliseconds: 200)); // splash is well underway
|
||||
final RenderBox box = Material.of(tester.element(find.byType(InkWell)))as RenderBox;
|
||||
// Material 3 uses the InkSparkle which uses a shader, so we can't capture
|
||||
// the effect with paint methods.
|
||||
expect(
|
||||
box,
|
||||
paints
|
||||
..rect()
|
||||
..rect(rect: const Rect.fromLTRB(0.0, 56.0, 800.0, 104.0), color: pressedColor.withOpacity(0.0)),
|
||||
);
|
||||
await gesture.up();
|
||||
});
|
||||
|
||||
testWidgetsWithLeakTracking('DataTable can render inside an AlertDialog', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
Loading…
x
Reference in New Issue
Block a user