cleanup accessibility test skips in gallery (#23977)
diff --git a/examples/flutter_gallery/lib/demo/material/backdrop_demo.dart b/examples/flutter_gallery/lib/demo/material/backdrop_demo.dart
index 9f7b624..67d0a61 100644
--- a/examples/flutter_gallery/lib/demo/material/backdrop_demo.dart
+++ b/examples/flutter_gallery/lib/demo/material/backdrop_demo.dart
@@ -395,6 +395,7 @@
onPressed: _toggleBackdropPanelVisibility,
icon: AnimatedIcon(
icon: AnimatedIcons.close_menu,
+ semanticLabel: 'close',
progress: _controller.view,
),
),
diff --git a/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart b/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart
index 0b1a272..0baef79 100644
--- a/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart
+++ b/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart
@@ -33,7 +33,7 @@
label: 'circular floating action button',
value: FloatingActionButton(
onPressed: _showSnackbar,
- child: Icon(Icons.add),
+ child: Icon(Icons.add, semanticLabel: 'Action'),
backgroundColor: Colors.orange,
),
);
@@ -43,7 +43,7 @@
label: 'diamond shape floating action button',
value: _DiamondFab(
onPressed: _showSnackbar,
- child: Icon(Icons.add),
+ child: Icon(Icons.add, semanticLabel: 'Action'),
),
);
@@ -147,7 +147,7 @@
actions: <Widget>[
MaterialDemoDocumentationButton(BottomAppBarDemo.routeName),
IconButton(
- icon: const Icon(Icons.sentiment_very_satisfied),
+ icon: const Icon(Icons.sentiment_very_satisfied, semanticLabel: 'Update shape'),
onPressed: () {
setState(() {
_fabShape = _fabShape == kCircularFab ? kDiamondFab : kCircularFab;
@@ -349,7 +349,7 @@
Widget build(BuildContext context) {
final List<Widget> rowContents = <Widget> [
IconButton(
- icon: const Icon(Icons.menu),
+ icon: const Icon(Icons.menu, semanticLabel: 'Show bottom sheet'),
onPressed: () {
showModalBottomSheet<void>(
context: context,
@@ -367,7 +367,7 @@
rowContents.addAll(<Widget> [
IconButton(
- icon: const Icon(Icons.search),
+ icon: const Icon(Icons.search, semanticLabel: 'show search action',),
onPressed: () {
Scaffold.of(context).showSnackBar(
const SnackBar(content: Text('This is a dummy search action.')),
@@ -379,6 +379,7 @@
Theme.of(context).platform == TargetPlatform.iOS
? Icons.more_horiz
: Icons.more_vert,
+ semanticLabel: 'Show menu actions',
),
onPressed: () {
Scaffold.of(context).showSnackBar(
diff --git a/examples/flutter_gallery/lib/demo/material/buttons_demo.dart b/examples/flutter_gallery/lib/demo/material/buttons_demo.dart
index 9de0655..4b5f079 100644
--- a/examples/flutter_gallery/lib/demo/material/buttons_demo.dart
+++ b/examples/flutter_gallery/lib/demo/material/buttons_demo.dart
@@ -120,7 +120,7 @@
demos: demos,
actions: <Widget>[
IconButton(
- icon: const Icon(Icons.sentiment_very_satisfied),
+ icon: const Icon(Icons.sentiment_very_satisfied, semanticLabel: 'Update shape'),
onPressed: () {
setState(() {
_buttonShape = _buttonShape == null ? const StadiumBorder() : null;
@@ -141,13 +141,13 @@
mainAxisSize: MainAxisSize.min,
children: <Widget>[
RaisedButton(
- child: const Text('RAISED BUTTON'),
+ child: const Text('RAISED BUTTON', semanticsLabel: 'RAISED BUTTON 1'),
onPressed: () {
// Perform some action
},
),
const RaisedButton(
- child: Text('DISABLED'),
+ child: Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 1'),
onPressed: null,
),
],
@@ -157,14 +157,14 @@
children: <Widget>[
RaisedButton.icon(
icon: const Icon(Icons.add, size: 18.0),
- label: const Text('RAISED BUTTON'),
+ label: const Text('RAISED BUTTON', semanticsLabel: 'RAISED BUTTON 2'),
onPressed: () {
// Perform some action
},
),
RaisedButton.icon(
icon: const Icon(Icons.add, size: 18.0),
- label: const Text('DISABLED'),
+ label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 2'),
onPressed: null,
),
],
@@ -184,13 +184,13 @@
mainAxisSize: MainAxisSize.min,
children: <Widget>[
FlatButton(
- child: const Text('FLAT BUTTON'),
+ child: const Text('FLAT BUTTON', semanticsLabel: 'FLAT BUTTON 1'),
onPressed: () {
// Perform some action
},
),
const FlatButton(
- child: Text('DISABLED'),
+ child: Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 3',),
onPressed: null,
),
],
@@ -200,14 +200,14 @@
children: <Widget>[
FlatButton.icon(
icon: const Icon(Icons.add_circle_outline, size: 18.0),
- label: const Text('FLAT BUTTON'),
+ label: const Text('FLAT BUTTON', semanticsLabel: 'FLAT BUTTON 2'),
onPressed: () {
// Perform some action
},
),
FlatButton.icon(
icon: const Icon(Icons.add_circle_outline, size: 18.0),
- label: const Text('DISABLED'),
+ label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 4'),
onPressed: null,
),
],
@@ -227,13 +227,13 @@
mainAxisSize: MainAxisSize.min,
children: <Widget>[
OutlineButton(
- child: const Text('OUTLINE BUTTON'),
+ child: const Text('OUTLINE BUTTON', semanticsLabel: 'OUTLINE BUTTON 1'),
onPressed: () {
// Perform some action
},
),
const OutlineButton(
- child: Text('DISABLED'),
+ child: Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 5'),
onPressed: null,
),
],
@@ -243,14 +243,14 @@
children: <Widget>[
OutlineButton.icon(
icon: const Icon(Icons.add, size: 18.0),
- label: const Text('OUTLINE BUTTON'),
+ label: const Text('OUTLINE BUTTON', semanticsLabel: 'OUTLINE BUTTON 2'),
onPressed: () {
// Perform some action
},
),
OutlineButton.icon(
icon: const Icon(Icons.add, size: 18.0),
- label: const Text('DISABLED'),
+ label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 6'),
onPressed: null,
),
],
@@ -360,7 +360,7 @@
const IconButton(
icon: Icon(
Icons.thumb_up,
- semanticLabel: 'Thumbs up',
+ semanticLabel: 'Thumbs not up',
),
onPressed: null,
)
@@ -379,6 +379,7 @@
onPressed: () {
// Perform some action
},
+ tooltip: 'floating action button',
),
);
}
diff --git a/examples/flutter_gallery/lib/demo/material/cards_demo.dart b/examples/flutter_gallery/lib/demo/material/cards_demo.dart
index 2a09e8c..f7ea1b9 100644
--- a/examples/flutter_gallery/lib/demo/material/cards_demo.dart
+++ b/examples/flutter_gallery/lib/demo/material/cards_demo.dart
@@ -133,12 +133,12 @@
alignment: MainAxisAlignment.start,
children: <Widget>[
FlatButton(
- child: const Text('SHARE'),
+ child: Text('SHARE', semanticsLabel: 'Share ${destination.title}'),
textColor: Colors.amber.shade500,
onPressed: () { /* do nothing */ },
),
FlatButton(
- child: const Text('EXPLORE'),
+ child: Text('EXPLORE', semanticsLabel: 'Explore ${destination.title}'),
textColor: Colors.amber.shade500,
onPressed: () { /* do nothing */ },
),
@@ -172,7 +172,10 @@
actions: <Widget>[
MaterialDemoDocumentationButton(CardsDemo.routeName),
IconButton(
- icon: const Icon(Icons.sentiment_very_satisfied),
+ icon: const Icon(
+ Icons.sentiment_very_satisfied,
+ semanticLabel: 'update shape',
+ ),
onPressed: () {
setState(() {
_shape = _shape != null ? null : const RoundedRectangleBorder(
diff --git a/examples/flutter_gallery/lib/demo/material/tabs_fab_demo.dart b/examples/flutter_gallery/lib/demo/material/tabs_fab_demo.dart
index 6f09cb8..b24daf7 100644
--- a/examples/flutter_gallery/lib/demo/material/tabs_fab_demo.dart
+++ b/examples/flutter_gallery/lib/demo/material/tabs_fab_demo.dart
@@ -141,7 +141,7 @@
actions: <Widget>[
MaterialDemoDocumentationButton(TabsFabDemo.routeName),
IconButton(
- icon: const Icon(Icons.sentiment_very_satisfied),
+ icon: const Icon(Icons.sentiment_very_satisfied, semanticLabel: 'Toggle extended buttons'),
onPressed: () {
setState(() {
_extendedButtons = !_extendedButtons;
diff --git a/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart b/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart
index bcaa216..2fab33a 100644
--- a/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart
+++ b/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart
@@ -72,7 +72,10 @@
_obscureText = !_obscureText;
});
},
- child: Icon(_obscureText ? Icons.visibility : Icons.visibility_off),
+ child: Icon(
+ _obscureText ? Icons.visibility : Icons.visibility_off,
+ semanticLabel: _obscureText ? 'show password' : 'hide password',
+ ),
),
),
);
diff --git a/examples/flutter_gallery/lib/gallery/demo.dart b/examples/flutter_gallery/lib/gallery/demo.dart
index 12afd7d..25a13b7 100644
--- a/examples/flutter_gallery/lib/gallery/demo.dart
+++ b/examples/flutter_gallery/lib/gallery/demo.dart
@@ -78,7 +78,7 @@
Builder(
builder: (BuildContext context) {
return IconButton(
- icon: const Icon(Icons.library_books),
+ icon: const Icon(Icons.library_books, semanticLabel: 'Show documentation'),
onPressed: () => _showApiDocumentation(context),
);
},
diff --git a/examples/flutter_gallery/test/accessibility_test.dart b/examples/flutter_gallery/test/accessibility_test.dart
index 27a3c51..59358c7 100644
--- a/examples/flutter_gallery/test/accessibility_test.dart
+++ b/examples/flutter_gallery/test/accessibility_test.dart
@@ -243,14 +243,14 @@
await tester.pumpWidget(MaterialApp(home: BackdropDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
- }, skip: true);
+ });
testWidgets('bottom_app_bar_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: BottomAppBarDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
- }, skip: true);
+ });
testWidgets('bottom_navigation_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
@@ -264,14 +264,14 @@
await tester.pumpWidget(MaterialApp(home: ButtonsDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
- }, skip: true);
+ });
testWidgets('cards_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: CardsDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
- }, skip: true);
+ });
testWidgets('chip_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
@@ -446,14 +446,14 @@
await tester.pumpWidget(MaterialApp(home: TabsFabDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
- }, skip: true);
+ });
testWidgets('text_form_field_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(const MaterialApp(home: TextFormFieldDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
- }, skip: true);
+ });
testWidgets('tooltip_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
@@ -503,7 +503,7 @@
await tester.pumpWidget(MaterialApp(theme: theme, home: BottomAppBarDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
- }, skip: true); // https://github.com/flutter/flutter/issues/21651
+ });
testWidgets('bottom_navigation_demo $themeName', (WidgetTester tester) async {
final AutomatedTestWidgetsFlutterBinding binding = tester.binding;
@@ -521,7 +521,7 @@
await tester.pumpWidget(MaterialApp(theme: theme, home: ButtonsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
- }, skip: true); // https://github.com/flutter/flutter/issues/21647
+ });
testWidgets('cards_demo $themeName', (WidgetTester tester) async {
final AutomatedTestWidgetsFlutterBinding binding = tester.binding;
@@ -530,7 +530,7 @@
await tester.pumpWidget(MaterialApp(theme: theme, home: CardsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
- }, skip: true); // https://github.com/flutter/flutter/issues/21651
+ });
testWidgets('chip_demo $themeName', (WidgetTester tester) async {
final AutomatedTestWidgetsFlutterBinding binding = tester.binding;
diff --git a/packages/flutter_test/lib/src/accessibility.dart b/packages/flutter_test/lib/src/accessibility.dart
index 3433ae0..97a269d 100644
--- a/packages/flutter_test/lib/src/accessibility.dart
+++ b/packages/flutter_test/lib/src/accessibility.dart
@@ -142,7 +142,7 @@
result += traverse(child);
return true;
});
- if (node.isMergedIntoParent)
+ if (node.isMergedIntoParent || node.isInvisible || node.hasFlag(ui.SemanticsFlag.isHidden))
return result;
final SemanticsData data = node.getSemanticsData();
// Skip node if it has no actions, or is marked as hidden.
@@ -203,9 +203,11 @@
});
Future<Evaluation> evaluateNode(SemanticsNode node) async {
+ Evaluation result = const Evaluation.pass();
+ if (node.isInvisible || node.isMergedIntoParent || node.hasFlag(ui.SemanticsFlag.isHidden))
+ return result;
final SemanticsData data = node.getSemanticsData();
final List<SemanticsNode> children = <SemanticsNode>[];
- Evaluation result = const Evaluation.pass();
node.visitChildren((SemanticsNode child) {
children.add(child);
return true;