Unverified Commit 5623fea5 authored by chunhtai's avatar chunhtai Committed by GitHub

Reverse the semantics order of modal barrier and modal scope (#59290)

* Add semantics sort key for modal scope and modal barrier

* fix test

* fix test

* fix test

* fix space

* fix more tests

* addressing comments
parent 50612db8
...@@ -9,6 +9,7 @@ import 'dart:ui' as ui; ...@@ -9,6 +9,7 @@ import 'dart:ui' as ui;
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter/semantics.dart';
import 'actions.dart'; import 'actions.dart';
import 'basic.dart'; import 'basic.dart';
...@@ -1448,11 +1449,19 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T ...@@ -1448,11 +1449,19 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
child: barrier, child: barrier,
); );
} }
return IgnorePointer( barrier = IgnorePointer(
ignoring: animation.status == AnimationStatus.reverse || // changedInternalState is called when animation.status updates ignoring: animation.status == AnimationStatus.reverse || // changedInternalState is called when animation.status updates
animation.status == AnimationStatus.dismissed, // dismissed is possible when doing a manual pop gesture animation.status == AnimationStatus.dismissed, // dismissed is possible when doing a manual pop gesture
child: barrier, child: barrier,
); );
if (semanticsDismissible && barrierDismissible) {
// To be sorted after the _modalScope.
barrier = Semantics(
sortKey: const OrdinalSortKey(1.0),
child: barrier,
);
}
return barrier;
} }
// We cache the part of the modal scope that doesn't change from frame to // We cache the part of the modal scope that doesn't change from frame to
...@@ -1461,10 +1470,14 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T ...@@ -1461,10 +1470,14 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
// one of the builders // one of the builders
Widget _buildModalScope(BuildContext context) { Widget _buildModalScope(BuildContext context) {
return _modalScopeCache ??= _ModalScope<T>( // To be sorted before the _modalBarrier.
key: _scopeKey, return _modalScopeCache ??= Semantics(
route: this, sortKey: const OrdinalSortKey(0.0),
// _ModalScope calls buildTransitions() and buildChild(), defined above child: _ModalScope<T>(
key: _scopeKey,
route: this,
// _ModalScope calls buildTransitions() and buildChild(), defined above
)
); );
} }
......
...@@ -923,38 +923,51 @@ void main() { ...@@ -923,38 +923,51 @@ void main() {
TestSemantics( TestSemantics(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
],
label: 'Alert',
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
SemanticsFlag.hasImplicitScrolling, SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
], ],
label: 'Alert',
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'The title', flags: <SemanticsFlag>[
SemanticsFlag.hasImplicitScrolling,
],
children: <TestSemantics>[
TestSemantics(
label: 'The title',
),
TestSemantics(
label: 'The message',
),
],
), ),
TestSemantics(
label: 'The message',
),
],
),
TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.hasImplicitScrolling,
],
children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
SemanticsFlag.isButton, SemanticsFlag.hasImplicitScrolling,
], ],
actions: <SemanticsAction>[ children: <TestSemantics>[
SemanticsAction.tap, TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.isButton,
],
actions: <SemanticsAction>[
SemanticsAction.tap,
],
label: 'One',
),
TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.isButton,
],
actions: <SemanticsAction>[
SemanticsAction.tap,
],
label: 'Two',
),
], ],
label: 'One',
), ),
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
...@@ -963,20 +976,11 @@ void main() { ...@@ -963,20 +976,11 @@ void main() {
actions: <SemanticsAction>[ actions: <SemanticsAction>[
SemanticsAction.tap, SemanticsAction.tap,
], ],
label: 'Two', label: 'Cancel',
), ),
], ],
), ),
TestSemantics( ]
flags: <SemanticsFlag>[
SemanticsFlag.isButton,
],
actions: <SemanticsAction>[
SemanticsAction.tap,
],
label: 'Cancel',
),
],
), ),
], ],
), ),
......
...@@ -169,54 +169,58 @@ void main() { ...@@ -169,54 +169,58 @@ void main() {
expect( expect(
semantics, semantics,
hasSemantics( hasSemantics(
TestSemantics.root( TestSemantics.root(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute], children: <TestSemantics>[
children: <TestSemantics>[ TestSemantics(
TestSemantics( flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute], children: <TestSemantics>[
label: 'Alert', TestSemantics(
children: <TestSemantics>[ flags: <SemanticsFlag>[SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute],
TestSemantics( label: 'Alert',
flags: <SemanticsFlag>[ children: <TestSemantics>[
SemanticsFlag.hasImplicitScrolling, TestSemantics(
], flags: <SemanticsFlag>[
children: <TestSemantics>[ SemanticsFlag.hasImplicitScrolling,
TestSemantics(label: 'The Title'), ],
TestSemantics(label: 'Content'), children: <TestSemantics>[
], TestSemantics(label: 'The Title'),
), TestSemantics(label: 'Content'),
TestSemantics( ],
flags: <SemanticsFlag>[ ),
SemanticsFlag.hasImplicitScrolling, TestSemantics(
], flags: <SemanticsFlag>[
children: <TestSemantics>[ SemanticsFlag.hasImplicitScrolling,
TestSemantics( ],
flags: <SemanticsFlag>[SemanticsFlag.isButton], children: <TestSemantics>[
label: 'Cancel', TestSemantics(
), flags: <SemanticsFlag>[SemanticsFlag.isButton],
TestSemantics( label: 'Cancel',
flags: <SemanticsFlag>[SemanticsFlag.isButton], ),
label: 'OK', TestSemantics(
), flags: <SemanticsFlag>[SemanticsFlag.isButton],
], label: 'OK',
), ),
], ],
), ),
], ],
), ),
], ],
), ),
], ]
)
],
),
],
),
ignoreId: true,
ignoreRect: true,
ignoreTransform: true,
), ),
ignoreId: true, );
ignoreRect: true,
ignoreTransform: true,
),
);
semantics.dispose(); semantics.dispose();
}); });
......
...@@ -1370,37 +1370,41 @@ void main() { ...@@ -1370,37 +1370,41 @@ void main() {
TestSemantics( TestSemantics(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute], children: <TestSemantics> [
children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Leading', children: <TestSemantics>[
textDirection: TextDirection.ltr, TestSemantics(
), label: 'Leading',
TestSemantics( textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[ ),
SemanticsFlag.namesRoute, TestSemantics(
SemanticsFlag.isHeader, flags: <SemanticsFlag>[
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,
), ),
], ],
), ),
...@@ -1453,40 +1457,44 @@ void main() { ...@@ -1453,40 +1457,44 @@ void main() {
TestSemantics( TestSemantics(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
textDirection: TextDirection.rtl, flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
textDirection: TextDirection.rtl,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Leading', children: <TestSemantics>[
textDirection: TextDirection.rtl, TestSemantics(
), label: 'Leading',
TestSemantics( textDirection: TextDirection.rtl,
flags: <SemanticsFlag>[ ),
SemanticsFlag.namesRoute, TestSemantics(
SemanticsFlag.isHeader, flags: <SemanticsFlag>[
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,
), ),
], ],
), ),
...@@ -1530,17 +1538,21 @@ void main() { ...@@ -1530,17 +1538,21 @@ void main() {
TestSemantics( TestSemantics(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Leading', children: <TestSemantics>[
textDirection: TextDirection.ltr, TestSemantics(
), label: 'Leading',
TestSemantics( textDirection: TextDirection.ltr,
label: 'Action 1', ),
textDirection: TextDirection.ltr, TestSemantics(
label: 'Action 1',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
...@@ -1583,22 +1595,26 @@ void main() { ...@@ -1583,22 +1595,26 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Leading', children: <TestSemantics>[
textDirection: TextDirection.ltr, TestSemantics(
), label: 'Leading',
TestSemantics( textDirection: TextDirection.ltr,
label: 'Action 1', ),
textDirection: TextDirection.ltr, TestSemantics(
label: 'Action 1',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
......
...@@ -504,19 +504,24 @@ void main() { ...@@ -504,19 +504,24 @@ void main() {
TestSemantics.rootChild( TestSemantics.rootChild(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Dialog',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'BottomSheet', label: 'Dialog',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
],
children: <TestSemantics>[
TestSemantics(
label: 'BottomSheet',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
TestSemantics(),
], ],
), ),
], ],
...@@ -603,25 +608,30 @@ void main() { ...@@ -603,25 +608,30 @@ void main() {
TestSemantics.rootChild( TestSemantics.rootChild(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Dialog',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling], label: 'Dialog',
actions: <SemanticsAction>[SemanticsAction.scrollDown, SemanticsAction.scrollUp], textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'BottomSheet', flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
textDirection: TextDirection.ltr, actions: <SemanticsAction>[SemanticsAction.scrollDown, SemanticsAction.scrollUp],
children: <TestSemantics>[
TestSemantics(
label: 'BottomSheet',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
], ],
), ),
TestSemantics(),
], ],
), ),
], ],
......
...@@ -1617,11 +1617,15 @@ void main() { ...@@ -1617,11 +1617,15 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'test', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr, children: <TestSemantics>[
TestSemantics(
label: 'test',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
...@@ -1651,18 +1655,22 @@ void main() { ...@@ -1651,18 +1655,22 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'test', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Delete', label: 'test',
actions: <SemanticsAction>[SemanticsAction.tap],
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[ children: <TestSemantics>[
SemanticsFlag.isButton, TestSemantics(
label: 'Delete',
actions: <SemanticsAction>[SemanticsAction.tap],
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.isButton,
],
),
], ],
), ),
], ],
...@@ -1695,17 +1703,21 @@ void main() { ...@@ -1695,17 +1703,21 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute], children: <TestSemantics> [
children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'test', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr, children: <TestSemantics>[
flags: <SemanticsFlag>[ TestSemantics(
SemanticsFlag.hasEnabledState, label: 'test',
SemanticsFlag.isEnabled, textDirection: TextDirection.ltr,
SemanticsFlag.isFocusable, flags: <SemanticsFlag>[
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[SemanticsAction.tap],
),
], ],
actions: <SemanticsAction>[SemanticsAction.tap],
), ),
], ],
), ),
...@@ -1742,17 +1754,21 @@ void main() { ...@@ -1742,17 +1754,21 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'test', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr, children: <TestSemantics>[
flags: <SemanticsFlag>[ TestSemantics(
SemanticsFlag.hasEnabledState, label: 'test',
SemanticsFlag.isEnabled, textDirection: TextDirection.ltr,
SemanticsFlag.isFocusable, flags: <SemanticsFlag>[
SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[SemanticsAction.tap],
),
], ],
actions: <SemanticsAction>[SemanticsAction.tap],
), ),
], ],
), ),
...@@ -1783,18 +1799,22 @@ void main() { ...@@ -1783,18 +1799,22 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'test', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr, children: <TestSemantics>[
flags: <SemanticsFlag>[ TestSemantics(
SemanticsFlag.hasEnabledState, label: 'test',
SemanticsFlag.isEnabled, textDirection: TextDirection.ltr,
SemanticsFlag.isFocusable, flags: <SemanticsFlag>[
SemanticsFlag.isSelected, SemanticsFlag.hasEnabledState,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocusable,
SemanticsFlag.isSelected,
],
actions: <SemanticsAction>[SemanticsAction.tap],
),
], ],
actions: <SemanticsAction>[SemanticsAction.tap],
), ),
], ],
), ),
...@@ -1826,13 +1846,17 @@ void main() { ...@@ -1826,13 +1846,17 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'test', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr, children: <TestSemantics>[
flags: <SemanticsFlag>[], TestSemantics(
actions: <SemanticsAction>[], label: 'test',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[],
actions: <SemanticsAction>[],
),
],
), ),
], ],
), ),
......
...@@ -143,6 +143,7 @@ void main() { ...@@ -143,6 +143,7 @@ void main() {
' Offstage\n' ' Offstage\n'
' _ModalScopeStatus\n' ' _ModalScopeStatus\n'
' _ModalScope<dynamic>-[LabeledGlobalKey<_ModalScopeState<dynamic>>#00000]\n' ' _ModalScope<dynamic>-[LabeledGlobalKey<_ModalScopeState<dynamic>>#00000]\n'
' Semantics\n'
' _EffectiveTickerMode\n' ' _EffectiveTickerMode\n'
' TickerMode\n' ' TickerMode\n'
' _OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#00000]\n' ' _OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#00000]\n'
......
...@@ -1244,49 +1244,53 @@ void main() { ...@@ -1244,49 +1244,53 @@ void main() {
TestSemantics.rootChild( TestSemantics.rootChild(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
],
label: 'Popup menu',
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
],
label: 'Popup menu',
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.hasImplicitScrolling,
],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'one',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
SemanticsFlag.isFocused, SemanticsFlag.hasImplicitScrolling,
SemanticsFlag.isFocusable, ],
children: <TestSemantics>[
TestSemantics(
label: 'one',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[
SemanticsFlag.isFocused,
SemanticsFlag.isFocusable,
],
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
actions: <SemanticsAction>[SemanticsAction.tap],
),
TestSemantics(
label: 'two',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
actions: <SemanticsAction>[SemanticsAction.tap],
),
TestSemantics(
label: 'three',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
actions: <SemanticsAction>[SemanticsAction.tap],
),
TestSemantics(
label: 'four',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
actions: <SemanticsAction>[SemanticsAction.tap],
),
], ],
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
actions: <SemanticsAction>[SemanticsAction.tap],
),
TestSemantics(
label: 'two',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
actions: <SemanticsAction>[SemanticsAction.tap],
),
TestSemantics(
label: 'three',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
actions: <SemanticsAction>[SemanticsAction.tap],
),
TestSemantics(
label: 'four',
textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
actions: <SemanticsAction>[SemanticsAction.tap],
), ),
], ],
), ),
...@@ -1294,6 +1298,7 @@ void main() { ...@@ -1294,6 +1298,7 @@ void main() {
), ),
], ],
), ),
TestSemantics(),
], ],
), ),
], ],
......
...@@ -627,20 +627,24 @@ void main() { ...@@ -627,20 +627,24 @@ void main() {
TestSemantics.rootChild( TestSemantics.rootChild(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.scopesRoute,
],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Add Photo',
actions: <SemanticsAction>[
SemanticsAction.tap,
],
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
SemanticsFlag.hasEnabledState, SemanticsFlag.scopesRoute,
SemanticsFlag.isButton, ],
SemanticsFlag.isEnabled, children: <TestSemantics>[
SemanticsFlag.isFocusable, TestSemantics(
label: 'Add Photo',
actions: <SemanticsAction>[
SemanticsAction.tap,
],
flags: <SemanticsFlag>[
SemanticsFlag.hasEnabledState,
SemanticsFlag.isButton,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocusable,
],
),
], ],
), ),
], ],
......
...@@ -1974,38 +1974,42 @@ TestSemantics _expectedSemantics() { ...@@ -1974,38 +1974,42 @@ TestSemantics _expectedSemantics() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
SemanticsFlag.isSelected, children: <TestSemantics>[
SemanticsFlag.isFocusable, TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.isSelected,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Abc\nTab 1 of 4',
textDirection: TextDirection.ltr,
),
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Def\nTab 2 of 4',
textDirection: TextDirection.ltr,
),
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Ghi\nTab 3 of 4',
textDirection: TextDirection.ltr,
),
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Jkl\nTab 4 of 4',
textDirection: TextDirection.ltr,
),
TestSemantics(
label: 'body',
textDirection: TextDirection.ltr,
),
], ],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Abc\nTab 1 of 4',
textDirection: TextDirection.ltr,
),
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Def\nTab 2 of 4',
textDirection: TextDirection.ltr,
),
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Ghi\nTab 3 of 4',
textDirection: TextDirection.ltr,
),
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Jkl\nTab 4 of 4',
textDirection: TextDirection.ltr,
),
TestSemantics(
label: 'body',
textDirection: TextDirection.ltr,
), ),
], ],
), ),
......
...@@ -750,52 +750,57 @@ void main() { ...@@ -750,52 +750,57 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
],
label: 'Popup menu',
textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
SemanticsFlag.hasImplicitScrolling, SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
], ],
label: 'Popup menu',
textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isFocusable], flags: <SemanticsFlag>[
actions: <SemanticsAction>[SemanticsAction.tap], SemanticsFlag.hasImplicitScrolling,
label: '1', ],
textDirection: TextDirection.ltr, children: <TestSemantics>[
), TestSemantics(
TestSemantics( flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
flags: <SemanticsFlag>[SemanticsFlag.isFocusable], actions: <SemanticsAction>[SemanticsAction.tap],
actions: <SemanticsAction>[SemanticsAction.tap], label: '1',
label: '2', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
), TestSemantics(
TestSemantics( flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
flags: <SemanticsFlag>[SemanticsFlag.isFocusable], actions: <SemanticsAction>[SemanticsAction.tap],
actions: <SemanticsAction>[SemanticsAction.tap], label: '2',
label: '3', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
), TestSemantics(
TestSemantics( flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
flags: <SemanticsFlag>[SemanticsFlag.isFocusable], actions: <SemanticsAction>[SemanticsAction.tap],
actions: <SemanticsAction>[SemanticsAction.tap], label: '3',
label: '4', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
), TestSemantics(
TestSemantics( flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
flags: <SemanticsFlag>[SemanticsFlag.isFocusable], actions: <SemanticsAction>[SemanticsAction.tap],
actions: <SemanticsAction>[SemanticsAction.tap], label: '4',
label: '5', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isFocusable],
actions: <SemanticsAction>[SemanticsAction.tap],
label: '5',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
], ],
), ),
TestSemantics(),
], ],
), ),
], ],
......
...@@ -593,19 +593,54 @@ void main() { ...@@ -593,19 +593,54 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 7, id: 2,
flags: <SemanticsFlag>[
SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
],
label: routeName,
textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 9, id: 7,
flags: <SemanticsFlag>[
SemanticsFlag.scopesRoute,
SemanticsFlag.namesRoute,
],
label: routeName,
textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 10, id: 9,
children: <TestSemantics>[
TestSemantics(
id: 10,
flags: <SemanticsFlag>[
SemanticsFlag.hasEnabledState,
SemanticsFlag.isButton,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Back',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 11,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.isFocused,
SemanticsFlag.isHeader,
if (debugDefaultTargetPlatformOverride != TargetPlatform.iOS &&
debugDefaultTargetPlatformOverride != TargetPlatform.macOS) SemanticsFlag.namesRoute,
],
actions: <SemanticsAction>[
SemanticsAction.tap,
SemanticsAction.setSelection,
SemanticsAction.paste,
],
label: 'Search',
textDirection: TextDirection.ltr,
textSelection: const TextSelection(baseOffset: 0, extentOffset: 0),
),
],
),
TestSemantics(
id: 8,
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
SemanticsFlag.hasEnabledState, SemanticsFlag.hasEnabledState,
SemanticsFlag.isButton, SemanticsFlag.isButton,
...@@ -613,41 +648,11 @@ void main() { ...@@ -613,41 +648,11 @@ void main() {
SemanticsFlag.isFocusable, SemanticsFlag.isFocusable,
], ],
actions: <SemanticsAction>[SemanticsAction.tap], actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Back', label: 'Suggestions',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 11,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.isFocused,
SemanticsFlag.isHeader,
if (debugDefaultTargetPlatformOverride != TargetPlatform.iOS &&
debugDefaultTargetPlatformOverride != TargetPlatform.macOS) SemanticsFlag.namesRoute,
],
actions: <SemanticsAction>[
SemanticsAction.tap,
SemanticsAction.setSelection,
SemanticsAction.paste,
],
label: 'Search',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
textSelection: const TextSelection(baseOffset: 0, extentOffset: 0),
), ),
], ],
), ),
TestSemantics(
id: 8,
flags: <SemanticsFlag>[
SemanticsFlag.hasEnabledState,
SemanticsFlag.isButton,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocusable,
],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Suggestions',
textDirection: TextDirection.ltr,
),
], ],
), ),
], ],
......
...@@ -1341,16 +1341,21 @@ void main() { ...@@ -1341,16 +1341,21 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 2, id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 3, id: 3,
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable], flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
actions: <SemanticsAction>[SemanticsAction.increase, SemanticsAction.decrease], children: <TestSemantics>[
value: '50%', TestSemantics(
increasedValue: '55%', id: 4,
decreasedValue: '45%', flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable],
textDirection: TextDirection.ltr, actions: <SemanticsAction>[SemanticsAction.increase, SemanticsAction.decrease],
value: '50%',
increasedValue: '55%',
decreasedValue: '45%',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
...@@ -1390,15 +1395,20 @@ void main() { ...@@ -1390,15 +1395,20 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 2, id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 3, id: 3,
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState], flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
value: '50%', children: <TestSemantics>[
increasedValue: '55%', TestSemantics(
decreasedValue: '45%', id: 4,
textDirection: TextDirection.ltr, flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState],
value: '50%',
increasedValue: '55%',
decreasedValue: '45%',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
...@@ -1449,16 +1459,21 @@ void main() { ...@@ -1449,16 +1459,21 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 2, id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 3, id: 3,
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable], flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
actions: <SemanticsAction>[SemanticsAction.increase, SemanticsAction.decrease], children: <TestSemantics>[
value: '50%', TestSemantics(
increasedValue: '60%', id: 4,
decreasedValue: '40%', flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable],
textDirection: TextDirection.ltr, actions: <SemanticsAction>[SemanticsAction.increase, SemanticsAction.decrease],
value: '50%',
increasedValue: '60%',
decreasedValue: '40%',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
...@@ -1498,15 +1513,20 @@ void main() { ...@@ -1498,15 +1513,20 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 2, id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 4, id: 3,
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState], flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
value: '50%', children: <TestSemantics>[
increasedValue: '60%', TestSemantics(
decreasedValue: '40%', id: 5,
textDirection: TextDirection.ltr, flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState],
value: '50%',
increasedValue: '60%',
decreasedValue: '40%',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
...@@ -1554,16 +1574,21 @@ void main() { ...@@ -1554,16 +1574,21 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 2, id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 3, id: 3,
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable], flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
actions: <SemanticsAction>[SemanticsAction.increase, SemanticsAction.decrease], children: <TestSemantics>[
value: '40', TestSemantics(
increasedValue: '60', id: 4,
decreasedValue: '20', flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable],
textDirection: TextDirection.ltr, actions: <SemanticsAction>[SemanticsAction.increase, SemanticsAction.decrease],
value: '40',
increasedValue: '60',
decreasedValue: '20',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
......
...@@ -1040,11 +1040,15 @@ void main() { ...@@ -1040,11 +1040,15 @@ void main() {
TestSemantics.rootChild( TestSemantics.rootChild(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Foo\nBar', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr, children: <TestSemantics>[
TestSemantics(
label: 'Foo\nBar',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
...@@ -1076,11 +1080,15 @@ void main() { ...@@ -1076,11 +1080,15 @@ void main() {
TestSemantics.rootChild( TestSemantics.rootChild(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Bar', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr, children: <TestSemantics>[
TestSemantics(
label: 'Bar',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
......
...@@ -1006,11 +1006,15 @@ void main() { ...@@ -1006,11 +1006,15 @@ void main() {
TestSemantics.rootChild( TestSemantics.rootChild(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Foo\nBar', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr, children: <TestSemantics>[
TestSemantics(
label: 'Foo\nBar',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
...@@ -1044,11 +1048,15 @@ void main() { ...@@ -1044,11 +1048,15 @@ void main() {
TestSemantics.rootChild( TestSemantics.rootChild(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Foo\nBar', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr, children: <TestSemantics>[
TestSemantics(
label: 'Foo\nBar',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
...@@ -1084,11 +1092,15 @@ void main() { ...@@ -1084,11 +1092,15 @@ void main() {
TestSemantics.rootChild( TestSemantics.rootChild(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Bar', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr, children: <TestSemantics>[
TestSemantics(
label: 'Bar',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
...@@ -1122,11 +1134,15 @@ void main() { ...@@ -1122,11 +1134,15 @@ void main() {
TestSemantics.rootChild( TestSemantics.rootChild(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Bar', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr, children: <TestSemantics>[
TestSemantics(
label: 'Bar',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
......
...@@ -480,6 +480,8 @@ void main() { ...@@ -480,6 +480,8 @@ void main() {
TestSemantics( TestSemantics(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute], flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
...@@ -509,6 +511,8 @@ void main() { ...@@ -509,6 +511,8 @@ void main() {
), ),
], ],
), ),
],
),
], ],
), ),
], ],
...@@ -558,23 +562,27 @@ void main() { ...@@ -558,23 +562,27 @@ void main() {
TestSemantics( TestSemantics(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: 'Signed in', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr,
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
label: r'B', label: 'Signed in',
textDirection: TextDirection.ltr,
),
TestSemantics(
label: r'C',
textDirection: TextDirection.ltr,
),
TestSemantics(
label: r'D',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
label: r'B',
textDirection: TextDirection.ltr,
),
TestSemantics(
label: r'C',
textDirection: TextDirection.ltr,
),
TestSemantics(
label: r'D',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
......
...@@ -41,52 +41,57 @@ void main() { ...@@ -41,52 +41,57 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 2, id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 3, id: 3,
label: '0 - 0', flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr, children: <TestSemantics>[
), TestSemantics(
TestSemantics( id: 4,
id: 4, label: '0 - 0',
label: '0 - 1', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
), TestSemantics(
TestSemantics( id: 5,
id: 5, label: '0 - 1',
label: '0 - 2', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
), TestSemantics(
TestSemantics( id: 6,
id: 6, label: '0 - 2',
label: '1 - 0', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
), TestSemantics(
TestSemantics( id: 7,
id: 7, label: '1 - 0',
label: '1 - 1', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
), TestSemantics(
TestSemantics( id: 8,
id: 8, label: '1 - 1',
label: '1 - 2', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
), TestSemantics(
TestSemantics( id: 9,
id: 9, label: '1 - 2',
label: '2 - 0', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
), TestSemantics(
TestSemantics( id: 10,
id: 10, label: '2 - 0',
label: '2 - 1', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
), TestSemantics(
TestSemantics( id: 11,
id: 11, label: '2 - 1',
label: '2 - 2', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
TestSemantics(
id: 12,
label: '2 - 2',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
......
...@@ -2284,39 +2284,44 @@ void main() { ...@@ -2284,39 +2284,44 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 2, id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 3, id: 3,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 8, id: 4,
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
actions: <SemanticsAction>[SemanticsAction.scrollLeft],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 4, id: 9,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')], flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
label: 'Target', actions: <SemanticsAction>[SemanticsAction.scrollLeft],
textDirection: TextDirection.ltr, children: <TestSemantics>[
), TestSemantics(
TestSemantics( id: 5,
id: 5, tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')], label: 'Target',
label: 'H', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
), TestSemantics(
TestSemantics( id: 6,
id: 6, tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')], label: 'H',
label: 'V', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
), TestSemantics(
TestSemantics( id: 7,
id: 7, tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')], label: 'V',
label: 'N', textDirection: TextDirection.ltr,
textDirection: TextDirection.ltr, ),
TestSemantics(
id: 8,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
label: 'N',
textDirection: TextDirection.ltr,
),
],
), ),
], ],
), ),
...@@ -2345,34 +2350,39 @@ void main() { ...@@ -2345,34 +2350,39 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 2, id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 3, id: 3,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 8, id: 4,
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 4, id: 9,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')], flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
label: 'Target', children: <TestSemantics>[
textDirection: TextDirection.ltr, TestSemantics(
), id: 5,
TestSemantics( tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
id: 5, label: 'Target',
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')], textDirection: TextDirection.ltr,
label: 'H', ),
textDirection: TextDirection.ltr, TestSemantics(
), id: 6,
TestSemantics( tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
id: 6, label: 'H',
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')], textDirection: TextDirection.ltr,
label: 'V', ),
textDirection: TextDirection.ltr, TestSemantics(
id: 7,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
label: 'V',
textDirection: TextDirection.ltr,
),
/// N is moved offscreen.
],
), ),
/// N is moved offscreen.
], ],
), ),
], ],
......
...@@ -2375,18 +2375,22 @@ void main() { ...@@ -2375,18 +2375,22 @@ void main() {
TestSemantics.rootChild( TestSemantics.rootChild(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
SemanticsFlag.isTextField, children: <TestSemantics>[
SemanticsFlag.isObscured, TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.isObscured,
],
value: expectedValue,
textDirection: TextDirection.ltr,
),
], ],
value: expectedValue, )
textDirection: TextDirection.ltr,
),
], ],
), )
], ],
), ),
], ],
...@@ -2426,16 +2430,20 @@ void main() { ...@@ -2426,16 +2430,20 @@ void main() {
TestSemantics.rootChild( TestSemantics.rootChild(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute], children:<TestSemantics>[
children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
SemanticsFlag.isTextField, children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
],
value: originalText,
textDirection: TextDirection.ltr,
),
], ],
value: originalText,
textDirection: TextDirection.ltr,
), ),
], ]
), ),
], ],
), ),
...@@ -2471,25 +2479,29 @@ void main() { ...@@ -2471,25 +2479,29 @@ void main() {
TestSemantics.rootChild( TestSemantics.rootChild(
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute], children:<TestSemantics>[
children: <TestSemantics>[
TestSemantics( TestSemantics(
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
SemanticsFlag.isTextField, children: <TestSemantics>[
SemanticsFlag.isObscured, TestSemantics(
SemanticsFlag.isFocused, flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.isObscured,
SemanticsFlag.isFocused,
],
actions: <SemanticsAction>[
SemanticsAction.moveCursorBackwardByCharacter,
SemanticsAction.setSelection,
SemanticsAction.moveCursorBackwardByWord,
],
value: expectedValue,
textDirection: TextDirection.ltr,
textSelection: const TextSelection.collapsed(offset: 24),
),
], ],
actions: <SemanticsAction>[
SemanticsAction.moveCursorBackwardByCharacter,
SemanticsAction.setSelection,
SemanticsAction.moveCursorBackwardByWord,
],
value: expectedValue,
textDirection: TextDirection.ltr,
textSelection: const TextSelection.collapsed(offset: 24),
), ),
], ]
), )
], ],
), ),
], ],
...@@ -2654,7 +2666,7 @@ void main() { ...@@ -2654,7 +2666,7 @@ void main() {
await tester.pump(); await tester.pump();
final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner; final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner;
const int expectedNodeId = 4; const int expectedNodeId = 5;
expect( expect(
semantics, semantics,
...@@ -2666,29 +2678,34 @@ void main() { ...@@ -2666,29 +2678,34 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 2, id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics.rootChild( TestSemantics(
id: expectedNodeId, id: 3,
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
SemanticsFlag.isTextField, children: <TestSemantics>[
SemanticsFlag.isFocused, TestSemantics.rootChild(
id: expectedNodeId,
flags: <SemanticsFlag>[
SemanticsFlag.isTextField,
SemanticsFlag.isFocused,
],
actions: <SemanticsAction>[
SemanticsAction.moveCursorBackwardByCharacter,
SemanticsAction.moveCursorBackwardByWord,
SemanticsAction.setSelection,
SemanticsAction.copy,
SemanticsAction.cut,
SemanticsAction.paste,
],
value: 'test',
textSelection: TextSelection.collapsed(
offset: controller.text.length),
textDirection: TextDirection.ltr,
),
], ],
actions: <SemanticsAction>[
SemanticsAction.moveCursorBackwardByCharacter,
SemanticsAction.moveCursorBackwardByWord,
SemanticsAction.setSelection,
SemanticsAction.copy,
SemanticsAction.cut,
SemanticsAction.paste,
],
value: 'test',
textSelection: TextSelection.collapsed(
offset: controller.text.length),
textDirection: TextDirection.ltr,
), ),
], ]
), )
], ],
), ),
], ],
......
...@@ -13,6 +13,8 @@ import 'package:flutter/widgets.dart'; ...@@ -13,6 +13,8 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import 'semantics_tester.dart';
final List<String> results = <String>[]; final List<String> results = <String>[];
Set<TestRoute> routes = HashSet<TestRoute>(); Set<TestRoute> routes = HashSet<TestRoute>();
...@@ -1200,6 +1202,79 @@ void main() { ...@@ -1200,6 +1202,79 @@ void main() {
expect(modalBarrierAnimation.value, Colors.black); expect(modalBarrierAnimation.value, Colors.black);
}); });
testWidgets('modal route semantics order', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/46625.
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(MaterialApp(
home: Material(
child: Builder(
builder: (BuildContext context) {
return Center(
child: RaisedButton(
child: const Text('X'),
onPressed: () {
Navigator.of(context).push<void>(
_TestDialogRouteWithCustomBarrierCurve<void>(
child: const Text('Hello World'),
barrierLabel: 'test label',
barrierCurve: Curves.linear,
),
);
},
),
);
},
),
),
));
await tester.tap(find.text('X'));
await tester.pumpAndSettle();
expect(find.text('Hello World'), findsOneWidget);
final TestSemantics expectedSemantics = TestSemantics.root(
children: <TestSemantics>[
TestSemantics.rootChild(
id: 1,
rect: TestSemantics.fullScreen,
children: <TestSemantics>[
TestSemantics(
id: 6,
rect: TestSemantics.fullScreen,
children: <TestSemantics>[
TestSemantics(
id: 7,
rect: TestSemantics.fullScreen,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 8,
label: 'Hello World',
rect: TestSemantics.fullScreen,
textDirection: TextDirection.ltr,
),
],
),
],
),
// Modal barrier is put after modal scope
TestSemantics(
id: 5,
rect: TestSemantics.fullScreen,
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'test label',
textDirection: TextDirection.ltr,
),
],
),
],
)
;
expect(semantics, hasSemantics(expectedSemantics));
semantics.dispose();
}, variant: const TargetPlatformVariant(<TargetPlatform>{TargetPlatform.iOS}));
testWidgets('focus traverse correct when pop multiple page simultaneously', (WidgetTester tester) async { testWidgets('focus traverse correct when pop multiple page simultaneously', (WidgetTester tester) async {
// Regression test: https://github.com/flutter/flutter/issues/48903 // Regression test: https://github.com/flutter/flutter/issues/48903
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
...@@ -1401,6 +1476,7 @@ class DialogObserver extends NavigatorObserver { ...@@ -1401,6 +1476,7 @@ class DialogObserver extends NavigatorObserver {
class _TestDialogRouteWithCustomBarrierCurve<T> extends PopupRoute<T> { class _TestDialogRouteWithCustomBarrierCurve<T> extends PopupRoute<T> {
_TestDialogRouteWithCustomBarrierCurve({ _TestDialogRouteWithCustomBarrierCurve({
@required Widget child, @required Widget child,
this.barrierLabel,
Curve barrierCurve, Curve barrierCurve,
}) : _barrierCurve = barrierCurve, }) : _barrierCurve = barrierCurve,
_child = child; _child = child;
...@@ -1411,7 +1487,7 @@ class _TestDialogRouteWithCustomBarrierCurve<T> extends PopupRoute<T> { ...@@ -1411,7 +1487,7 @@ class _TestDialogRouteWithCustomBarrierCurve<T> extends PopupRoute<T> {
bool get barrierDismissible => true; bool get barrierDismissible => true;
@override @override
String get barrierLabel => null; final String barrierLabel;
@override @override
Color get barrierColor => Colors.black; // easier value to test against Color get barrierColor => Colors.black; // easier value to test against
......
...@@ -112,32 +112,37 @@ void _tests() { ...@@ -112,32 +112,37 @@ void _tests() {
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 2, id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 3, id: 3,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 6, id: 4,
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 4, id: 7,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')], flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
label: 'Plain text', children: <TestSemantics>[
textDirection: TextDirection.ltr, TestSemantics(
), id: 5,
TestSemantics( tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
id: 5, label: 'Plain text',
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')], textDirection: TextDirection.ltr,
flags: <SemanticsFlag>[SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, SemanticsFlag.isSelected], ),
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.decrease], TestSemantics(
label: '‪Interactive text‬', id: 6,
value: 'test-value', tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
increasedValue: 'test-increasedValue', flags: <SemanticsFlag>[SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, SemanticsFlag.isSelected],
decreasedValue: 'test-decreasedValue', actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.decrease],
hint: 'test-hint', label: '‪Interactive text‬',
textDirection: TextDirection.rtl, value: 'test-value',
increasedValue: 'test-increasedValue',
decreasedValue: 'test-decreasedValue',
hint: 'test-hint',
textDirection: TextDirection.rtl,
),
],
), ),
], ],
), ),
......
...@@ -63,14 +63,20 @@ void main() { ...@@ -63,14 +63,20 @@ void main() {
TestSemantics( TestSemantics(
id: 2, id: 2,
rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 600.0), rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 600.0),
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[ children: <TestSemantics>[
TestSemantics( TestSemantics(
id: 3, id: 3,
label: 'Hello!', rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 600.0),
textDirection: TextDirection.ltr, flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
rect: const Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), children: <TestSemantics>[
transform: Matrix4.translationValues(395.0, 295.0, 0.0), 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),
),
],
), ),
], ],
), ),
......
...@@ -123,7 +123,7 @@ void main() { ...@@ -123,7 +123,7 @@ void main() {
final Evaluation result = await textContrastGuideline.evaluate(tester); final Evaluation result = await textContrastGuideline.evaluate(tester);
expect(result.passed, false); expect(result.passed, false);
expect(result.reason, expect(result.reason,
'SemanticsNode#3(Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), label: "this is a test",' 'SemanticsNode#4(Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), label: "this is a test",'
' textDirection: ltr):\nExpected contrast ratio of at least ' ' textDirection: ltr):\nExpected contrast ratio of at least '
'4.5 but found 1.17 for a font size of 14.0. The ' '4.5 but found 1.17 for a font size of 14.0. The '
'computed light color was: Color(0xfffafafa), The computed dark color was:' 'computed light color was: Color(0xfffafafa), The computed dark color was:'
...@@ -410,7 +410,7 @@ void main() { ...@@ -410,7 +410,7 @@ void main() {
final Evaluation result = await androidTapTargetGuideline.evaluate(tester); final Evaluation result = await androidTapTargetGuideline.evaluate(tester);
expect(result.passed, false); expect(result.passed, false);
expect(result.reason, expect(result.reason,
'SemanticsNode#3(Rect.fromLTRB(376.0, 276.5, 424.0, 323.5), actions: [tap]): expected tap ' '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' 'target size of at least Size(48.0, 48.0), but found Size(48.0, 47.0)\n'
'See also: https://support.google.com/accessibility/android/answer/7101858?hl=en'); 'See also: https://support.google.com/accessibility/android/answer/7101858?hl=en');
handle.dispose(); handle.dispose();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment