Unverified Commit b703f75f authored by Hans Muller's avatar Hans Muller Committed by GitHub

Updated chip_test.dart tests for M3 (#129570)

Updated the chip tests per the changes from https://github.com/flutter/flutter/pull/128584 so that Chip tests that depend on Material2 will continue to pass when Material3 becomes the default. 

Part of: https://github.com/flutter/flutter/issues/127064
parent 02c0abbb
...@@ -143,9 +143,11 @@ Widget chipWithOptionalDeleteButton({ ...@@ -143,9 +143,11 @@ Widget chipWithOptionalDeleteButton({
String? chipTooltip, String? chipTooltip,
String? deleteButtonTooltipMessage, String? deleteButtonTooltipMessage,
VoidCallback? onPressed = doNothing, VoidCallback? onPressed = doNothing,
bool? useMaterial3,
}) { }) {
return wrapForChip( return wrapForChip(
textDirection: textDirection, textDirection: textDirection,
useMaterial3: useMaterial3,
child: Wrap( child: Wrap(
children: <Widget>[ children: <Widget>[
RawChip( RawChip(
...@@ -580,6 +582,7 @@ void main() { ...@@ -580,6 +582,7 @@ void main() {
const TextStyle style = TextStyle(fontSize: 10.0); const TextStyle style = TextStyle(fontSize: 10.0);
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
useMaterial3: false,
child: const Row( child: const Row(
children: <Widget>[ children: <Widget>[
Chip(label: Text('Test'), labelStyle: style), Chip(label: Text('Test'), labelStyle: style),
...@@ -616,6 +619,7 @@ void main() { ...@@ -616,6 +619,7 @@ void main() {
testWidgets('Chip responds to materialTapTargetSize', (WidgetTester tester) async { testWidgets('Chip responds to materialTapTargetSize', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
useMaterial3: false,
child: const Column( child: const Column(
children: <Widget>[ children: <Widget>[
Chip( Chip(
...@@ -732,6 +736,7 @@ void main() { ...@@ -732,6 +736,7 @@ void main() {
testWidgets('Chip responds to textScaleFactor', (WidgetTester tester) async { testWidgets('Chip responds to textScaleFactor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
useMaterial3: false,
child: const Column( child: const Column(
children: <Widget>[ children: <Widget>[
Chip( Chip(
...@@ -810,6 +815,7 @@ void main() { ...@@ -810,6 +815,7 @@ void main() {
final Key keyB = GlobalKey(); final Key keyB = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
useMaterial3: false,
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
Chip( Chip(
...@@ -947,6 +953,7 @@ void main() { ...@@ -947,6 +953,7 @@ void main() {
Future<void> pushChip({ Widget? avatar }) async { Future<void> pushChip({ Widget? avatar }) async {
return tester.pumpWidget( return tester.pumpWidget(
wrapForChip( wrapForChip(
useMaterial3: false,
child: Wrap( child: Wrap(
children: <Widget>[ children: <Widget>[
RawChip( RawChip(
...@@ -1061,6 +1068,7 @@ void main() { ...@@ -1061,6 +1068,7 @@ void main() {
Future<void> pushChip({ bool deletable = false }) async { Future<void> pushChip({ bool deletable = false }) async {
return tester.pumpWidget( return tester.pumpWidget(
wrapForChip( wrapForChip(
useMaterial3: false,
child: Wrap( child: Wrap(
children: <Widget>[ children: <Widget>[
StatefulBuilder(builder: (BuildContext context, StateSetter setState) { StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
...@@ -1212,6 +1220,7 @@ void main() { ...@@ -1212,6 +1220,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
chipWithOptionalDeleteButton( chipWithOptionalDeleteButton(
useMaterial3: false,
labelKey: labelKey, labelKey: labelKey,
deleteButtonKey: deleteButtonKey, deleteButtonKey: deleteButtonKey,
deletable: true, deletable: true,
...@@ -1294,6 +1303,7 @@ void main() { ...@@ -1294,6 +1303,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
chipWithOptionalDeleteButton( chipWithOptionalDeleteButton(
useMaterial3: false,
labelKey: labelKey, labelKey: labelKey,
deleteButtonKey: deleteButtonKey, deleteButtonKey: deleteButtonKey,
deletable: true, deletable: true,
...@@ -1347,6 +1357,7 @@ void main() { ...@@ -1347,6 +1357,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
chipWithOptionalDeleteButton( chipWithOptionalDeleteButton(
useMaterial3: false,
labelKey: labelKey, labelKey: labelKey,
onPressed: null, onPressed: null,
deleteButtonKey: deleteButtonKey, deleteButtonKey: deleteButtonKey,
...@@ -1431,6 +1442,7 @@ void main() { ...@@ -1431,6 +1442,7 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
chipWithOptionalDeleteButton( chipWithOptionalDeleteButton(
useMaterial3: false,
labelKey: labelKey, labelKey: labelKey,
deletable: false, deletable: false,
), ),
...@@ -1485,6 +1497,7 @@ void main() { ...@@ -1485,6 +1497,7 @@ void main() {
Future<void> pushChip({ Widget? avatar, bool selectable = false }) async { Future<void> pushChip({ Widget? avatar, bool selectable = false }) async {
return tester.pumpWidget( return tester.pumpWidget(
wrapForChip( wrapForChip(
useMaterial3: false,
child: Wrap( child: Wrap(
children: <Widget>[ children: <Widget>[
StatefulBuilder(builder: (BuildContext context, StateSetter setState) { StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
...@@ -1565,6 +1578,7 @@ void main() { ...@@ -1565,6 +1578,7 @@ void main() {
Future<void> pushChip({ bool selectable = false }) async { Future<void> pushChip({ bool selectable = false }) async {
return tester.pumpWidget( return tester.pumpWidget(
wrapForChip( wrapForChip(
useMaterial3: false,
child: Wrap( child: Wrap(
children: <Widget>[ children: <Widget>[
StatefulBuilder(builder: (BuildContext context, StateSetter setState) { StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
...@@ -1638,6 +1652,7 @@ void main() { ...@@ -1638,6 +1652,7 @@ void main() {
Future<void> pushChip({ Widget? avatar, bool selectable = false }) async { Future<void> pushChip({ Widget? avatar, bool selectable = false }) async {
return tester.pumpWidget( return tester.pumpWidget(
wrapForChip( wrapForChip(
useMaterial3: false,
child: Wrap( child: Wrap(
children: <Widget>[ children: <Widget>[
StatefulBuilder(builder: (BuildContext context, StateSetter setState) { StatefulBuilder(builder: (BuildContext context, StateSetter setState) {
...@@ -2573,12 +2588,17 @@ void main() { ...@@ -2573,12 +2588,17 @@ void main() {
}); });
testWidgets('selected chip and avatar draw darkened layer within avatar circle', (WidgetTester tester) async { testWidgets('selected chip and avatar draw darkened layer within avatar circle', (WidgetTester tester) async {
await tester.pumpWidget(wrapForChip(child: const FilterChip( await tester.pumpWidget(
avatar: CircleAvatar(child: Text('t')), wrapForChip(
label: Text('test'), useMaterial3: false,
selected: true, child: const FilterChip(
onSelected: null, avatar: CircleAvatar(child: Text('t')),
))); label: Text('test'),
selected: true,
onSelected: null,
),
),
);
final RenderBox rawChip = tester.firstRenderObject<RenderBox>( final RenderBox rawChip = tester.firstRenderObject<RenderBox>(
find.descendant( find.descendant(
of: find.byType(RawChip), of: find.byType(RawChip),
...@@ -3299,6 +3319,7 @@ void main() { ...@@ -3299,6 +3319,7 @@ void main() {
const OutlinedBorder shape = ContinuousRectangleBorder(); const OutlinedBorder shape = ContinuousRectangleBorder();
await tester.pumpWidget(wrapForChip( await tester.pumpWidget(wrapForChip(
useMaterial3: false,
child: const RawChip( child: const RawChip(
label: Text('text'), label: Text('text'),
backgroundColor: backgroundColor, backgroundColor: backgroundColor,
......
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