diff --git a/packages/flutter/test/material/circle_avatar_test.dart b/packages/flutter/test/material/circle_avatar_test.dart index 8487f124cf..fde6909596 100644 --- a/packages/flutter/test/material/circle_avatar_test.dart +++ b/packages/flutter/test/material/circle_avatar_test.dart @@ -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( diff --git a/packages/flutter/test/material/data_table_test.dart b/packages/flutter/test/material/data_table_test.dart index fc738b73a6..561fede1e8 100644 --- a/packages/flutter/test/material/data_table_test.dart +++ b/packages/flutter/test/material/data_table_test.dart @@ -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( + label: Text('Column1'), + ), + ], + rows: [ + DataRow( + color: MaterialStateProperty.resolveWith( + (Set states) { + if (states.contains(MaterialState.pressed)) { + return pressedColor; + } + return Colors.transparent; + }, + ), + onSelectChanged: (bool? value) {}, + cells: const [ + 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(