From b5262f0d80eb6da1b1cd6ceff0943367fbc29331 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20S=20Guerrero?= Date: Wed, 24 Jan 2024 08:13:26 -0800 Subject: [PATCH] Revert "[web] - Fix broken `TextField` in semantics mode when it's a sibling of `Navigator`" (#142129) Reverts flutter/flutter#138446 b/322136071 --- .../flutter/lib/src/widgets/navigator.dart | 15 +- .../test/cupertino/action_sheet_test.dart | 102 +++--- .../test/cupertino/date_picker_test.dart | 2 +- .../flutter/test/cupertino/dialog_test.dart | 42 ++- .../test/cupertino/text_field_test.dart | 19 +- .../flutter/test/material/app_bar_test.dart | 192 +++++------- .../material/bottom_navigation_bar_test.dart | 30 +- .../test/material/bottom_sheet_test.dart | 140 ++++----- packages/flutter/test/material/chip_test.dart | 178 +++++------ .../flutter/test/material/dialog_test.dart | 80 +++-- .../flutter/test/material/dropdown_test.dart | 87 +++--- .../material/flexible_space_bar_test.dart | 257 ++++++++------- .../material/floating_action_button_test.dart | 26 +- .../test/material/icon_button_test.dart | 26 +- .../test/material/menu_anchor_test.dart | 80 ++--- .../test/material/navigation_rail_test.dart | 62 ++-- .../test/material/popup_menu_test.dart | 294 +++++++++--------- .../flutter/test/material/search_test.dart | 228 +++++++------- .../flutter/test/material/slider_test.dart | 285 +++++++---------- packages/flutter/test/material/tabs_test.dart | 2 +- .../test/material/text_field_test.dart | 23 +- .../flutter/test/material/tooltip_test.dart | 22 +- .../test/material/tooltip_theme_test.dart | 44 +-- .../user_accounts_drawer_header_test.dart | 70 ++--- .../test/semantics/traversal_order_test.dart | 117 ++++--- .../flutter/test/widgets/draggable_test.dart | 102 +++--- .../test/widgets/editable_text_test.dart | 144 ++++----- .../flutter/test/widgets/navigator_test.dart | 32 -- .../flutter/test/widgets/routes_test.dart | 29 +- .../test/widgets/selectable_region_test.dart | 38 +-- .../test/widgets/selectable_text_test.dart | 34 +- ...ssion_for_current_semantics_tree_test.dart | 43 ++- .../test/widgets/simple_semantics_test.dart | 16 +- .../flutter_test/test/accessibility_test.dart | 6 +- 34 files changed, 1248 insertions(+), 1619 deletions(-) diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index c5b09ab6bd2..e6a58beb158 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -5569,17 +5569,10 @@ class NavigatorState extends State with TickerProviderStateMixin, Res includeSemantics: false, child: UnmanagedRestorationScope( bucket: bucket, - // Generating a semantics node here fixes an issue where widgets rendered - // before Navigator mistakenly get their semantics node dropped. - // See: https://github.com/flutter/flutter/pull/138446 - child: Semantics( - explicitChildNodes: true, - container: true, - child: Overlay( - key: _overlayKey, - clipBehavior: widget.clipBehavior, - initialEntries: overlay == null ? _allRouteOverlayEntries.toList(growable: false) : const [], - ), + child: Overlay( + key: _overlayKey, + clipBehavior: widget.clipBehavior, + initialEntries: overlay == null ? _allRouteOverlayEntries.toList(growable: false) : const [], ), ), ), diff --git a/packages/flutter/test/cupertino/action_sheet_test.dart b/packages/flutter/test/cupertino/action_sheet_test.dart index d6fdaf12e92..c734737da08 100644 --- a/packages/flutter/test/cupertino/action_sheet_test.dart +++ b/packages/flutter/test/cupertino/action_sheet_test.dart @@ -960,81 +960,63 @@ void main() { TestSemantics.root( children: [ TestSemantics( - id: 1, - textDirection: TextDirection.ltr, children: [ TestSemantics( - id: 2, children: [ TestSemantics( - id: 6, + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], + label: 'Alert', children: [ TestSemantics( - id: 7, flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute + SemanticsFlag.hasImplicitScrolling, ], - label: 'Alert', - textDirection: TextDirection.ltr, children: [ TestSemantics( - id: 8, - flags: [ - SemanticsFlag.hasImplicitScrolling - ], - children: [ - TestSemantics( - id: 9, - label: 'The title', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 10, - label: 'The message', - textDirection: TextDirection.ltr, - ), - ], + label: 'The title', ), TestSemantics( - id: 11, - flags: [ - SemanticsFlag.hasImplicitScrolling - ], - children: [ - TestSemantics( - id: 12, - flags: [ - SemanticsFlag.isButton - ], - actions: [ - SemanticsAction.tap - ], - label: 'One', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 13, - flags: [ - SemanticsFlag.isButton - ], - actions: [ - SemanticsAction.tap - ], - label: 'Two', - textDirection: TextDirection.ltr, - ), - ], - ), - TestSemantics( - id: 14, - flags: [SemanticsFlag.isButton], - actions: [SemanticsAction.tap], - label: 'Cancel', - textDirection: TextDirection.ltr, + label: 'The message', ), ], ), + TestSemantics( + flags: [ + SemanticsFlag.hasImplicitScrolling, + ], + children: [ + TestSemantics( + flags: [ + SemanticsFlag.isButton, + ], + actions: [ + SemanticsAction.tap, + ], + label: 'One', + ), + TestSemantics( + flags: [ + SemanticsFlag.isButton, + ], + actions: [ + SemanticsAction.tap, + ], + label: 'Two', + ), + ], + ), + TestSemantics( + flags: [ + SemanticsFlag.isButton, + ], + actions: [ + SemanticsAction.tap, + ], + label: 'Cancel', + ), ], ), ], diff --git a/packages/flutter/test/cupertino/date_picker_test.dart b/packages/flutter/test/cupertino/date_picker_test.dart index 280b4ba5c80..7656623ebe0 100644 --- a/packages/flutter/test/cupertino/date_picker_test.dart +++ b/packages/flutter/test/cupertino/date_picker_test.dart @@ -1824,7 +1824,7 @@ void main() { ), ); - tester.binding.pipelineOwner.semanticsOwner!.performAction(5, SemanticsAction.decrease); + tester.binding.pipelineOwner.semanticsOwner!.performAction(4, SemanticsAction.decrease); await tester.pumpAndSettle(); expect(date, DateTime(2018, 6, 7)); diff --git a/packages/flutter/test/cupertino/dialog_test.dart b/packages/flutter/test/cupertino/dialog_test.dart index 290bf258a6c..24bacd2ffa8 100644 --- a/packages/flutter/test/cupertino/dialog_test.dart +++ b/packages/flutter/test/cupertino/dialog_test.dart @@ -201,37 +201,33 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], + flags: [SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute], + label: 'Alert', children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute], - label: 'Alert', + flags: [ + SemanticsFlag.hasImplicitScrolling, + ], + children: [ + TestSemantics(label: 'The Title'), + TestSemantics(label: 'Content'), + ], + ), + TestSemantics( + flags: [ + SemanticsFlag.hasImplicitScrolling, + ], children: [ TestSemantics( - flags: [ - SemanticsFlag.hasImplicitScrolling, - ], - children: [ - TestSemantics(label: 'The Title'), - TestSemantics(label: 'Content'), - ], + flags: [SemanticsFlag.isButton], + label: 'Cancel', ), TestSemantics( - flags: [ - SemanticsFlag.hasImplicitScrolling, - ], - children: [ - TestSemantics( - flags: [SemanticsFlag.isButton], - label: 'Cancel', - ), - TestSemantics( - flags: [SemanticsFlag.isButton], - label: 'OK', - ), - ], + flags: [SemanticsFlag.isButton], + label: 'OK', ), ], ), diff --git a/packages/flutter/test/cupertino/text_field_test.dart b/packages/flutter/test/cupertino/text_field_test.dart index 28dde9fb150..98d73d235f7 100644 --- a/packages/flutter/test/cupertino/text_field_test.dart +++ b/packages/flutter/test/cupertino/text_field_test.dart @@ -525,20 +525,15 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - flags: [SemanticsFlag.isTextField, - SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled,], - actions: [SemanticsAction.tap, - SemanticsAction.didGainAccessibilityFocus,], - textDirection: TextDirection.ltr, - ), - ], + flags: [SemanticsFlag.isTextField, + SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled,], + actions: [SemanticsAction.tap, + SemanticsAction.didGainAccessibilityFocus,], + textDirection: TextDirection.ltr, ), ], ), @@ -553,7 +548,7 @@ void main() { )); expect(focusNode.hasFocus, isFalse); - semanticsOwner.performAction(5, SemanticsAction.didGainAccessibilityFocus); + semanticsOwner.performAction(4, SemanticsAction.didGainAccessibilityFocus); await tester.pumpAndSettle(); expect(focusNode.hasFocus, isTrue); semantics.dispose(); diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index 1231725e4d9..441e2c966c6 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -2369,41 +2369,37 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - children: [ - TestSemantics( - label: 'Leading', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.namesRoute, - SemanticsFlag.isHeader, - ], - label: 'Title', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: 'Action 1', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: 'Action 2', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: 'Action 3', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: 'Bottom', - textDirection: TextDirection.ltr, - ), + label: 'Leading', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [ + SemanticsFlag.namesRoute, + SemanticsFlag.isHeader, ], + label: 'Title', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: 'Action 1', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: 'Action 2', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: 'Action 3', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: 'Bottom', + textDirection: TextDirection.ltr, ), ], ), @@ -2460,44 +2456,40 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], + textDirection: TextDirection.rtl, children: [ TestSemantics( - textDirection: TextDirection.rtl, children: [ TestSemantics( - children: [ - TestSemantics( - label: 'Leading', - textDirection: TextDirection.rtl, - ), - TestSemantics( - flags: [ - SemanticsFlag.namesRoute, - SemanticsFlag.isHeader, - ], - label: 'Title', - textDirection: TextDirection.rtl, - ), - TestSemantics( - label: 'Action 1', - textDirection: TextDirection.rtl, - ), - TestSemantics( - label: 'Action 2', - textDirection: TextDirection.rtl, - ), - TestSemantics( - label: 'Action 3', - textDirection: TextDirection.rtl, - ), - TestSemantics( - label: 'Bottom', - textDirection: TextDirection.rtl, - ), + label: 'Leading', + textDirection: TextDirection.rtl, + ), + TestSemantics( + flags: [ + SemanticsFlag.namesRoute, + SemanticsFlag.isHeader, ], + label: 'Title', + textDirection: TextDirection.rtl, + ), + TestSemantics( + label: 'Action 1', + textDirection: TextDirection.rtl, + ), + TestSemantics( + label: 'Action 2', + textDirection: TextDirection.rtl, + ), + TestSemantics( + label: 'Action 3', + textDirection: TextDirection.rtl, + ), + TestSemantics( + label: 'Bottom', + textDirection: TextDirection.rtl, ), ], ), @@ -2545,21 +2537,17 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - children: [ - TestSemantics( - label: 'Leading', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: 'Action 1', - textDirection: TextDirection.ltr, - ), - ], + label: 'Leading', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: 'Action 1', + textDirection: TextDirection.ltr, ), ], ), @@ -2606,34 +2594,30 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( children: [ TestSemantics( children: [ TestSemantics( - children: [ - TestSemantics( - label: 'Leading', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: 'Action 1', - textDirection: TextDirection.ltr, - ), - ], + label: 'Leading', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: 'Action 1', + textDirection: TextDirection.ltr, ), - TestSemantics(), ], ), - TestSemantics( - flags: [SemanticsFlag.hasImplicitScrolling], - ), + TestSemantics(), ], ), + TestSemantics( + flags: [SemanticsFlag.hasImplicitScrolling], + ), ], ), ], @@ -2679,42 +2663,38 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( children: [ TestSemantics( children: [ TestSemantics( - children: [ - TestSemantics( - label: 'Leading', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: 'Action 1', - textDirection: TextDirection.ltr, - ), - ], + label: 'Leading', + textDirection: TextDirection.ltr, ), TestSemantics( - children: [ - TestSemantics( - flags: [SemanticsFlag.isHeader], - label: 'Flexible space', - textDirection: TextDirection.ltr, - ), - ], + label: 'Action 1', + textDirection: TextDirection.ltr, ), ], ), TestSemantics( - flags: [SemanticsFlag.hasImplicitScrolling], + children: [ + TestSemantics( + flags: [SemanticsFlag.isHeader], + label: 'Flexible space', + textDirection: TextDirection.ltr, + ), + ], ), ], ), + TestSemantics( + flags: [SemanticsFlag.hasImplicitScrolling], + ), ], ), ], diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index edad467bf7f..b9fc12edeea 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -2738,28 +2738,24 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - children: [ - TestSemantics( - flags: [ - SemanticsFlag.isSelected, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: 'A\nTab 1 of 2', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [SemanticsFlag.isFocusable], - actions: [SemanticsAction.tap], - label: 'B\nTab 2 of 2', - textDirection: TextDirection.ltr, - ), + flags: [ + SemanticsFlag.isSelected, + SemanticsFlag.isFocusable, ], + actions: [SemanticsAction.tap], + label: 'A\nTab 1 of 2', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [SemanticsFlag.isFocusable], + actions: [SemanticsAction.tap], + label: 'B\nTab 2 of 2', + textDirection: TextDirection.ltr, ), ], ), diff --git a/packages/flutter/test/material/bottom_sheet_test.dart b/packages/flutter/test/material/bottom_sheet_test.dart index 101b5dfa7aa..8d1358dcc96 100644 --- a/packages/flutter/test/material/bottom_sheet_test.dart +++ b/packages/flutter/test/material/bottom_sheet_test.dart @@ -839,31 +839,27 @@ void main() { TestSemantics( children: [ TestSemantics( + label: 'Dialog', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], children: [ TestSemantics( - label: 'Dialog', + label: 'BottomSheet', textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], - children: [ - TestSemantics( - label: 'BottomSheet', - textDirection: TextDirection.ltr, - ), - ], ), ], ), + ], + ), + TestSemantics( + children: [ TestSemantics( - children: [ - TestSemantics( - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'Scrim', - textDirection: TextDirection.ltr, - ), - ], + actions: [SemanticsAction.tap, SemanticsAction.dismiss], + label: 'Scrim', + textDirection: TextDirection.ltr, ), ], ), @@ -1015,36 +1011,32 @@ void main() { TestSemantics( children: [ TestSemantics( + label: 'Dialog', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], children: [ TestSemantics( - label: 'Dialog', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], + flags: [SemanticsFlag.hasImplicitScrolling], children: [ TestSemantics( - flags: [SemanticsFlag.hasImplicitScrolling], - children: [ - TestSemantics( - label: 'BottomSheet', - textDirection: TextDirection.ltr, - ), - ], + label: 'BottomSheet', + textDirection: TextDirection.ltr, ), ], ), ], ), + ], + ), + TestSemantics( + children: [ TestSemantics( - children: [ - TestSemantics( - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'Scrim', - textDirection: TextDirection.ltr, - ), - ], + actions: [SemanticsAction.tap, SemanticsAction.dismiss], + label: 'Scrim', + textDirection: TextDirection.ltr, ), ], ), @@ -1092,25 +1084,21 @@ void main() { TestSemantics( children: [ TestSemantics( + label: 'Dialog', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], children: [ TestSemantics( - label: 'Dialog', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], children: [ TestSemantics( + flags: [SemanticsFlag.hasImplicitScrolling], children: [ TestSemantics( - flags: [SemanticsFlag.hasImplicitScrolling], - children: [ - TestSemantics( - label: 'BottomSheet', - textDirection: TextDirection.ltr, - ), - ], + label: 'BottomSheet', + textDirection: TextDirection.ltr, ), ], ), @@ -1118,14 +1106,14 @@ void main() { ), ], ), + ], + ), + TestSemantics( + children: [ TestSemantics( - children: [ - TestSemantics( - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'Scrim', - textDirection: TextDirection.ltr, - ), - ], + actions: [SemanticsAction.tap, SemanticsAction.dismiss], + label: 'Scrim', + textDirection: TextDirection.ltr, ), ], ), @@ -1167,38 +1155,34 @@ void main() { TestSemantics( children: [ TestSemantics( + label: 'Dialog', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], children: [ TestSemantics( - label: 'Dialog', + label: 'BottomSheet', textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], children: [ TestSemantics( - label: 'BottomSheet', + actions: [SemanticsAction.tap], + label: 'Dismiss', textDirection: TextDirection.ltr, - children: [ - TestSemantics( - actions: [SemanticsAction.tap], - label: 'Dismiss', - textDirection: TextDirection.ltr, - ), - ], ), ], ), ], ), + ], + ), + TestSemantics( + children: [ TestSemantics( - children: [ - TestSemantics( - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'Scrim', - textDirection: TextDirection.ltr, - ), - ], + actions: [SemanticsAction.tap, SemanticsAction.dismiss], + label: 'Scrim', + textDirection: TextDirection.ltr, ), ], ), diff --git a/packages/flutter/test/material/chip_test.dart b/packages/flutter/test/material/chip_test.dart index ccd8ea41028..96da8329a6b 100644 --- a/packages/flutter/test/material/chip_test.dart +++ b/packages/flutter/test/material/chip_test.dart @@ -2896,18 +2896,14 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - ], - ), + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, ], ), ], @@ -2949,27 +2945,23 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + ], children: [ TestSemantics( - label: 'test', + tooltip: 'Delete', + actions: [SemanticsAction.tap], textDirection: TextDirection.ltr, flags: [ - SemanticsFlag.hasEnabledState, SemanticsFlag.isButton, - ], - children: [ - TestSemantics( - tooltip: 'Delete', - actions: [SemanticsAction.tap], - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.isFocusable, - ], - ), + SemanticsFlag.isFocusable, ], ), ], @@ -3013,22 +3005,18 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - ), + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, ], + actions: [SemanticsAction.tap], ), ], ), @@ -3075,22 +3063,18 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - ), + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, ], + actions: [SemanticsAction.tap], ), ], ), @@ -3131,23 +3115,19 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - SemanticsFlag.isSelected, - ], - actions: [SemanticsAction.tap], - ), + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + SemanticsFlag.isSelected, ], + actions: [SemanticsAction.tap], ), ], ), @@ -3190,20 +3170,16 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - ], - actions: [], - ), + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, ], + actions: [], ), ], ), @@ -3245,17 +3221,13 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [], // Must not be a button when tapping is disabled. - actions: [], - ), - ], + label: 'test', + textDirection: TextDirection.ltr, + flags: [], // Must not be a button when tapping is disabled. + actions: [], ), ], ), @@ -3298,22 +3270,18 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - ), + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, ], + actions: [SemanticsAction.tap], ), ], ), @@ -3354,18 +3322,14 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - ], - ), + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, ], ), ], diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart index 1353e366550..d3b47c87040 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart @@ -1716,36 +1716,31 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 5, - children: [ - TestSemantics( - id: 6, - label: 'title', - textDirection: TextDirection.ltr, - ), - // The content semantics does not merge into the semantics - // node 4. - TestSemantics( - id: 7, - label: 'content', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 8, - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - ], - label: 'action', - textDirection: TextDirection.ltr, - ), + label: 'title', + textDirection: TextDirection.ltr, + ), + // The content semantics does not merge into the semantics + // node 4. + TestSemantics( + id: 6, + label: 'content', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 7, + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, ], + label: 'action', + textDirection: TextDirection.ltr, ), ], ), @@ -1887,40 +1882,35 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], children: [ + // Title semantics does not merge into the semantics + // node 4. TestSemantics( id: 5, + label: 'title', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 6, + flags: [SemanticsFlag.hasImplicitScrolling], children: [ - // Title semantics does not merge into the semantics - // node 4. TestSemantics( - id: 6, - label: 'title', + id: 7, + label: 'content', textDirection: TextDirection.ltr, ), TestSemantics( - id: 7, - flags: [SemanticsFlag.hasImplicitScrolling], - children: [ - TestSemantics( - id: 8, - label: 'content', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 9, - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - ], - label: 'action', - textDirection: TextDirection.ltr, - ), + id: 8, + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, ], + label: 'action', + textDirection: TextDirection.ltr, ), ], ), diff --git a/packages/flutter/test/material/dropdown_test.dart b/packages/flutter/test/material/dropdown_test.dart index 7f29d05c16f..0a41c99378b 100644 --- a/packages/flutter/test/material/dropdown_test.dart +++ b/packages/flutter/test/material/dropdown_test.dart @@ -1330,71 +1330,60 @@ void main() { expect(semantics, hasSemantics(TestSemantics.root( children: [ - TestSemantics( + TestSemantics.rootChild( + actions: [SemanticsAction.tap, SemanticsAction.dismiss], + label: 'Dismiss', + textDirection: TextDirection.ltr, children: [ TestSemantics( + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], + label: 'Popup menu', children: [ TestSemantics( children: [ TestSemantics( flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, + SemanticsFlag.hasImplicitScrolling, ], - label: 'Popup menu', children: [ TestSemantics( - children: [ - TestSemantics( - flags: [ - SemanticsFlag.hasImplicitScrolling, - ], - children: [ - TestSemantics( - label: 'one', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.isFocused, - SemanticsFlag.isFocusable, - ], - tags: [const SemanticsTag('RenderViewport.twoPane')], - actions: [SemanticsAction.tap], - ), - TestSemantics( - label: 'two', - textDirection: TextDirection.ltr, - flags: [SemanticsFlag.isFocusable], - tags: [const SemanticsTag('RenderViewport.twoPane')], - actions: [SemanticsAction.tap], - ), - TestSemantics( - label: 'three', - textDirection: TextDirection.ltr, - flags: [SemanticsFlag.isFocusable], - tags: [const SemanticsTag('RenderViewport.twoPane')], - actions: [SemanticsAction.tap], - ), - TestSemantics( - label: 'four', - textDirection: TextDirection.ltr, - flags: [SemanticsFlag.isFocusable], - tags: [const SemanticsTag('RenderViewport.twoPane')], - actions: [SemanticsAction.tap], - ), - ], - ), + label: 'one', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.isFocused, + SemanticsFlag.isFocusable, ], + tags: [const SemanticsTag('RenderViewport.twoPane')], + actions: [SemanticsAction.tap], + ), + TestSemantics( + label: 'two', + textDirection: TextDirection.ltr, + flags: [SemanticsFlag.isFocusable], + tags: [const SemanticsTag('RenderViewport.twoPane')], + actions: [SemanticsAction.tap], + ), + TestSemantics( + label: 'three', + textDirection: TextDirection.ltr, + flags: [SemanticsFlag.isFocusable], + tags: [const SemanticsTag('RenderViewport.twoPane')], + actions: [SemanticsAction.tap], + ), + TestSemantics( + label: 'four', + textDirection: TextDirection.ltr, + flags: [SemanticsFlag.isFocusable], + tags: [const SemanticsTag('RenderViewport.twoPane')], + actions: [SemanticsAction.tap], ), ], ), ], ), - TestSemantics( - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'Dismiss', - textDirection: TextDirection.ltr, - children: [] - ), ], ), ], diff --git a/packages/flutter/test/material/flexible_space_bar_test.dart b/packages/flutter/test/material/flexible_space_bar_test.dart index 8d05938a9f4..706f7653f44 100644 --- a/packages/flutter/test/material/flexible_space_bar_test.dart +++ b/packages/flutter/test/material/flexible_space_bar_test.dart @@ -214,86 +214,81 @@ void main() { TestSemantics( id: 3, rect: TestSemantics.fullScreen, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, rect: TestSemantics.fullScreen, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - id: 5, - rect: TestSemantics.fullScreen, + id: 9, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, expandedHeight), children: [ TestSemantics( - id: 10, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, expandedHeight), + id: 12, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), children: [ TestSemantics( id: 13, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), - children: [ - TestSemantics( - id: 14, - rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 20.0), - flags: [ - SemanticsFlag.isHeader, - SemanticsFlag.namesRoute, - ], - label: 'Title', - textDirection: TextDirection.ltr, - ), - ], - ), - TestSemantics( - id: 11, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), - children: [ - TestSemantics( - id: 12, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, expandedHeight), - label: 'Expanded title', - textDirection: TextDirection.ltr, - ), + rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 20.0), + flags: [ + SemanticsFlag.isHeader, + SemanticsFlag.namesRoute, ], + label: 'Title', + textDirection: TextDirection.ltr, ), ], ), TestSemantics( - id: 15, - flags: [SemanticsFlag.hasImplicitScrolling], - rect: TestSemantics.fullScreen, - actions: [SemanticsAction.scrollUp], + id: 10, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), children: [ TestSemantics( - id: 6, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), - label: 'Item 0', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 7, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), - label: 'Item 1', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 8, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), - flags: [SemanticsFlag.isHidden], - label: 'Item 2', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 9, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 50.0), - flags: [SemanticsFlag.isHidden], - label: 'Item 3', + id: 11, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, expandedHeight), + label: 'Expanded title', textDirection: TextDirection.ltr, ), ], ), ], ), + TestSemantics( + id: 14, + flags: [SemanticsFlag.hasImplicitScrolling], + rect: TestSemantics.fullScreen, + actions: [SemanticsAction.scrollUp], + children: [ + TestSemantics( + id: 5, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + label: 'Item 0', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 6, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + label: 'Item 1', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 7, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + flags: [SemanticsFlag.isHidden], + label: 'Item 2', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 8, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 50.0), + flags: [SemanticsFlag.isHidden], + label: 'Item 3', + textDirection: TextDirection.ltr, + ), + + ], + ), ], ), ], @@ -324,109 +319,103 @@ void main() { TestSemantics( id: 3, rect: TestSemantics.fullScreen, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, rect: TestSemantics.fullScreen, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - id: 5, - rect: TestSemantics.fullScreen, + id: 9, + // The app bar is collapsed. + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 56.0), children: [ TestSemantics( - id: 10, - // The app bar is collapsed. + id: 12, rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 56.0), children: [ TestSemantics( id: 13, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 56.0), - children: [ - TestSemantics( - id: 14, - rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 20.0), - flags: [ - SemanticsFlag.isHeader, - SemanticsFlag.namesRoute, - ], - label: 'Title', - textDirection: TextDirection.ltr, - ), - ], - ), - // The flexible space bar still persists in the - // semantic tree even if it is collapsed. - TestSemantics( - id: 11, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 56.0), - children: [ - TestSemantics( - id: 12, - rect: const Rect.fromLTRB(0.0, 36.0, 800.0, 92.0), - label: 'Expanded title', - textDirection: TextDirection.ltr, - ), + rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 20.0), + flags: [ + SemanticsFlag.isHeader, + SemanticsFlag.namesRoute, ], + label: 'Title', + textDirection: TextDirection.ltr, ), ], ), + // The flexible space bar still persists in the + // semantic tree even if it is collapsed. TestSemantics( - id: 15, - flags: [SemanticsFlag.hasImplicitScrolling], - rect: TestSemantics.fullScreen, - actions: [SemanticsAction.scrollUp, SemanticsAction.scrollDown], + id: 10, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 56.0), children: [ TestSemantics( - id: 6, - rect: const Rect.fromLTRB(0.0, 150.0, 800.0, 200.0), - flags: [SemanticsFlag.isHidden], - label: 'Item 0', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 7, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), - flags: [SemanticsFlag.isHidden], - label: 'Item 1', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 8, - rect: const Rect.fromLTRB(0.0, 56.0, 800.0, 200.0), - label: 'Item 2', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 9, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), - label: 'Item 3', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 16, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), - label: 'Item 4', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 17, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), - flags: [SemanticsFlag.isHidden], - label: 'Item 5', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 18, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 50.0), - flags: [SemanticsFlag.isHidden], - label: 'Item 6', + id: 11, + rect: const Rect.fromLTRB(0.0, 36.0, 800.0, 92.0), + label: 'Expanded title', textDirection: TextDirection.ltr, ), ], ), ], ), + TestSemantics( + id: 14, + flags: [SemanticsFlag.hasImplicitScrolling], + rect: TestSemantics.fullScreen, + actions: [SemanticsAction.scrollUp, SemanticsAction.scrollDown], + children: [ + TestSemantics( + id: 5, + rect: const Rect.fromLTRB(0.0, 150.0, 800.0, 200.0), + flags: [SemanticsFlag.isHidden], + label: 'Item 0', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 6, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + flags: [SemanticsFlag.isHidden], + label: 'Item 1', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 7, + rect: const Rect.fromLTRB(0.0, 56.0, 800.0, 200.0), + label: 'Item 2', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 8, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + label: 'Item 3', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 15, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + label: 'Item 4', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 16, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + flags: [SemanticsFlag.isHidden], + label: 'Item 5', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 17, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 50.0), + flags: [SemanticsFlag.isHidden], + label: 'Item 6', + textDirection: TextDirection.ltr, + ), + ], + ), ], ), ], diff --git a/packages/flutter/test/material/floating_action_button_test.dart b/packages/flutter/test/material/floating_action_button_test.dart index eba1c6330cc..95dfe57b73f 100644 --- a/packages/flutter/test/material/floating_action_button_test.dart +++ b/packages/flutter/test/material/floating_action_button_test.dart @@ -691,24 +691,20 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [ + SemanticsFlag.scopesRoute, + ], children: [ TestSemantics( - flags: [ - SemanticsFlag.scopesRoute, + tooltip: 'Add Photo', + actions: [ + SemanticsAction.tap, ], - children: [ - TestSemantics( - tooltip: 'Add Photo', - actions: [ - SemanticsAction.tap, - ], - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - ), + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, ], ), ], diff --git a/packages/flutter/test/material/icon_button_test.dart b/packages/flutter/test/material/icon_button_test.dart index d6d5d22d060..80d91f9e0ed 100644 --- a/packages/flutter/test/material/icon_button_test.dart +++ b/packages/flutter/test/material/icon_button_test.dart @@ -680,24 +680,20 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - actions: [ - SemanticsAction.tap, - ], - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - SemanticsFlag.isSelected, - ], - label: 'link', - ), + actions: [ + SemanticsAction.tap, ], + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + SemanticsFlag.isSelected, + ], + label: 'link', ), ], ), diff --git a/packages/flutter/test/material/menu_anchor_test.dart b/packages/flutter/test/material/menu_anchor_test.dart index 502b108aeeb..f722879c8ad 100644 --- a/packages/flutter/test/material/menu_anchor_test.dart +++ b/packages/flutter/test/material/menu_anchor_test.dart @@ -3355,47 +3355,41 @@ void main() { TestSemantics( id: 3, rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), - flags: [SemanticsFlag.scopesRoute], + flags: [ + SemanticsFlag.isFocused, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + SemanticsFlag.hasExpandedState, + SemanticsFlag.isExpanded, + ], + actions: [SemanticsAction.tap], + label: 'ABC', + rect: const Rect.fromLTRB(0.0, 0.0, 88.0, 48.0), + ), + TestSemantics( + id: 6, + rect: const Rect.fromLTRB(0.0, 0.0, 120.0, 64.0), children: [ - TestSemantics( - id: 5, - flags: [ - SemanticsFlag.isFocused, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - SemanticsFlag.hasExpandedState, - SemanticsFlag.isExpanded, - ], - actions: [SemanticsAction.tap], - label: 'ABC', - rect: const Rect.fromLTRB(0.0, 0.0, 88.0, 48.0), - ), TestSemantics( id: 7, - rect: const Rect.fromLTRB(0.0, 0.0, 120.0, 64.0), + rect: const Rect.fromLTRB(0.0, 0.0, 120.0, 48.0), + flags: [SemanticsFlag.hasImplicitScrolling], children: [ TestSemantics( id: 8, + label: 'Item 0', rect: const Rect.fromLTRB(0.0, 0.0, 120.0, 48.0), - flags: [SemanticsFlag.hasImplicitScrolling], - children: [ - TestSemantics( - id: 9, - label: 'Item 0', - rect: const Rect.fromLTRB(0.0, 0.0, 120.0, 48.0), - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - ), + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, ], + actions: [SemanticsAction.tap], ), ], ), @@ -3432,26 +3426,20 @@ void main() { TestSemantics( id: 3, rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - flags: [ - SemanticsFlag.hasExpandedState, - SemanticsFlag.isFocused, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: 'ABC', - rect: const Rect.fromLTRB(0.0, 0.0, 88.0, 48.0), - ), + flags: [ + SemanticsFlag.hasExpandedState, + SemanticsFlag.isFocused, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, ], + actions: [SemanticsAction.tap], + label: 'ABC', + rect: const Rect.fromLTRB(0.0, 0.0, 88.0, 48.0), ), ], ), diff --git a/packages/flutter/test/material/navigation_rail_test.dart b/packages/flutter/test/material/navigation_rail_test.dart index 77ad762a2e2..916b6594295 100644 --- a/packages/flutter/test/material/navigation_rail_test.dart +++ b/packages/flutter/test/material/navigation_rail_test.dart @@ -5428,42 +5428,38 @@ TestSemantics _expectedSemantics() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - flags: [ - SemanticsFlag.isSelected, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: 'Abc\nTab 1 of 4', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [SemanticsFlag.isFocusable], - actions: [SemanticsAction.tap], - label: 'Def\nTab 2 of 4', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [SemanticsFlag.isFocusable], - actions: [SemanticsAction.tap], - label: 'Ghi\nTab 3 of 4', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [SemanticsFlag.isFocusable], - actions: [SemanticsAction.tap], - label: 'Jkl\nTab 4 of 4', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: 'body', - textDirection: TextDirection.ltr, - ), + flags: [ + SemanticsFlag.isSelected, + SemanticsFlag.isFocusable, ], + actions: [SemanticsAction.tap], + label: 'Abc\nTab 1 of 4', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [SemanticsFlag.isFocusable], + actions: [SemanticsAction.tap], + label: 'Def\nTab 2 of 4', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [SemanticsFlag.isFocusable], + actions: [SemanticsAction.tap], + label: 'Ghi\nTab 3 of 4', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [SemanticsFlag.isFocusable], + actions: [SemanticsAction.tap], + label: 'Jkl\nTab 4 of 4', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: 'body', + textDirection: TextDirection.ltr, ), ], ), diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart index 3e29d7f5f75..e462834c917 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -1122,88 +1122,84 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], + label: 'Popup menu', + textDirection: TextDirection.ltr, children: [ TestSemantics( flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, + SemanticsFlag.hasImplicitScrolling, ], - label: 'Popup menu', - textDirection: TextDirection.ltr, children: [ TestSemantics( flags: [ - SemanticsFlag.hasImplicitScrolling, + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, ], - children: [ - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: '1', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: '2', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: '3', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: '4', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: '5', - textDirection: TextDirection.ltr, - ), + actions: [SemanticsAction.tap], + label: '1', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, ], + actions: [SemanticsAction.tap], + label: '2', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + ], + actions: [SemanticsAction.tap], + label: '3', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + ], + actions: [SemanticsAction.tap], + label: '4', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + ], + actions: [SemanticsAction.tap], + label: '5', + textDirection: TextDirection.ltr, ), ], ), ], ), - TestSemantics( - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'Dismiss menu', - textDirection: TextDirection.ltr, - ), ], ), + TestSemantics( + actions: [SemanticsAction.tap, SemanticsAction.dismiss], + label: 'Dismiss menu', + textDirection: TextDirection.ltr, + ), ], ), ], @@ -1258,44 +1254,40 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], + label: 'Popup menu', + textDirection: TextDirection.ltr, children: [ TestSemantics( flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, + SemanticsFlag.hasImplicitScrolling, ], - label: 'Popup menu', - textDirection: TextDirection.ltr, children: [ TestSemantics( flags: [ - SemanticsFlag.hasImplicitScrolling, - ], - children: [ - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: 'test1\ntest2', - textDirection: TextDirection.ltr, - ), + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, ], + actions: [SemanticsAction.tap], + label: 'test1\ntest2', + textDirection: TextDirection.ltr, ), ], ), ], ), - TestSemantics( - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'Dismiss menu', - textDirection: TextDirection.ltr, - ), ], ), + TestSemantics( + actions: [SemanticsAction.tap, SemanticsAction.dismiss], + label: 'Dismiss menu', + textDirection: TextDirection.ltr, + ), ], ), ], @@ -1343,86 +1335,82 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], + label: 'Popup menu', + textDirection: TextDirection.ltr, children: [ TestSemantics( flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, + SemanticsFlag.hasImplicitScrolling, ], - label: 'Popup menu', - textDirection: TextDirection.ltr, children: [ TestSemantics( flags: [ - SemanticsFlag.hasImplicitScrolling, + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, ], - children: [ - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: '1', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - ], - actions: [], - label: '2', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: '3', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: '4', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - label: '5', - textDirection: TextDirection.ltr, - ), + actions: [SemanticsAction.tap], + label: '1', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, ], + actions: [], + label: '2', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + ], + actions: [SemanticsAction.tap], + label: '3', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + ], + actions: [SemanticsAction.tap], + label: '4', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + ], + actions: [SemanticsAction.tap], + label: '5', + textDirection: TextDirection.ltr, ), ], ), ], ), - TestSemantics( - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'Dismiss menu', - textDirection: TextDirection.ltr, - ), ], ), + TestSemantics( + actions: [SemanticsAction.tap, SemanticsAction.dismiss], + label: 'Dismiss menu', + textDirection: TextDirection.ltr, + ), ], ), ], diff --git a/packages/flutter/test/material/search_test.dart b/packages/flutter/test/material/search_test.dart index 2dd3758f749..4b4359b7696 100644 --- a/packages/flutter/test/material/search_test.dart +++ b/packages/flutter/test/material/search_test.dart @@ -641,90 +641,85 @@ void main() { children: [ TestSemantics( id: 3, + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], + label: routeName, + textDirection: TextDirection.ltr, children: [ TestSemantics( id: 4, - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], - label: routeName, - textDirection: TextDirection.ltr, children: [ TestSemantics( - id: 5, + id: 6, children: [ TestSemantics( - id: 7, - children: [ - TestSemantics( - id: 9, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - tooltip: 'Back', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 10, - flags: [ - SemanticsFlag.isTextField, - SemanticsFlag.isFocused, - SemanticsFlag.isHeader, - if (debugDefaultTargetPlatformOverride != TargetPlatform.iOS && - debugDefaultTargetPlatformOverride != TargetPlatform.macOS) SemanticsFlag.namesRoute, - ], - actions: [ - if (isDesktop) - SemanticsAction.didGainAccessibilityFocus, - if (isDesktop) - SemanticsAction.didLoseAccessibilityFocus, - SemanticsAction.tap, - SemanticsAction.setSelection, - SemanticsAction.setText, - SemanticsAction.paste, - ], - label: 'Search', - textDirection: TextDirection.ltr, - textSelection: const TextSelection(baseOffset: 0, extentOffset: 0), - ), - TestSemantics( - id: 11, - label: 'Bottom', - textDirection: TextDirection.ltr, - ), + id: 8, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, ], + actions: [SemanticsAction.tap], + tooltip: 'Back', + textDirection: TextDirection.ltr, ), TestSemantics( - id: 8, - children: [ - TestSemantics( - id: 12, - label: 'FlexibleSpace', - textDirection: TextDirection.ltr, - ), + id: 9, + flags: [ + SemanticsFlag.isTextField, + SemanticsFlag.isFocused, + SemanticsFlag.isHeader, + if (debugDefaultTargetPlatformOverride != TargetPlatform.iOS && + debugDefaultTargetPlatformOverride != TargetPlatform.macOS) SemanticsFlag.namesRoute, ], + actions: [ + if (isDesktop) + SemanticsAction.didGainAccessibilityFocus, + if (isDesktop) + SemanticsAction.didLoseAccessibilityFocus, + SemanticsAction.tap, + SemanticsAction.setSelection, + SemanticsAction.setText, + SemanticsAction.paste, + ], + label: 'Search', + textDirection: TextDirection.ltr, + textSelection: const TextSelection(baseOffset: 0, extentOffset: 0), + ), + TestSemantics( + id: 10, + label: 'Bottom', + textDirection: TextDirection.ltr, ), ], ), TestSemantics( - id: 6, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, + id: 7, + children: [ + TestSemantics( + id: 11, + label: 'FlexibleSpace', + textDirection: TextDirection.ltr, + ), ], - actions: [SemanticsAction.tap], - label: 'Suggestions', - textDirection: TextDirection.ltr, ), ], ), + TestSemantics( + id: 5, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + ], + actions: [SemanticsAction.tap], + label: 'Suggestions', + textDirection: TextDirection.ltr, + ), ], ), ], @@ -796,64 +791,19 @@ void main() { id: 2, children: [ TestSemantics( - id: 3, + id: 7, + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], + label: routeName, + textDirection: TextDirection.ltr, children: [ TestSemantics( - id: 8, - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], - label: routeName, - textDirection: TextDirection.ltr, + id: 9, children: [ TestSemantics( id: 10, - children: [ - TestSemantics( - id: 11, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - ], - actions: [SemanticsAction.tap], - tooltip: 'Back', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 12, - flags: [ - SemanticsFlag.isTextField, - SemanticsFlag.isFocused, - SemanticsFlag.isHeader, - if (debugDefaultTargetPlatformOverride != TargetPlatform.iOS && - debugDefaultTargetPlatformOverride != TargetPlatform.macOS) SemanticsFlag.namesRoute, - ], - actions: [ - if (isDesktop) - SemanticsAction.didGainAccessibilityFocus, - if (isDesktop) - SemanticsAction.didLoseAccessibilityFocus, - SemanticsAction.tap, - SemanticsAction.setSelection, - SemanticsAction.setText, - SemanticsAction.paste, - ], - label: 'Search', - textDirection: TextDirection.ltr, - textSelection: const TextSelection(baseOffset: 0, extentOffset: 0), - ), - TestSemantics( - id: 15, - label: 'Bottom', - textDirection: TextDirection.ltr, - ), - ], - ), - TestSemantics( - id: 9, flags: [ SemanticsFlag.hasEnabledState, SemanticsFlag.isButton, @@ -861,11 +811,51 @@ void main() { SemanticsFlag.isFocusable, ], actions: [SemanticsAction.tap], - label: 'Suggestions', + tooltip: 'Back', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 11, + flags: [ + SemanticsFlag.isTextField, + SemanticsFlag.isFocused, + SemanticsFlag.isHeader, + if (debugDefaultTargetPlatformOverride != TargetPlatform.iOS && + debugDefaultTargetPlatformOverride != TargetPlatform.macOS) SemanticsFlag.namesRoute, + ], + actions: [ + if (isDesktop) + SemanticsAction.didGainAccessibilityFocus, + if (isDesktop) + SemanticsAction.didLoseAccessibilityFocus, + SemanticsAction.tap, + SemanticsAction.setSelection, + SemanticsAction.setText, + SemanticsAction.paste, + ], + label: 'Search', + textDirection: TextDirection.ltr, + textSelection: const TextSelection(baseOffset: 0, extentOffset: 0), + ), + TestSemantics( + id: 14, + label: 'Bottom', textDirection: TextDirection.ltr, ), ], ), + TestSemantics( + id: 8, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + ], + actions: [SemanticsAction.tap], + label: 'Suggestions', + textDirection: TextDirection.ltr, + ), ], ), ], diff --git a/packages/flutter/test/material/slider_test.dart b/packages/flutter/test/material/slider_test.dart index b14bcfa7d2f..f422c0449bf 100644 --- a/packages/flutter/test/material/slider_test.dart +++ b/packages/flutter/test/material/slider_test.dart @@ -1178,29 +1178,24 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - SemanticsFlag.isSlider, - ], - actions: [ - SemanticsAction.increase, - SemanticsAction.decrease, - ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, - ), + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + SemanticsFlag.isSlider, ], + actions: [ + SemanticsAction.increase, + SemanticsAction.decrease, + ], + value: '50%', + increasedValue: '55%', + decreasedValue: '45%', + textDirection: TextDirection.ltr, ), ], ), @@ -1242,25 +1237,20 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - flags: [ - SemanticsFlag.hasEnabledState, - // isFocusable is delayed by 1 frame. - SemanticsFlag.isFocusable, - SemanticsFlag.isSlider, - ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, - ), + flags: [ + SemanticsFlag.hasEnabledState, + // isFocusable is delayed by 1 frame. + SemanticsFlag.isFocusable, + SemanticsFlag.isSlider, ], + value: '50%', + increasedValue: '55%', + decreasedValue: '45%', + textDirection: TextDirection.ltr, ), ], ), @@ -1290,23 +1280,18 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isSlider, - ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, - ), + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isSlider, ], + value: '50%', + increasedValue: '55%', + decreasedValue: '45%', + textDirection: TextDirection.ltr, ), ], ), @@ -1359,21 +1344,16 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - flags: [SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isSlider], - actions: [SemanticsAction.increase, SemanticsAction.decrease], - value: '50%', - increasedValue: '60%', - decreasedValue: '40%', - textDirection: TextDirection.ltr, - ), - ], + flags: [SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isSlider], + actions: [SemanticsAction.increase, SemanticsAction.decrease], + value: '50%', + increasedValue: '60%', + decreasedValue: '40%', + textDirection: TextDirection.ltr, ), ], ), @@ -1415,20 +1395,15 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 6, - flags: [SemanticsFlag.hasEnabledState, SemanticsFlag.isSlider], - value: '50%', - increasedValue: '60%', - decreasedValue: '40%', - textDirection: TextDirection.ltr, - ), - ], + id: 5, + flags: [SemanticsFlag.hasEnabledState, SemanticsFlag.isSlider], + value: '50%', + increasedValue: '60%', + decreasedValue: '40%', + textDirection: TextDirection.ltr, ), ], ), @@ -1476,30 +1451,25 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - SemanticsFlag.isSlider, - ], - actions: [ - SemanticsAction.increase, - SemanticsAction.decrease, - SemanticsAction.didGainAccessibilityFocus, - ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, - ), + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + SemanticsFlag.isSlider, ], + actions: [ + SemanticsAction.increase, + SemanticsAction.decrease, + SemanticsAction.didGainAccessibilityFocus, + ], + value: '50%', + increasedValue: '55%', + decreasedValue: '45%', + textDirection: TextDirection.ltr, ), ], ), @@ -1541,28 +1511,23 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - flags: [ - SemanticsFlag.hasEnabledState, - // isFocusable is delayed by 1 frame. - SemanticsFlag.isFocusable, - SemanticsFlag.isSlider, - ], - actions: [ - SemanticsAction.didGainAccessibilityFocus, - ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, - ), + flags: [ + SemanticsFlag.hasEnabledState, + // isFocusable is delayed by 1 frame. + SemanticsFlag.isFocusable, + SemanticsFlag.isSlider, ], + actions: [ + SemanticsAction.didGainAccessibilityFocus, + ], + value: '50%', + increasedValue: '55%', + decreasedValue: '45%', + textDirection: TextDirection.ltr, ), ], ), @@ -1592,26 +1557,21 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isSlider, - ], - actions: [ - SemanticsAction.didGainAccessibilityFocus, - ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, - ), + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isSlider, ], + actions: [ + SemanticsAction.didGainAccessibilityFocus, + ], + value: '50%', + increasedValue: '55%', + decreasedValue: '45%', + textDirection: TextDirection.ltr, ), ], ), @@ -1661,21 +1621,16 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - flags: [SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isSlider], - actions: [SemanticsAction.increase, SemanticsAction.decrease], - value: '40', - increasedValue: '60', - decreasedValue: '20', - textDirection: TextDirection.ltr, - ), - ], + flags: [SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isSlider], + actions: [SemanticsAction.increase, SemanticsAction.decrease], + value: '40', + increasedValue: '60', + decreasedValue: '20', + textDirection: TextDirection.ltr, ), ], ), @@ -1726,21 +1681,16 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - flags: [SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isSlider], - actions: [SemanticsAction.increase, SemanticsAction.decrease], - value: '40', - increasedValue: '60', - decreasedValue: '20', - textDirection: TextDirection.ltr, - ), - ], + flags: [SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable, SemanticsFlag.isSlider], + actions: [SemanticsAction.increase, SemanticsAction.decrease], + value: '40', + increasedValue: '60', + decreasedValue: '20', + textDirection: TextDirection.ltr, ), ], ), @@ -2569,30 +2519,25 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - SemanticsFlag.isSlider, - ], - actions: [ - SemanticsAction.increase, - SemanticsAction.decrease, - SemanticsAction.didGainAccessibilityFocus, - ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, - ), + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + SemanticsFlag.isSlider, ], + actions: [ + SemanticsAction.increase, + SemanticsAction.decrease, + SemanticsAction.didGainAccessibilityFocus, + ], + value: '50%', + increasedValue: '55%', + decreasedValue: '45%', + textDirection: TextDirection.ltr, ), ], ), @@ -2607,7 +2552,7 @@ void main() { )); expect(focusNode.hasFocus, isFalse); - semanticsOwner.performAction(5, SemanticsAction.didGainAccessibilityFocus); + semanticsOwner.performAction(4, SemanticsAction.didGainAccessibilityFocus); await tester.pumpAndSettle(); expect(focusNode.hasFocus, isTrue); semantics.dispose(); diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 438cd625280..01654998754 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -5693,7 +5693,7 @@ void main() { rect: TestSemantics.fullScreen, label: 'PAGE1' ), - ], + ] ), ], ), diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 01023a1993d..8d305794a45 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -742,22 +742,17 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - flags: [SemanticsFlag.isTextField], - actions: [ - SemanticsAction.tap, - SemanticsAction.didGainAccessibilityFocus, - SemanticsAction.didLoseAccessibilityFocus, - ], - textDirection: TextDirection.ltr, - ), + flags: [SemanticsFlag.isTextField], + actions: [ + SemanticsAction.tap, + SemanticsAction.didGainAccessibilityFocus, + SemanticsAction.didLoseAccessibilityFocus, ], + textDirection: TextDirection.ltr, ), ], ), @@ -772,11 +767,11 @@ void main() { )); expect(focusNode.hasFocus, isFalse); - semanticsOwner.performAction(5, SemanticsAction.didGainAccessibilityFocus); + semanticsOwner.performAction(4, SemanticsAction.didGainAccessibilityFocus); await tester.pumpAndSettle(); expect(focusNode.hasFocus, isTrue); - semanticsOwner.performAction(5, SemanticsAction.didLoseAccessibilityFocus); + semanticsOwner.performAction(4, SemanticsAction.didLoseAccessibilityFocus); await tester.pumpAndSettle(); expect(focusNode.hasFocus, isFalse); semantics.dispose(); diff --git a/packages/flutter/test/material/tooltip_test.dart b/packages/flutter/test/material/tooltip_test.dart index c4fe09f32bf..205dbad447f 100644 --- a/packages/flutter/test/material/tooltip_test.dart +++ b/packages/flutter/test/material/tooltip_test.dart @@ -2130,16 +2130,12 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - tooltip: 'Foo', - label: 'Bar', - textDirection: TextDirection.ltr, - ), - ], + tooltip: 'Foo', + label: 'Bar', + textDirection: TextDirection.ltr, ), ], ), @@ -2175,15 +2171,11 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - label: 'Bar', - textDirection: TextDirection.ltr, - ), - ], + label: 'Bar', + textDirection: TextDirection.ltr, ), ], ), diff --git a/packages/flutter/test/material/tooltip_theme_test.dart b/packages/flutter/test/material/tooltip_theme_test.dart index d1c36e46b7d..56a356db85d 100644 --- a/packages/flutter/test/material/tooltip_theme_test.dart +++ b/packages/flutter/test/material/tooltip_theme_test.dart @@ -1243,16 +1243,12 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - tooltip: 'Foo', - label: 'Bar', - textDirection: TextDirection.ltr, - ), - ], + tooltip: 'Foo', + label: 'Bar', + textDirection: TextDirection.ltr, ), ], ), @@ -1290,16 +1286,12 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - tooltip: 'Foo', - label: 'Bar', - textDirection: TextDirection.ltr, - ), - ], + tooltip: 'Foo', + label: 'Bar', + textDirection: TextDirection.ltr, ), ], ), @@ -1339,15 +1331,11 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - label: 'Bar', - textDirection: TextDirection.ltr, - ), - ], + label: 'Bar', + textDirection: TextDirection.ltr, ), ], ), @@ -1385,15 +1373,11 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - label: 'Bar', - textDirection: TextDirection.ltr, - ), - ], + label: 'Bar', + textDirection: TextDirection.ltr, ), ], ), diff --git a/packages/flutter/test/material/user_accounts_drawer_header_test.dart b/packages/flutter/test/material/user_accounts_drawer_header_test.dart index 1f1f964e358..a106eaabf8f 100644 --- a/packages/flutter/test/material/user_accounts_drawer_header_test.dart +++ b/packages/flutter/test/material/user_accounts_drawer_header_test.dart @@ -525,34 +525,30 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], + flags: [SemanticsFlag.isFocusable], + label: 'Signed in\nname\nemail', + textDirection: TextDirection.ltr, children: [ TestSemantics( - flags: [SemanticsFlag.isFocusable], - label: 'Signed in\nname\nemail', + label: r'B', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: r'C', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: r'D', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [SemanticsFlag.isButton], + actions: [SemanticsAction.tap], + label: r'Show accounts', textDirection: TextDirection.ltr, - children: [ - TestSemantics( - label: r'B', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: r'C', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: r'D', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [SemanticsFlag.isButton], - actions: [SemanticsAction.tap], - label: r'Show accounts', - textDirection: TextDirection.ltr, - ), - ], ), ], ), @@ -611,27 +607,23 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], + label: 'Signed in', + textDirection: TextDirection.ltr, children: [ TestSemantics( - label: 'Signed in', + label: r'B', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: r'C', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: r'D', textDirection: TextDirection.ltr, - children: [ - TestSemantics( - label: r'B', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: r'C', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: r'D', - textDirection: TextDirection.ltr, - ), - ], ), ], ), diff --git a/packages/flutter/test/semantics/traversal_order_test.dart b/packages/flutter/test/semantics/traversal_order_test.dart index 78fc47c0703..2b469bb1139 100644 --- a/packages/flutter/test/semantics/traversal_order_test.dart +++ b/packages/flutter/test/semantics/traversal_order_test.dart @@ -39,66 +39,63 @@ void main() { TestSemantics( id: 2, children: [ - TestSemantics(id: 3, children: [ - TestSemantics( - id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - label: '0 - 0', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 6, - label: '0 - 1', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 7, - label: '0 - 2', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 8, - label: '1 - 0', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 9, - label: '1 - 1', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 10, - label: '1 - 2', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 11, - label: '2 - 0', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 12, - label: '2 - 1', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 13, - label: '2 - 2', - textDirection: TextDirection.ltr, - ), - ], - ), - ], - ), - ], - ), - ], - ), - ], - ); + TestSemantics( + id: 3, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + id: 4, + label: '0 - 0', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 5, + label: '0 - 1', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 6, + label: '0 - 2', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 7, + label: '1 - 0', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 8, + label: '1 - 1', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 9, + label: '1 - 2', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 10, + label: '2 - 0', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 11, + label: '2 - 1', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 12, + label: '2 - 2', + textDirection: TextDirection.ltr, + ), + ], + ), + ], + ), + ], + ), + ], + ); expect(semantics, hasSemantics(expected, ignoreRect: true, ignoreTransform: true)); semantics.dispose(); }); diff --git a/packages/flutter/test/widgets/draggable_test.dart b/packages/flutter/test/widgets/draggable_test.dart index d9dddd59291..5af50d9af42 100644 --- a/packages/flutter/test/widgets/draggable_test.dart +++ b/packages/flutter/test/widgets/draggable_test.dart @@ -3268,44 +3268,39 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - id: 5, + id: 9, + flags: [SemanticsFlag.hasImplicitScrolling], + actions: [SemanticsAction.scrollLeft], children: [ TestSemantics( - id: 10, - flags: [SemanticsFlag.hasImplicitScrolling], - actions: [SemanticsAction.scrollLeft], - children: [ - TestSemantics( - id: 6, - tags: [const SemanticsTag('RenderViewport.twoPane')], - label: 'Target', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 7, - tags: [const SemanticsTag('RenderViewport.twoPane')], - label: 'H', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 8, - tags: [const SemanticsTag('RenderViewport.twoPane')], - label: 'V', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 9, - tags: [const SemanticsTag('RenderViewport.twoPane')], - label: 'N', - textDirection: TextDirection.ltr, - ), - ], + id: 5, + tags: [const SemanticsTag('RenderViewport.twoPane')], + label: 'Target', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 6, + tags: [const SemanticsTag('RenderViewport.twoPane')], + label: 'H', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 7, + tags: [const SemanticsTag('RenderViewport.twoPane')], + label: 'V', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 8, + tags: [const SemanticsTag('RenderViewport.twoPane')], + label: 'N', + textDirection: TextDirection.ltr, ), ], ), @@ -3342,39 +3337,34 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - id: 5, + id: 9, + flags: [SemanticsFlag.hasImplicitScrolling], children: [ TestSemantics( - id: 10, - flags: [SemanticsFlag.hasImplicitScrolling], - children: [ - TestSemantics( - id: 6, - tags: [const SemanticsTag('RenderViewport.twoPane')], - label: 'Target', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 7, - tags: [const SemanticsTag('RenderViewport.twoPane')], - label: 'H', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 8, - tags: [const SemanticsTag('RenderViewport.twoPane')], - label: 'V', - textDirection: TextDirection.ltr, - ), - /// N is moved offscreen. - ], + id: 5, + tags: [const SemanticsTag('RenderViewport.twoPane')], + label: 'Target', + textDirection: TextDirection.ltr, ), + TestSemantics( + id: 6, + tags: [const SemanticsTag('RenderViewport.twoPane')], + label: 'H', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 7, + tags: [const SemanticsTag('RenderViewport.twoPane')], + label: 'V', + textDirection: TextDirection.ltr, + ), + /// N is moved offscreen. ], ), ], diff --git a/packages/flutter/test/widgets/editable_text_test.dart b/packages/flutter/test/widgets/editable_text_test.dart index f08102bf4d3..d259253c2d3 100644 --- a/packages/flutter/test/widgets/editable_text_test.dart +++ b/packages/flutter/test/widgets/editable_text_test.dart @@ -4577,19 +4577,15 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - flags: [ - SemanticsFlag.isTextField, - SemanticsFlag.isObscured, - ], - value: expectedValue, - textDirection: TextDirection.ltr, - ), + flags: [ + SemanticsFlag.isTextField, + SemanticsFlag.isObscured, ], + value: expectedValue, + textDirection: TextDirection.ltr, ), ], ), @@ -4636,18 +4632,14 @@ void main() { TestSemantics( children:[ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - flags: [ - SemanticsFlag.isTextField, - ], - value: originalText, - textDirection: TextDirection.ltr, - ), + flags: [ + SemanticsFlag.isTextField, ], + value: originalText, + textDirection: TextDirection.ltr, ), ], ), @@ -4689,30 +4681,26 @@ void main() { TestSemantics( children:[ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - flags: [ - SemanticsFlag.isTextField, - SemanticsFlag.isObscured, - SemanticsFlag.isFocused, - ], - actions: [ - SemanticsAction.moveCursorBackwardByCharacter, - SemanticsAction.setSelection, - SemanticsAction.setText, - SemanticsAction.moveCursorBackwardByWord, - ], - value: expectedValue, - textDirection: TextDirection.ltr, - // Focusing a single-line field on web selects it. - textSelection: kIsWeb - ? const TextSelection(baseOffset: 0, extentOffset: 24) - : const TextSelection.collapsed(offset: 24), - ), + flags: [ + SemanticsFlag.isTextField, + SemanticsFlag.isObscured, + SemanticsFlag.isFocused, ], + actions: [ + SemanticsAction.moveCursorBackwardByCharacter, + SemanticsAction.setSelection, + SemanticsAction.setText, + SemanticsAction.moveCursorBackwardByWord, + ], + value: expectedValue, + textDirection: TextDirection.ltr, + // Focusing a single-line field on web selects it. + textSelection: kIsWeb + ? const TextSelection(baseOffset: 0, extentOffset: 24) + : const TextSelection.collapsed(offset: 24), ), ], ), @@ -4914,7 +4902,7 @@ void main() { await tester.pump(); final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner!; - const int expectedNodeId = 6; + const int expectedNodeId = 5; expect( semantics, @@ -4929,31 +4917,26 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ - TestSemantics( - id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics.rootChild( - id: expectedNodeId, - flags: [ - SemanticsFlag.isTextField, - SemanticsFlag.isFocused, - ], - actions: [ - SemanticsAction.moveCursorBackwardByCharacter, - SemanticsAction.moveCursorBackwardByWord, - SemanticsAction.setSelection, - SemanticsAction.setText, - SemanticsAction.copy, - SemanticsAction.cut, - SemanticsAction.paste, - ], - value: 'test', - textSelection: TextSelection.collapsed(offset: controller.text.length), - textDirection: TextDirection.ltr, - ), + TestSemantics.rootChild( + id: expectedNodeId, + flags: [ + SemanticsFlag.isTextField, + SemanticsFlag.isFocused, ], + actions: [ + SemanticsAction.moveCursorBackwardByCharacter, + SemanticsAction.moveCursorBackwardByWord, + SemanticsAction.setSelection, + SemanticsAction.setText, + SemanticsAction.copy, + SemanticsAction.cut, + SemanticsAction.paste, + ], + value: 'test', + textSelection: TextSelection.collapsed(offset: controller.text.length), + textDirection: TextDirection.ltr, ), ], ), @@ -5001,7 +4984,7 @@ void main() { await tester.pump(); final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner!; - const int expectedNodeId = 6; + const int expectedNodeId = 5; expect(controller.value.selection.isCollapsed, isTrue); @@ -5042,7 +5025,7 @@ void main() { await tester.pump(); final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner!; - const int expectedNodeId = 5; + const int expectedNodeId = 4; expect( semantics, @@ -5057,25 +5040,20 @@ void main() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ - TestSemantics( - id: 4, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics.rootChild( - id: expectedNodeId, - flags: [ - SemanticsFlag.isTextField, - SemanticsFlag.isFocused, - ], - actions: [ - SemanticsAction.setSelection, - SemanticsAction.setText, - ], - textSelection: TextSelection.collapsed(offset: controller.text.length), - textDirection: TextDirection.ltr, - ), + TestSemantics.rootChild( + id: expectedNodeId, + flags: [ + SemanticsFlag.isTextField, + SemanticsFlag.isFocused, ], + actions: [ + SemanticsAction.setSelection, + SemanticsAction.setText, + ], + textSelection: TextSelection.collapsed(offset: controller.text.length), + textDirection: TextDirection.ltr, ), ], ), diff --git a/packages/flutter/test/widgets/navigator_test.dart b/packages/flutter/test/widgets/navigator_test.dart index ee471c2c751..2c893e0b6d4 100644 --- a/packages/flutter/test/widgets/navigator_test.dart +++ b/packages/flutter/test/widgets/navigator_test.dart @@ -5235,38 +5235,6 @@ void main() { ); }); }); - - testWidgets('Navigator does not hide semantics node of its sibling', (WidgetTester tester) async { - final SemanticsTester semantics = SemanticsTester(tester); - const MaterialPage page = MaterialPage(child: Text('page')); - - await tester.pumpWidget(MaterialApp( - home: Scaffold( - body: Stack( - textDirection: TextDirection.ltr, - children: [ - Semantics( - label: 'layer#1', - textDirection: TextDirection.ltr, - child: Container(), - ), - SizedBox( - height: 100, - width: 100, - child: Navigator( - pages: const >[page], - onPopPage: (_, __) => false - ), - ), - ], - ), - ), - )); - - expect(semantics, includesNodeWith(label: 'layer#1')); - - semantics.dispose(); - }); } typedef AnnouncementCallBack = void Function(Route?); diff --git a/packages/flutter/test/widgets/routes_test.dart b/packages/flutter/test/widgets/routes_test.dart index 9a12dc0155c..9d1023a2c5f 100644 --- a/packages/flutter/test/widgets/routes_test.dart +++ b/packages/flutter/test/widgets/routes_test.dart @@ -1700,37 +1700,32 @@ void main() { rect: TestSemantics.fullScreen, children: [ TestSemantics( - id: 2, + id: 6, rect: TestSemantics.fullScreen, children: [ TestSemantics( id: 7, rect: TestSemantics.fullScreen, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 8, + label: 'Hello World', rect: TestSemantics.fullScreen, - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 9, - label: 'Hello World', - rect: TestSemantics.fullScreen, - textDirection: TextDirection.ltr, - ), - ], + textDirection: TextDirection.ltr, ), ], ), - TestSemantics( - id: 6, - rect: TestSemantics.fullScreen, - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'test label', - textDirection: TextDirection.ltr, - ), ], ), + // Modal barrier is put after modal scope + TestSemantics( + id: 5, + rect: TestSemantics.fullScreen, + actions: [SemanticsAction.tap, SemanticsAction.dismiss], + label: 'test label', + textDirection: TextDirection.ltr, + ), ], ), ], diff --git a/packages/flutter/test/widgets/selectable_region_test.dart b/packages/flutter/test/widgets/selectable_region_test.dart index d215d2b7346..bc8908c1731 100644 --- a/packages/flutter/test/widgets/selectable_region_test.dart +++ b/packages/flutter/test/widgets/selectable_region_test.dart @@ -243,30 +243,26 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - label: 'Line one', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: 'Line two', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable - ], - actions: [SemanticsAction.tap], - label: 'Button', - textDirection: TextDirection.ltr, - ), + label: 'Line one', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: 'Line two', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable ], + actions: [SemanticsAction.tap], + label: 'Button', + textDirection: TextDirection.ltr, ), ], ), diff --git a/packages/flutter/test/widgets/selectable_text_test.dart b/packages/flutter/test/widgets/selectable_text_test.dart index 255efa8eb65..a63c4d02472 100644 --- a/packages/flutter/test/widgets/selectable_text_test.dart +++ b/packages/flutter/test/widgets/selectable_text_test.dart @@ -2544,33 +2544,29 @@ void main() { TestSemantics( children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], + flags: [SemanticsFlag.hasImplicitScrolling], + actions: [SemanticsAction.scrollUp], children: [ TestSemantics( - flags: [SemanticsFlag.hasImplicitScrolling], - actions: [SemanticsAction.scrollUp], + actions: [SemanticsAction.longPress], children: [ TestSemantics( - actions: [SemanticsAction.longPress], children: [ TestSemantics( - children: [ - TestSemantics( - label: 'onscreen\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isHidden, - SemanticsFlag.isLink, - ], - actions: [SemanticsAction.tap], - label: 'off screen', - textDirection: TextDirection.ltr, - ), + label: 'onscreen\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n', + textDirection: TextDirection.ltr, + ), + TestSemantics( + flags: [ + SemanticsFlag.isHidden, + SemanticsFlag.isLink, ], + actions: [SemanticsAction.tap], + label: 'off screen', + textDirection: TextDirection.ltr, ), ], ), @@ -2598,7 +2594,7 @@ void main() { // Test shows on screen. expect(controller.offset, 0.0); - tester.binding.pipelineOwner.semanticsOwner!.performAction(9, SemanticsAction.showOnScreen); + tester.binding.pipelineOwner.semanticsOwner!.performAction(8, SemanticsAction.showOnScreen); await tester.pumpAndSettle(); expect(controller.offset != 0.0, isTrue); 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 e4703860e9f..57f2c5740c0 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 @@ -118,37 +118,32 @@ void _tests() { children: [ TestSemantics( id: 3, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - id: 5, + id: 7, + flags: [SemanticsFlag.hasImplicitScrolling], children: [ TestSemantics( - id: 8, - flags: [SemanticsFlag.hasImplicitScrolling], - children: [ - TestSemantics( - id: 6, - tags: [const SemanticsTag('RenderViewport.twoPane')], - label: 'Plain text', - textDirection: TextDirection.ltr, - ), - TestSemantics( - id: 7, - tags: [const SemanticsTag('RenderViewport.twoPane')], - flags: [SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, SemanticsFlag.isSelected], - actions: [SemanticsAction.tap, SemanticsAction.decrease], - label: '\u202aInteractive text\u202c', - value: 'test-value', - increasedValue: 'test-increasedValue', - decreasedValue: 'test-decreasedValue', - hint: 'test-hint', - textDirection: TextDirection.rtl, - ), - ], + id: 5, + tags: [const SemanticsTag('RenderViewport.twoPane')], + label: 'Plain text', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 6, + tags: [const SemanticsTag('RenderViewport.twoPane')], + flags: [SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, SemanticsFlag.isSelected], + actions: [SemanticsAction.tap, SemanticsAction.decrease], + label: '\u202aInteractive text\u202c', + value: 'test-value', + increasedValue: 'test-increasedValue', + decreasedValue: 'test-decreasedValue', + hint: 'test-hint', + textDirection: TextDirection.rtl, ), ], ), diff --git a/packages/flutter/test/widgets/simple_semantics_test.dart b/packages/flutter/test/widgets/simple_semantics_test.dart index 975203a8cdf..4b5729ea5d4 100644 --- a/packages/flutter/test/widgets/simple_semantics_test.dart +++ b/packages/flutter/test/widgets/simple_semantics_test.dart @@ -63,20 +63,14 @@ void main() { TestSemantics( id: 3, rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 600.0), + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 600.0), - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - id: 5, - label: 'Hello!', - textDirection: TextDirection.ltr, - rect: const Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), - transform: Matrix4.translationValues(395.0, 295.0, 0.0), - ), - ], + label: 'Hello!', + textDirection: TextDirection.ltr, + rect: const Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), + transform: Matrix4.translationValues(395.0, 295.0, 0.0), ), ], ), diff --git a/packages/flutter_test/test/accessibility_test.dart b/packages/flutter_test/test/accessibility_test.dart index e020fa49c9f..2bf455c290f 100644 --- a/packages/flutter_test/test/accessibility_test.dart +++ b/packages/flutter_test/test/accessibility_test.dart @@ -296,7 +296,7 @@ void main() { expect(result.passed, false); expect( result.reason, - 'SemanticsNode#5(Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), ' + 'SemanticsNode#4(Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), ' 'label: "this is a test", textDirection: ltr):\n' 'Expected contrast ratio of at least 4.5 but found 1.17 for a font ' 'size of 14.0.\n' @@ -328,7 +328,7 @@ void main() { expect(result.passed, false); expect( result.reason, - 'SemanticsNode#5(Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), ' + 'SemanticsNode#4(Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), ' 'label: "this is a test", textDirection: ltr):\n' 'Expected contrast ratio of at least 4.5 but found 1.19 for a font ' 'size of 14.0.\n' @@ -715,7 +715,7 @@ void main() { expect(result.passed, false); expect( result.reason, - 'SemanticsNode#5(Rect.fromLTRB(376.0, 276.5, 424.0, 323.5), ' + 'SemanticsNode#4(Rect.fromLTRB(376.0, 276.5, 424.0, 323.5), ' 'actions: [tap]): expected tap ' 'target size of at least Size(48.0, 48.0), ' 'but found Size(48.0, 47.0)\n'