diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index e6a58beb15..c5b09ab6bd 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -5569,10 +5569,17 @@ class NavigatorState extends State with TickerProviderStateMixin, Res includeSemantics: false, child: UnmanagedRestorationScope( bucket: bucket, - child: Overlay( - key: _overlayKey, - clipBehavior: widget.clipBehavior, - initialEntries: overlay == null ? _allRouteOverlayEntries.toList(growable: false) : const [], + // 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 [], + ), ), ), ), diff --git a/packages/flutter/test/cupertino/action_sheet_test.dart b/packages/flutter/test/cupertino/action_sheet_test.dart index c734737da0..d6fdaf12e9 100644 --- a/packages/flutter/test/cupertino/action_sheet_test.dart +++ b/packages/flutter/test/cupertino/action_sheet_test.dart @@ -960,63 +960,81 @@ void main() { TestSemantics.root( children: [ TestSemantics( + id: 1, + textDirection: TextDirection.ltr, children: [ TestSemantics( + id: 2, children: [ TestSemantics( - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], - label: 'Alert', + id: 6, children: [ TestSemantics( + id: 7, flags: [ - SemanticsFlag.hasImplicitScrolling, - ], - children: [ - TestSemantics( - label: 'The title', - ), - TestSemantics( - label: 'The message', - ), - ], - ), - TestSemantics( - flags: [ - SemanticsFlag.hasImplicitScrolling, + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute ], + label: 'Alert', + textDirection: TextDirection.ltr, children: [ TestSemantics( + id: 8, flags: [ - SemanticsFlag.isButton, + SemanticsFlag.hasImplicitScrolling ], - actions: [ - SemanticsAction.tap, + children: [ + TestSemantics( + id: 9, + label: 'The title', + textDirection: TextDirection.ltr, + ), + TestSemantics( + id: 10, + label: 'The message', + textDirection: TextDirection.ltr, + ), ], - label: 'One', ), TestSemantics( + id: 11, flags: [ - SemanticsFlag.isButton, + SemanticsFlag.hasImplicitScrolling ], - actions: [ - SemanticsAction.tap, + 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, + ), ], - label: 'Two', + ), + TestSemantics( + id: 14, + flags: [SemanticsFlag.isButton], + actions: [SemanticsAction.tap], + label: 'Cancel', + textDirection: TextDirection.ltr, ), ], ), - 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 7656623ebe..280b4ba5c8 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(4, SemanticsAction.decrease); + tester.binding.pipelineOwner.semanticsOwner!.performAction(5, 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 24bacd2ffa..290bf258a6 100644 --- a/packages/flutter/test/cupertino/dialog_test.dart +++ b/packages/flutter/test/cupertino/dialog_test.dart @@ -201,33 +201,37 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute], - label: 'Alert', + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [ - SemanticsFlag.hasImplicitScrolling, - ], - children: [ - TestSemantics(label: 'The Title'), - TestSemantics(label: 'Content'), - ], - ), - TestSemantics( - flags: [ - SemanticsFlag.hasImplicitScrolling, - ], + flags: [SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute], + label: 'Alert', children: [ TestSemantics( - flags: [SemanticsFlag.isButton], - label: 'Cancel', + flags: [ + SemanticsFlag.hasImplicitScrolling, + ], + children: [ + TestSemantics(label: 'The Title'), + TestSemantics(label: 'Content'), + ], ), TestSemantics( - flags: [SemanticsFlag.isButton], - label: 'OK', + flags: [ + SemanticsFlag.hasImplicitScrolling, + ], + children: [ + TestSemantics( + flags: [SemanticsFlag.isButton], + label: 'Cancel', + ), + TestSemantics( + 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 98d73d235f..28dde9fb15 100644 --- a/packages/flutter/test/cupertino/text_field_test.dart +++ b/packages/flutter/test/cupertino/text_field_test.dart @@ -525,15 +525,20 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.isTextField, - SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled,], - actions: [SemanticsAction.tap, - SemanticsAction.didGainAccessibilityFocus,], - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + id: 5, + flags: [SemanticsFlag.isTextField, + SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled,], + actions: [SemanticsAction.tap, + SemanticsAction.didGainAccessibilityFocus,], + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -548,7 +553,7 @@ void main() { )); expect(focusNode.hasFocus, isFalse); - semanticsOwner.performAction(4, SemanticsAction.didGainAccessibilityFocus); + semanticsOwner.performAction(5, 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 441e2c966c..1231725e4d 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -2369,37 +2369,41 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'Leading', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.namesRoute, - SemanticsFlag.isHeader, + 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: '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, ), ], ), @@ -2456,40 +2460,44 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - textDirection: TextDirection.rtl, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( + textDirection: TextDirection.rtl, children: [ TestSemantics( - label: 'Leading', - textDirection: TextDirection.rtl, - ), - TestSemantics( - flags: [ - SemanticsFlag.namesRoute, - SemanticsFlag.isHeader, + 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: '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, ), ], ), @@ -2537,17 +2545,21 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'Leading', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: 'Action 1', - textDirection: TextDirection.ltr, + children: [ + TestSemantics( + label: 'Leading', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: 'Action 1', + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -2594,30 +2606,34 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( children: [ TestSemantics( children: [ TestSemantics( - label: 'Leading', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: 'Action 1', - textDirection: TextDirection.ltr, + children: [ + TestSemantics( + label: 'Leading', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: 'Action 1', + textDirection: TextDirection.ltr, + ), + ], ), + TestSemantics(), ], ), - TestSemantics(), + TestSemantics( + flags: [SemanticsFlag.hasImplicitScrolling], + ), ], ), - TestSemantics( - flags: [SemanticsFlag.hasImplicitScrolling], - ), ], ), ], @@ -2663,38 +2679,42 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( children: [ TestSemantics( children: [ TestSemantics( - label: 'Leading', - textDirection: TextDirection.ltr, + children: [ + TestSemantics( + label: 'Leading', + textDirection: TextDirection.ltr, + ), + TestSemantics( + label: 'Action 1', + textDirection: TextDirection.ltr, + ), + ], ), TestSemantics( - label: 'Action 1', - textDirection: TextDirection.ltr, + children: [ + TestSemantics( + flags: [SemanticsFlag.isHeader], + label: 'Flexible space', + textDirection: TextDirection.ltr, + ), + ], ), ], ), TestSemantics( - children: [ - TestSemantics( - flags: [SemanticsFlag.isHeader], - label: 'Flexible space', - textDirection: TextDirection.ltr, - ), - ], + flags: [SemanticsFlag.hasImplicitScrolling], ), ], ), - 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 b9fc12edee..edad467bf7 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -2738,24 +2738,28 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [ - SemanticsFlag.isSelected, - SemanticsFlag.isFocusable, + 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, + ), ], - 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 8d1358dcc9..101b5dfa7a 100644 --- a/packages/flutter/test/material/bottom_sheet_test.dart +++ b/packages/flutter/test/material/bottom_sheet_test.dart @@ -839,27 +839,31 @@ void main() { TestSemantics( children: [ TestSemantics( - label: 'Dialog', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], children: [ TestSemantics( - label: 'BottomSheet', + label: 'Dialog', textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], + children: [ + TestSemantics( + label: 'BottomSheet', + textDirection: TextDirection.ltr, + ), + ], ), ], ), - ], - ), - TestSemantics( - children: [ TestSemantics( - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'Scrim', - textDirection: TextDirection.ltr, + children: [ + TestSemantics( + actions: [SemanticsAction.tap, SemanticsAction.dismiss], + label: 'Scrim', + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -1011,32 +1015,36 @@ void main() { TestSemantics( children: [ TestSemantics( - label: 'Dialog', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], children: [ TestSemantics( - flags: [SemanticsFlag.hasImplicitScrolling], + label: 'Dialog', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], children: [ TestSemantics( - label: 'BottomSheet', - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.hasImplicitScrolling], + children: [ + TestSemantics( + label: 'BottomSheet', + textDirection: TextDirection.ltr, + ), + ], ), ], ), ], ), - ], - ), - TestSemantics( - children: [ TestSemantics( - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'Scrim', - textDirection: TextDirection.ltr, + children: [ + TestSemantics( + actions: [SemanticsAction.tap, SemanticsAction.dismiss], + label: 'Scrim', + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -1084,21 +1092,25 @@ 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( - label: 'BottomSheet', - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.hasImplicitScrolling], + children: [ + TestSemantics( + label: 'BottomSheet', + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -1106,14 +1118,14 @@ void main() { ), ], ), - ], - ), - TestSemantics( - children: [ TestSemantics( - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'Scrim', - textDirection: TextDirection.ltr, + children: [ + TestSemantics( + actions: [SemanticsAction.tap, SemanticsAction.dismiss], + label: 'Scrim', + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -1155,34 +1167,38 @@ void main() { TestSemantics( children: [ TestSemantics( - label: 'Dialog', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], children: [ TestSemantics( - label: 'BottomSheet', + label: 'Dialog', textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], children: [ TestSemantics( - actions: [SemanticsAction.tap], - label: 'Dismiss', + label: 'BottomSheet', textDirection: TextDirection.ltr, + children: [ + TestSemantics( + actions: [SemanticsAction.tap], + label: 'Dismiss', + textDirection: TextDirection.ltr, + ), + ], ), ], ), ], ), - ], - ), - TestSemantics( - children: [ TestSemantics( - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'Scrim', - textDirection: TextDirection.ltr, + children: [ + TestSemantics( + 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 96da8329a6..ccd8ea4102 100644 --- a/packages/flutter/test/material/chip_test.dart +++ b/packages/flutter/test/material/chip_test.dart @@ -2896,14 +2896,18 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + ], + ), ], ), ], @@ -2945,23 +2949,27 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - ], + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - tooltip: 'Delete', - actions: [SemanticsAction.tap], + label: 'test', textDirection: TextDirection.ltr, flags: [ + SemanticsFlag.hasEnabledState, SemanticsFlag.isButton, - SemanticsFlag.isFocusable, + ], + children: [ + TestSemantics( + tooltip: 'Delete', + actions: [SemanticsAction.tap], + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.isFocusable, + ], + ), ], ), ], @@ -3005,18 +3013,22 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + ], + actions: [SemanticsAction.tap], + ), ], - actions: [SemanticsAction.tap], ), ], ), @@ -3063,18 +3075,22 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + ], + actions: [SemanticsAction.tap], + ), ], - actions: [SemanticsAction.tap], ), ], ), @@ -3115,19 +3131,23 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - SemanticsFlag.isSelected, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + SemanticsFlag.isSelected, + ], + actions: [SemanticsAction.tap], + ), ], - actions: [SemanticsAction.tap], ), ], ), @@ -3170,16 +3190,20 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + ], + actions: [], + ), ], - actions: [], ), ], ), @@ -3221,13 +3245,17 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [], // Must not be a button when tapping is disabled. - actions: [], + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + label: 'test', + textDirection: TextDirection.ltr, + flags: [], // Must not be a button when tapping is disabled. + actions: [], + ), + ], ), ], ), @@ -3270,18 +3298,22 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + label: 'test', + textDirection: TextDirection.ltr, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + ], + actions: [SemanticsAction.tap], + ), ], - actions: [SemanticsAction.tap], ), ], ), @@ -3322,14 +3354,18 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'test', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + 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 d3b47c8704..1353e36655 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart @@ -1716,31 +1716,36 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 5, - 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, + 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: 'action', - textDirection: TextDirection.ltr, ), ], ), @@ -1882,35 +1887,40 @@ 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: 7, - label: 'content', + id: 6, + label: 'title', textDirection: TextDirection.ltr, ), TestSemantics( - id: 8, - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, + 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, + ), ], - label: 'action', - textDirection: TextDirection.ltr, ), ], ), diff --git a/packages/flutter/test/material/dropdown_test.dart b/packages/flutter/test/material/dropdown_test.dart index 0a41c99378..7f29d05c16 100644 --- a/packages/flutter/test/material/dropdown_test.dart +++ b/packages/flutter/test/material/dropdown_test.dart @@ -1330,60 +1330,71 @@ void main() { expect(semantics, hasSemantics(TestSemantics.root( children: [ - TestSemantics.rootChild( - actions: [SemanticsAction.tap, SemanticsAction.dismiss], - label: 'Dismiss', - textDirection: TextDirection.ltr, + TestSemantics( children: [ TestSemantics( - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], - label: 'Popup menu', children: [ TestSemantics( children: [ TestSemantics( flags: [ - SemanticsFlag.hasImplicitScrolling, + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, ], + label: 'Popup menu', children: [ TestSemantics( - label: 'one', - textDirection: TextDirection.ltr, - flags: [ - SemanticsFlag.isFocused, - SemanticsFlag.isFocusable, + 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], + ), + ], + ), ], - 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 706f7653f4..8d05938a9f 100644 --- a/packages/flutter/test/material/flexible_space_bar_test.dart +++ b/packages/flutter/test/material/flexible_space_bar_test.dart @@ -214,81 +214,86 @@ void main() { TestSemantics( id: 3, rect: TestSemantics.fullScreen, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, rect: TestSemantics.fullScreen, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - id: 9, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, expandedHeight), + id: 5, + rect: TestSemantics.fullScreen, children: [ TestSemantics( - id: 12, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + id: 10, + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, expandedHeight), children: [ TestSemantics( id: 13, - rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 20.0), - flags: [ - SemanticsFlag.isHeader, - SemanticsFlag.namesRoute, + 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, + ), ], - label: 'Title', - textDirection: TextDirection.ltr, ), - ], - ), - TestSemantics( - id: 10, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), - children: [ TestSemantics( id: 11, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, expandedHeight), - label: 'Expanded title', + 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, + ), + ], + ), + ], + ), + TestSemantics( + id: 15, + flags: [SemanticsFlag.hasImplicitScrolling], + rect: TestSemantics.fullScreen, + actions: [SemanticsAction.scrollUp], + 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', 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, - ), - - ], - ), ], ), ], @@ -319,100 +324,106 @@ void main() { TestSemantics( id: 3, rect: TestSemantics.fullScreen, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, rect: TestSemantics.fullScreen, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - id: 9, - // The app bar is collapsed. - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 56.0), + id: 5, + rect: TestSemantics.fullScreen, children: [ TestSemantics( - id: 12, + id: 10, + // The app bar is collapsed. rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 56.0), children: [ TestSemantics( id: 13, - rect: const Rect.fromLTRB(0.0, 0.0, 100.0, 20.0), - flags: [ - SemanticsFlag.isHeader, - SemanticsFlag.namesRoute, + 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, + ), ], - label: 'Title', - textDirection: TextDirection.ltr, ), - ], - ), - // The flexible space bar still persists in the - // semantic tree even if it is collapsed. - TestSemantics( - id: 10, - rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 56.0), - children: [ + // The flexible space bar still persists in the + // semantic tree even if it is collapsed. TestSemantics( id: 11, - 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, 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, + ), + ], ), ], ), - ], - ), - 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, + flags: [SemanticsFlag.hasImplicitScrolling], + rect: TestSemantics.fullScreen, + actions: [SemanticsAction.scrollUp, SemanticsAction.scrollDown], + 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', + 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 95dfe57b73..eba1c6330c 100644 --- a/packages/flutter/test/material/floating_action_button_test.dart +++ b/packages/flutter/test/material/floating_action_button_test.dart @@ -691,20 +691,24 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [ - SemanticsFlag.scopesRoute, - ], children: [ TestSemantics( - tooltip: 'Add Photo', - actions: [ - SemanticsAction.tap, - ], flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, + SemanticsFlag.scopesRoute, + ], + children: [ + TestSemantics( + tooltip: 'Add Photo', + actions: [ + SemanticsAction.tap, + ], + 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 80d91f9e0e..d6d5d22d06 100644 --- a/packages/flutter/test/material/icon_button_test.dart +++ b/packages/flutter/test/material/icon_button_test.dart @@ -680,20 +680,24 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - actions: [ - SemanticsAction.tap, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + actions: [ + SemanticsAction.tap, + ], + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + SemanticsFlag.isSelected, + ], + label: 'link', + ), ], - 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 f722879c8a..502b108aee 100644 --- a/packages/flutter/test/material/menu_anchor_test.dart +++ b/packages/flutter/test/material/menu_anchor_test.dart @@ -3355,41 +3355,47 @@ void main() { TestSemantics( id: 3, rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - 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), + rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), + flags: [SemanticsFlag.scopesRoute], 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, 48.0), - flags: [SemanticsFlag.hasImplicitScrolling], + rect: const Rect.fromLTRB(0.0, 0.0, 120.0, 64.0), children: [ TestSemantics( id: 8, - label: 'Item 0', rect: const Rect.fromLTRB(0.0, 0.0, 120.0, 48.0), - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, + 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], + ), ], - actions: [SemanticsAction.tap], ), ], ), @@ -3426,20 +3432,26 @@ void main() { TestSemantics( id: 3, rect: const Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [ - SemanticsFlag.hasExpandedState, - SemanticsFlag.isFocused, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, + 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), + ), ], - 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 916b659429..77ad762a2e 100644 --- a/packages/flutter/test/material/navigation_rail_test.dart +++ b/packages/flutter/test/material/navigation_rail_test.dart @@ -5428,38 +5428,42 @@ TestSemantics _expectedSemantics() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [ - SemanticsFlag.isSelected, - SemanticsFlag.isFocusable, + 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, + ), ], - 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 e462834c91..3e29d7f5f7 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -1122,84 +1122,88 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], - label: 'Popup menu', - textDirection: TextDirection.ltr, children: [ TestSemantics( flags: [ - SemanticsFlag.hasImplicitScrolling, + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, ], + label: 'Popup menu', + textDirection: TextDirection.ltr, children: [ TestSemantics( flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, + SemanticsFlag.hasImplicitScrolling, ], - actions: [SemanticsAction.tap], - label: '1', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - 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: '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, - ), ], ), ], @@ -1254,40 +1258,44 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], - label: 'Popup menu', - textDirection: TextDirection.ltr, children: [ TestSemantics( flags: [ - SemanticsFlag.hasImplicitScrolling, + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, ], + label: 'Popup menu', + textDirection: TextDirection.ltr, children: [ TestSemantics( flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, + SemanticsFlag.hasImplicitScrolling, + ], + children: [ + TestSemantics( + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, + ], + actions: [SemanticsAction.tap], + label: 'test1\ntest2', + textDirection: TextDirection.ltr, + ), ], - 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, - ), ], ), ], @@ -1335,82 +1343,86 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], - label: 'Popup menu', - textDirection: TextDirection.ltr, children: [ TestSemantics( flags: [ - SemanticsFlag.hasImplicitScrolling, + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, ], + label: 'Popup menu', + textDirection: TextDirection.ltr, children: [ TestSemantics( flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, + SemanticsFlag.hasImplicitScrolling, ], - actions: [SemanticsAction.tap], - label: '1', - textDirection: TextDirection.ltr, - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, + 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: [], - 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 4b4359b769..2dd3758f74 100644 --- a/packages/flutter/test/material/search_test.dart +++ b/packages/flutter/test/material/search_test.dart @@ -641,85 +641,90 @@ 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: 6, + id: 5, 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, + ), + ], + ), TestSemantics( id: 8, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isButton, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, + children: [ + TestSemantics( + id: 12, + label: 'FlexibleSpace', + textDirection: TextDirection.ltr, + ), ], - actions: [SemanticsAction.tap], - tooltip: 'Back', - textDirection: TextDirection.ltr, - ), - TestSemantics( - 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: 7, - children: [ - TestSemantics( - id: 11, - label: 'FlexibleSpace', - textDirection: TextDirection.ltr, - ), + id: 6, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isButton, + SemanticsFlag.isEnabled, + SemanticsFlag.isFocusable, ], + 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, - ), ], ), ], @@ -791,19 +796,64 @@ void main() { id: 2, children: [ TestSemantics( - id: 7, - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], - label: routeName, - textDirection: TextDirection.ltr, + id: 3, children: [ TestSemantics( - id: 9, + id: 8, + flags: [ + SemanticsFlag.scopesRoute, + SemanticsFlag.namesRoute, + ], + label: routeName, + textDirection: TextDirection.ltr, 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, @@ -811,51 +861,11 @@ void main() { SemanticsFlag.isFocusable, ], actions: [SemanticsAction.tap], - 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', + label: 'Suggestions', 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 f422c0449b..b14bcfa7d2 100644 --- a/packages/flutter/test/material/slider_test.dart +++ b/packages/flutter/test/material/slider_test.dart @@ -1178,24 +1178,29 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - SemanticsFlag.isSlider, + 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, + ), ], - actions: [ - SemanticsAction.increase, - SemanticsAction.decrease, - ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, ), ], ), @@ -1237,20 +1242,25 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [ - SemanticsFlag.hasEnabledState, - // isFocusable is delayed by 1 frame. - SemanticsFlag.isFocusable, - SemanticsFlag.isSlider, + 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, + ), ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, ), ], ), @@ -1280,18 +1290,23 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isSlider, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + id: 5, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isSlider, + ], + value: '50%', + increasedValue: '55%', + decreasedValue: '45%', + textDirection: TextDirection.ltr, + ), ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, ), ], ), @@ -1344,16 +1359,21 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - 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.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, + ), + ], ), ], ), @@ -1395,15 +1415,20 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - id: 5, - flags: [SemanticsFlag.hasEnabledState, SemanticsFlag.isSlider], - value: '50%', - increasedValue: '60%', - decreasedValue: '40%', - textDirection: TextDirection.ltr, + id: 4, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + id: 6, + flags: [SemanticsFlag.hasEnabledState, SemanticsFlag.isSlider], + value: '50%', + increasedValue: '60%', + decreasedValue: '40%', + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -1451,25 +1476,30 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - SemanticsFlag.isSlider, + 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, + ), ], - actions: [ - SemanticsAction.increase, - SemanticsAction.decrease, - SemanticsAction.didGainAccessibilityFocus, - ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, ), ], ), @@ -1511,23 +1541,28 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [ - SemanticsFlag.hasEnabledState, - // isFocusable is delayed by 1 frame. - SemanticsFlag.isFocusable, - SemanticsFlag.isSlider, + 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, + ), ], - actions: [ - SemanticsAction.didGainAccessibilityFocus, - ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, ), ], ), @@ -1557,21 +1592,26 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isSlider, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + id: 5, + flags: [ + SemanticsFlag.hasEnabledState, + SemanticsFlag.isSlider, + ], + actions: [ + SemanticsAction.didGainAccessibilityFocus, + ], + value: '50%', + increasedValue: '55%', + decreasedValue: '45%', + textDirection: TextDirection.ltr, + ), ], - actions: [ - SemanticsAction.didGainAccessibilityFocus, - ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, ), ], ), @@ -1621,16 +1661,21 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - 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.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, + ), + ], ), ], ), @@ -1681,16 +1726,21 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - 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.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, + ), + ], ), ], ), @@ -2519,25 +2569,30 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [ - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, - SemanticsFlag.isFocusable, - SemanticsFlag.isSlider, + 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, + ), ], - actions: [ - SemanticsAction.increase, - SemanticsAction.decrease, - SemanticsAction.didGainAccessibilityFocus, - ], - value: '50%', - increasedValue: '55%', - decreasedValue: '45%', - textDirection: TextDirection.ltr, ), ], ), @@ -2552,7 +2607,7 @@ void main() { )); expect(focusNode.hasFocus, isFalse); - semanticsOwner.performAction(4, SemanticsAction.didGainAccessibilityFocus); + semanticsOwner.performAction(5, 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 9ae0c2676d..37dbe1be73 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 8d305794a4..01023a1993 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -742,17 +742,22 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - flags: [SemanticsFlag.isTextField], - actions: [ - SemanticsAction.tap, - SemanticsAction.didGainAccessibilityFocus, - SemanticsAction.didLoseAccessibilityFocus, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + id: 5, + flags: [SemanticsFlag.isTextField], + actions: [ + SemanticsAction.tap, + SemanticsAction.didGainAccessibilityFocus, + SemanticsAction.didLoseAccessibilityFocus, + ], + textDirection: TextDirection.ltr, + ), ], - textDirection: TextDirection.ltr, ), ], ), @@ -767,11 +772,11 @@ void main() { )); expect(focusNode.hasFocus, isFalse); - semanticsOwner.performAction(4, SemanticsAction.didGainAccessibilityFocus); + semanticsOwner.performAction(5, SemanticsAction.didGainAccessibilityFocus); await tester.pumpAndSettle(); expect(focusNode.hasFocus, isTrue); - semanticsOwner.performAction(4, SemanticsAction.didLoseAccessibilityFocus); + semanticsOwner.performAction(5, 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 205dbad447..c4fe09f32b 100644 --- a/packages/flutter/test/material/tooltip_test.dart +++ b/packages/flutter/test/material/tooltip_test.dart @@ -2130,12 +2130,16 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - tooltip: 'Foo', - label: 'Bar', - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + tooltip: 'Foo', + label: 'Bar', + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -2171,11 +2175,15 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'Bar', - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + 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 56a356db85..d1c36e46b7 100644 --- a/packages/flutter/test/material/tooltip_theme_test.dart +++ b/packages/flutter/test/material/tooltip_theme_test.dart @@ -1243,12 +1243,16 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - tooltip: 'Foo', - label: 'Bar', - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + tooltip: 'Foo', + label: 'Bar', + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -1286,12 +1290,16 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - tooltip: 'Foo', - label: 'Bar', - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + tooltip: 'Foo', + label: 'Bar', + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -1331,11 +1339,15 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'Bar', - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + label: 'Bar', + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -1373,11 +1385,15 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'Bar', - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + 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 a106eaabf8..1f1f964e35 100644 --- a/packages/flutter/test/material/user_accounts_drawer_header_test.dart +++ b/packages/flutter/test/material/user_accounts_drawer_header_test.dart @@ -525,30 +525,34 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.isFocusable], - label: 'Signed in\nname\nemail', - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.scopesRoute], 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', + flags: [SemanticsFlag.isFocusable], + label: 'Signed in\nname\nemail', 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, + ), + ], ), ], ), @@ -607,23 +611,27 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: 'Signed in', - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - label: r'B', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: r'C', - textDirection: TextDirection.ltr, - ), - TestSemantics( - label: r'D', + label: 'Signed in', 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 2b469bb113..78fc47c070 100644 --- a/packages/flutter/test/semantics/traversal_order_test.dart +++ b/packages/flutter/test/semantics/traversal_order_test.dart @@ -39,63 +39,66 @@ void main() { TestSemantics( id: 2, children: [ - 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, - ), - ], - ), - ], - ), - ], - ), - ], - ); + 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, + ), + ], + ), + ], + ), + ], + ), + ], + ), + ], + ); 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 5af50d9af4..d9dddd5929 100644 --- a/packages/flutter/test/widgets/draggable_test.dart +++ b/packages/flutter/test/widgets/draggable_test.dart @@ -3268,39 +3268,44 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - id: 9, - flags: [SemanticsFlag.hasImplicitScrolling], - actions: [SemanticsAction.scrollLeft], + id: 5, children: [ TestSemantics( - 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, + 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, + ), + ], ), ], ), @@ -3337,34 +3342,39 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - id: 9, - flags: [SemanticsFlag.hasImplicitScrolling], + id: 5, children: [ TestSemantics( - id: 5, - tags: [const SemanticsTag('RenderViewport.twoPane')], - label: 'Target', - textDirection: TextDirection.ltr, + 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. + ], ), - 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 d259253c2d..f08102bf4d 100644 --- a/packages/flutter/test/widgets/editable_text_test.dart +++ b/packages/flutter/test/widgets/editable_text_test.dart @@ -4577,15 +4577,19 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [ - SemanticsFlag.isTextField, - SemanticsFlag.isObscured, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + flags: [ + SemanticsFlag.isTextField, + SemanticsFlag.isObscured, + ], + value: expectedValue, + textDirection: TextDirection.ltr, + ), ], - value: expectedValue, - textDirection: TextDirection.ltr, ), ], ), @@ -4632,14 +4636,18 @@ void main() { TestSemantics( children:[ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [ - SemanticsFlag.isTextField, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + flags: [ + SemanticsFlag.isTextField, + ], + value: originalText, + textDirection: TextDirection.ltr, + ), ], - value: originalText, - textDirection: TextDirection.ltr, ), ], ), @@ -4681,26 +4689,30 @@ void main() { TestSemantics( children:[ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [ - SemanticsFlag.isTextField, - SemanticsFlag.isObscured, - SemanticsFlag.isFocused, + 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), + ), ], - 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), ), ], ), @@ -4902,7 +4914,7 @@ void main() { await tester.pump(); final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner!; - const int expectedNodeId = 5; + const int expectedNodeId = 6; expect( semantics, @@ -4917,26 +4929,31 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ - TestSemantics.rootChild( - id: expectedNodeId, - flags: [ - SemanticsFlag.isTextField, - SemanticsFlag.isFocused, + 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, + ), ], - 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, ), ], ), @@ -4984,7 +5001,7 @@ void main() { await tester.pump(); final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner!; - const int expectedNodeId = 5; + const int expectedNodeId = 6; expect(controller.value.selection.isCollapsed, isTrue); @@ -5025,7 +5042,7 @@ void main() { await tester.pump(); final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner!; - const int expectedNodeId = 4; + const int expectedNodeId = 5; expect( semantics, @@ -5040,20 +5057,25 @@ void main() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ - TestSemantics.rootChild( - id: expectedNodeId, - flags: [ - SemanticsFlag.isTextField, - SemanticsFlag.isFocused, + 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, + ), ], - 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 2c893e0b6d..ee471c2c75 100644 --- a/packages/flutter/test/widgets/navigator_test.dart +++ b/packages/flutter/test/widgets/navigator_test.dart @@ -5235,6 +5235,38 @@ 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 9d1023a2c5..9a12dc0155 100644 --- a/packages/flutter/test/widgets/routes_test.dart +++ b/packages/flutter/test/widgets/routes_test.dart @@ -1700,32 +1700,37 @@ void main() { rect: TestSemantics.fullScreen, children: [ TestSemantics( - id: 6, + id: 2, rect: TestSemantics.fullScreen, children: [ TestSemantics( id: 7, rect: TestSemantics.fullScreen, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 8, - label: 'Hello World', rect: TestSemantics.fullScreen, - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.scopesRoute], + children: [ + TestSemantics( + id: 9, + label: 'Hello World', + rect: TestSemantics.fullScreen, + 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 b0db7cefc7..5e6d3f5b2b 100644 --- a/packages/flutter/test/widgets/selectable_region_test.dart +++ b/packages/flutter/test/widgets/selectable_region_test.dart @@ -243,26 +243,30 @@ void main() { TestSemantics( 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 + 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, + ), ], - 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 a63c4d0247..255efa8eb6 100644 --- a/packages/flutter/test/widgets/selectable_text_test.dart +++ b/packages/flutter/test/widgets/selectable_text_test.dart @@ -2544,29 +2544,33 @@ void main() { TestSemantics( children: [ TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - flags: [SemanticsFlag.hasImplicitScrolling], - actions: [SemanticsAction.scrollUp], + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - actions: [SemanticsAction.longPress], + flags: [SemanticsFlag.hasImplicitScrolling], + actions: [SemanticsAction.scrollUp], children: [ TestSemantics( + actions: [SemanticsAction.longPress], 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, + 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, + ), ], - actions: [SemanticsAction.tap], - label: 'off screen', - textDirection: TextDirection.ltr, ), ], ), @@ -2594,7 +2598,7 @@ void main() { // Test shows on screen. expect(controller.offset, 0.0); - tester.binding.pipelineOwner.semanticsOwner!.performAction(8, SemanticsAction.showOnScreen); + tester.binding.pipelineOwner.semanticsOwner!.performAction(9, 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 57f2c5740c..e4703860e9 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,32 +118,37 @@ void _tests() { children: [ TestSemantics( id: 3, - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, + flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( - id: 7, - flags: [SemanticsFlag.hasImplicitScrolling], + id: 5, children: [ TestSemantics( - 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, + 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, + ), + ], ), ], ), diff --git a/packages/flutter/test/widgets/simple_semantics_test.dart b/packages/flutter/test/widgets/simple_semantics_test.dart index 4b5729ea5d..975203a8cd 100644 --- a/packages/flutter/test/widgets/simple_semantics_test.dart +++ b/packages/flutter/test/widgets/simple_semantics_test.dart @@ -63,14 +63,20 @@ void main() { TestSemantics( id: 3, rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 600.0), - flags: [SemanticsFlag.scopesRoute], children: [ TestSemantics( id: 4, - 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), + 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), + ), + ], ), ], ), diff --git a/packages/flutter_test/test/accessibility_test.dart b/packages/flutter_test/test/accessibility_test.dart index 2bf455c290..e020fa49c9 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#4(Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), ' + 'SemanticsNode#5(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#4(Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), ' + 'SemanticsNode#5(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#4(Rect.fromLTRB(376.0, 276.5, 424.0, 323.5), ' + 'SemanticsNode#5(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'