Skip to content

Commit e516d3a

Browse files
[material_ui] Unskip web tests that pass on CanvasKit and Skwasm: color_scheme_test, elevated_button_test, filled_button_test, icon_button_test (#13327)
Removes the `skip: isBrowser` from the text-contrast accessibility guideline tests in `color_scheme_test.dart`, `elevated_button_test.dart`, `filled_button_test.dart`, and `icon_button_test.dart`. These tests were skipped on the web because `meetsGuideline(textContrastGuideline)` used to throw there, but they now pass on Chrome under both CI web renderers (CanvasKit via dart2js and Skwasm via `--wasm`). Keeping them skipped hides web regressions. The rest of the diff is the formatter re-wrapping the `testWidgets` calls now that the `skip:` argument is gone. Part of flutter/flutter#44115 This is a test-only change, so no version or CHANGELOG update is needed. ## Pre-Review Checklist **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 8b1b579 commit e516d3a

4 files changed

Lines changed: 122 additions & 134 deletions

File tree

‎packages/material_ui/test/color_scheme_test.dart‎

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -686,40 +686,38 @@ void main() {
686686
);
687687
});
688688

689-
testWidgets(
690-
'generated scheme "on" colors meet a11y contrast guidelines',
691-
(WidgetTester tester) async {
692-
final colors = ColorScheme.fromSeed(seedColor: Colors.teal);
689+
testWidgets('generated scheme "on" colors meet a11y contrast guidelines', (
690+
WidgetTester tester,
691+
) async {
692+
final colors = ColorScheme.fromSeed(seedColor: Colors.teal);
693693

694-
Widget label(String text, Color textColor, Color background) {
695-
return Container(
696-
color: background,
697-
padding: const EdgeInsets.all(8),
698-
child: Text(text, style: TextStyle(color: textColor)),
699-
);
700-
}
694+
Widget label(String text, Color textColor, Color background) {
695+
return Container(
696+
color: background,
697+
padding: const EdgeInsets.all(8),
698+
child: Text(text, style: TextStyle(color: textColor)),
699+
);
700+
}
701701

702-
await tester.pumpWidget(
703-
MaterialApp(
704-
theme: ThemeData.from(colorScheme: colors),
705-
home: Scaffold(
706-
body: Column(
707-
children: <Widget>[
708-
label('primary', colors.onPrimary, colors.primary),
709-
label('secondary', colors.onSecondary, colors.secondary),
710-
label('tertiary', colors.onTertiary, colors.tertiary),
711-
label('error', colors.onError, colors.error),
712-
label('background', colors.onBackground, colors.background),
713-
label('surface', colors.onSurface, colors.surface),
714-
],
715-
),
702+
await tester.pumpWidget(
703+
MaterialApp(
704+
theme: ThemeData.from(colorScheme: colors),
705+
home: Scaffold(
706+
body: Column(
707+
children: <Widget>[
708+
label('primary', colors.onPrimary, colors.primary),
709+
label('secondary', colors.onSecondary, colors.secondary),
710+
label('tertiary', colors.onTertiary, colors.tertiary),
711+
label('error', colors.onError, colors.error),
712+
label('background', colors.onBackground, colors.background),
713+
label('surface', colors.onSurface, colors.surface),
714+
],
716715
),
717716
),
718-
);
719-
await expectLater(tester, meetsGuideline(textContrastGuideline));
720-
},
721-
skip: isBrowser, // https://github.com/flutter/flutter/issues/44115
722-
);
717+
),
718+
);
719+
await expectLater(tester, meetsGuideline(textContrastGuideline));
720+
});
723721

724722
testWidgets(
725723
'Color values in ColorScheme.fromSeed with different variants matches values in DynamicScheme',

‎packages/material_ui/test/elevated_button_test.dart‎

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -330,45 +330,41 @@ void main() {
330330
expect(find.text('label'), findsOneWidget);
331331
});
332332

333-
testWidgets(
334-
'Default ElevatedButton meets a11y contrast guidelines',
335-
(WidgetTester tester) async {
336-
final focusNode = FocusNode();
333+
testWidgets('Default ElevatedButton meets a11y contrast guidelines', (WidgetTester tester) async {
334+
final focusNode = FocusNode();
337335

338-
await tester.pumpWidget(
339-
MaterialApp(
340-
theme: ThemeData.from(colorScheme: const ColorScheme.light()),
341-
home: Scaffold(
342-
body: Center(
343-
child: ElevatedButton(
344-
onPressed: () {},
345-
focusNode: focusNode,
346-
child: const Text('ElevatedButton'),
347-
),
336+
await tester.pumpWidget(
337+
MaterialApp(
338+
theme: ThemeData.from(colorScheme: const ColorScheme.light()),
339+
home: Scaffold(
340+
body: Center(
341+
child: ElevatedButton(
342+
onPressed: () {},
343+
focusNode: focusNode,
344+
child: const Text('ElevatedButton'),
348345
),
349346
),
350347
),
351-
);
348+
),
349+
);
352350

353-
// Default, not disabled.
354-
await expectLater(tester, meetsGuideline(textContrastGuideline));
351+
// Default, not disabled.
352+
await expectLater(tester, meetsGuideline(textContrastGuideline));
355353

356-
// Focused.
357-
focusNode.requestFocus();
358-
await tester.pumpAndSettle();
359-
await expectLater(tester, meetsGuideline(textContrastGuideline));
354+
// Focused.
355+
focusNode.requestFocus();
356+
await tester.pumpAndSettle();
357+
await expectLater(tester, meetsGuideline(textContrastGuideline));
360358

361-
// Hovered.
362-
final Offset center = tester.getCenter(find.byType(ElevatedButton));
363-
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
364-
await gesture.addPointer();
365-
await gesture.moveTo(center);
366-
await tester.pumpAndSettle();
367-
await expectLater(tester, meetsGuideline(textContrastGuideline));
368-
focusNode.dispose();
369-
},
370-
skip: isBrowser, // https://github.com/flutter/flutter/issues/44115
371-
);
359+
// Hovered.
360+
final Offset center = tester.getCenter(find.byType(ElevatedButton));
361+
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
362+
await gesture.addPointer();
363+
await gesture.moveTo(center);
364+
await tester.pumpAndSettle();
365+
await expectLater(tester, meetsGuideline(textContrastGuideline));
366+
focusNode.dispose();
367+
});
372368

373369
testWidgets('ElevatedButton default overlayColor and elevation resolve pressed state', (
374370
WidgetTester tester,

‎packages/material_ui/test/filled_button_test.dart‎

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -436,45 +436,41 @@ void main() {
436436
await tester.pumpAndSettle();
437437
});
438438

439-
testWidgets(
440-
'Default FilledButton meets a11y contrast guidelines',
441-
(WidgetTester tester) async {
442-
final focusNode = FocusNode();
443-
addTearDown(focusNode.dispose);
439+
testWidgets('Default FilledButton meets a11y contrast guidelines', (WidgetTester tester) async {
440+
final focusNode = FocusNode();
441+
addTearDown(focusNode.dispose);
444442

445-
await tester.pumpWidget(
446-
MaterialApp(
447-
theme: ThemeData.from(colorScheme: const ColorScheme.light()),
448-
home: Scaffold(
449-
body: Center(
450-
child: FilledButton(
451-
onPressed: () {},
452-
focusNode: focusNode,
453-
child: const Text('FilledButton'),
454-
),
443+
await tester.pumpWidget(
444+
MaterialApp(
445+
theme: ThemeData.from(colorScheme: const ColorScheme.light()),
446+
home: Scaffold(
447+
body: Center(
448+
child: FilledButton(
449+
onPressed: () {},
450+
focusNode: focusNode,
451+
child: const Text('FilledButton'),
455452
),
456453
),
457454
),
458-
);
455+
),
456+
);
459457

460-
// Default, not disabled.
461-
await expectLater(tester, meetsGuideline(textContrastGuideline));
458+
// Default, not disabled.
459+
await expectLater(tester, meetsGuideline(textContrastGuideline));
462460

463-
// Focused.
464-
focusNode.requestFocus();
465-
await tester.pumpAndSettle();
466-
await expectLater(tester, meetsGuideline(textContrastGuideline));
461+
// Focused.
462+
focusNode.requestFocus();
463+
await tester.pumpAndSettle();
464+
await expectLater(tester, meetsGuideline(textContrastGuideline));
467465

468-
// Hovered.
469-
final Offset center = tester.getCenter(find.byType(FilledButton));
470-
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
471-
await gesture.addPointer();
472-
await gesture.moveTo(center);
473-
await tester.pumpAndSettle();
474-
await expectLater(tester, meetsGuideline(textContrastGuideline));
475-
},
476-
skip: isBrowser, // https://github.com/flutter/flutter/issues/44115
477-
);
466+
// Hovered.
467+
final Offset center = tester.getCenter(find.byType(FilledButton));
468+
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
469+
await gesture.addPointer();
470+
await gesture.moveTo(center);
471+
await tester.pumpAndSettle();
472+
await expectLater(tester, meetsGuideline(textContrastGuideline));
473+
});
478474

479475
testWidgets('FilledButton default overlayColor and elevation resolve pressed state', (
480476
WidgetTester tester,

‎packages/material_ui/test/icon_button_test.dart‎

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,56 +2046,54 @@ void main() {
20462046
expect(iconColor(), colorScheme.onSurface.withOpacity(0.38));
20472047
});
20482048

2049-
testWidgets(
2050-
'Default IconButton meets a11y contrast guidelines - M3',
2051-
(WidgetTester tester) async {
2052-
final focusNode = FocusNode();
2049+
testWidgets('Default IconButton meets a11y contrast guidelines - M3', (
2050+
WidgetTester tester,
2051+
) async {
2052+
final focusNode = FocusNode();
20532053

2054-
await tester.pumpWidget(
2055-
MaterialApp(
2056-
theme: ThemeData.from(colorScheme: const ColorScheme.light()),
2057-
home: Scaffold(
2058-
body: Center(
2059-
child: IconButton(
2060-
onPressed: () {},
2061-
focusNode: focusNode,
2062-
icon: const Icon(Icons.ac_unit),
2063-
),
2054+
await tester.pumpWidget(
2055+
MaterialApp(
2056+
theme: ThemeData.from(colorScheme: const ColorScheme.light()),
2057+
home: Scaffold(
2058+
body: Center(
2059+
child: IconButton(
2060+
onPressed: () {},
2061+
focusNode: focusNode,
2062+
icon: const Icon(Icons.ac_unit),
20642063
),
20652064
),
20662065
),
2067-
);
2066+
),
2067+
);
20682068

2069-
// Default, not disabled.
2070-
await expectLater(tester, meetsGuideline(textContrastGuideline));
2069+
// Default, not disabled.
2070+
await expectLater(tester, meetsGuideline(textContrastGuideline));
20712071

2072-
// Focused.
2073-
focusNode.requestFocus();
2074-
await tester.pumpAndSettle();
2075-
await expectLater(tester, meetsGuideline(textContrastGuideline));
2072+
// Focused.
2073+
focusNode.requestFocus();
2074+
await tester.pumpAndSettle();
2075+
await expectLater(tester, meetsGuideline(textContrastGuideline));
20762076

2077-
// Hovered.
2078-
final Offset center = tester.getCenter(find.byType(IconButton));
2079-
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
2080-
await gesture.addPointer();
2081-
await gesture.moveTo(center);
2082-
await tester.pumpAndSettle();
2083-
await expectLater(tester, meetsGuideline(textContrastGuideline));
2077+
// Hovered.
2078+
final Offset center = tester.getCenter(find.byType(IconButton));
2079+
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
2080+
await gesture.addPointer();
2081+
await gesture.moveTo(center);
2082+
await tester.pumpAndSettle();
2083+
await expectLater(tester, meetsGuideline(textContrastGuideline));
20842084

2085-
// Highlighted (pressed).
2086-
await gesture.down(center);
2087-
await tester.pump(); // Start the splash and highlight animations.
2088-
await tester.pump(
2089-
const Duration(milliseconds: 800),
2090-
); // Wait for splash and highlight to be well under way.
2091-
await expectLater(tester, meetsGuideline(textContrastGuideline));
2085+
// Highlighted (pressed).
2086+
await gesture.down(center);
2087+
await tester.pump(); // Start the splash and highlight animations.
2088+
await tester.pump(
2089+
const Duration(milliseconds: 800),
2090+
); // Wait for splash and highlight to be well under way.
2091+
await expectLater(tester, meetsGuideline(textContrastGuideline));
20922092

2093-
await gesture.removePointer();
2093+
await gesture.removePointer();
20942094

2095-
focusNode.dispose();
2096-
},
2097-
skip: isBrowser, // https://github.com/flutter/flutter/issues/44115
2098-
);
2095+
focusNode.dispose();
2096+
});
20992097

21002098
testWidgets('IconButton uses stateful color for icon color in different states - M3', (
21012099
WidgetTester tester,

0 commit comments

Comments
 (0)