Unverified Commit a7d7652a authored by Yegor's avatar Yegor Committed by GitHub

Set text direction in semantics along with Directionality (#16907)

* Set text direction in semantics along with Directionality

* update tests for the extra SemanticsNode
parent 00221820
......@@ -544,7 +544,9 @@ class _LocalizationsState extends State<Localizations> {
Widget build(BuildContext context) {
if (_locale == null)
return new Container();
return new _LocalizationsScope(
return new Semantics(
textDirection: _textDirection,
child: new _LocalizationsScope(
key: _localizedResourcesScopeKey,
locale: _locale,
localizationsState: this,
......@@ -553,6 +555,7 @@ class _LocalizationsState extends State<Localizations> {
textDirection: _textDirection,
child: widget.child,
),
),
);
}
}
......@@ -1214,6 +1214,8 @@ void main() {
expect(semantics, hasSemantics(
new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics(
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1251,6 +1253,8 @@ void main() {
),
],
),
],
),
ignoreRect: true,
ignoreTransform: true,
ignoreId: true,
......@@ -1290,6 +1294,8 @@ void main() {
expect(semantics, hasSemantics(
new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics(
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
......@@ -1332,6 +1338,8 @@ void main() {
),
],
),
],
),
ignoreRect: true,
ignoreTransform: true,
ignoreId: true,
......
......@@ -519,19 +519,22 @@ void main() {
children: <TestSemantics>[
new TestSemantics(
id: 2,
children: <TestSemantics>[
new TestSemantics(
id: 3,
flags: <SemanticsFlag>[SemanticsFlag.isSelected],
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'AC\nTab 1 of 3',
textDirection: TextDirection.ltr,
),
new TestSemantics(
id: 3,
id: 4,
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Alarm\nTab 2 of 3',
textDirection: TextDirection.ltr,
),
new TestSemantics(
id: 4,
id: 5,
actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Hot Tub\nTab 3 of 3',
textDirection: TextDirection.ltr,
......@@ -539,6 +542,8 @@ void main() {
],
),
],
),
],
);
expect(semantics, hasSemantics(expected, ignoreTransform: true, ignoreRect: true));
......
......@@ -609,7 +609,11 @@ void _tests() {
);
expect(semantics, hasSemantics(
new TestSemantics.root(children: <TestSemantics>[expected]),
new TestSemantics.root(children: <TestSemantics>[
new TestSemantics(
children: <TestSemantics>[expected],
),
]),
ignoreId: true,
ignoreTransform: true,
ignoreRect: true,
......
......@@ -281,6 +281,8 @@ void main() {
expect(semantics, hasSemantics(new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics.rootChild(
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[
SemanticsFlag.scopesRoute,
],
......@@ -299,6 +301,8 @@ void main() {
],
),
],
),
],
), ignoreTransform: true, ignoreId: true, ignoreRect: true));
semantics.dispose();
......
......@@ -1361,6 +1361,10 @@ void main() {
children: <TestSemantics>[
new TestSemantics(
id: 3,
rect: TestSemantics.fullScreen,
children: <TestSemantics>[
new TestSemantics(
id: 4,
actions: SemanticsAction.tap.index,
flags: SemanticsFlag.isSelected.index,
label: 'TAB #0\nTab 1 of 2',
......@@ -1368,7 +1372,7 @@ void main() {
transform: new Matrix4.translationValues(0.0, 276.0, 0.0),
),
new TestSemantics(
id: 4,
id: 5,
actions: SemanticsAction.tap.index,
label: 'TAB #1\nTab 2 of 2',
rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight),
......@@ -1379,6 +1383,8 @@ void main() {
],
),
],
),
],
);
expect(semantics, hasSemantics(expectedSemantics));
......@@ -1618,6 +1624,10 @@ void main() {
children: <TestSemantics>[
new TestSemantics(
id: 3,
rect: TestSemantics.fullScreen,
children: <TestSemantics>[
new TestSemantics(
id: 4,
actions: SemanticsAction.tap.index,
flags: SemanticsFlag.isSelected.index,
label: 'Semantics override 0\nTab 1 of 2',
......@@ -1625,7 +1635,7 @@ void main() {
transform: new Matrix4.translationValues(0.0, 276.0, 0.0),
),
new TestSemantics(
id: 4,
id: 5,
actions: SemanticsAction.tap.index,
label: 'Semantics override 1\nTab 2 of 2',
rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight),
......@@ -1636,6 +1646,8 @@ void main() {
],
),
],
),
],
);
expect(semantics, hasSemantics(expectedSemantics));
......
......@@ -622,6 +622,8 @@ void main() {
expect(semantics, hasSemantics(new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics.rootChild(
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
new TestSemantics(
......@@ -631,6 +633,8 @@ void main() {
],
),
],
),
],
), ignoreRect: true, ignoreId: true, ignoreTransform: true));
semantics.dispose();
......@@ -654,6 +658,8 @@ void main() {
expect(semantics, hasSemantics(new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics.rootChild(
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
new TestSemantics(
......@@ -663,6 +669,8 @@ void main() {
],
),
],
),
],
), ignoreRect: true, ignoreId: true, ignoreTransform: true));
semantics.dispose();
......
......@@ -330,6 +330,8 @@ void main() {
expect(
semantics,
hasSemantics(
new TestSemantics(
children: <TestSemantics>[
new TestSemantics(
children: <TestSemantics>[
new TestSemantics(
......@@ -363,6 +365,8 @@ void main() {
),
],
),
],
),
ignoreId: true, ignoreTransform: true, ignoreRect: true,
),
);
......@@ -382,6 +386,8 @@ void main() {
expect(
semantics,
hasSemantics(
new TestSemantics(
children: <TestSemantics>[
new TestSemantics(
children: <TestSemantics>[
new TestSemantics(
......@@ -409,6 +415,8 @@ void main() {
),
],
),
],
),
ignoreId: true, ignoreTransform: true, ignoreRect: true,
),
);
......
......@@ -592,6 +592,8 @@ void main() {
expect(semantics, hasSemantics(new TestSemantics(
children: <TestSemantics>[
new TestSemantics.rootChild(
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
new TestSemantics(
......@@ -602,6 +604,8 @@ void main() {
],
),
],
),
],
), ignoreTransform: true, ignoreRect: true, ignoreId: true));
semantics.dispose();
......@@ -714,12 +718,15 @@ void main() {
await tester.pump();
final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner;
const int expectedNodeId = 3;
const int expectedNodeId = 4;
expect(semantics, hasSemantics(new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics.rootChild(
id: 1,
children: <TestSemantics>[
new TestSemantics(
id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
new TestSemantics.rootChild(
......@@ -742,6 +749,8 @@ void main() {
],
),
],
),
],
), ignoreRect: true, ignoreTransform: true));
owner.performAction(expectedNodeId, SemanticsAction.copy);
......
......@@ -105,22 +105,26 @@ void _tests() {
children: <TestSemantics>[
new TestSemantics(
id: 1,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
textDirection: TextDirection.ltr,
children: <TestSemantics>[
new TestSemantics(
id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
new TestSemantics(
id: 5,
id: 3,
children: <TestSemantics>[
new TestSemantics(
id: 3,
id: 6,
children: <TestSemantics>[
new TestSemantics(
id: 4,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
label: 'Plain text',
textDirection: TextDirection.ltr,
),
new TestSemantics(
id: 4,
id: 5,
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
flags: <SemanticsFlag>[SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, SemanticsFlag.isSelected],
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.decrease],
......@@ -139,6 +143,8 @@ void _tests() {
),
],
),
],
),
// ^^^^^^^^^^^^
ignoreRect: true,
ignoreTransform: true,
......
......@@ -55,12 +55,16 @@ void main() {
expect(semantics, hasSemantics(new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics.rootChild(
rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 600.0),
id: 2,
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 600.0),
children: <TestSemantics>[
new TestSemantics(
id: 3,
rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 600.0),
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
new TestSemantics(
id: 4,
label: 'Hello!',
textDirection: TextDirection.ltr,
rect: new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0),
......@@ -69,6 +73,8 @@ void main() {
],
),
],
),
],
)));
semantics.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