Unverified Commit ab2d0323 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

cleanup accessibility test skips in gallery (#23977)

parent 48c00dc7
...@@ -395,6 +395,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt ...@@ -395,6 +395,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
onPressed: _toggleBackdropPanelVisibility, onPressed: _toggleBackdropPanelVisibility,
icon: AnimatedIcon( icon: AnimatedIcon(
icon: AnimatedIcons.close_menu, icon: AnimatedIcons.close_menu,
semanticLabel: 'close',
progress: _controller.view, progress: _controller.view,
), ),
), ),
......
...@@ -33,7 +33,7 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> { ...@@ -33,7 +33,7 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
label: 'circular floating action button', label: 'circular floating action button',
value: FloatingActionButton( value: FloatingActionButton(
onPressed: _showSnackbar, onPressed: _showSnackbar,
child: Icon(Icons.add), child: Icon(Icons.add, semanticLabel: 'Action'),
backgroundColor: Colors.orange, backgroundColor: Colors.orange,
), ),
); );
...@@ -43,7 +43,7 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> { ...@@ -43,7 +43,7 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
label: 'diamond shape floating action button', label: 'diamond shape floating action button',
value: _DiamondFab( value: _DiamondFab(
onPressed: _showSnackbar, onPressed: _showSnackbar,
child: Icon(Icons.add), child: Icon(Icons.add, semanticLabel: 'Action'),
), ),
); );
...@@ -147,7 +147,7 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> { ...@@ -147,7 +147,7 @@ class _BottomAppBarDemoState extends State<BottomAppBarDemo> {
actions: <Widget>[ actions: <Widget>[
MaterialDemoDocumentationButton(BottomAppBarDemo.routeName), MaterialDemoDocumentationButton(BottomAppBarDemo.routeName),
IconButton( IconButton(
icon: const Icon(Icons.sentiment_very_satisfied), icon: const Icon(Icons.sentiment_very_satisfied, semanticLabel: 'Update shape'),
onPressed: () { onPressed: () {
setState(() { setState(() {
_fabShape = _fabShape == kCircularFab ? kDiamondFab : kCircularFab; _fabShape = _fabShape == kCircularFab ? kDiamondFab : kCircularFab;
...@@ -349,7 +349,7 @@ class _DemoBottomAppBar extends StatelessWidget { ...@@ -349,7 +349,7 @@ class _DemoBottomAppBar extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final List<Widget> rowContents = <Widget> [ final List<Widget> rowContents = <Widget> [
IconButton( IconButton(
icon: const Icon(Icons.menu), icon: const Icon(Icons.menu, semanticLabel: 'Show bottom sheet'),
onPressed: () { onPressed: () {
showModalBottomSheet<void>( showModalBottomSheet<void>(
context: context, context: context,
...@@ -367,7 +367,7 @@ class _DemoBottomAppBar extends StatelessWidget { ...@@ -367,7 +367,7 @@ class _DemoBottomAppBar extends StatelessWidget {
rowContents.addAll(<Widget> [ rowContents.addAll(<Widget> [
IconButton( IconButton(
icon: const Icon(Icons.search), icon: const Icon(Icons.search, semanticLabel: 'show search action',),
onPressed: () { onPressed: () {
Scaffold.of(context).showSnackBar( Scaffold.of(context).showSnackBar(
const SnackBar(content: Text('This is a dummy search action.')), const SnackBar(content: Text('This is a dummy search action.')),
...@@ -379,6 +379,7 @@ class _DemoBottomAppBar extends StatelessWidget { ...@@ -379,6 +379,7 @@ class _DemoBottomAppBar extends StatelessWidget {
Theme.of(context).platform == TargetPlatform.iOS Theme.of(context).platform == TargetPlatform.iOS
? Icons.more_horiz ? Icons.more_horiz
: Icons.more_vert, : Icons.more_vert,
semanticLabel: 'Show menu actions',
), ),
onPressed: () { onPressed: () {
Scaffold.of(context).showSnackBar( Scaffold.of(context).showSnackBar(
......
...@@ -120,7 +120,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -120,7 +120,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
demos: demos, demos: demos,
actions: <Widget>[ actions: <Widget>[
IconButton( IconButton(
icon: const Icon(Icons.sentiment_very_satisfied), icon: const Icon(Icons.sentiment_very_satisfied, semanticLabel: 'Update shape'),
onPressed: () { onPressed: () {
setState(() { setState(() {
_buttonShape = _buttonShape == null ? const StadiumBorder() : null; _buttonShape = _buttonShape == null ? const StadiumBorder() : null;
...@@ -141,13 +141,13 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -141,13 +141,13 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
RaisedButton( RaisedButton(
child: const Text('RAISED BUTTON'), child: const Text('RAISED BUTTON', semanticsLabel: 'RAISED BUTTON 1'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
}, },
), ),
const RaisedButton( const RaisedButton(
child: Text('DISABLED'), child: Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 1'),
onPressed: null, onPressed: null,
), ),
], ],
...@@ -157,14 +157,14 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -157,14 +157,14 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
children: <Widget>[ children: <Widget>[
RaisedButton.icon( RaisedButton.icon(
icon: const Icon(Icons.add, size: 18.0), icon: const Icon(Icons.add, size: 18.0),
label: const Text('RAISED BUTTON'), label: const Text('RAISED BUTTON', semanticsLabel: 'RAISED BUTTON 2'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
}, },
), ),
RaisedButton.icon( RaisedButton.icon(
icon: const Icon(Icons.add, size: 18.0), icon: const Icon(Icons.add, size: 18.0),
label: const Text('DISABLED'), label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 2'),
onPressed: null, onPressed: null,
), ),
], ],
...@@ -184,13 +184,13 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -184,13 +184,13 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
FlatButton( FlatButton(
child: const Text('FLAT BUTTON'), child: const Text('FLAT BUTTON', semanticsLabel: 'FLAT BUTTON 1'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
}, },
), ),
const FlatButton( const FlatButton(
child: Text('DISABLED'), child: Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 3',),
onPressed: null, onPressed: null,
), ),
], ],
...@@ -200,14 +200,14 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -200,14 +200,14 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
children: <Widget>[ children: <Widget>[
FlatButton.icon( FlatButton.icon(
icon: const Icon(Icons.add_circle_outline, size: 18.0), 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: () { onPressed: () {
// Perform some action // Perform some action
}, },
), ),
FlatButton.icon( FlatButton.icon(
icon: const Icon(Icons.add_circle_outline, size: 18.0), icon: const Icon(Icons.add_circle_outline, size: 18.0),
label: const Text('DISABLED'), label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 4'),
onPressed: null, onPressed: null,
), ),
], ],
...@@ -227,13 +227,13 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -227,13 +227,13 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
OutlineButton( OutlineButton(
child: const Text('OUTLINE BUTTON'), child: const Text('OUTLINE BUTTON', semanticsLabel: 'OUTLINE BUTTON 1'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
}, },
), ),
const OutlineButton( const OutlineButton(
child: Text('DISABLED'), child: Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 5'),
onPressed: null, onPressed: null,
), ),
], ],
...@@ -243,14 +243,14 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -243,14 +243,14 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
children: <Widget>[ children: <Widget>[
OutlineButton.icon( OutlineButton.icon(
icon: const Icon(Icons.add, size: 18.0), icon: const Icon(Icons.add, size: 18.0),
label: const Text('OUTLINE BUTTON'), label: const Text('OUTLINE BUTTON', semanticsLabel: 'OUTLINE BUTTON 2'),
onPressed: () { onPressed: () {
// Perform some action // Perform some action
}, },
), ),
OutlineButton.icon( OutlineButton.icon(
icon: const Icon(Icons.add, size: 18.0), icon: const Icon(Icons.add, size: 18.0),
label: const Text('DISABLED'), label: const Text('DISABLED', semanticsLabel: 'DISABLED BUTTON 6'),
onPressed: null, onPressed: null,
), ),
], ],
...@@ -360,7 +360,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -360,7 +360,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
const IconButton( const IconButton(
icon: Icon( icon: Icon(
Icons.thumb_up, Icons.thumb_up,
semanticLabel: 'Thumbs up', semanticLabel: 'Thumbs not up',
), ),
onPressed: null, onPressed: null,
) )
...@@ -379,6 +379,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> { ...@@ -379,6 +379,7 @@ class _ButtonsDemoState extends State<ButtonsDemo> {
onPressed: () { onPressed: () {
// Perform some action // Perform some action
}, },
tooltip: 'floating action button',
), ),
); );
} }
......
...@@ -133,12 +133,12 @@ class TravelDestinationItem extends StatelessWidget { ...@@ -133,12 +133,12 @@ class TravelDestinationItem extends StatelessWidget {
alignment: MainAxisAlignment.start, alignment: MainAxisAlignment.start,
children: <Widget>[ children: <Widget>[
FlatButton( FlatButton(
child: const Text('SHARE'), child: Text('SHARE', semanticsLabel: 'Share ${destination.title}'),
textColor: Colors.amber.shade500, textColor: Colors.amber.shade500,
onPressed: () { /* do nothing */ }, onPressed: () { /* do nothing */ },
), ),
FlatButton( FlatButton(
child: const Text('EXPLORE'), child: Text('EXPLORE', semanticsLabel: 'Explore ${destination.title}'),
textColor: Colors.amber.shade500, textColor: Colors.amber.shade500,
onPressed: () { /* do nothing */ }, onPressed: () { /* do nothing */ },
), ),
...@@ -172,7 +172,10 @@ class _CardsDemoState extends State<CardsDemo> { ...@@ -172,7 +172,10 @@ class _CardsDemoState extends State<CardsDemo> {
actions: <Widget>[ actions: <Widget>[
MaterialDemoDocumentationButton(CardsDemo.routeName), MaterialDemoDocumentationButton(CardsDemo.routeName),
IconButton( IconButton(
icon: const Icon(Icons.sentiment_very_satisfied), icon: const Icon(
Icons.sentiment_very_satisfied,
semanticLabel: 'update shape',
),
onPressed: () { onPressed: () {
setState(() { setState(() {
_shape = _shape != null ? null : const RoundedRectangleBorder( _shape = _shape != null ? null : const RoundedRectangleBorder(
......
...@@ -141,7 +141,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat ...@@ -141,7 +141,7 @@ class _TabsFabDemoState extends State<TabsFabDemo> with SingleTickerProviderStat
actions: <Widget>[ actions: <Widget>[
MaterialDemoDocumentationButton(TabsFabDemo.routeName), MaterialDemoDocumentationButton(TabsFabDemo.routeName),
IconButton( IconButton(
icon: const Icon(Icons.sentiment_very_satisfied), icon: const Icon(Icons.sentiment_very_satisfied, semanticLabel: 'Toggle extended buttons'),
onPressed: () { onPressed: () {
setState(() { setState(() {
_extendedButtons = !_extendedButtons; _extendedButtons = !_extendedButtons;
......
...@@ -72,7 +72,10 @@ class _PasswordFieldState extends State<PasswordField> { ...@@ -72,7 +72,10 @@ class _PasswordFieldState extends State<PasswordField> {
_obscureText = !_obscureText; _obscureText = !_obscureText;
}); });
}, },
child: Icon(_obscureText ? Icons.visibility : Icons.visibility_off), child: Icon(
_obscureText ? Icons.visibility : Icons.visibility_off,
semanticLabel: _obscureText ? 'show password' : 'hide password',
),
), ),
), ),
); );
......
...@@ -78,7 +78,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ...@@ -78,7 +78,7 @@ class TabbedComponentDemoScaffold extends StatelessWidget {
Builder( Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return IconButton( return IconButton(
icon: const Icon(Icons.library_books), icon: const Icon(Icons.library_books, semanticLabel: 'Show documentation'),
onPressed: () => _showApiDocumentation(context), onPressed: () => _showApiDocumentation(context),
); );
}, },
......
...@@ -243,14 +243,14 @@ void main() { ...@@ -243,14 +243,14 @@ void main() {
await tester.pumpWidget(MaterialApp(home: BackdropDemo())); await tester.pumpWidget(MaterialApp(home: BackdropDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose(); handle.dispose();
}, skip: true); });
testWidgets('bottom_app_bar_demo', (WidgetTester tester) async { testWidgets('bottom_app_bar_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: BottomAppBarDemo())); await tester.pumpWidget(MaterialApp(home: BottomAppBarDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose(); handle.dispose();
}, skip: true); });
testWidgets('bottom_navigation_demo', (WidgetTester tester) async { testWidgets('bottom_navigation_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
...@@ -264,14 +264,14 @@ void main() { ...@@ -264,14 +264,14 @@ void main() {
await tester.pumpWidget(MaterialApp(home: ButtonsDemo())); await tester.pumpWidget(MaterialApp(home: ButtonsDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose(); handle.dispose();
}, skip: true); });
testWidgets('cards_demo', (WidgetTester tester) async { testWidgets('cards_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: CardsDemo())); await tester.pumpWidget(MaterialApp(home: CardsDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose(); handle.dispose();
}, skip: true); });
testWidgets('chip_demo', (WidgetTester tester) async { testWidgets('chip_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
...@@ -446,14 +446,14 @@ void main() { ...@@ -446,14 +446,14 @@ void main() {
await tester.pumpWidget(MaterialApp(home: TabsFabDemo())); await tester.pumpWidget(MaterialApp(home: TabsFabDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose(); handle.dispose();
}, skip: true); });
testWidgets('text_form_field_demo', (WidgetTester tester) async { testWidgets('text_form_field_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(const MaterialApp(home: TextFormFieldDemo())); await tester.pumpWidget(const MaterialApp(home: TextFormFieldDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline)); await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose(); handle.dispose();
}, skip: true); });
testWidgets('tooltip_demo', (WidgetTester tester) async { testWidgets('tooltip_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
...@@ -503,7 +503,7 @@ void main() { ...@@ -503,7 +503,7 @@ void main() {
await tester.pumpWidget(MaterialApp(theme: theme, home: BottomAppBarDemo())); await tester.pumpWidget(MaterialApp(theme: theme, home: BottomAppBarDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose(); handle.dispose();
}, skip: true); // https://github.com/flutter/flutter/issues/21651 });
testWidgets('bottom_navigation_demo $themeName', (WidgetTester tester) async { testWidgets('bottom_navigation_demo $themeName', (WidgetTester tester) async {
final AutomatedTestWidgetsFlutterBinding binding = tester.binding; final AutomatedTestWidgetsFlutterBinding binding = tester.binding;
...@@ -521,7 +521,7 @@ void main() { ...@@ -521,7 +521,7 @@ void main() {
await tester.pumpWidget(MaterialApp(theme: theme, home: ButtonsDemo())); await tester.pumpWidget(MaterialApp(theme: theme, home: ButtonsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose(); handle.dispose();
}, skip: true); // https://github.com/flutter/flutter/issues/21647 });
testWidgets('cards_demo $themeName', (WidgetTester tester) async { testWidgets('cards_demo $themeName', (WidgetTester tester) async {
final AutomatedTestWidgetsFlutterBinding binding = tester.binding; final AutomatedTestWidgetsFlutterBinding binding = tester.binding;
...@@ -530,7 +530,7 @@ void main() { ...@@ -530,7 +530,7 @@ void main() {
await tester.pumpWidget(MaterialApp(theme: theme, home: CardsDemo())); await tester.pumpWidget(MaterialApp(theme: theme, home: CardsDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose(); handle.dispose();
}, skip: true); // https://github.com/flutter/flutter/issues/21651 });
testWidgets('chip_demo $themeName', (WidgetTester tester) async { testWidgets('chip_demo $themeName', (WidgetTester tester) async {
final AutomatedTestWidgetsFlutterBinding binding = tester.binding; final AutomatedTestWidgetsFlutterBinding binding = tester.binding;
......
...@@ -142,7 +142,7 @@ class LabeledTapTargetGuideline extends AccessibilityGuideline { ...@@ -142,7 +142,7 @@ class LabeledTapTargetGuideline extends AccessibilityGuideline {
result += traverse(child); result += traverse(child);
return true; return true;
}); });
if (node.isMergedIntoParent) if (node.isMergedIntoParent || node.isInvisible || node.hasFlag(ui.SemanticsFlag.isHidden))
return result; return result;
final SemanticsData data = node.getSemanticsData(); final SemanticsData data = node.getSemanticsData();
// Skip node if it has no actions, or is marked as hidden. // Skip node if it has no actions, or is marked as hidden.
...@@ -203,9 +203,11 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline { ...@@ -203,9 +203,11 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline {
}); });
Future<Evaluation> evaluateNode(SemanticsNode node) async { 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 SemanticsData data = node.getSemanticsData();
final List<SemanticsNode> children = <SemanticsNode>[]; final List<SemanticsNode> children = <SemanticsNode>[];
Evaluation result = const Evaluation.pass();
node.visitChildren((SemanticsNode child) { node.visitChildren((SemanticsNode child) {
children.add(child); children.add(child);
return true; return true;
......
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