Skip to content

Commit 5e3747e

Browse files
[material_ui] Unskip web tests that pass on CanvasKit and Skwasm: adaptive_text_selection_toolbar_test, material_button_test, outlined_button_test, text_button_test (flutter#13335)
Removes web skips (`skip: isBrowser`) from tests in `packages/material_ui/test` that now pass on both CI web renderers (CanvasKit and Skwasm). Keeping these skips hides web regressions in these tests. - `adaptive_text_selection_toolbar_test.dart`: `Builds the right toolbar on each platform, including web, and shows buttonItems` was skipped for `Path.combine` not working with the (now removed) HTML renderer. - `material_button_test.dart`, `outlined_button_test.dart`, `text_button_test.dart`: the `meetsGuideline(textContrastGuideline)` accessibility tests now run on the web. Each file was run with `flutter test --platform chrome` (CanvasKit) and `flutter test --platform chrome --wasm` (Skwasm) and all tests passed. None of the unskipped tests use goldens. The diff is the skip removal plus the formatter rewrap that results from dropping the trailing `skip:` argument. Part of flutter#44115 Related: flutter#108382 (closed) Test-only change, so no version bump or CHANGELOG entry 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 250879b commit 5e3747e

4 files changed

Lines changed: 254 additions & 273 deletions

File tree

‎packages/material_ui/test/adaptive_text_selection_toolbar_test.dart‎

Lines changed: 42 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -27,56 +27,53 @@ void main() {
2727
await Clipboard.setData(const ClipboardData(text: 'Clipboard data'));
2828
});
2929

