From c082abe6298eeae508fd677cb23c2b602a42ba31 Mon Sep 17 00:00:00 2001 From: Greg Spencer Date: Mon, 8 Jul 2024 14:01:56 -0700 Subject: [PATCH] Re-enable `SemanticsAction.focus` matchers (#150990) ## Description This re-enables the `SemanticsAction.focus` matchers so that they actually do something now instead of ignoring the action. This was so that we could land the focus action changes without causing breakages in customer tests, and now that customer tests have been updated, we can land this PR turning it on again. ## Related Issues - Fixes https://github.com/flutter/flutter/issues/149842 ## Related PRs - https://github.com/flutter/flutter/pull/149840 ## Tests - Updates semantics tests to actually look for the focus action. --- .../flutter/test/cupertino/button_test.dart | 2 +- .../flutter/test/cupertino/checkbox_test.dart | 2 +- .../flutter/test/cupertino/radio_test.dart | 2 +- .../test/cupertino/text_field_test.dart | 9 +++- .../test/material/back_button_test.dart | 4 +- .../flutter/test/material/checkbox_test.dart | 15 +++++-- .../test/material/date_picker_test.dart | 1 + .../test/material/drawer_button_test.dart | 4 +- .../input_date_picker_form_field_test.dart | 1 + .../flutter/test/material/radio_test.dart | 6 +-- .../flutter/test/material/search_test.dart | 32 ++++++++++---- .../flutter/test/material/slider_test.dart | 5 ++- .../test/material/text_field_test.dart | 42 +++++++++++++++---- .../test/material/time_picker_test.dart | 20 +++++++-- .../test/widgets/semantics_tester.dart | 27 +++--------- packages/flutter_test/lib/src/matchers.dart | 32 +++----------- 16 files changed, 122 insertions(+), 82 deletions(-) diff --git a/packages/flutter/test/cupertino/button_test.dart b/packages/flutter/test/cupertino/button_test.dart index 56d7e7e2398..44ea39aba5b 100644 --- a/packages/flutter/test/cupertino/button_test.dart +++ b/packages/flutter/test/cupertino/button_test.dart @@ -296,7 +296,7 @@ void main() { TestSemantics.root( children: [ TestSemantics.rootChild( - actions: SemanticsAction.tap.index, + actions: SemanticsAction.tap.index | SemanticsAction.focus.index, label: 'ABC', flags: [ SemanticsFlag.isButton, diff --git a/packages/flutter/test/cupertino/checkbox_test.dart b/packages/flutter/test/cupertino/checkbox_test.dart index b6bdaf6baf2..d3cafe524f3 100644 --- a/packages/flutter/test/cupertino/checkbox_test.dart +++ b/packages/flutter/test/cupertino/checkbox_test.dart @@ -251,7 +251,7 @@ void main() { SemanticsFlag.isFocusable, SemanticsFlag.isCheckStateMixed, ], - actions: [SemanticsAction.tap, SemanticsAction.focus], + actions: [SemanticsAction.focus, SemanticsAction.tap], ), hasLength(1)); await tester.pumpWidget( diff --git a/packages/flutter/test/cupertino/radio_test.dart b/packages/flutter/test/cupertino/radio_test.dart index 6035c20ceeb..f44369afbca 100644 --- a/packages/flutter/test/cupertino/radio_test.dart +++ b/packages/flutter/test/cupertino/radio_test.dart @@ -148,7 +148,7 @@ void main() { ], actions: [ SemanticsAction.tap, - SemanticsAction.focus, + if (defaultTargetPlatform != TargetPlatform.iOS) SemanticsAction.focus, ], ), ); diff --git a/packages/flutter/test/cupertino/text_field_test.dart b/packages/flutter/test/cupertino/text_field_test.dart index cd12e34ace0..1efdb3e123c 100644 --- a/packages/flutter/test/cupertino/text_field_test.dart +++ b/packages/flutter/test/cupertino/text_field_test.dart @@ -534,8 +534,11 @@ void main() { SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, ], - actions: [SemanticsAction.tap, - SemanticsAction.didGainAccessibilityFocus,], + actions: [ + SemanticsAction.tap, + SemanticsAction.focus, + SemanticsAction.didGainAccessibilityFocus, + ], textDirection: TextDirection.ltr, ), ], @@ -7971,6 +7974,7 @@ void main() { isEnabled: true, hasEnabledState: true, hasTapAction: true, + hasFocusAction: true, ), ); }); @@ -10313,6 +10317,7 @@ void main() { ], actions: [ SemanticsAction.tap, + SemanticsAction.focus, if (defaultTargetPlatform == TargetPlatform.windows || defaultTargetPlatform == TargetPlatform.macOS) SemanticsAction.didGainAccessibilityFocus, // TODO(gspencergoog): also test for the presence of SemanticsAction.focus when diff --git a/packages/flutter/test/material/back_button_test.dart b/packages/flutter/test/material/back_button_test.dart index 682dc4b2325..d16818b66b0 100644 --- a/packages/flutter/test/material/back_button_test.dart +++ b/packages/flutter/test/material/back_button_test.dart @@ -215,7 +215,7 @@ void main() { hasEnabledState: true, isEnabled: true, hasTapAction: true, - hasFocusAction: true, + hasFocusAction: defaultTargetPlatform != TargetPlatform.iOS, isFocusable: true, )); handle.dispose(); @@ -259,7 +259,7 @@ void main() { hasEnabledState: true, isEnabled: true, hasTapAction: true, - hasFocusAction: true, + hasFocusAction: defaultTargetPlatform != TargetPlatform.iOS, isFocusable: true, )); handle.dispose(); diff --git a/packages/flutter/test/material/checkbox_test.dart b/packages/flutter/test/material/checkbox_test.dart index 56cbf37d977..293d7c72ae5 100644 --- a/packages/flutter/test/material/checkbox_test.dart +++ b/packages/flutter/test/material/checkbox_test.dart @@ -322,7 +322,10 @@ void main() { SemanticsFlag.isFocusable, SemanticsFlag.isCheckStateMixed, ], - actions: [SemanticsAction.tap, SemanticsAction.focus], + actions: [ + SemanticsAction.tap, + SemanticsAction.focus, + ], ), hasLength(1)); await tester.pumpWidget( @@ -346,7 +349,10 @@ void main() { SemanticsFlag.isChecked, SemanticsFlag.isFocusable, ], - actions: [SemanticsAction.tap, SemanticsAction.focus], + actions: [ + SemanticsAction.tap, + SemanticsAction.focus, + ], ), hasLength(1)); await tester.pumpWidget( @@ -369,7 +375,10 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, ], - actions: [SemanticsAction.tap, SemanticsAction.focus], + actions: [ + SemanticsAction.tap, + SemanticsAction.focus, + ], ), hasLength(1)); semantics.dispose(); diff --git a/packages/flutter/test/material/date_picker_test.dart b/packages/flutter/test/material/date_picker_test.dart index 8ba368cbea1..cfb232b106f 100644 --- a/packages/flutter/test/material/date_picker_test.dart +++ b/packages/flutter/test/material/date_picker_test.dart @@ -1621,6 +1621,7 @@ void main() { isFocused: true, value: '01/15/2016', hasTapAction: true, + hasFocusAction: true, hasSetTextAction: true, hasSetSelectionAction: true, hasCopyAction: true, diff --git a/packages/flutter/test/material/drawer_button_test.dart b/packages/flutter/test/material/drawer_button_test.dart index e1fe7353238..6de04c68ad7 100644 --- a/packages/flutter/test/material/drawer_button_test.dart +++ b/packages/flutter/test/material/drawer_button_test.dart @@ -182,7 +182,7 @@ void main() { hasEnabledState: true, isEnabled: true, hasTapAction: true, - hasFocusAction: true, + hasFocusAction: defaultTargetPlatform != TargetPlatform.iOS, isFocusable: true, )); handle.dispose(); @@ -240,7 +240,7 @@ void main() { hasEnabledState: true, isEnabled: true, hasTapAction: true, - hasFocusAction: true, + hasFocusAction: defaultTargetPlatform != TargetPlatform.iOS, isFocusable: true, )); handle.dispose(); diff --git a/packages/flutter/test/material/input_date_picker_form_field_test.dart b/packages/flutter/test/material/input_date_picker_form_field_test.dart index 14773781409..960c208624d 100644 --- a/packages/flutter/test/material/input_date_picker_form_field_test.dart +++ b/packages/flutter/test/material/input_date_picker_form_field_test.dart @@ -284,6 +284,7 @@ void main() { isFocused: true, value: '01/15/2016', hasTapAction: true, + hasFocusAction: true, hasSetTextAction: true, hasSetSelectionAction: true, hasCopyAction: true, diff --git a/packages/flutter/test/material/radio_test.dart b/packages/flutter/test/material/radio_test.dart index 8b0456b7fc8..c3ede77683a 100644 --- a/packages/flutter/test/material/radio_test.dart +++ b/packages/flutter/test/material/radio_test.dart @@ -205,7 +205,7 @@ void main() { ), ), )); - final bool isApple = defaultTargetPlatform == TargetPlatform.iOS || + final bool isCupertino = defaultTargetPlatform == TargetPlatform.iOS || defaultTargetPlatform == TargetPlatform.macOS; expect( semantics, @@ -217,11 +217,11 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isChecked, - if (isApple) SemanticsFlag.isSelected, + if (isCupertino) SemanticsFlag.isSelected, ], actions: [ SemanticsAction.tap, - SemanticsAction.focus, + if (defaultTargetPlatform != TargetPlatform.iOS) SemanticsAction.focus, ], ), ); diff --git a/packages/flutter/test/material/search_test.dart b/packages/flutter/test/material/search_test.dart index 61963b37ecf..0fbc196e447 100644 --- a/packages/flutter/test/material/search_test.dart +++ b/packages/flutter/test/material/search_test.dart @@ -630,6 +630,8 @@ void main() { final bool isDesktop = debugDefaultTargetPlatformOverride == TargetPlatform.macOS || debugDefaultTargetPlatformOverride == TargetPlatform.windows || debugDefaultTargetPlatformOverride == TargetPlatform.linux; + final bool isCupertino = debugDefaultTargetPlatformOverride == TargetPlatform.iOS || + debugDefaultTargetPlatformOverride == TargetPlatform.macOS; return TestSemantics.root( children: [ TestSemantics( @@ -662,7 +664,10 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, ], - actions: [SemanticsAction.tap, SemanticsAction.focus], + actions: [ + SemanticsAction.tap, + if (defaultTargetPlatform != TargetPlatform.iOS) SemanticsAction.focus, + ], tooltip: 'Back', textDirection: TextDirection.ltr, ), @@ -674,8 +679,7 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isFocused, SemanticsFlag.isHeader, - if (debugDefaultTargetPlatformOverride != TargetPlatform.iOS && - debugDefaultTargetPlatformOverride != TargetPlatform.macOS) SemanticsFlag.namesRoute, + if (!isCupertino) SemanticsFlag.namesRoute, ], actions: [ if (isDesktop) @@ -683,6 +687,7 @@ void main() { if (isDesktop) SemanticsAction.didLoseAccessibilityFocus, SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.setSelection, SemanticsAction.setText, SemanticsAction.paste, @@ -718,7 +723,10 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, ], - actions: [SemanticsAction.tap, SemanticsAction.focus], + actions: [ + SemanticsAction.tap, + if (defaultTargetPlatform != TargetPlatform.iOS) SemanticsAction.focus, + ], label: 'Suggestions', textDirection: TextDirection.ltr, ), @@ -783,6 +791,8 @@ void main() { final bool isDesktop = debugDefaultTargetPlatformOverride == TargetPlatform.macOS || debugDefaultTargetPlatformOverride == TargetPlatform.windows || debugDefaultTargetPlatformOverride == TargetPlatform.linux; + final bool isCupertino = debugDefaultTargetPlatformOverride == TargetPlatform.iOS || + debugDefaultTargetPlatformOverride == TargetPlatform.macOS; return TestSemantics.root( children: [ TestSemantics( @@ -812,7 +822,10 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, ], - actions: [SemanticsAction.tap, SemanticsAction.focus], + actions: [ + SemanticsAction.tap, + if (defaultTargetPlatform != TargetPlatform.iOS) SemanticsAction.focus, + ], tooltip: 'Back', textDirection: TextDirection.ltr, ), @@ -824,8 +837,7 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isFocused, SemanticsFlag.isHeader, - if (debugDefaultTargetPlatformOverride != TargetPlatform.iOS && - debugDefaultTargetPlatformOverride != TargetPlatform.macOS) SemanticsFlag.namesRoute, + if (!isCupertino) SemanticsFlag.namesRoute, ], actions: [ if (isDesktop) @@ -833,6 +845,7 @@ void main() { if (isDesktop) SemanticsAction.didLoseAccessibilityFocus, SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.setSelection, SemanticsAction.setText, SemanticsAction.paste, @@ -856,7 +869,10 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, ], - actions: [SemanticsAction.tap, SemanticsAction.focus], + actions: [ + SemanticsAction.tap, + if (defaultTargetPlatform != TargetPlatform.iOS) SemanticsAction.focus, + ], label: 'Suggestions', textDirection: TextDirection.ltr, ), diff --git a/packages/flutter/test/material/slider_test.dart b/packages/flutter/test/material/slider_test.dart index 9f2786db2e3..ce1a110f41c 100644 --- a/packages/flutter/test/material/slider_test.dart +++ b/packages/flutter/test/material/slider_test.dart @@ -1454,7 +1454,10 @@ void main() { TestSemantics( id: 4, flags: [SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isSlider], - actions: [SemanticsAction.focus, SemanticsAction.increase, SemanticsAction.decrease], + actions: [ + if (defaultTargetPlatform != TargetPlatform.iOS) SemanticsAction.focus, + SemanticsAction.increase, SemanticsAction.decrease, + ], value: '50%', increasedValue: '60%', decreasedValue: '40%', diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 17e0fc368d6..5ccf40f6802 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -749,6 +749,7 @@ void main() { flags: [SemanticsFlag.isTextField, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled], actions: [ SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.didGainAccessibilityFocus, SemanticsAction.didLoseAccessibilityFocus, ], @@ -2042,6 +2043,7 @@ void main() { ], actions: [ SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.moveCursorBackwardByCharacter, SemanticsAction.setSelection, SemanticsAction.paste, @@ -5576,6 +5578,7 @@ void main() { value: 'some text', actions: [ SemanticsAction.tap, + SemanticsAction.focus, ], flags: [ SemanticsFlag.isTextField, @@ -8410,6 +8413,7 @@ void main() { textDirection: TextDirection.ltr, actions: [ SemanticsAction.tap, + SemanticsAction.focus, ], flags: [ SemanticsFlag.isTextField, @@ -8431,6 +8435,7 @@ void main() { value: 'Guten Tag', actions: [ SemanticsAction.tap, + SemanticsAction.focus, ], flags: [ SemanticsFlag.isTextField, @@ -8453,6 +8458,7 @@ void main() { textSelection: const TextSelection.collapsed(offset: 9), actions: [ SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.moveCursorBackwardByCharacter, SemanticsAction.moveCursorBackwardByWord, SemanticsAction.setSelection, @@ -8481,6 +8487,7 @@ void main() { value: 'Guten Tag', actions: [ SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.moveCursorBackwardByCharacter, SemanticsAction.moveCursorForwardByCharacter, SemanticsAction.moveCursorBackwardByWord, @@ -8512,6 +8519,7 @@ void main() { value: 'Schönen Feierabend', actions: [ SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.moveCursorForwardByCharacter, SemanticsAction.moveCursorForwardByWord, SemanticsAction.setSelection, @@ -8543,7 +8551,10 @@ void main() { expect( semantics, includesNodeWith( - actions: [SemanticsAction.tap], + actions: [ + SemanticsAction.tap, + SemanticsAction.focus, + ], textDirection: TextDirection.ltr, flags: [ SemanticsFlag.isTextField, @@ -8560,7 +8571,10 @@ void main() { expect( semantics, includesNodeWith( - actions: [SemanticsAction.tap], + actions: [ + SemanticsAction.tap, + SemanticsAction.focus, + ], textDirection: TextDirection.ltr, flags: [ SemanticsFlag.isTextField, @@ -8577,7 +8591,10 @@ void main() { expect( semantics, includesNodeWith( - actions: [SemanticsAction.tap], + actions: [ + SemanticsAction.tap, + SemanticsAction.focus, + ], textDirection: TextDirection.ltr, flags: [ SemanticsFlag.isTextField, @@ -8616,6 +8633,7 @@ void main() { textDirection: TextDirection.ltr, actions: [ SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.setText, // Absent the following because enableInteractiveSelection: false // SemanticsAction.moveCursorBackwardByCharacter, @@ -8659,6 +8677,7 @@ void main() { textDirection: TextDirection.ltr, actions: [ SemanticsAction.tap, + SemanticsAction.focus, ], flags: [ SemanticsFlag.isTextField, @@ -8682,6 +8701,7 @@ void main() { textDirection: TextDirection.ltr, actions: [ SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.moveCursorBackwardByCharacter, SemanticsAction.moveCursorBackwardByWord, SemanticsAction.setSelection, @@ -8710,6 +8730,7 @@ void main() { textDirection: TextDirection.ltr, actions: [ SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.moveCursorBackwardByCharacter, SemanticsAction.moveCursorForwardByCharacter, SemanticsAction.moveCursorBackwardByWord, @@ -8765,6 +8786,7 @@ void main() { textDirection: TextDirection.ltr, actions: [ SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.moveCursorBackwardByCharacter, SemanticsAction.moveCursorBackwardByWord, SemanticsAction.setSelection, @@ -8813,6 +8835,7 @@ void main() { textDirection: TextDirection.ltr, actions: [ SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.moveCursorBackwardByCharacter, SemanticsAction.moveCursorBackwardByWord, SemanticsAction.setSelection, @@ -8862,7 +8885,7 @@ void main() { TestSemantics( id: inputFieldId, flags: [SemanticsFlag.isTextField, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled], - actions: [SemanticsAction.tap], + actions: [SemanticsAction.tap, SemanticsAction.focus], value: textInTextField, textDirection: TextDirection.ltr, ), @@ -8887,6 +8910,7 @@ void main() { ], actions: [ SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.moveCursorBackwardByCharacter, SemanticsAction.moveCursorBackwardByWord, SemanticsAction.setSelection, @@ -8937,7 +8961,7 @@ void main() { TestSemantics( id: inputFieldId, flags: [SemanticsFlag.isTextField, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled], - actions: [SemanticsAction.tap], + actions: [SemanticsAction.tap, SemanticsAction.focus], value: textInTextField, textDirection: TextDirection.ltr, ), @@ -8962,6 +8986,7 @@ void main() { ], actions: [ SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.moveCursorBackwardByCharacter, SemanticsAction.moveCursorBackwardByWord, SemanticsAction.setSelection, @@ -9135,6 +9160,7 @@ void main() { textDirection: TextDirection.ltr, actions: [ SemanticsAction.tap, + SemanticsAction.focus, ], flags: [ SemanticsFlag.isTextField, @@ -9169,6 +9195,7 @@ void main() { textSelection: const TextSelection(baseOffset: 0, extentOffset: 0), actions: [ SemanticsAction.tap, + SemanticsAction.focus, SemanticsAction.setSelection, SemanticsAction.setText, SemanticsAction.paste, @@ -9231,6 +9258,7 @@ void main() { textDirection: TextDirection.ltr, actions: [ SemanticsAction.tap, + SemanticsAction.focus, ], flags: [ SemanticsFlag.isTextField, @@ -9280,6 +9308,7 @@ void main() { textDirection: TextDirection.ltr, actions: [ SemanticsAction.tap, + SemanticsAction.focus, ], flags: [ SemanticsFlag.isTextField, @@ -18392,8 +18421,7 @@ void main() { SemanticsAction.didGainAccessibilityFocus, if (defaultTargetPlatform == TargetPlatform.windows || defaultTargetPlatform == TargetPlatform.macOS || defaultTargetPlatform == TargetPlatform.linux) SemanticsAction.didLoseAccessibilityFocus, - // TODO(gspencergoog): also test for the presence of SemanticsAction.focus when - // this iOS issue is addressed: https://github.com/flutter/flutter/issues/150030 + SemanticsAction.focus ], ), ], diff --git a/packages/flutter/test/material/time_picker_test.dart b/packages/flutter/test/material/time_picker_test.dart index 1236c63fc11..0b23fa26ed1 100644 --- a/packages/flutter/test/material/time_picker_test.dart +++ b/packages/flutter/test/material/time_picker_test.dart @@ -1250,7 +1250,10 @@ void main() { semantics, includesNodeWith( label: amString, - actions: [SemanticsAction.tap, SemanticsAction.focus], + actions: [ + SemanticsAction.tap, + SemanticsAction.focus, + ], flags: [ SemanticsFlag.isButton, SemanticsFlag.isChecked, @@ -1264,7 +1267,10 @@ void main() { semantics, includesNodeWith( label: pmString, - actions: [SemanticsAction.tap, SemanticsAction.focus], + actions: [ + SemanticsAction.tap, + SemanticsAction.focus, + ], flags: [ SemanticsFlag.isButton, SemanticsFlag.isInMutuallyExclusiveGroup, @@ -1342,7 +1348,10 @@ void main() { includesNodeWith( label: 'Hour', value: '07', - actions: [SemanticsAction.tap], + actions: [ + SemanticsAction.tap, + SemanticsAction.focus, + ], flags: [ SemanticsFlag.isTextField, SemanticsFlag.hasEnabledState, @@ -1356,7 +1365,10 @@ void main() { includesNodeWith( label: 'Minute', value: '00', - actions: [SemanticsAction.tap], + actions: [ + SemanticsAction.tap, + SemanticsAction.focus, + ], flags: [ SemanticsFlag.isTextField, SemanticsFlag.hasEnabledState, diff --git a/packages/flutter/test/widgets/semantics_tester.dart b/packages/flutter/test/widgets/semantics_tester.dart index e71bb142d66..6eff2713067 100644 --- a/packages/flutter/test/widgets/semantics_tester.dart +++ b/packages/flutter/test/widgets/semantics_tester.dart @@ -269,10 +269,7 @@ class TestSemantics { final int actionsBitmask = actions is int ? actions as int : (actions as List).fold(0, (int bitmask, SemanticsAction action) => bitmask | action.index); - // TODO(gspencergoog): Remove focus filter once customer tests have been - // updated with the proper actions information for focus. - // https://github.com/flutter/flutter/issues/149842 - if ((actionsBitmask & ~SemanticsAction.focus.index) != (nodeData.actions & ~SemanticsAction.focus.index)) { + if (actionsBitmask != nodeData.actions) { return fail('expected node id $id to have actions $actions but found actions ${nodeData.actions}.'); } @@ -528,14 +525,8 @@ class SemanticsTester { } if (actions != null) { - // TODO(gspencergoog): Remove focus filter once customer tests have been - // updated with the proper actions information for focus. - // https://github.com/flutter/flutter/issues/149842 - final List nonFocusActions = actions.where( - (SemanticsAction action) => action != SemanticsAction.focus - ).toList(); - final int expectedActions = nonFocusActions.fold(0, (int value, SemanticsAction action) => value | action.index); - final int actualActions = node.getSemanticsData().actions & ~SemanticsAction.focus.index; + final int expectedActions = actions.fold(0, (int value, SemanticsAction action) => value | action.index); + final int actualActions = node.getSemanticsData().actions; if (expectedActions != actualActions) { return false; } @@ -657,14 +648,11 @@ class SemanticsTester { static String _actionsToSemanticsActionExpression(dynamic actions) { Iterable list; - // TODO(gspencergoog): Remove focus filter once customer tests have been - // updated with the proper actions information for focus. - // https://github.com/flutter/flutter/issues/149842 if (actions is int) { list = SemanticsAction.values - .where((SemanticsAction action) => action != SemanticsAction.focus && (action.index & actions) != 0); + .where((SemanticsAction action) => (action.index & actions) != 0); } else { - list = (actions as List).where((SemanticsAction action) => action != SemanticsAction.focus); + list = actions as List; } return '[${list.join(', ')}]'; } @@ -887,10 +875,7 @@ class _IncludesNodeWith extends Matcher { if (value != null) 'value "$value"', if (hint != null) 'hint "$hint"', if (textDirection != null) ' (${textDirection!.name})', - // TODO(gspencergoog): Remove focus filter once customer tests have been - // updated with the proper actions information for focus. - // https://github.com/flutter/flutter/issues/149842 - if (actions != null) 'actions "${actions!.where((SemanticsAction action) => action != SemanticsAction.focus).join(', ')}"', + if (actions != null) 'actions "${actions!.join(', ')}"', if (flags != null) 'flags "${flags!.join(', ')}"', if (tags != null) 'tags "${tags!.join(', ')}"', if (scrollPosition != null) 'scrollPosition "$scrollPosition"', diff --git a/packages/flutter_test/lib/src/matchers.dart b/packages/flutter_test/lib/src/matchers.dart index c9b9f0183d6..bd2ba099e39 100644 --- a/packages/flutter_test/lib/src/matchers.dart +++ b/packages/flutter_test/lib/src/matchers.dart @@ -2266,10 +2266,6 @@ class _MatchesSemanticsData extends Matcher { required bool? isExpanded, // Actions required bool? hasTapAction, - // TODO(gspencergoog): Once this has landed, and customer tests have been - // updated, remove the ignore below. - // https://github.com/flutter/flutter/issues/149842 - // ignore: avoid_unused_constructor_parameters required bool? hasFocusAction, required bool? hasLongPressAction, required bool? hasScrollLeftAction, @@ -2329,9 +2325,7 @@ class _MatchesSemanticsData extends Matcher { }, actions = { if (hasTapAction != null) SemanticsAction.tap: hasTapAction, - // TODO(gspencergoog): Once this has landed, and customer tests have - // been updated, add a line here that adds handling for - // hasFocusAction. https://github.com/flutter/flutter/issues/149842 + if (hasFocusAction != null) SemanticsAction.focus: hasFocusAction, if (hasLongPressAction != null) SemanticsAction.longPress: hasLongPressAction, if (hasScrollLeftAction != null) SemanticsAction.scrollLeft: hasScrollLeftAction, if (hasScrollRightAction != null) SemanticsAction.scrollRight: hasScrollRightAction, @@ -2429,19 +2423,12 @@ class _MatchesSemanticsData extends Matcher { if (tooltip != null) { description.add(' with tooltip: $tooltip'); } - // TODO(gspencergoog): Remove filter once customer tests have been updated - // with the proper actions information for focus. - // https://github.com/flutter/flutter/issues/149842 - final Map nonFocusActions = - Map.fromEntries(actions.entries.where( - (MapEntry e) => e.key != SemanticsAction.focus - )); - if (nonFocusActions.isNotEmpty) { - final List expectedActions = nonFocusActions.entries + if (actions.isNotEmpty) { + final List expectedActions = actions.entries .where((MapEntry e) => e.value) .map((MapEntry e) => e.key) .toList(); - final List notExpectedActions = nonFocusActions.entries + final List notExpectedActions = actions.entries .where((MapEntry e) => !e.value) .map((MapEntry e) => e.key) .toList(); @@ -2620,17 +2607,10 @@ class _MatchesSemanticsData extends Matcher { if (maxValueLength != null && maxValueLength != data.maxValueLength) { return failWithDescription(matchState, 'maxValueLength was: ${data.maxValueLength}'); } - // TODO(gspencergoog): Remove filter once customer tests have been updated - // with the proper actions information for focus. - // https://github.com/flutter/flutter/issues/149842 - final Map nonFocusActions = - Map.fromEntries(actions.entries.where( - (MapEntry e) => e.key != SemanticsAction.focus - )); - if (nonFocusActions.isNotEmpty) { + if (actions.isNotEmpty) { final List unexpectedActions = []; final List missingActions = []; - for (final MapEntry actionEntry in nonFocusActions.entries) { + for (final MapEntry actionEntry in actions.entries) { final ui.SemanticsAction action = actionEntry.key; final bool actionExpected = actionEntry.value; final bool actionPresent = (action.index & data.actions) == action.index;