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;
import 'package:flutter/foundation.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/semantics.dart';
import 'actions.dart';
import 'basic.dart';
......@@ -1448,11 +1449,19 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
child: barrier,
);
}
return IgnorePointer(
barrier = IgnorePointer(
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
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
......@@ -1461,10 +1470,14 @@ abstract class ModalRoute<T> extends TransitionRoute<T> with LocalHistoryRoute<T
// one of the builders
Widget _buildModalScope(BuildContext context) {
return _modalScopeCache ??= _ModalScope<T>(
// To be sorted before the _modalBarrier.
return _modalScopeCache ??= Semantics(
sortKey: const OrdinalSortKey(0.0),
child: _ModalScope<T>(
key: _scopeKey,
route: this,
// _ModalScope calls buildTransitions() and buildChild(), defined above
)
);
}
......
......@@ -920,6 +920,8 @@ void main() {
hasSemantics(
TestSemantics.root(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
......@@ -978,6 +980,8 @@ void main() {
),
],
),
]
),
],
),
],
......
......@@ -171,6 +171,8 @@ void main() {
hasSemantics(
TestSemantics.root(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
......@@ -208,6 +210,8 @@ void main() {
),
],
),
]
)
],
),
],
......
......@@ -1369,6 +1369,8 @@ void main() {
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics> [
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
......@@ -1410,6 +1412,8 @@ void main() {
),
],
),
],
),
ignoreRect: true,
ignoreTransform: true,
ignoreId: true,
......@@ -1450,6 +1454,8 @@ void main() {
expect(semantics, hasSemantics(
TestSemantics.root(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
......@@ -1498,6 +1504,8 @@ void main() {
),
],
),
],
),
ignoreRect: true,
ignoreTransform: true,
ignoreId: true,
......@@ -1527,6 +1535,8 @@ void main() {
expect(semantics, hasSemantics(
TestSemantics.root(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
......@@ -1550,6 +1560,8 @@ void main() {
),
],
),
],
),
ignoreRect: true,
ignoreTransform: true,
ignoreId: true,
......@@ -1581,6 +1593,8 @@ void main() {
children: <TestSemantics>[
TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1612,6 +1626,8 @@ void main() {
),
],
),
],
),
ignoreRect: true,
ignoreTransform: true,
ignoreId: true,
......
......@@ -502,6 +502,8 @@ void main() {
expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[
TestSemantics.rootChild(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
label: 'Dialog',
......@@ -519,6 +521,9 @@ void main() {
),
],
),
TestSemantics(),
],
),
],
), ignoreTransform: true, ignoreRect: true, ignoreId: true));
semantics.dispose();
......@@ -601,6 +606,8 @@ void main() {
expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[
TestSemantics.rootChild(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
label: 'Dialog',
......@@ -624,6 +631,9 @@ void main() {
),
],
),
TestSemantics(),
],
),
],
), ignoreTransform: true, ignoreRect: true, ignoreId: true));
semantics.dispose();
......
......@@ -1615,6 +1615,8 @@ void main() {
children: <TestSemantics>[
TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1628,6 +1630,8 @@ void main() {
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
semanticsTester.dispose();
});
......@@ -1649,6 +1653,8 @@ void main() {
children: <TestSemantics>[
TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1672,6 +1678,8 @@ void main() {
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
semanticsTester.dispose();
});
......@@ -1694,6 +1702,8 @@ void main() {
TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics> [
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
......@@ -1712,6 +1722,8 @@ void main() {
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
semanticsTester.dispose();
......@@ -1740,6 +1752,8 @@ void main() {
children: <TestSemantics>[
TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1759,6 +1773,8 @@ void main() {
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
await tester.tap(find.byType(RawChip));
......@@ -1781,6 +1797,8 @@ void main() {
children: <TestSemantics>[
TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1801,6 +1819,8 @@ void main() {
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
semanticsTester.dispose();
......@@ -1824,6 +1844,8 @@ void main() {
children: <TestSemantics>[
TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1839,6 +1861,8 @@ void main() {
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
semanticsTester.dispose();
......
......@@ -143,6 +143,7 @@ void main() {
' Offstage\n'
' _ModalScopeStatus\n'
' _ModalScope<dynamic>-[LabeledGlobalKey<_ModalScopeState<dynamic>>#00000]\n'
' Semantics\n'
' _EffectiveTickerMode\n'
' TickerMode\n'
' _OverlayEntryWidget-[LabeledGlobalKey<_OverlayEntryWidgetState>#00000]\n'
......
......@@ -1242,6 +1242,8 @@ void main() {
expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[
TestSemantics.rootChild(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[
......@@ -1296,6 +1298,9 @@ void main() {
),
],
),
TestSemantics(),
],
),
],
), ignoreId: true, ignoreRect: true, ignoreTransform: true));
semantics.dispose();
......
......@@ -625,6 +625,8 @@ void main() {
expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[
TestSemantics.rootChild(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[
......@@ -648,6 +650,8 @@ void main() {
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
semantics.dispose();
......
......@@ -1972,6 +1972,8 @@ TestSemantics _expectedSemantics() {
children: <TestSemantics>[
TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -2012,6 +2014,8 @@ TestSemantics _expectedSemantics() {
],
),
],
),
],
);
}
......
......@@ -748,6 +748,8 @@ void main() {
children: <TestSemantics>[
TestSemantics(
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[
......@@ -798,6 +800,9 @@ void main() {
),
],
),
TestSemantics(),
],
),
],
),
ignoreId: true, ignoreTransform: true, ignoreRect: true,
......
......@@ -591,6 +591,9 @@ void main() {
TestSemantics(
id: 1,
textDirection: TextDirection.ltr,
children: <TestSemantics>[
TestSemantics(
id: 2,
children: <TestSemantics>[
TestSemantics(
id: 7,
......@@ -653,6 +656,8 @@ void main() {
],
),
],
),
],
);
}
......
......@@ -1341,10 +1341,13 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 3,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 4,
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable],
actions: <SemanticsAction>[SemanticsAction.increase, SemanticsAction.decrease],
value: '50%',
......@@ -1358,6 +1361,8 @@ void main() {
),
],
),
],
),
ignoreRect: true,
ignoreTransform: true,
),
......@@ -1390,10 +1395,13 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 3,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 4,
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState],
value: '50%',
increasedValue: '55%',
......@@ -1406,6 +1414,8 @@ void main() {
),
],
),
],
),
ignoreRect: true,
ignoreTransform: true,
),
......@@ -1449,10 +1459,13 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 3,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 4,
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable],
actions: <SemanticsAction>[SemanticsAction.increase, SemanticsAction.decrease],
value: '50%',
......@@ -1466,6 +1479,8 @@ void main() {
),
],
),
],
),
ignoreRect: true,
ignoreTransform: true,
),
......@@ -1498,10 +1513,13 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 2,
children: <TestSemantics>[
TestSemantics(
id: 3,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 4,
id: 5,
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState],
value: '50%',
increasedValue: '60%',
......@@ -1514,6 +1532,8 @@ void main() {
),
],
),
],
),
ignoreRect: true,
ignoreTransform: true,
),
......@@ -1554,10 +1574,13 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 3,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 4,
flags: <SemanticsFlag>[SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, SemanticsFlag.isFocusable],
actions: <SemanticsAction>[SemanticsAction.increase, SemanticsAction.decrease],
value: '40',
......@@ -1571,6 +1594,8 @@ void main() {
),
],
),
],
),
ignoreRect: true,
ignoreTransform: true,
),
......
......@@ -1038,6 +1038,8 @@ void main() {
expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[
TestSemantics.rootChild(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1051,6 +1053,8 @@ void main() {
],
),
],
),
],
), ignoreRect: true, ignoreId: true, ignoreTransform: true));
semantics.dispose();
......@@ -1074,6 +1078,8 @@ void main() {
expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[
TestSemantics.rootChild(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1087,6 +1093,8 @@ void main() {
],
),
],
),
],
), ignoreRect: true, ignoreId: true, ignoreTransform: true));
semantics.dispose();
......
......@@ -1004,6 +1004,8 @@ void main() {
expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[
TestSemantics.rootChild(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1017,6 +1019,8 @@ void main() {
],
),
],
),
],
), ignoreRect: true, ignoreId: true, ignoreTransform: true));
semantics.dispose();
......@@ -1042,6 +1046,8 @@ void main() {
expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[
TestSemantics.rootChild(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1055,6 +1061,8 @@ void main() {
],
),
],
),
],
), ignoreRect: true, ignoreId: true, ignoreTransform: true));
semantics.dispose();
......@@ -1082,6 +1090,8 @@ void main() {
expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[
TestSemantics.rootChild(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1095,6 +1105,8 @@ void main() {
],
),
],
),
],
), ignoreRect: true, ignoreId: true, ignoreTransform: true));
semantics.dispose();
......@@ -1120,6 +1132,8 @@ void main() {
expect(semantics, hasSemantics(TestSemantics.root(
children: <TestSemantics>[
TestSemantics.rootChild(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1133,6 +1147,8 @@ void main() {
],
),
],
),
],
), ignoreRect: true, ignoreId: true, ignoreTransform: true));
semantics.dispose();
......
......@@ -477,6 +477,8 @@ void main() {
hasSemantics(
TestSemantics(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
......@@ -513,6 +515,8 @@ void main() {
),
],
),
],
),
ignoreId: true, ignoreTransform: true, ignoreRect: true,
),
);
......@@ -555,6 +559,8 @@ void main() {
hasSemantics(
TestSemantics(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
......@@ -584,6 +590,8 @@ void main() {
),
],
),
],
),
ignoreId: true, ignoreTransform: true, ignoreRect: true,
),
);
......
......@@ -41,50 +41,53 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 3,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 4,
label: '0 - 0',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 4,
id: 5,
label: '0 - 1',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 5,
id: 6,
label: '0 - 2',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 6,
id: 7,
label: '1 - 0',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 7,
id: 8,
label: '1 - 1',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 8,
id: 9,
label: '1 - 2',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 9,
id: 10,
label: '2 - 0',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 10,
id: 11,
label: '2 - 1',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 11,
id: 12,
label: '2 - 2',
textDirection: TextDirection.ltr,
),
......@@ -93,6 +96,8 @@ void main() {
],
),
],
),
],
);
expect(semantics, hasSemantics(expected, ignoreRect: true, ignoreTransform: true));
semantics.dispose();
......
......@@ -2284,36 +2284,39 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 3,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 8,
id: 4,
children: <TestSemantics>[
TestSemantics(
id: 9,
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
actions: <SemanticsAction>[SemanticsAction.scrollLeft],
children: <TestSemantics>[
TestSemantics(
id: 4,
id: 5,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
label: 'Target',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 5,
id: 6,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
label: 'H',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 6,
id: 7,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
label: 'V',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 7,
id: 8,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
label: 'N',
textDirection: TextDirection.ltr,
......@@ -2327,6 +2330,8 @@ void main() {
],
),
],
),
],
), ignoreTransform: true, ignoreRect: true));
final Offset firstLocation = tester.getTopLeft(find.text('N'));
......@@ -2345,29 +2350,32 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 3,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 8,
id: 4,
children: <TestSemantics>[
TestSemantics(
id: 9,
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
children: <TestSemantics>[
TestSemantics(
id: 4,
id: 5,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
label: 'Target',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 5,
id: 6,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
label: 'H',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 6,
id: 7,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
label: 'V',
textDirection: TextDirection.ltr,
......@@ -2382,6 +2390,8 @@ void main() {
],
),
],
),
],
), ignoreTransform: true, ignoreRect: true));
semantics.dispose();
}, skip: isBrowser);
......
......@@ -2373,6 +2373,8 @@ void main() {
TestSemantics(
children: <TestSemantics>[
TestSemantics.rootChild(
children: <TestSemantics>[
TestSemantics(
children: <TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -2386,7 +2388,9 @@ void main() {
textDirection: TextDirection.ltr,
),
],
),
)
],
)
],
),
],
......@@ -2425,6 +2429,8 @@ void main() {
children: <TestSemantics>[
TestSemantics.rootChild(
children: <TestSemantics>[
TestSemantics(
children:<TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
......@@ -2437,6 +2443,8 @@ void main() {
),
],
),
]
),
],
),
],
......@@ -2470,6 +2478,8 @@ void main() {
children: <TestSemantics>[
TestSemantics.rootChild(
children: <TestSemantics>[
TestSemantics(
children:<TestSemantics>[
TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
......@@ -2490,6 +2500,8 @@ void main() {
),
],
),
]
)
],
),
],
......@@ -2654,7 +2666,7 @@ void main() {
await tester.pump();
final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner;
const int expectedNodeId = 4;
const int expectedNodeId = 5;
expect(
semantics,
......@@ -2666,6 +2678,9 @@ void main() {
children: <TestSemantics>[
TestSemantics(
id: 2,
children: <TestSemantics>[
TestSemantics(
id: 3,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics.rootChild(
......@@ -2689,6 +2704,8 @@ void main() {
),
],
),
]
)
],
),
],
......
......@@ -13,6 +13,8 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'semantics_tester.dart';
final List<String> results = <String>[];
Set<TestRoute> routes = HashSet<TestRoute>();
......@@ -1200,6 +1202,79 @@ void main() {
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 {
// Regression test: https://github.com/flutter/flutter/issues/48903
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
......@@ -1401,6 +1476,7 @@ class DialogObserver extends NavigatorObserver {
class _TestDialogRouteWithCustomBarrierCurve<T> extends PopupRoute<T> {
_TestDialogRouteWithCustomBarrierCurve({
@required Widget child,
this.barrierLabel,
Curve barrierCurve,
}) : _barrierCurve = barrierCurve,
_child = child;
......@@ -1411,7 +1487,7 @@ class _TestDialogRouteWithCustomBarrierCurve<T> extends PopupRoute<T> {
bool get barrierDismissible => true;
@override
String get barrierLabel => null;
final String barrierLabel;
@override
Color get barrierColor => Colors.black; // easier value to test against
......
......@@ -112,23 +112,26 @@ void _tests() {
children: <TestSemantics>[
TestSemantics(
id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 3,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 6,
id: 4,
children: <TestSemantics>[
TestSemantics(
id: 7,
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
children: <TestSemantics>[
TestSemantics(
id: 4,
id: 5,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
label: 'Plain text',
textDirection: TextDirection.ltr,
),
TestSemantics(
id: 5,
id: 6,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
flags: <SemanticsFlag>[SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, SemanticsFlag.isSelected],
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.decrease],
......@@ -149,6 +152,8 @@ void _tests() {
),
],
),
],
),
// ^^^^^^^^^^^^
ignoreRect: true,
ignoreTransform: true,
......
......@@ -63,10 +63,14 @@ void main() {
TestSemantics(
id: 2,
rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 600.0),
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 3,
rect: const Rect.fromLTWH(0.0, 0.0, 800.0, 600.0),
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
TestSemantics(
id: 4,
label: 'Hello!',
textDirection: TextDirection.ltr,
rect: const Rect.fromLTRB(0.0, 0.0, 10.0, 10.0),
......@@ -77,6 +81,8 @@ void main() {
],
),
],
),
],
)));
semantics.dispose();
......
......@@ -123,7 +123,7 @@ void main() {
final Evaluation result = await textContrastGuideline.evaluate(tester);
expect(result.passed, false);
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 '
'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:'
......@@ -410,7 +410,7 @@ void main() {
final Evaluation result = await androidTapTargetGuideline.evaluate(tester);
expect(result.passed, false);
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'
'See also: https://support.google.com/accessibility/android/answer/7101858?hl=en');
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