Skip to content

Commit c082abe

Browse files
authored
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 flutter/flutter#149842 ## Related PRs - flutter/flutter#149840 ## Tests - Updates semantics tests to actually look for the focus action.
1 parent f2be126 commit c082abe

16 files changed

+122
-82
lines changed

packages/flutter/test/cupertino/button_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ void main() {
296296
TestSemantics.root(
297297
children: <TestSemantics>[
298298
TestSemantics.rootChild(
299-
actions: SemanticsAction.tap.index,
299+
actions: SemanticsAction.tap.index | SemanticsAction.focus.index,
300300
label: 'ABC',
301301
flags: <SemanticsFlag>[
302302
SemanticsFlag.isButton,

packages/flutter/test/cupertino/checkbox_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void main() {
251251
SemanticsFlag.isFocusable,
252252
SemanticsFlag.isCheckStateMixed,
253253
],
254-
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
254+
actions: <SemanticsAction>[SemanticsAction.focus, SemanticsAction.tap],
255255
), hasLength(1));
256256

257257
await tester.pumpWidget(

packages/flutter/test/cupertino/radio_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void main() {
148148
],
149149
actions: <SemanticsAction>[
150150
SemanticsAction.tap,
151-
SemanticsAction.focus,
151+
if (defaultTargetPlatform != TargetPlatform.iOS) SemanticsAction.focus,
152152
],
153153
),
154154
);

packages/flutter/test/cupertino/text_field_test.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,11 @@ void main() {
534534
SemanticsFlag.hasEnabledState,
535535
SemanticsFlag.isEnabled,
536536
],
537-
actions: <SemanticsAction>[SemanticsAction.tap,
538-
SemanticsAction.didGainAccessibilityFocus,],
537+
actions: <SemanticsAction>[
538+
SemanticsAction.tap,
539+
SemanticsAction.focus,
540+
SemanticsAction.didGainAccessibilityFocus,
541+
],
539542
textDirection: TextDirection.ltr,
540543
),
541544
],
@@ -7971,6 +7974,7 @@ void main() {
79717974
isEnabled: true,
79727975
hasEnabledState: true,
79737976
hasTapAction: true,
7977+
hasFocusAction: true,
79747978
),
79757979
);
79767980
});
@@ -10313,6 +10317,7 @@ void main() {
1031310317
],
1031410318
actions: <SemanticsAction>[
1031510319
SemanticsAction.tap,
10320+
SemanticsAction.focus,
1031610321
if (defaultTargetPlatform == TargetPlatform.windows || defaultTargetPlatform == TargetPlatform.macOS)
1031710322
SemanticsAction.didGainAccessibilityFocus,
1031810323
// TODO(gspencergoog): also test for the presence of SemanticsAction.focus when

packages/flutter/test/material/back_button_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ void main() {
215215
hasEnabledState: true,
216216
isEnabled: true,
217217
hasTapAction: true,
218-
hasFocusAction: true,
218+
hasFocusAction: defaultTargetPlatform != TargetPlatform.iOS,
219219
isFocusable: true,
220220
));
221221
handle.dispose();
@@ -259,7 +259,7 @@ void main() {
259259
hasEnabledState: true,
260260
isEnabled: true,
261261
hasTapAction: true,
262-
hasFocusAction: true,
262+
hasFocusAction: defaultTargetPlatform != TargetPlatform.iOS,
263263
isFocusable: true,
264264
));
265265
handle.dispose();

packages/flutter/test/material/checkbox_test.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,10 @@ void main() {
322322
SemanticsFlag.isFocusable,
323323
SemanticsFlag.isCheckStateMixed,
324324
],
325-
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
325+
actions: <SemanticsAction>[
326+
SemanticsAction.tap,
327+
SemanticsAction.focus,
328+
],
326329
), hasLength(1));
327330

328331
await tester.pumpWidget(
@@ -346,7 +349,10 @@ void main() {
346349
SemanticsFlag.isChecked,
347350
SemanticsFlag.isFocusable,
348351
],
349-
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
352+
actions: <SemanticsAction>[
353+
SemanticsAction.tap,
354+
SemanticsAction.focus,
355+
],
350356
), hasLength(1));
351357

352358
await tester.pumpWidget(
@@ -369,7 +375,10 @@ void main() {
369375
SemanticsFlag.isEnabled,
370376
SemanticsFlag.isFocusable,
371377
],
372-
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
378+
actions: <SemanticsAction>[
379+
SemanticsAction.tap,
380+
SemanticsAction.focus,
381+
],
373382
), hasLength(1));
374383

375384
semantics.dispose();

packages/flutter/test/material/date_picker_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,7 @@ void main() {
16211621
isFocused: true,
16221622
value: '01/15/2016',
16231623
hasTapAction: true,
1624+
hasFocusAction: true,
16241625
hasSetTextAction: true,
16251626
hasSetSelectionAction: true,
16261627
hasCopyAction: true,

packages/flutter/test/material/drawer_button_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ void main() {
182182
hasEnabledState: true,
183183
isEnabled: true,
184184
hasTapAction: true,
185-
hasFocusAction: true,
185+
hasFocusAction: defaultTargetPlatform != TargetPlatform.iOS,
186186
isFocusable: true,
187187
));
188188
handle.dispose();
@@ -240,7 +240,7 @@ void main() {
240240
hasEnabledState: true,
241241
isEnabled: true,
242242
hasTapAction: true,
243-
hasFocusAction: true,
243+
hasFocusAction: defaultTargetPlatform != TargetPlatform.iOS,
244244
isFocusable: true,
245245
));
246246
handle.dispose();

packages/flutter/test/material/input_date_picker_form_field_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ void main() {
284284
isFocused: true,
285285
value: '01/15/2016',
286286
hasTapAction: true,
287+
hasFocusAction: true,
287288
hasSetTextAction: true,
288289
hasSetSelectionAction: true,
289290
hasCopyAction: true,

packages/flutter/test/material/radio_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ void main() {
205205
),
206206
),
207207
));
208-
final bool isApple = defaultTargetPlatform == TargetPlatform.iOS ||
208+
final bool isCupertino = defaultTargetPlatform == TargetPlatform.iOS ||
209209
defaultTargetPlatform == TargetPlatform.macOS;
210210
expect(
211211
semantics,
@@ -217,11 +217,11 @@ void main() {
217217
SemanticsFlag.isEnabled,
218218
SemanticsFlag.isFocusable,
219219
SemanticsFlag.isChecked,
220-
if (isApple) SemanticsFlag.isSelected,
220+
if (isCupertino) SemanticsFlag.isSelected,
221221
],
222222
actions: <SemanticsAction>[
223223
SemanticsAction.tap,
224-
SemanticsAction.focus,
224+
if (defaultTargetPlatform != TargetPlatform.iOS) SemanticsAction.focus,
225225
],
226226
),
227227
);

0 commit comments

Comments
 (0)