From cd0aa2b537db5ddc181b504733147b95a052a4ff Mon Sep 17 00:00:00 2001 From: Yegor Date: Fri, 18 Oct 2024 15:37:51 -0700 Subject: [PATCH] all selectable widgets set the hasSelectedState flag (#157191) Set the `hasSelectedState` flag in all selectable widgets. This happens automatically because only selectable widgets have `Semantics.selected` set to a non-null value. When the value is propagated to `SemanticsConfiguration.isSelected`, it sets both `hasSelectedState` to true and `isSelected` as appropriate. More progress towards https://github.com/flutter/flutter/issues/66673 --- .../flutter/lib/src/semantics/semantics.dart | 1 + .../test/cupertino/bottom_tab_bar_test.dart | 2 +- .../flutter/test/cupertino/radio_test.dart | 1 + .../cupertino/segmented_control_test.dart | 6 +++++ .../sliding_segmented_control_test.dart | 6 +++++ .../material/bottom_navigation_bar_test.dart | 4 ++- packages/flutter/test/material/chip_test.dart | 13 +++++++++- .../test/material/icon_button_test.dart | 1 + .../flutter/test/material/list_tile_test.dart | 6 ++++- .../test/material/navigation_rail_test.dart | 7 +++--- .../test/material/radio_list_tile_test.dart | 4 +++ .../flutter/test/material/radio_test.dart | 1 + .../test/material/switch_list_tile_test.dart | 3 +++ packages/flutter/test/material/tabs_test.dart | 25 +++++++++++++++---- .../test/semantics/semantics_test.dart | 9 +++++-- .../test/widgets/custom_painter_test.dart | 16 ++++++------ .../test/widgets/implicit_semantics_test.dart | 6 ++--- .../test/widgets/semantics_1_test.dart | 14 +++++------ .../test/widgets/semantics_2_test.dart | 10 ++++---- .../test/widgets/semantics_merge_test.dart | 1 + .../flutter/test/widgets/semantics_test.dart | 6 +---- ...ssion_for_current_semantics_tree_test.dart | 2 +- .../semantics_zero_surface_size_test.dart | 2 +- 23 files changed, 103 insertions(+), 43 deletions(-) diff --git a/packages/flutter/lib/src/semantics/semantics.dart b/packages/flutter/lib/src/semantics/semantics.dart index 00729829fba..1934aa2b80c 100644 --- a/packages/flutter/lib/src/semantics/semantics.dart +++ b/packages/flutter/lib/src/semantics/semantics.dart @@ -4672,6 +4672,7 @@ class SemanticsConfiguration { /// in which case it will not be flagged as selected. bool get isSelected => _hasFlag(SemanticsFlag.isSelected); set isSelected(bool value) { + _setFlag(SemanticsFlag.hasSelectedState, true); _setFlag(SemanticsFlag.isSelected, value); } diff --git a/packages/flutter/test/cupertino/bottom_tab_bar_test.dart b/packages/flutter/test/cupertino/bottom_tab_bar_test.dart index 04576a904d6..d704a91fb46 100644 --- a/packages/flutter/test/cupertino/bottom_tab_bar_test.dart +++ b/packages/flutter/test/cupertino/bottom_tab_bar_test.dart @@ -513,7 +513,7 @@ Future main() async { expect(semantics, includesNodeWith( label: 'Tab 1', hint: 'Tab 1 of 2', - flags: [SemanticsFlag.isSelected], + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], textDirection: TextDirection.ltr, )); diff --git a/packages/flutter/test/cupertino/radio_test.dart b/packages/flutter/test/cupertino/radio_test.dart index 8692250634a..77059ba4390 100644 --- a/packages/flutter/test/cupertino/radio_test.dart +++ b/packages/flutter/test/cupertino/radio_test.dart @@ -150,6 +150,7 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isChecked, + if (isApple) SemanticsFlag.hasSelectedState, if (isApple) SemanticsFlag.isSelected, ], actions: [ diff --git a/packages/flutter/test/cupertino/segmented_control_test.dart b/packages/flutter/test/cupertino/segmented_control_test.dart index ebcdfbd156d..b19c9590f05 100644 --- a/packages/flutter/test/cupertino/segmented_control_test.dart +++ b/packages/flutter/test/cupertino/segmented_control_test.dart @@ -829,6 +829,7 @@ void main() { flags: [ SemanticsFlag.isButton, SemanticsFlag.isInMutuallyExclusiveGroup, + SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected, ], actions: [ @@ -840,6 +841,8 @@ void main() { flags: [ SemanticsFlag.isButton, SemanticsFlag.isInMutuallyExclusiveGroup, + // Declares that it is selectable, but not currently selected. + SemanticsFlag.hasSelectedState, ], actions: [ SemanticsAction.tap, @@ -866,6 +869,8 @@ void main() { flags: [ SemanticsFlag.isButton, SemanticsFlag.isInMutuallyExclusiveGroup, + // Declares that it is selectable, but not currently selected. + SemanticsFlag.hasSelectedState, ], actions: [ SemanticsAction.tap, @@ -876,6 +881,7 @@ void main() { flags: [ SemanticsFlag.isButton, SemanticsFlag.isInMutuallyExclusiveGroup, + SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected, ], actions: [ diff --git a/packages/flutter/test/cupertino/sliding_segmented_control_test.dart b/packages/flutter/test/cupertino/sliding_segmented_control_test.dart index c944406bacc..98a02195602 100644 --- a/packages/flutter/test/cupertino/sliding_segmented_control_test.dart +++ b/packages/flutter/test/cupertino/sliding_segmented_control_test.dart @@ -960,6 +960,7 @@ void main() { flags: [ SemanticsFlag.isButton, SemanticsFlag.isInMutuallyExclusiveGroup, + SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected, ], actions: [ @@ -971,6 +972,8 @@ void main() { flags: [ SemanticsFlag.isButton, SemanticsFlag.isInMutuallyExclusiveGroup, + // Declares that it is selectable, but not currently selected. + SemanticsFlag.hasSelectedState, ], actions: [ SemanticsAction.tap, @@ -997,6 +1000,8 @@ void main() { flags: [ SemanticsFlag.isButton, SemanticsFlag.isInMutuallyExclusiveGroup, + // Declares that it is selectable, but not currently selected. + SemanticsFlag.hasSelectedState, ], actions: [ SemanticsAction.tap, @@ -1007,6 +1012,7 @@ void main() { flags: [ SemanticsFlag.isButton, SemanticsFlag.isInMutuallyExclusiveGroup, + SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected, ], actions: [ diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index ea256354576..3017fae23f6 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -2765,8 +2765,9 @@ void main() { TestSemantics( flags: [ SemanticsFlag.isButton, - SemanticsFlag.isSelected, SemanticsFlag.isFocusable, + SemanticsFlag.hasSelectedState, + SemanticsFlag.isSelected, ], actions: [SemanticsAction.tap, SemanticsAction.focus], label: 'A\nTab 1 of 2', @@ -2776,6 +2777,7 @@ void main() { flags: [ SemanticsFlag.isButton, SemanticsFlag.isFocusable, + SemanticsFlag.hasSelectedState, ], actions: [SemanticsAction.tap, SemanticsAction.focus], label: 'B\nTab 2 of 2', diff --git a/packages/flutter/test/material/chip_test.dart b/packages/flutter/test/material/chip_test.dart index ace23b44b7f..7342eec9ed3 100644 --- a/packages/flutter/test/material/chip_test.dart +++ b/packages/flutter/test/material/chip_test.dart @@ -2839,6 +2839,7 @@ void main() { label: 'test', textDirection: TextDirection.ltr, flags: [ + SemanticsFlag.hasSelectedState, SemanticsFlag.hasEnabledState, SemanticsFlag.isButton, ], @@ -2888,6 +2889,7 @@ void main() { label: 'test', textDirection: TextDirection.ltr, flags: [ + SemanticsFlag.hasSelectedState, SemanticsFlag.hasEnabledState, SemanticsFlag.isButton, ], @@ -2948,6 +2950,7 @@ void main() { label: 'test', textDirection: TextDirection.ltr, flags: [ + SemanticsFlag.hasSelectedState, SemanticsFlag.hasEnabledState, SemanticsFlag.isButton, SemanticsFlag.isEnabled, @@ -3006,6 +3009,7 @@ void main() { label: 'test', textDirection: TextDirection.ltr, flags: [ + SemanticsFlag.hasSelectedState, SemanticsFlag.hasEnabledState, SemanticsFlag.isButton, SemanticsFlag.isEnabled, @@ -3062,6 +3066,7 @@ void main() { SemanticsFlag.isButton, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, + SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected, ], actions: [SemanticsAction.tap, SemanticsAction.focus], @@ -3113,6 +3118,7 @@ void main() { label: 'test', textDirection: TextDirection.ltr, flags: [ + SemanticsFlag.hasSelectedState, SemanticsFlag.hasEnabledState, SemanticsFlag.isButton, ], @@ -3163,7 +3169,10 @@ void main() { TestSemantics( label: 'test', textDirection: TextDirection.ltr, - flags: [], // Must not be a button when tapping is disabled. + // Must not be a button when tapping is disabled. + flags: [ + SemanticsFlag.hasSelectedState + ], actions: [], ), ], @@ -3213,6 +3222,7 @@ void main() { label: 'test', textDirection: TextDirection.ltr, flags: [ + SemanticsFlag.hasSelectedState, SemanticsFlag.hasEnabledState, SemanticsFlag.isButton, SemanticsFlag.isEnabled, @@ -3265,6 +3275,7 @@ void main() { label: 'test', textDirection: TextDirection.ltr, flags: [ + SemanticsFlag.hasSelectedState, SemanticsFlag.hasEnabledState, SemanticsFlag.isButton, ], diff --git a/packages/flutter/test/material/icon_button_test.dart b/packages/flutter/test/material/icon_button_test.dart index 2088ccfb723..6f2f695cfe7 100644 --- a/packages/flutter/test/material/icon_button_test.dart +++ b/packages/flutter/test/material/icon_button_test.dart @@ -703,6 +703,7 @@ void main() { SemanticsFlag.isButton, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, + SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected, ], label: 'link', diff --git a/packages/flutter/test/material/list_tile_test.dart b/packages/flutter/test/material/list_tile_test.dart index efed1ee18ee..1c0780411f5 100644 --- a/packages/flutter/test/material/list_tile_test.dart +++ b/packages/flutter/test/material/list_tile_test.dart @@ -299,6 +299,7 @@ void main() { flags: [ SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, + SemanticsFlag.hasSelectedState, ], label: 'one', ), @@ -308,21 +309,24 @@ void main() { SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, + SemanticsFlag.hasSelectedState, ], actions: [SemanticsAction.tap, SemanticsAction.focus], label: 'two', ), TestSemantics.rootChild( flags: [ - SemanticsFlag.isSelected, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, + SemanticsFlag.hasSelectedState, + SemanticsFlag.isSelected, ], label: 'three', ), TestSemantics.rootChild( flags: [ SemanticsFlag.hasEnabledState, + SemanticsFlag.hasSelectedState, ], label: 'four', ), diff --git a/packages/flutter/test/material/navigation_rail_test.dart b/packages/flutter/test/material/navigation_rail_test.dart index 87a9040ba29..8a5582baf51 100644 --- a/packages/flutter/test/material/navigation_rail_test.dart +++ b/packages/flutter/test/material/navigation_rail_test.dart @@ -5999,6 +5999,7 @@ TestSemantics _expectedSemantics() { children: [ TestSemantics( flags: [ + SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected, SemanticsFlag.isFocusable, ], @@ -6007,19 +6008,19 @@ TestSemantics _expectedSemantics() { textDirection: TextDirection.ltr, ), TestSemantics( - flags: [SemanticsFlag.isFocusable], + flags: [SemanticsFlag.isFocusable, SemanticsFlag.hasSelectedState], actions: [SemanticsAction.tap, SemanticsAction.focus], label: 'Def\nTab 2 of 4', textDirection: TextDirection.ltr, ), TestSemantics( - flags: [SemanticsFlag.isFocusable], + flags: [SemanticsFlag.isFocusable, SemanticsFlag.hasSelectedState], actions: [SemanticsAction.tap, SemanticsAction.focus], label: 'Ghi\nTab 3 of 4', textDirection: TextDirection.ltr, ), TestSemantics( - flags: [SemanticsFlag.isFocusable], + flags: [SemanticsFlag.isFocusable, SemanticsFlag.hasSelectedState], actions: [SemanticsAction.tap, SemanticsAction.focus], label: 'Jkl\nTab 4 of 4', textDirection: TextDirection.ltr, diff --git a/packages/flutter/test/material/radio_list_tile_test.dart b/packages/flutter/test/material/radio_list_tile_test.dart index 92e14dec3b7..30845f1e7db 100644 --- a/packages/flutter/test/material/radio_list_tile_test.dart +++ b/packages/flutter/test/material/radio_list_tile_test.dart @@ -412,6 +412,7 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isInMutuallyExclusiveGroup, SemanticsFlag.isFocusable, + SemanticsFlag.hasSelectedState, ], actions: [SemanticsAction.tap, SemanticsAction.focus], label: 'Title', @@ -451,6 +452,7 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isInMutuallyExclusiveGroup, SemanticsFlag.isFocusable, + SemanticsFlag.hasSelectedState, ], actions: [SemanticsAction.tap, SemanticsAction.focus], label: 'Title', @@ -487,6 +489,7 @@ void main() { SemanticsFlag.hasEnabledState, SemanticsFlag.isInMutuallyExclusiveGroup, SemanticsFlag.isFocusable, + SemanticsFlag.hasSelectedState, ], actions: [SemanticsAction.focus], label: 'Title', @@ -524,6 +527,7 @@ void main() { SemanticsFlag.isChecked, SemanticsFlag.hasEnabledState, SemanticsFlag.isInMutuallyExclusiveGroup, + SemanticsFlag.hasSelectedState, ], label: 'Title', textDirection: TextDirection.ltr, diff --git a/packages/flutter/test/material/radio_test.dart b/packages/flutter/test/material/radio_test.dart index c3ede77683a..948c5405dd6 100644 --- a/packages/flutter/test/material/radio_test.dart +++ b/packages/flutter/test/material/radio_test.dart @@ -217,6 +217,7 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isChecked, + if (isCupertino) SemanticsFlag.hasSelectedState, if (isCupertino) SemanticsFlag.isSelected, ], actions: [ diff --git a/packages/flutter/test/material/switch_list_tile_test.dart b/packages/flutter/test/material/switch_list_tile_test.dart index 985270cb6d8..29bed2d2531 100644 --- a/packages/flutter/test/material/switch_list_tile_test.dart +++ b/packages/flutter/test/material/switch_list_tile_test.dart @@ -81,6 +81,7 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isToggled, + SemanticsFlag.hasSelectedState, ], actions: SemanticsAction.tap.index | SemanticsAction.focus.index, label: 'aaa\nAAA', @@ -96,6 +97,7 @@ void main() { SemanticsFlag.isChecked, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, + SemanticsFlag.hasSelectedState, ], actions: SemanticsAction.tap.index | SemanticsAction.focus.index, label: 'bbb\nBBB', @@ -111,6 +113,7 @@ void main() { SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isInMutuallyExclusiveGroup, + SemanticsFlag.hasSelectedState, ], actions: SemanticsAction.tap.index | SemanticsAction.focus.index, label: 'CCC\nccc', diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 8ed9b9114c9..8342ccdaad8 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -3615,6 +3615,7 @@ void main() { id: 4, actions: [SemanticsAction.tap, SemanticsAction.focus], flags: [ + SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected, SemanticsFlag.isFocusable, ], @@ -3624,7 +3625,10 @@ void main() { ), TestSemantics( id: 5, - flags: [SemanticsFlag.isFocusable], + flags: [ + SemanticsFlag.hasSelectedState, + SemanticsFlag.isFocusable, + ], actions: [SemanticsAction.tap, SemanticsAction.focus], label: 'TAB #1\nTab 2 of 2', rect: const Rect.fromLTRB(0.0, 0.0, 116.0, kTextTabBarHeight), @@ -3672,7 +3676,7 @@ void main() { const String tab0title = 'This is a very wide tab #0\nTab 1 of 20'; const String tab10title = 'This is a very wide tab #10\nTab 11 of 20'; - const List hiddenFlags = [SemanticsFlag.isHidden, SemanticsFlag.isFocusable]; + const List hiddenFlags = [SemanticsFlag.isHidden, SemanticsFlag.isFocusable, SemanticsFlag.hasSelectedState]; expect(semantics, includesNodeWith(actions: [SemanticsAction.scrollLeft])); expect(semantics, includesNodeWith(label: tab0title)); expect(semantics, includesNodeWith(label: tab10title, flags: hiddenFlags)); @@ -3881,6 +3885,7 @@ void main() { TestSemantics( id: 4, flags: [ + SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected, SemanticsFlag.isFocusable, ], @@ -3891,7 +3896,10 @@ void main() { ), TestSemantics( id: 5, - flags: [SemanticsFlag.isFocusable], + flags: [ + SemanticsFlag.hasSelectedState, + SemanticsFlag.isFocusable, + ], actions: [SemanticsAction.tap, SemanticsAction.focus], label: 'Semantics override 1\nTab 2 of 2', rect: const Rect.fromLTRB(0.0, 0.0, 116.0, kTextTabBarHeight), @@ -5670,14 +5678,21 @@ void main() { children: [ TestSemantics( label: 'TAB1\nTab 1 of 2', - flags: [SemanticsFlag.isFocusable, SemanticsFlag.isSelected], + flags: [ + SemanticsFlag.isFocusable, + SemanticsFlag.isSelected, + SemanticsFlag.hasSelectedState, + ], id: 2, rect: TestSemantics.fullScreen, actions: 1 | SemanticsAction.focus.index, ), TestSemantics( label: 'TAB2\nTab 2 of 2', - flags: [SemanticsFlag.isFocusable], + flags: [ + SemanticsFlag.isFocusable, + SemanticsFlag.hasSelectedState, + ], id: 3, rect: TestSemantics.fullScreen, actions: [SemanticsAction.tap, SemanticsAction.focus], diff --git a/packages/flutter/test/semantics/semantics_test.dart b/packages/flutter/test/semantics/semantics_test.dart index 3936342b280..c1e5976f00b 100644 --- a/packages/flutter/test/semantics/semantics_test.dart +++ b/packages/flutter/test/semantics/semantics_test.dart @@ -730,7 +730,7 @@ void main() { ' merge boundary ⛔️\n' ' Rect.fromLTRB(60.0, 20.0, 80.0, 50.0)\n' ' actions: longPress, scrollUp, showOnScreen\n' - ' flags: hasCheckedState, isSelected, isButton\n' + ' flags: hasCheckedState, hasSelectedState, isSelected, isButton\n' ' label: "Use all the properties"\n' ' textDirection: rtl\n' ' sortKey: OrdinalSortKey#19df5(order: 1.0)\n', @@ -738,7 +738,12 @@ void main() { ); expect( allProperties.getSemanticsData().toString(), - 'SemanticsData(Rect.fromLTRB(50.0, 10.0, 70.0, 40.0), [1.0,0.0,0.0,10.0; 0.0,1.0,0.0,10.0; 0.0,0.0,1.0,0.0; 0.0,0.0,0.0,1.0], actions: [longPress, scrollUp, showOnScreen], flags: [hasCheckedState, isSelected, isButton], label: "Use all the properties", textDirection: rtl)', + 'SemanticsData(' + 'Rect.fromLTRB(50.0, 10.0, 70.0, 40.0), ' + '[1.0,0.0,0.0,10.0; 0.0,1.0,0.0,10.0; 0.0,0.0,1.0,0.0; 0.0,0.0,0.0,1.0], ' + 'actions: [longPress, scrollUp, showOnScreen], ' + 'flags: [hasCheckedState, hasSelectedState, isSelected, isButton], ' + 'label: "Use all the properties", textDirection: rtl)', ); final SemanticsNode scaled = SemanticsNode() diff --git a/packages/flutter/test/widgets/custom_painter_test.dart b/packages/flutter/test/widgets/custom_painter_test.dart index 24928eb24db..af165401282 100644 --- a/packages/flutter/test/widgets/custom_painter_test.dart +++ b/packages/flutter/test/widgets/custom_painter_test.dart @@ -200,7 +200,7 @@ void _defineTests() { TestSemantics( rect: const Rect.fromLTRB(1.0, 2.0, 3.0, 4.0), id: 2, - flags: 1, + flags: [SemanticsFlag.hasCheckedState, SemanticsFlag.hasSelectedState], label: 'label-before', value: 'value-before', increasedValue: 'increase-before', @@ -253,7 +253,13 @@ void _defineTests() { rect: const Rect.fromLTRB(5.0, 6.0, 7.0, 8.0), actions: 255, id: 2, - flags: 15, + flags: [ + SemanticsFlag.hasCheckedState, + SemanticsFlag.isChecked, + SemanticsFlag.hasSelectedState, + SemanticsFlag.isSelected, + SemanticsFlag.isButton, + ], label: 'label-after', value: 'value-after', increasedValue: 'increase-after', @@ -524,11 +530,7 @@ void _defineTests() { ); expect(semantics, hasSemantics(expectedSemantics, ignoreRect: true, ignoreTransform: true)); semantics.dispose(); - }, skip: true); // TODO(yjbanov): https://github.com/flutter/flutter/issues/66673 - // Skipped temporarily to allow https://github.com/flutter/engine/pull/55780 - // to roll into the framework, which introduces a new flag. Because this - // test enumerates all flags, the new flag breaks it. This test will need - // to be updated after the roll. + }); group('diffing', () { testWidgets('complains about duplicate keys', (WidgetTester tester) async { diff --git a/packages/flutter/test/widgets/implicit_semantics_test.dart b/packages/flutter/test/widgets/implicit_semantics_test.dart index 42ef7922353..7acbad48df7 100644 --- a/packages/flutter/test/widgets/implicit_semantics_test.dart +++ b/packages/flutter/test/widgets/implicit_semantics_test.dart @@ -227,17 +227,17 @@ void main() { children: [ TestSemantics( id: 2, - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], label: 'node 1', ), TestSemantics( id: 3, - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], label: 'node 2', ), TestSemantics( id: 4, - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], label: 'node 3', ), ], diff --git a/packages/flutter/test/widgets/semantics_1_test.dart b/packages/flutter/test/widgets/semantics_1_test.dart index 7d475627942..1a28950d12f 100644 --- a/packages/flutter/test/widgets/semantics_1_test.dart +++ b/packages/flutter/test/widgets/semantics_1_test.dart @@ -31,7 +31,7 @@ void main() { id: 1, label: 'test1', rect: TestSemantics.fullScreen, - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], ), ], ))); @@ -72,7 +72,7 @@ void main() { id: 1, label: 'child1', rect: TestSemantics.fullScreen, - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], ), ], ))); @@ -118,13 +118,13 @@ void main() { id: 2, label: 'child1', rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], ), TestSemantics( id: 3, label: 'child2', rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], ), ], ), @@ -167,7 +167,7 @@ void main() { id: 1, label: 'child1', rect: TestSemantics.fullScreen, - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], ), ], ))); @@ -213,13 +213,13 @@ void main() { id: 4, label: 'child1', rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], ), TestSemantics( id: 3, label: 'child2', rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], ), ], ), diff --git a/packages/flutter/test/widgets/semantics_2_test.dart b/packages/flutter/test/widgets/semantics_2_test.dart index 2a0c69bf357..f65001b43b6 100644 --- a/packages/flutter/test/widgets/semantics_2_test.dart +++ b/packages/flutter/test/widgets/semantics_2_test.dart @@ -57,13 +57,13 @@ void main() { id: 2, label: 'child1', rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], ), TestSemantics( id: 3, label: 'child2', rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], ), ], ), @@ -106,7 +106,7 @@ void main() { id: 1, label: 'child1', rect: TestSemantics.fullScreen, - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], ), ], ))); @@ -152,13 +152,13 @@ void main() { id: 4, label: 'child1', rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], ), TestSemantics( id: 3, label: 'child2', rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), - flags: SemanticsFlag.isSelected.index, + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], ), ], ), diff --git a/packages/flutter/test/widgets/semantics_merge_test.dart b/packages/flutter/test/widgets/semantics_merge_test.dart index a4a997d37b9..10946785987 100644 --- a/packages/flutter/test/widgets/semantics_merge_test.dart +++ b/packages/flutter/test/widgets/semantics_merge_test.dart @@ -152,6 +152,7 @@ void main() { TestSemantics.rootChild( id: 1, flags: [ + SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected, ], label: 'test1\ntest2', diff --git a/packages/flutter/test/widgets/semantics_test.dart b/packages/flutter/test/widgets/semantics_test.dart index 29ca3b20bf7..8b0d18375f2 100644 --- a/packages/flutter/test/widgets/semantics_test.dart +++ b/packages/flutter/test/widgets/semantics_test.dart @@ -710,11 +710,7 @@ void main() { ], ); expect(semantics, hasSemantics(expectedSemantics, ignoreId: true)); - }, skip: true); // TODO(yjbanov): https://github.com/flutter/flutter/issues/66673 - // Skipped temporarily to allow https://github.com/flutter/engine/pull/55780 - // to roll into the framework, which introduces a new flag. Because this - // test enumerates all flags, the new flag breaks it. This test will need - // to be updated after the roll. + }); testWidgets('Actions can be replaced without triggering semantics update', (WidgetTester tester) async { final SemanticsTester semantics = SemanticsTester(tester); diff --git a/packages/flutter/test/widgets/semantics_tester_generate_test_semantics_expression_for_current_semantics_tree_test.dart b/packages/flutter/test/widgets/semantics_tester_generate_test_semantics_expression_for_current_semantics_tree_test.dart index 1f7aec466cf..5349eef02ce 100644 --- a/packages/flutter/test/widgets/semantics_tester_generate_test_semantics_expression_for_current_semantics_tree_test.dart +++ b/packages/flutter/test/widgets/semantics_tester_generate_test_semantics_expression_for_current_semantics_tree_test.dart @@ -132,7 +132,7 @@ void _tests() { TestSemantics( id: 6, tags: [const SemanticsTag('RenderViewport.twoPane')], - flags: [SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, SemanticsFlag.isSelected], + flags: [SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], actions: [SemanticsAction.tap, SemanticsAction.decrease], label: '\u202aInteractive text\u202c', value: 'test-value', diff --git a/packages/flutter/test/widgets/semantics_zero_surface_size_test.dart b/packages/flutter/test/widgets/semantics_zero_surface_size_test.dart index 07c58cdafa4..2917a8fe354 100644 --- a/packages/flutter/test/widgets/semantics_zero_surface_size_test.dart +++ b/packages/flutter/test/widgets/semantics_zero_surface_size_test.dart @@ -24,7 +24,7 @@ void main() { TestSemantics( id: 1, rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), - flags: [SemanticsFlag.isSelected], + flags: [SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected], ), ], ), ignoreTransform: true,