diff --git a/packages/flutter/lib/src/widgets/localizations.dart b/packages/flutter/lib/src/widgets/localizations.dart index d50b5223ee..92768b0fa9 100644 --- a/packages/flutter/lib/src/widgets/localizations.dart +++ b/packages/flutter/lib/src/widgets/localizations.dart @@ -544,14 +544,17 @@ class _LocalizationsState extends State { Widget build(BuildContext context) { if (_locale == null) return new Container(); - return new _LocalizationsScope( - key: _localizedResourcesScopeKey, - locale: _locale, - localizationsState: this, - typeToResources: _typeToResources, - child: new Directionality( - textDirection: _textDirection, - child: widget.child, + return new Semantics( + textDirection: _textDirection, + child: new _LocalizationsScope( + key: _localizedResourcesScopeKey, + locale: _locale, + localizationsState: this, + typeToResources: _typeToResources, + child: new Directionality( + textDirection: _textDirection, + child: widget.child, + ), ), ); } diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index 2a3e6b687d..c7aa4da07d 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -1216,34 +1216,38 @@ void main() { new TestSemantics.root( children: [ new TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ new TestSemantics( + flags: [SemanticsFlag.scopesRoute], children: [ new TestSemantics( - label: 'Leading', - textDirection: TextDirection.ltr, - ), - new TestSemantics( - flags: [SemanticsFlag.namesRoute], - label: 'Title', - textDirection: TextDirection.ltr, - ), - new TestSemantics( - label: 'Action 1', - textDirection: TextDirection.ltr, - ), - new TestSemantics( - label: 'Action 2', - textDirection: TextDirection.ltr, - ), - new TestSemantics( - label: 'Action 3', - textDirection: TextDirection.ltr, - ), - new TestSemantics( - label: 'Bottom', - textDirection: TextDirection.ltr, + children: [ + new TestSemantics( + label: 'Leading', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + flags: [SemanticsFlag.namesRoute], + label: 'Title', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + label: 'Action 1', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + label: 'Action 2', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + label: 'Action 3', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + label: 'Bottom', + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -1292,37 +1296,41 @@ void main() { new TestSemantics.root( children: [ new TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ new TestSemantics( - textDirection: TextDirection.rtl, + flags: [SemanticsFlag.scopesRoute], children: [ new TestSemantics( + textDirection: TextDirection.rtl, children: [ new TestSemantics( - label: 'Leading', - textDirection: TextDirection.rtl, - ), - new TestSemantics( - flags: [SemanticsFlag.namesRoute], - label: 'Title', - textDirection: TextDirection.rtl, - ), - new TestSemantics( - label: 'Action 1', - textDirection: TextDirection.rtl, - ), - new TestSemantics( - label: 'Action 2', - textDirection: TextDirection.rtl, - ), - new TestSemantics( - label: 'Action 3', - textDirection: TextDirection.rtl, - ), - new TestSemantics( - label: 'Bottom', - textDirection: TextDirection.rtl, + children: [ + new TestSemantics( + label: 'Leading', + textDirection: TextDirection.rtl, + ), + new TestSemantics( + flags: [SemanticsFlag.namesRoute], + label: 'Title', + textDirection: TextDirection.rtl, + ), + new TestSemantics( + label: 'Action 1', + textDirection: TextDirection.rtl, + ), + new TestSemantics( + label: 'Action 2', + textDirection: TextDirection.rtl, + ), + new TestSemantics( + label: 'Action 3', + textDirection: TextDirection.rtl, + ), + new TestSemantics( + label: 'Bottom', + textDirection: TextDirection.rtl, + ), + ], ), ], ), diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index 0a171adc60..20cf54c1f0 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -519,22 +519,27 @@ void main() { children: [ new TestSemantics( id: 2, - flags: [SemanticsFlag.isSelected], - actions: [SemanticsAction.tap], - label: 'AC\nTab 1 of 3', - textDirection: TextDirection.ltr, - ), - new TestSemantics( - id: 3, - actions: [SemanticsAction.tap], - label: 'Alarm\nTab 2 of 3', - textDirection: TextDirection.ltr, - ), - new TestSemantics( - id: 4, - actions: [SemanticsAction.tap], - label: 'Hot Tub\nTab 3 of 3', - textDirection: TextDirection.ltr, + children: [ + new TestSemantics( + id: 3, + flags: [SemanticsFlag.isSelected], + actions: [SemanticsAction.tap], + label: 'AC\nTab 1 of 3', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + id: 4, + actions: [SemanticsAction.tap], + label: 'Alarm\nTab 2 of 3', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + id: 5, + actions: [SemanticsAction.tap], + label: 'Hot Tub\nTab 3 of 3', + textDirection: TextDirection.ltr, + ), + ], ), ], ), diff --git a/packages/flutter/test/material/date_picker_test.dart b/packages/flutter/test/material/date_picker_test.dart index 0aebafae33..871a4b7796 100644 --- a/packages/flutter/test/material/date_picker_test.dart +++ b/packages/flutter/test/material/date_picker_test.dart @@ -609,7 +609,11 @@ void _tests() { ); expect(semantics, hasSemantics( - new TestSemantics.root(children: [expected]), + new TestSemantics.root(children: [ + new TestSemantics( + children: [expected], + ), + ]), ignoreId: true, ignoreTransform: true, ignoreRect: true, diff --git a/packages/flutter/test/material/floating_action_button_test.dart b/packages/flutter/test/material/floating_action_button_test.dart index d51810afb9..85621f8ecb 100644 --- a/packages/flutter/test/material/floating_action_button_test.dart +++ b/packages/flutter/test/material/floating_action_button_test.dart @@ -281,19 +281,23 @@ void main() { expect(semantics, hasSemantics(new TestSemantics.root( children: [ new TestSemantics.rootChild( - flags: [ - SemanticsFlag.scopesRoute, - ], children: [ new TestSemantics( - label: 'Add Photo', - actions: [ - SemanticsAction.tap - ], flags: [ - SemanticsFlag.isButton, - SemanticsFlag.hasEnabledState, - SemanticsFlag.isEnabled, + SemanticsFlag.scopesRoute, + ], + children: [ + new TestSemantics( + label: 'Add Photo', + actions: [ + SemanticsAction.tap + ], + flags: [ + SemanticsFlag.isButton, + SemanticsFlag.hasEnabledState, + SemanticsFlag.isEnabled, + ], + ), ], ), ], diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 96624fa683..918376a873 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -1360,22 +1360,28 @@ void main() { rect: TestSemantics.fullScreen, children: [ new TestSemantics( - id: 3, - actions: SemanticsAction.tap.index, - flags: SemanticsFlag.isSelected.index, - label: 'TAB #0\nTab 1 of 2', - rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight), - transform: new Matrix4.translationValues(0.0, 276.0, 0.0), - ), - new TestSemantics( - id: 4, - actions: SemanticsAction.tap.index, - label: 'TAB #1\nTab 2 of 2', - rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight), - transform: new Matrix4.translationValues(108.0, 276.0, 0.0), - ), - ] - ) + id: 3, + rect: TestSemantics.fullScreen, + children: [ + new TestSemantics( + id: 4, + actions: SemanticsAction.tap.index, + flags: SemanticsFlag.isSelected.index, + label: 'TAB #0\nTab 1 of 2', + rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight), + transform: new Matrix4.translationValues(0.0, 276.0, 0.0), + ), + new TestSemantics( + id: 5, + actions: SemanticsAction.tap.index, + label: 'TAB #1\nTab 2 of 2', + rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight), + transform: new Matrix4.translationValues(108.0, 276.0, 0.0), + ), + ] + ) + ], + ), ], ), ], @@ -1617,22 +1623,28 @@ void main() { rect: TestSemantics.fullScreen, children: [ new TestSemantics( - id: 3, - actions: SemanticsAction.tap.index, - flags: SemanticsFlag.isSelected.index, - label: 'Semantics override 0\nTab 1 of 2', - rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight), - transform: new Matrix4.translationValues(0.0, 276.0, 0.0), - ), - new TestSemantics( - id: 4, - actions: SemanticsAction.tap.index, - label: 'Semantics override 1\nTab 2 of 2', - rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight), - transform: new Matrix4.translationValues(108.0, 276.0, 0.0), - ), - ] - ) + id: 3, + rect: TestSemantics.fullScreen, + children: [ + new TestSemantics( + id: 4, + actions: SemanticsAction.tap.index, + flags: SemanticsFlag.isSelected.index, + label: 'Semantics override 0\nTab 1 of 2', + rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight), + transform: new Matrix4.translationValues(0.0, 276.0, 0.0), + ), + new TestSemantics( + 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), + transform: new Matrix4.translationValues(108.0, 276.0, 0.0), + ), + ] + ) + ], + ), ], ), ], diff --git a/packages/flutter/test/material/tooltip_test.dart b/packages/flutter/test/material/tooltip_test.dart index 064e0f994a..2cf59b65ee 100644 --- a/packages/flutter/test/material/tooltip_test.dart +++ b/packages/flutter/test/material/tooltip_test.dart @@ -622,12 +622,16 @@ void main() { expect(semantics, hasSemantics(new TestSemantics.root( children: [ new TestSemantics.rootChild( - flags: [SemanticsFlag.scopesRoute], children: [ new TestSemantics( - label: 'Foo\nBar', - textDirection: TextDirection.ltr, - ) + flags: [SemanticsFlag.scopesRoute], + children: [ + new TestSemantics( + label: 'Foo\nBar', + textDirection: TextDirection.ltr, + ) + ], + ), ], ), ], @@ -654,12 +658,16 @@ void main() { expect(semantics, hasSemantics(new TestSemantics.root( children: [ new TestSemantics.rootChild( - flags: [SemanticsFlag.scopesRoute], children: [ new TestSemantics( - label: 'Bar', - textDirection: TextDirection.ltr, - ) + flags: [SemanticsFlag.scopesRoute], + children: [ + new TestSemantics( + label: 'Bar', + textDirection: TextDirection.ltr, + ) + ], + ), ], ), ], diff --git a/packages/flutter/test/material/user_accounts_drawer_header_test.dart b/packages/flutter/test/material/user_accounts_drawer_header_test.dart index 5441b24421..2edbb29659 100644 --- a/packages/flutter/test/material/user_accounts_drawer_header_test.dart +++ b/packages/flutter/test/material/user_accounts_drawer_header_test.dart @@ -333,29 +333,33 @@ void main() { new TestSemantics( children: [ new TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ new TestSemantics( - label: 'Signed in\nname\nemail', - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.scopesRoute], children: [ new TestSemantics( - label: r'B', - textDirection: TextDirection.ltr, - ), - new TestSemantics( - label: r'C', - textDirection: TextDirection.ltr, - ), - new TestSemantics( - label: r'D', - textDirection: TextDirection.ltr, - ), - new TestSemantics( - flags: [SemanticsFlag.isButton], - actions: [SemanticsAction.tap], - label: r'Show accounts', + label: 'Signed in\nname\nemail', textDirection: TextDirection.ltr, + children: [ + new TestSemantics( + label: r'B', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + label: r'C', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + label: r'D', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + flags: [SemanticsFlag.isButton], + actions: [SemanticsAction.tap], + label: r'Show accounts', + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -385,23 +389,27 @@ void main() { new TestSemantics( children: [ new TestSemantics( - flags: [SemanticsFlag.scopesRoute], children: [ new TestSemantics( - label: 'Signed in', - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.scopesRoute], children: [ new TestSemantics( - label: r'B', - textDirection: TextDirection.ltr, - ), - new TestSemantics( - label: r'C', - textDirection: TextDirection.ltr, - ), - new TestSemantics( - label: r'D', + label: 'Signed in', textDirection: TextDirection.ltr, + children: [ + new TestSemantics( + label: r'B', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + label: r'C', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + label: r'D', + textDirection: TextDirection.ltr, + ), + ], ), ], ), diff --git a/packages/flutter/test/widgets/editable_text_test.dart b/packages/flutter/test/widgets/editable_text_test.dart index b329e2b0b7..75a7e2c3dc 100644 --- a/packages/flutter/test/widgets/editable_text_test.dart +++ b/packages/flutter/test/widgets/editable_text_test.dart @@ -592,12 +592,16 @@ void main() { expect(semantics, hasSemantics(new TestSemantics( children: [ new TestSemantics.rootChild( - flags: [SemanticsFlag.scopesRoute], - children: [ + children: [ new TestSemantics( - flags: [SemanticsFlag.isTextField, SemanticsFlag.isObscured], - value: expectedValue, - textDirection: TextDirection.ltr, + flags: [SemanticsFlag.scopesRoute], + children: [ + new TestSemantics( + flags: [SemanticsFlag.isTextField, SemanticsFlag.isObscured], + value: expectedValue, + textDirection: TextDirection.ltr, + ), + ], ), ], ), @@ -714,30 +718,35 @@ 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: [ new TestSemantics.rootChild( id: 1, - flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics.rootChild( - id: expectedNodeId, - flags: [ - SemanticsFlag.isTextField, - SemanticsFlag.isFocused + new TestSemantics( + id: 2, + flags: [SemanticsFlag.scopesRoute], + children: [ + new TestSemantics.rootChild( + id: expectedNodeId, + flags: [ + SemanticsFlag.isTextField, + SemanticsFlag.isFocused + ], + actions: [ + SemanticsAction.moveCursorBackwardByCharacter, + SemanticsAction.setSelection, + SemanticsAction.copy, + SemanticsAction.cut, + SemanticsAction.paste + ], + value: 'test', + textSelection: new TextSelection.collapsed(offset: controller.text.length), + textDirection: TextDirection.ltr, + ), ], - actions: [ - SemanticsAction.moveCursorBackwardByCharacter, - SemanticsAction.setSelection, - SemanticsAction.copy, - SemanticsAction.cut, - SemanticsAction.paste - ], - value: 'test', - textSelection: new TextSelection.collapsed(offset: controller.text.length), - textDirection: TextDirection.ltr, ), ], ), diff --git a/packages/flutter/test/widgets/semantics_tester_generateTestSemanticsExpressionForCurrentSemanticsTree_test.dart b/packages/flutter/test/widgets/semantics_tester_generateTestSemanticsExpressionForCurrentSemanticsTree_test.dart index 276f97e32c..0cffd37ff7 100644 --- a/packages/flutter/test/widgets/semantics_tester_generateTestSemanticsExpressionForCurrentSemanticsTree_test.dart +++ b/packages/flutter/test/widgets/semantics_tester_generateTestSemanticsExpressionForCurrentSemanticsTree_test.dart @@ -105,31 +105,37 @@ void _tests() { children: [ new TestSemantics( id: 1, - flags: [SemanticsFlag.scopesRoute], + textDirection: TextDirection.ltr, children: [ new TestSemantics( id: 2, + flags: [SemanticsFlag.scopesRoute], children: [ new TestSemantics( - id: 5, + id: 3, children: [ new TestSemantics( - id: 3, - tags: [const SemanticsTag('RenderViewport.twoPane')], - label: 'Plain text', - textDirection: TextDirection.ltr, - ), - new TestSemantics( - id: 4, - tags: [const SemanticsTag('RenderViewport.twoPane')], - flags: [SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, SemanticsFlag.isSelected], - actions: [SemanticsAction.tap, SemanticsAction.decrease], - label: '‪Interactive text‬', - value: 'test-value', - increasedValue: 'test-increasedValue', - decreasedValue: 'test-decreasedValue', - hint: 'test-hint', - textDirection: TextDirection.rtl, + id: 6, + children: [ + new TestSemantics( + id: 4, + tags: [const SemanticsTag('RenderViewport.twoPane')], + label: 'Plain text', + textDirection: TextDirection.ltr, + ), + new TestSemantics( + id: 5, + tags: [const SemanticsTag('RenderViewport.twoPane')], + flags: [SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, SemanticsFlag.isSelected], + actions: [SemanticsAction.tap, SemanticsAction.decrease], + label: '‪Interactive text‬', + value: 'test-value', + increasedValue: 'test-increasedValue', + decreasedValue: 'test-decreasedValue', + hint: 'test-hint', + textDirection: TextDirection.rtl, + ), + ], ), ], ), diff --git a/packages/flutter/test/widgets/simple_semantics_test.dart b/packages/flutter/test/widgets/simple_semantics_test.dart index 92398d4e8c..8e1c2df09f 100644 --- a/packages/flutter/test/widgets/simple_semantics_test.dart +++ b/packages/flutter/test/widgets/simple_semantics_test.dart @@ -55,17 +55,23 @@ void main() { expect(semantics, hasSemantics(new TestSemantics.root( children: [ new TestSemantics.rootChild( - rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 600.0), id: 2, - flags: [SemanticsFlag.scopesRoute], + rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 600.0), children: [ new TestSemantics( id: 3, - label: 'Hello!', - textDirection: TextDirection.ltr, - rect: new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), - transform: new Matrix4.translationValues(395.0, 295.0, 0.0), - ) + rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 600.0), + flags: [SemanticsFlag.scopesRoute], + children: [ + new TestSemantics( + id: 4, + label: 'Hello!', + textDirection: TextDirection.ltr, + rect: new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), + transform: new Matrix4.translationValues(395.0, 295.0, 0.0), + ) + ], + ), ], ), ],