30-
testWidgets(
31-
'Builds the right toolbar on each platform, including web, and shows buttonItems',
32-
(WidgetTester tester) async {
33-
const buttonText = 'Click me';
30+
testWidgets('Builds the right toolbar on each platform, including web, and shows buttonItems', (
31+
WidgetTester tester,
32+
) async {
33+
const buttonText = 'Click me';
3434

35-
await tester.pumpWidget(
36-
MaterialApp(
37-
home: Scaffold(
38-
body: Center(
39-
child: AdaptiveTextSelectionToolbar.buttonItems(
40-
anchors: const TextSelectionToolbarAnchors(primaryAnchor: Offset.zero),
41-
buttonItems: <ContextMenuButtonItem>[
42-
ContextMenuButtonItem(label: buttonText, onPressed: () {}),
43-
],
44-
),
35+
await tester.pumpWidget(
36+
MaterialApp(
37+
home: Scaffold(
38+
body: Center(
39+
child: AdaptiveTextSelectionToolbar.buttonItems(
40+
anchors: const TextSelectionToolbarAnchors(primaryAnchor: Offset.zero),
41+
buttonItems: <ContextMenuButtonItem>[
42+
ContextMenuButtonItem(label: buttonText, onPressed: () {}),
43+
],
4544
),
4645
),
4746
),
48-
);
49-
50-
expect(find.text(buttonText), findsOneWidget);
47+
),
48+
);
5149

52-
switch (defaultTargetPlatform) {
53-
case TargetPlatform.android:
54-
expect(find.byType(TextSelectionToolbar), findsOneWidget);
55-
expect(find.byType(CupertinoTextSelectionToolbar), findsNothing);
56-
expect(find.byType(DesktopTextSelectionToolbar), findsNothing);
57-
expect(find.byType(CupertinoDesktopTextSelectionToolbar), findsNothing);
58-
case TargetPlatform.iOS:
59-
expect(find.byType(TextSelectionToolbar), findsNothing);
60-
expect(find.byType(CupertinoTextSelectionToolbar), findsOneWidget);
61-
expect(find.byType(DesktopTextSelectionToolbar), findsNothing);
62-
expect(find.byType(CupertinoDesktopTextSelectionToolbar), findsNothing);
63-
case TargetPlatform.macOS:
64-
expect(find.byType(TextSelectionToolbar), findsNothing);
65-
expect(find.byType(CupertinoTextSelectionToolbar), findsNothing);
66-
expect(find.byType(DesktopTextSelectionToolbar), findsNothing);
67-
expect(find.byType(CupertinoDesktopTextSelectionToolbar), findsOneWidget);
68-
case TargetPlatform.fuchsia:
69-
case TargetPlatform.linux:
70-
case TargetPlatform.windows:
71-
expect(find.byType(TextSelectionToolbar), findsNothing);
72-
expect(find.byType(CupertinoTextSelectionToolbar), findsNothing);
73-
expect(find.byType(DesktopTextSelectionToolbar), findsOneWidget);
74-
expect(find.byType(CupertinoDesktopTextSelectionToolbar), findsNothing);
75-
}
76-
},
77-
variant: TargetPlatformVariant.all(),
78-
skip: isBrowser, // [intended] see https://github.com/flutter/flutter/issues/108382
79-
);
50+
expect(find.text(buttonText), findsOneWidget);
51+
52+
switch (defaultTargetPlatform) {
53+
case TargetPlatform.android:
54+
expect(find.byType(TextSelectionToolbar), findsOneWidget);
55+
expect(find.byType(CupertinoTextSelectionToolbar), findsNothing);
56+
expect(find.byType(DesktopTextSelectionToolbar), findsNothing);
57+
expect(find.byType(CupertinoDesktopTextSelectionToolbar), findsNothing);
58+
case TargetPlatform.iOS:
59+
expect(find.byType(TextSelectionToolbar), findsNothing);
60+
expect(find.byType(CupertinoTextSelectionToolbar), findsOneWidget);
61+
expect(find.byType(DesktopTextSelectionToolbar), findsNothing);
62+
expect(find.byType(CupertinoDesktopTextSelectionToolbar), findsNothing);
63+
case TargetPlatform.macOS:
64+
expect(find.byType(TextSelectionToolbar), findsNothing);
65+
expect(find.byType(CupertinoTextSelectionToolbar), findsNothing);
66+
expect(find.byType(DesktopTextSelectionToolbar), findsNothing);
67+
expect(find.byType(CupertinoDesktopTextSelectionToolbar), findsOneWidget);
68+
case TargetPlatform.fuchsia:
69+
case TargetPlatform.linux:
70+
case TargetPlatform.windows:
71+
expect(find.byType(TextSelectionToolbar), findsNothing);
72+
expect(find.byType(CupertinoTextSelectionToolbar), findsNothing);
73+
expect(find.byType(DesktopTextSelectionToolbar), findsOneWidget);
74+
expect(find.byType(CupertinoDesktopTextSelectionToolbar), findsNothing);
75+
}
76+
}, variant: TargetPlatformVariant.all());
8077

8178
testWidgets('Can build children directly as well', (WidgetTester tester) async {
8279
final GlobalKey key = GlobalKey();

‎packages/material_ui/test/material_button_test.dart‎

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -275,37 +275,33 @@ void main() {
275275
expect(material.color, const Color(0xff00ff00));
276276
});
277277

278-
testWidgets(
279-
'Default MaterialButton meets a11y contrast guidelines',
280-
(WidgetTester tester) async {
281-
await tester.pumpWidget(
282-
MaterialApp(
283-
home: Scaffold(
284-
body: Center(
285-
child: MaterialButton(child: const Text('MaterialButton'), onPressed: () {}),
286-
),
278+
testWidgets('Default MaterialButton meets a11y contrast guidelines', (WidgetTester tester) async {
279+
await tester.pumpWidget(
280+
MaterialApp(
281+
home: Scaffold(
282+
body: Center(
283+
child: MaterialButton(child: const Text('MaterialButton'), onPressed: () {}),
287284
),
288285
),
289-
);
286+
),
287+
);
290288

291-
// Default, not disabled.
292-
await expectLater(tester, meetsGuideline(textContrastGuideline));
293-
294-
// Highlighted (pressed).
295-
final Offset center = tester.getCenter(find.byType(MaterialButton));
296-
final TestGesture gesture = await tester.startGesture(center);
297-
await tester.pump(); // Start the splash and highlight animations.
298-
await tester.pump(
299-
const Duration(milliseconds: 800),
300-
); // Wait for splash and highlight to be well under way.
301-
await expectLater(tester, meetsGuideline(textContrastGuideline));
302-
303-
// Finish gesture to release resources.
304-
await gesture.up();
305-
await tester.pumpAndSettle();
306-
},
307-
skip: isBrowser, // https://github.com/flutter/flutter/issues/44115
308-
);
289+
// Default, not disabled.
290+
await expectLater(tester, meetsGuideline(textContrastGuideline));
291+
292+
// Highlighted (pressed).
293+
final Offset center = tester.getCenter(find.byType(MaterialButton));
294+
final TestGesture gesture = await tester.startGesture(center);
295+
await tester.pump(); // Start the splash and highlight animations.
296+
await tester.pump(
297+
const Duration(milliseconds: 800),
298+
); // Wait for splash and highlight to be well under way.
299+
await expectLater(tester, meetsGuideline(textContrastGuideline));
300+
301+
// Finish gesture to release resources.
302+
await gesture.up();
303+
await tester.pumpAndSettle();
304+
});
309305

310306
testWidgets('MaterialButton gets focus when autofocus is set.', (WidgetTester tester) async {
311307
final focusNode = FocusNode(debugLabel: 'MaterialButton');

‎packages/material_ui/test/outlined_button_test.dart‎

Lines changed: 94 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -532,129 +532,123 @@ void main() {
532532
focusNode.dispose();
533533
});
534534

535-
testWidgets(
536-
'Default OutlinedButton meets a11y contrast guidelines',
537-
(WidgetTester tester) async {
538-
final focusNode = FocusNode();
535+
testWidgets('Default OutlinedButton meets a11y contrast guidelines', (WidgetTester tester) async {
536+
final focusNode = FocusNode();
539537

540-
await tester.pumpWidget(
541-
MaterialApp(
542-
theme: ThemeData.from(colorScheme: const ColorScheme.light()),
543-
home: Scaffold(
544-
body: Center(
545-
child: OutlinedButton(
546-
onPressed: () {},
547-
focusNode: focusNode,
548-
child: const Text('OutlinedButton'),
549-
),
538+
await tester.pumpWidget(
539+
MaterialApp(
540+
theme: ThemeData.from(colorScheme: const ColorScheme.light()),
541+
home: Scaffold(
542+
body: Center(
543+
child: OutlinedButton(
544+
onPressed: () {},
545+
focusNode: focusNode,
546+
child: const Text('OutlinedButton'),
550547
),
551548
),
552549
),
553-
);
550+
),
551+
);
554552

555-
// Default, not disabled.
556-
await expectLater(tester, meetsGuideline(textContrastGuideline));
553+
// Default, not disabled.
554+
await expectLater(tester, meetsGuideline(textContrastGuideline));
557555

558-
// Hovered.
559-
final Offset center = tester.getCenter(find.byType(OutlinedButton));
560-
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
561-
await gesture.addPointer();
562-
await gesture.moveTo(center);
563-
await tester.pumpAndSettle();
564-
await expectLater(tester, meetsGuideline(textContrastGuideline));
556+
// Hovered.
557+
final Offset center = tester.getCenter(find.byType(OutlinedButton));
558+
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
559+
await gesture.addPointer();
560+
await gesture.moveTo(center);
561+
await tester.pumpAndSettle();
562+
await expectLater(tester, meetsGuideline(textContrastGuideline));
565563

566-
// Highlighted (pressed).
567-
await gesture.down(center);
568-
await tester.pump(); // Start the splash and highlight animations.
569-
await tester.pump(
570-
const Duration(milliseconds: 800),
571-
); // Wait for splash and highlight to be well under way.
572-
await expectLater(tester, meetsGuideline(textContrastGuideline));
573-
await gesture.up();
574-
await tester.pumpAndSettle();
564+
// Highlighted (pressed).
565+
await gesture.down(center);
566+
await tester.pump(); // Start the splash and highlight animations.
567+
await tester.pump(
568+
const Duration(milliseconds: 800),
569+
); // Wait for splash and highlight to be well under way.
570+
await expectLater(tester, meetsGuideline(textContrastGuideline));
571+
await gesture.up();
572+
await tester.pumpAndSettle();
575573

576-
// Focused.
577-
focusNode.requestFocus();
578-
await tester.pumpAndSettle();
579-
await expectLater(tester, meetsGuideline(textContrastGuideline));
574+
// Focused.
575+
focusNode.requestFocus();
576+
await tester.pumpAndSettle();
577+
await expectLater(tester, meetsGuideline(textContrastGuideline));
580578

581-
focusNode.dispose();
582-
},
583-
skip: isBrowser, // https://github.com/flutter/flutter/issues/44115
584-
);
579+
focusNode.dispose();
580+
});
585581

586-
testWidgets(
587-
'OutlinedButton with colored theme meets a11y contrast guidelines',
588-
(WidgetTester tester) async {
589-
final focusNode = FocusNode();
582+
testWidgets('OutlinedButton with colored theme meets a11y contrast guidelines', (
583+
WidgetTester tester,
584+
) async {
585+
final focusNode = FocusNode();
590586

591-
Color getTextColor(Set<WidgetState> states) {
592-
final interactiveStates = <WidgetState>{
593-
WidgetState.pressed,
594-
WidgetState.hovered,
595-
WidgetState.focused,
596-
};
597-
if (states.any(interactiveStates.contains)) {
598-
return Colors.blue[900]!;
599-
}
600-
return Colors.blue[800]!;
587+
Color getTextColor(Set<WidgetState> states) {
588+
final interactiveStates = <WidgetState>{
589+
WidgetState.pressed,
590+
WidgetState.hovered,
591+
WidgetState.focused,
592+
};
593+
if (states.any(interactiveStates.contains)) {
594+
return Colors.blue[900]!;
601595
}
596+
return Colors.blue[800]!;
597+
}
602598

603-
await tester.pumpWidget(
604-
MaterialApp(
605-
theme: ThemeData.from(colorScheme: ColorScheme.fromSwatch()),
606-
home: Scaffold(
607-
backgroundColor: Colors.white,
608-
body: Center(
609-
child: OutlinedButtonTheme(
610-
data: OutlinedButtonThemeData(
611-
style: ButtonStyle(
612-
foregroundColor: WidgetStateProperty.resolveWith<Color>(getTextColor),
613-
),
614-
),
615-
child: Builder(
616-
builder: (BuildContext context) {
617-
return OutlinedButton(
618-
onPressed: () {},
619-
focusNode: focusNode,
620-
child: const Text('OutlinedButton'),
621-
);
622-
},
599+
await tester.pumpWidget(
600+
MaterialApp(
601+
theme: ThemeData.from(colorScheme: ColorScheme.fromSwatch()),
602+
home: Scaffold(
603+
backgroundColor: Colors.white,
604+
body: Center(
605+
child: OutlinedButtonTheme(
606+
data: OutlinedButtonThemeData(
607+
style: ButtonStyle(
608+
foregroundColor: WidgetStateProperty.resolveWith<Color>(getTextColor),
623609
),
624610
),
611+
child: Builder(
612+
builder: (BuildContext context) {
613+
return OutlinedButton(
614+
onPressed: () {},
615+
focusNode: focusNode,
616+
child: const Text('OutlinedButton'),
617+
);
618+
},
619+
),
625620
),
626621
),
627622
),
628-
);
623+
),
624+
);
629625

630-
// Default, not disabled.
631-
await expectLater(tester, meetsGuideline(textContrastGuideline));
626+
// Default, not disabled.
627+
await expectLater(tester, meetsGuideline(textContrastGuideline));
632628

633-
// Focused.
634-
focusNode.requestFocus();
635-
await tester.pumpAndSettle();
636-
await expectLater(tester, meetsGuideline(textContrastGuideline));
629+
// Focused.
630+
focusNode.requestFocus();
631+
await tester.pumpAndSettle();
632+
await expectLater(tester, meetsGuideline(textContrastGuideline));
637633

638-
// Hovered.
639-
final Offset center = tester.getCenter(find.byType(OutlinedButton));
640-
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
641-
await gesture.addPointer();
642-
await gesture.moveTo(center);
643-
await tester.pumpAndSettle();
644-
await expectLater(tester, meetsGuideline(textContrastGuideline));
634+
// Hovered.
635+
final Offset center = tester.getCenter(find.byType(OutlinedButton));
636+
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
637+
await gesture.addPointer();
638+
await gesture.moveTo(center);
639+
await tester.pumpAndSettle();
640+
await expectLater(tester, meetsGuideline(textContrastGuideline));
645641

646-
// Highlighted (pressed).
647-
await gesture.down(center);
648-
await tester.pump(); // Start the splash and highlight animations.
649-
await tester.pump(
650-
const Duration(milliseconds: 800),
651-
); // Wait for splash and highlight to be well under way.
652-
await expectLater(tester, meetsGuideline(textContrastGuideline));
642+
// Highlighted (pressed).
643+
await gesture.down(center);
644+
await tester.pump(); // Start the splash and highlight animations.
645+
await tester.pump(
646+
const Duration(milliseconds: 800),
647+
); // Wait for splash and highlight to be well under way.
648+
await expectLater(tester, meetsGuideline(textContrastGuideline));
653649

654-
focusNode.dispose();
655-
},
656-
skip: isBrowser, // https://github.com/flutter/flutter/issues/44115
657-
);
650+
focusNode.dispose();
651+
});
658652

659653
testWidgets('OutlinedButton uses stateful color for text color in different states', (
660654
WidgetTester tester,

0 commit comments

Comments
 (0)