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

a11y traversal: sort locally; use new sorting algorithm (#16253)

New a11y traversal:

- sort direct sibling SemanticsNodes only
- use new sorting algorithm
- implement RTL
- test semantics in traversal order by default
- add AppBar traversal test
- breaking: remove nextNodeId/previousNodeId from the framework
- breaking: remove DebugSemanticsDumpOrder.geometricOrder
parent d3d4976f
...@@ -130,7 +130,7 @@ class StockHomeState extends State<StockHome> { ...@@ -130,7 +130,7 @@ class StockHomeState extends State<StockHome> {
debugDumpApp(); debugDumpApp();
debugDumpRenderTree(); debugDumpRenderTree();
debugDumpLayerTree(); debugDumpLayerTree();
debugDumpSemanticsTree(DebugSemanticsDumpOrder.geometricOrder); debugDumpSemanticsTree(DebugSemanticsDumpOrder.traversalOrder);
} catch (e, stack) { } catch (e, stack) {
debugPrint('Exception while dumping app:\n$e\n$stack'); debugPrint('Exception while dumping app:\n$e\n$stack');
} }
......
...@@ -482,10 +482,14 @@ class _AppBarState extends State<AppBar> { ...@@ -482,10 +482,14 @@ class _AppBarState extends State<AppBar> {
); );
} }
return new Material( return new Semantics(
color: widget.backgroundColor ?? themeData.primaryColor, container: true,
elevation: widget.elevation, explicitChildNodes: true,
child: appBar, child: new Material(
color: widget.backgroundColor ?? themeData.primaryColor,
elevation: widget.elevation,
child: appBar,
),
); );
} }
} }
......
...@@ -485,41 +485,45 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr ...@@ -485,41 +485,45 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
backgroundColor = _backgroundColor; backgroundColor = _backgroundColor;
break; break;
} }
return new Stack( return new Semantics(
children: <Widget>[ container: true,
new Positioned.fill( explicitChildNodes: true,
child: new Material( // Casts shadow. child: new Stack(
elevation: 8.0, children: <Widget>[
color: backgroundColor, new Positioned.fill(
child: new Material( // Casts shadow.
elevation: 8.0,
color: backgroundColor,
),
), ),
), new ConstrainedBox(
new ConstrainedBox( constraints: new BoxConstraints(minHeight: kBottomNavigationBarHeight + additionalBottomPadding),
constraints: new BoxConstraints(minHeight: kBottomNavigationBarHeight + additionalBottomPadding), child: new Stack(
child: new Stack( children: <Widget>[
children: <Widget>[ new Positioned.fill(
new Positioned.fill( child: new CustomPaint(
child: new CustomPaint( painter: new _RadialPainter(
painter: new _RadialPainter( circles: _circles.toList(),
circles: _circles.toList(), textDirection: Directionality.of(context),
textDirection: Directionality.of(context), ),
), ),
), ),
), new Material( // Splashes.
new Material( // Splashes. type: MaterialType.transparency,
type: MaterialType.transparency, child: new Padding(
child: new Padding( padding: new EdgeInsets.only(bottom: additionalBottomPadding),
padding: new EdgeInsets.only(bottom: additionalBottomPadding), child: new MediaQuery.removePadding(
child: new MediaQuery.removePadding( context: context,
context: context, removeBottom: true,
removeBottom: true, child: _createContainer(_createTiles()),
child: _createContainer(_createTiles()), ),
), ),
), ),
), ],
], ),
), ),
), ],
], ),
); );
} }
} }
......
...@@ -641,30 +641,39 @@ class _MonthPickerState extends State<MonthPicker> { ...@@ -641,30 +641,39 @@ class _MonthPickerState extends State<MonthPicker> {
height: _kMaxDayPickerHeight, height: _kMaxDayPickerHeight,
child: new Stack( child: new Stack(
children: <Widget>[ children: <Widget>[
new PageView.builder( new Semantics(
key: new ValueKey<DateTime>(widget.selectedDate), sortKey: _MonthPickerSortKey.calendar,
controller: _dayPickerController, child: new PageView.builder(
scrollDirection: Axis.horizontal, key: new ValueKey<DateTime>(widget.selectedDate),
itemCount: _monthDelta(widget.firstDate, widget.lastDate) + 1, controller: _dayPickerController,
itemBuilder: _buildItems, scrollDirection: Axis.horizontal,
onPageChanged: _handleMonthPageChanged, itemCount: _monthDelta(widget.firstDate, widget.lastDate) + 1,
itemBuilder: _buildItems,
onPageChanged: _handleMonthPageChanged,
),
), ),
new PositionedDirectional( new PositionedDirectional(
top: 0.0, top: 0.0,
start: 8.0, start: 8.0,
child: new IconButton( child: new Semantics(
icon: const Icon(Icons.chevron_left), sortKey: _MonthPickerSortKey.previousMonth,
tooltip: _isDisplayingFirstMonth ? null : '${localizations.previousMonthTooltip} ${localizations.formatMonthYear(_previousMonthDate)}', child: new IconButton(
onPressed: _isDisplayingFirstMonth ? null : _handlePreviousMonth, icon: const Icon(Icons.chevron_left),
tooltip: _isDisplayingFirstMonth ? null : '${localizations.previousMonthTooltip} ${localizations.formatMonthYear(_previousMonthDate)}',
onPressed: _isDisplayingFirstMonth ? null : _handlePreviousMonth,
),
), ),
), ),
new PositionedDirectional( new PositionedDirectional(
top: 0.0, top: 0.0,
end: 8.0, end: 8.0,
child: new IconButton( child: new Semantics(
icon: const Icon(Icons.chevron_right), sortKey: _MonthPickerSortKey.nextMonth,
tooltip: _isDisplayingLastMonth ? null : '${localizations.nextMonthTooltip} ${localizations.formatMonthYear(_nextMonthDate)}', child: new IconButton(
onPressed: _isDisplayingLastMonth ? null : _handleNextMonth, icon: const Icon(Icons.chevron_right),
tooltip: _isDisplayingLastMonth ? null : '${localizations.nextMonthTooltip} ${localizations.formatMonthYear(_nextMonthDate)}',
onPressed: _isDisplayingLastMonth ? null : _handleNextMonth,
),
), ),
), ),
], ],
...@@ -680,6 +689,16 @@ class _MonthPickerState extends State<MonthPicker> { ...@@ -680,6 +689,16 @@ class _MonthPickerState extends State<MonthPicker> {
} }
} }
// Defines semantic traversal order of the top-level widgets inside the month
// picker.
class _MonthPickerSortKey extends OrdinalSortKey {
static const _MonthPickerSortKey previousMonth = const _MonthPickerSortKey(1.0);
static const _MonthPickerSortKey nextMonth = const _MonthPickerSortKey(2.0);
static const _MonthPickerSortKey calendar = const _MonthPickerSortKey(3.0);
const _MonthPickerSortKey(double order) : super(order);
}
/// A scrollable list of years to allow picking a year. /// A scrollable list of years to allow picking a year.
/// ///
/// The year picker widget is rarely used directly. Instead, consider using /// The year picker widget is rarely used directly. Instead, consider using
......
...@@ -101,8 +101,8 @@ abstract class RendererBinding extends BindingBase with ServicesBinding, Schedul ...@@ -101,8 +101,8 @@ abstract class RendererBinding extends BindingBase with ServicesBinding, Schedul
); );
registerSignalServiceExtension( registerSignalServiceExtension(
name: 'debugDumpSemanticsTreeInGeometricOrder', name: 'debugDumpSemanticsTreeInTraversalOrder',
callback: () { debugDumpSemanticsTree(DebugSemanticsDumpOrder.geometricOrder); return debugPrintDone; } callback: () { debugDumpSemanticsTree(DebugSemanticsDumpOrder.traversalOrder); return debugPrintDone; }
); );
registerSignalServiceExtension( registerSignalServiceExtension(
......
...@@ -602,7 +602,7 @@ class _WidgetsAppState extends State<WidgetsApp> implements WidgetsBindingObserv ...@@ -602,7 +602,7 @@ class _WidgetsAppState extends State<WidgetsApp> implements WidgetsBindingObserv
if (widget.onGenerateTitle != null) { if (widget.onGenerateTitle != null) {
title = new Builder( title = new Builder(
// This Builder exists to provide a context below the Localizations widget. // This Builder exists to provide a context below the Localizations widget.
// The onGenerateCallback() can refer to Localizations via its context // The onGenerateTitle callback can refer to Localizations via its context
// parameter. // parameter.
builder: (BuildContext context) { builder: (BuildContext context) {
final String title = widget.onGenerateTitle(context); final String title = widget.onGenerateTitle(context);
......
...@@ -65,11 +65,11 @@ class ModalBarrier extends StatelessWidget { ...@@ -65,11 +65,11 @@ class ModalBarrier extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(!dismissible || semanticsLabel == null || debugCheckHasDirectionality(context)); assert(!dismissible || semanticsLabel == null || debugCheckHasDirectionality(context));
final bool semanticsDismissable = dismissible && defaultTargetPlatform != TargetPlatform.android; final bool semanticsDismissible = dismissible && defaultTargetPlatform != TargetPlatform.android;
return new BlockSemantics( return new BlockSemantics(
child: new ExcludeSemantics( child: new ExcludeSemantics(
// On Android, the back button is used to dismiss a modal. // On Android, the back button is used to dismiss a modal.
excluding: !semanticsDismissable, excluding: !semanticsDismissible,
child: new GestureDetector( child: new GestureDetector(
onTapDown: (TapDownDetails details) { onTapDown: (TapDownDetails details) {
if (dismissible) if (dismissible)
...@@ -77,8 +77,8 @@ class ModalBarrier extends StatelessWidget { ...@@ -77,8 +77,8 @@ class ModalBarrier extends StatelessWidget {
}, },
behavior: HitTestBehavior.opaque, behavior: HitTestBehavior.opaque,
child: new Semantics( child: new Semantics(
label: semanticsDismissable ? semanticsLabel : null, label: semanticsDismissible ? semanticsLabel : null,
textDirection: semanticsDismissable && semanticsLabel != null ? Directionality.of(context) : null, textDirection: semanticsDismissible && semanticsLabel != null ? Directionality.of(context) : null,
child: new ConstrainedBox( child: new ConstrainedBox(
constraints: const BoxConstraints.expand(), constraints: const BoxConstraints.expand(),
child: color == null ? null : new DecoratedBox( child: color == null ? null : new DecoratedBox(
......
...@@ -102,8 +102,10 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { ...@@ -102,8 +102,10 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
/// create scroll positions and initialize this property. /// create scroll positions and initialize this property.
final bool keepScrollOffset; final bool keepScrollOffset;
/// A label that is used in the [toString] output. Intended to aid with /// A label that is used in the [toString] output.
/// identifying animation controller instances in debug output. ///
/// Intended to aid with identifying animation controller instances in debug
/// output.
final String debugLabel; final String debugLabel;
@override @override
...@@ -123,10 +125,9 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { ...@@ -123,10 +125,9 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics {
double _viewportDimension; double _viewportDimension;
/// Whether [viewportDimension], [minScrollExtent], [maxScrollExtent], /// Whether [viewportDimension], [minScrollExtent], [maxScrollExtent],
/// [outOfRange], and [atEdge] are available yet. /// [outOfRange], and [atEdge] are available.
/// ///
/// Set to true just before the first time that [applyNewDimensions] is /// Set to true just before the first time [applyNewDimensions] is called.
/// called.
bool get haveDimensions => _haveDimensions; bool get haveDimensions => _haveDimensions;
bool _haveDimensions = false; bool _haveDimensions = false;
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
......
...@@ -193,11 +193,11 @@ void main() { ...@@ -193,11 +193,11 @@ void main() {
console.clear(); console.clear();
}); });
test('Service extensions - debugDumpSemanticsTreeInGeometricOrder', () async { test('Service extensions - debugDumpSemanticsTreeInTraversalOrder', () async {
Map<String, dynamic> result; Map<String, dynamic> result;
await binding.doFrame(); await binding.doFrame();
result = await binding.testExtension('debugDumpSemanticsTreeInGeometricOrder', <String, String>{}); result = await binding.testExtension('debugDumpSemanticsTreeInTraversalOrder', <String, String>{});
expect(result, <String, String>{}); expect(result, <String, String>{});
expect(console, <String>['Semantics not collected.']); expect(console, <String>['Semantics not collected.']);
console.clear(); console.clear();
......
...@@ -7,6 +7,8 @@ import 'package:flutter/material.dart'; ...@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import '../widgets/semantics_tester.dart';
Widget buildSliverAppBarApp({ bool floating, bool pinned, double expandedHeight, bool snap: false }) { Widget buildSliverAppBarApp({ bool floating, bool pinned, double expandedHeight, bool snap: false }) {
return new Localizations( return new Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
...@@ -65,6 +67,10 @@ double appBarBottom(WidgetTester tester) => tester.getBottomLeft(find.byType(App ...@@ -65,6 +67,10 @@ double appBarBottom(WidgetTester tester) => tester.getBottomLeft(find.byType(App
double tabBarHeight(WidgetTester tester) => tester.getSize(find.byType(TabBar)).height; double tabBarHeight(WidgetTester tester) => tester.getSize(find.byType(TabBar)).height;
void main() { void main() {
setUp(() {
debugResetSemanticsIdCounter();
});
testWidgets('AppBar centers title on iOS', (WidgetTester tester) async { testWidgets('AppBar centers title on iOS', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
new MaterialApp( new MaterialApp(
...@@ -1182,4 +1188,155 @@ void main() { ...@@ -1182,4 +1188,155 @@ void main() {
expect(tester.getRect(find.byKey(leadingKey)), new Rect.fromLTRB(800.0 - 56.0, 100.0, 800.0, 100.0 + 56.0)); expect(tester.getRect(find.byKey(leadingKey)), new Rect.fromLTRB(800.0 - 56.0, 100.0, 800.0, 100.0 + 56.0));
expect(tester.getRect(find.byKey(trailingKey)), new Rect.fromLTRB(4.0, 100.0, 400.0 + 4.0, 100.0 + 56.0)); expect(tester.getRect(find.byKey(trailingKey)), new Rect.fromLTRB(4.0, 100.0, 400.0 + 4.0, 100.0 + 56.0));
}); });
testWidgets('SliverAppBar provides correct semantics in LTR', (WidgetTester tester) async {
final SemanticsTester semantics = new SemanticsTester(tester);
await tester.pumpWidget(
new MaterialApp(
home: new Center(
child: new AppBar(
leading: const Text('Leading'),
title: const Text('Title'),
actions: const <Widget>[
const Text('Action 1'),
const Text('Action 2'),
const Text('Action 3'),
],
bottom: const PreferredSize(
preferredSize: const Size(0.0, kToolbarHeight),
child: const Text('Bottom'),
),
),
),
),
);
expect(semantics, hasSemantics(
new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
new TestSemantics(
children: <TestSemantics>[
new TestSemantics(
label: 'Leading',
textDirection: TextDirection.ltr,
),
new TestSemantics(
flags: <SemanticsFlag>[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,
),
],
),
],
),
],
),
ignoreRect: true,
ignoreTransform: true,
ignoreId: true,
));
semantics.dispose();
});
testWidgets('SliverAppBar provides correct semantics in RTL', (WidgetTester tester) async {
final SemanticsTester semantics = new SemanticsTester(tester);
await tester.pumpWidget(
new MaterialApp(
home: new Semantics(
textDirection: TextDirection.rtl,
child: new Directionality(
textDirection: TextDirection.rtl,
child: new Center(
child: new AppBar(
leading: const Text('Leading'),
title: const Text('Title'),
actions: const <Widget>[
const Text('Action 1'),
const Text('Action 2'),
const Text('Action 3'),
],
bottom: const PreferredSize(
preferredSize: const Size(0.0, kToolbarHeight),
child: const Text('Bottom'),
),
),
),
),
),
),
);
expect(semantics, hasSemantics(
new TestSemantics.root(
children: <TestSemantics>[
new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute],
children: <TestSemantics>[
new TestSemantics(
textDirection: TextDirection.rtl,
children: <TestSemantics>[
new TestSemantics(
children: <TestSemantics>[
new TestSemantics(
label: 'Leading',
textDirection: TextDirection.rtl,
),
new TestSemantics(
flags: <SemanticsFlag>[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,
),
],
),
],
),
],
),
],
),
ignoreRect: true,
ignoreTransform: true,
ignoreId: true,
));
semantics.dispose();
});
} }
...@@ -512,32 +512,31 @@ void main() { ...@@ -512,32 +512,31 @@ void main() {
), ),
); );
// TODO(goderbauer): traversal order is incorrect, https://github.com/flutter/flutter/issues/14375
final TestSemantics expected = new TestSemantics.root( final TestSemantics expected = new TestSemantics.root(
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics( new TestSemantics(
id: 1, id: 1,
flags: <SemanticsFlag>[SemanticsFlag.isSelected], children: <TestSemantics>[
actions: <SemanticsAction>[SemanticsAction.tap], new TestSemantics(
label: 'AC\nTab 1 of 3', id: 2,
textDirection: TextDirection.ltr, flags: <SemanticsFlag>[SemanticsFlag.isSelected],
previousNodeId: 3, // Should be 2 actions: <SemanticsAction>[SemanticsAction.tap],
), label: 'AC\nTab 1 of 3',
new TestSemantics( textDirection: TextDirection.ltr,
id: 2, ),
actions: <SemanticsAction>[SemanticsAction.tap], new TestSemantics(
label: 'Alarm\nTab 2 of 3', id: 3,
textDirection: TextDirection.ltr, actions: <SemanticsAction>[SemanticsAction.tap],
nextNodeId: 3, label: 'Alarm\nTab 2 of 3',
previousNodeId: -1, // Should be 1 textDirection: TextDirection.ltr,
), ),
new TestSemantics( new TestSemantics(
id: 3, id: 4,
actions: <SemanticsAction>[SemanticsAction.tap], actions: <SemanticsAction>[SemanticsAction.tap],
label: 'Hot Tub\nTab 3 of 3', label: 'Hot Tub\nTab 3 of 3',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
nextNodeId: 1, // Should be -1 ),
previousNodeId: 2, ],
), ),
], ],
); );
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -100,7 +98,6 @@ void main() { ...@@ -100,7 +98,6 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 1, id: 1,
nextNodeId: 3,
rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 56.0), rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 56.0),
transform: null, transform: null,
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
...@@ -114,8 +111,6 @@ void main() { ...@@ -114,8 +111,6 @@ void main() {
), ),
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 3, id: 3,
previousNodeId: 1,
nextNodeId: 5,
rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 56.0), rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 56.0),
transform: new Matrix4.translationValues(0.0, 56.0, 0.0), transform: new Matrix4.translationValues(0.0, 56.0, 0.0),
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
...@@ -129,7 +124,6 @@ void main() { ...@@ -129,7 +124,6 @@ void main() {
), ),
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 5, id: 5,
previousNodeId: 3,
rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 56.0), rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 56.0),
transform: new Matrix4.translationValues(0.0, 112.0, 0.0), transform: new Matrix4.translationValues(0.0, 112.0, 0.0),
flags: <SemanticsFlag>[ flags: <SemanticsFlag>[
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag, SemanticsAction;
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -1363,7 +1361,6 @@ void main() { ...@@ -1363,7 +1361,6 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics( new TestSemantics(
id: 3, id: 3,
nextNodeId: 4,
actions: SemanticsAction.tap.index, actions: SemanticsAction.tap.index,
flags: SemanticsFlag.isSelected.index, flags: SemanticsFlag.isSelected.index,
label: 'TAB #0\nTab 1 of 2', label: 'TAB #0\nTab 1 of 2',
...@@ -1372,7 +1369,6 @@ void main() { ...@@ -1372,7 +1369,6 @@ void main() {
), ),
new TestSemantics( new TestSemantics(
id: 4, id: 4,
previousNodeId: 3,
actions: SemanticsAction.tap.index, actions: SemanticsAction.tap.index,
label: 'TAB #1\nTab 2 of 2', label: 'TAB #1\nTab 2 of 2',
rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight), rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight),
...@@ -1622,7 +1618,6 @@ void main() { ...@@ -1622,7 +1618,6 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics( new TestSemantics(
id: 3, id: 3,
nextNodeId: 4,
actions: SemanticsAction.tap.index, actions: SemanticsAction.tap.index,
flags: SemanticsFlag.isSelected.index, flags: SemanticsFlag.isSelected.index,
label: 'Semantics override 0\nTab 1 of 2', label: 'Semantics override 0\nTab 1 of 2',
...@@ -1631,7 +1626,6 @@ void main() { ...@@ -1631,7 +1626,6 @@ void main() {
), ),
new TestSemantics( new TestSemantics(
id: 4, id: 4,
previousNodeId: 3,
actions: SemanticsAction.tap.index, actions: SemanticsAction.tap.index,
label: 'Semantics override 1\nTab 2 of 2', label: 'Semantics override 1\nTab 2 of 2',
rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight), rect: new Rect.fromLTRB(0.0, 0.0, 108.0, kTextTabBarHeight),
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:io' show Platform; import 'dart:io' show Platform;
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -125,7 +125,7 @@ void main() { ...@@ -125,7 +125,7 @@ void main() {
expect(child2.transform, isNull); expect(child2.transform, isNull);
expect( expect(
root.toStringDeep(childOrder: DebugSemanticsDumpOrder.geometricOrder), root.toStringDeep(childOrder: DebugSemanticsDumpOrder.traversalOrder),
'SemanticsNode#3\n' 'SemanticsNode#3\n'
' │ STALE\n' ' │ STALE\n'
' │ owner: null\n' ' │ owner: null\n'
...@@ -143,18 +143,26 @@ void main() { ...@@ -143,18 +143,26 @@ void main() {
); );
}); });
test('Incompatible OrdinalSortKey throw AssertionError when compared', () {
// Different types.
expect(() {
const OrdinalSortKey(0.0).compareTo(const CustomSortKey(0.0));
}, throwsAssertionError);
// Different names.
expect(() {
const OrdinalSortKey(0.0, name: 'a').compareTo(const OrdinalSortKey(0.0, name: 'b'));
}, throwsAssertionError);
});
test('OrdinalSortKey compares correctly', () { test('OrdinalSortKey compares correctly', () {
const List<List<SemanticsSortKey>> tests = const <List<SemanticsSortKey>>[ const List<List<SemanticsSortKey>> tests = const <List<SemanticsSortKey>>[
const <SemanticsSortKey>[const OrdinalSortKey(0.0), const OrdinalSortKey(0.0)], const <SemanticsSortKey>[const OrdinalSortKey(0.0), const OrdinalSortKey(0.0)],
const <SemanticsSortKey>[const OrdinalSortKey(0.0), const OrdinalSortKey(1.0)], const <SemanticsSortKey>[const OrdinalSortKey(0.0), const OrdinalSortKey(1.0)],
const <SemanticsSortKey>[const OrdinalSortKey(1.0), const OrdinalSortKey(0.0)], const <SemanticsSortKey>[const OrdinalSortKey(1.0), const OrdinalSortKey(0.0)],
const <SemanticsSortKey>[const OrdinalSortKey(1.0), const OrdinalSortKey(1.0)], const <SemanticsSortKey>[const OrdinalSortKey(1.0), const OrdinalSortKey(1.0)],
const <SemanticsSortKey>[const OrdinalSortKey(0.0), const CustomSortKey(1.0)],
const <SemanticsSortKey>[const OrdinalSortKey(0.0), const CustomSortKey(0.0)],
const <SemanticsSortKey>[const CustomSortKey(0.0), const OrdinalSortKey(0.0)],
const <SemanticsSortKey>[const CustomSortKey(1.0), const OrdinalSortKey(0.0)],
]; ];
final List<int> expectedResults = <int>[0, -1, 1, 0, 0, 0, 0, 0]; final List<int> expectedResults = <int>[0, -1, 1, 0];
assert(tests.length == expectedResults.length); assert(tests.length == expectedResults.length);
final List<int> results = <int>[]; final List<int> results = <int>[];
for (List<SemanticsSortKey> tuple in tests) { for (List<SemanticsSortKey> tuple in tests) {
...@@ -163,31 +171,14 @@ void main() { ...@@ -163,31 +171,14 @@ void main() {
expect(results, orderedEquals(expectedResults)); expect(results, orderedEquals(expectedResults));
}); });
test('SemanticsSortKey sorts correctly when assigned names', () {
const SemanticsSortKey order1g1 = const CustomSortKey(0.0, name: 'group 1');
const SemanticsSortKey order2g1 = const CustomSortKey(1.0, name: 'group 1');
const SemanticsSortKey order2g2 = const CustomSortKey(1.0, name: 'group 2');
const SemanticsSortKey order3g2 = const OrdinalSortKey(1.0, name: 'group 1');
// Keys in the same group compare.
expect(order1g1.compareTo(order2g1), equals(-1));
// Keys with different names compare equal.
expect(order1g1.compareTo(order2g2), equals(0));
// Keys with same names but different types compare equal.
expect(order1g1.compareTo(order3g2), equals(0));
});
test('OrdinalSortKey compares correctly', () { test('OrdinalSortKey compares correctly', () {
const List<List<SemanticsSortKey>> tests = const <List<SemanticsSortKey>>[ const List<List<SemanticsSortKey>> tests = const <List<SemanticsSortKey>>[
const <SemanticsSortKey>[const OrdinalSortKey(0.0), const OrdinalSortKey(0.0)], const <SemanticsSortKey>[const OrdinalSortKey(0.0), const OrdinalSortKey(0.0)],
const <SemanticsSortKey>[const OrdinalSortKey(0.0), const OrdinalSortKey(1.0)], const <SemanticsSortKey>[const OrdinalSortKey(0.0), const OrdinalSortKey(1.0)],
const <SemanticsSortKey>[const OrdinalSortKey(1.0), const OrdinalSortKey(0.0)], const <SemanticsSortKey>[const OrdinalSortKey(1.0), const OrdinalSortKey(0.0)],
const <SemanticsSortKey>[const OrdinalSortKey(1.0), const OrdinalSortKey(1.0)], const <SemanticsSortKey>[const OrdinalSortKey(1.0), const OrdinalSortKey(1.0)],
const <SemanticsSortKey>[const OrdinalSortKey(0.0), const CustomSortKey(1.0)],
const <SemanticsSortKey>[const OrdinalSortKey(0.0), const CustomSortKey(0.0)],
const <SemanticsSortKey>[const CustomSortKey(0.0), const OrdinalSortKey(0.0)],
const <SemanticsSortKey>[const CustomSortKey(1.0), const OrdinalSortKey(0.0)],
]; ];
final List<int> expectedResults = <int>[0, -1, 1, 0, 0, 0, 0, 0]; final List<int> expectedResults = <int>[0, -1, 1, 0];
assert(tests.length == expectedResults.length); assert(tests.length == expectedResults.length);
final List<int> results = <int>[]; final List<int> results = <int>[];
for (List<SemanticsSortKey> tuple in tests) { for (List<SemanticsSortKey> tuple in tests) {
...@@ -196,19 +187,6 @@ void main() { ...@@ -196,19 +187,6 @@ void main() {
expect(results, orderedEquals(expectedResults)); expect(results, orderedEquals(expectedResults));
}); });
test('SemanticsSortKey sorts correctly when assigned names', () {
const SemanticsSortKey order1g1 = const CustomSortKey(0.0, name: 'group 1');
const SemanticsSortKey order2g1 = const CustomSortKey(1.0, name: 'group 1');
const SemanticsSortKey order2g2 = const CustomSortKey(1.0, name: 'group 2');
const SemanticsSortKey order3g2 = const OrdinalSortKey(1.0, name: 'group 1');
// Keys in the same group compare.
expect(order1g1.compareTo(order2g1), equals(-1));
// Keys with different names compare equal.
expect(order1g1.compareTo(order2g2), equals(0));
// Keys with same names but different types compare equal.
expect(order1g1.compareTo(order3g2), equals(0));
});
test('toStringDeep respects childOrder parameter', () { test('toStringDeep respects childOrder parameter', () {
final SemanticsNode child1 = new SemanticsNode() final SemanticsNode child1 = new SemanticsNode()
..rect = new Rect.fromLTRB(15.0, 0.0, 20.0, 5.0); ..rect = new Rect.fromLTRB(15.0, 0.0, 20.0, 5.0);
...@@ -221,21 +199,21 @@ void main() { ...@@ -221,21 +199,21 @@ void main() {
childrenInInversePaintOrder: <SemanticsNode>[child1, child2], childrenInInversePaintOrder: <SemanticsNode>[child1, child2],
); );
expect( expect(
root.toStringDeep(childOrder: DebugSemanticsDumpOrder.geometricOrder), root.toStringDeep(childOrder: DebugSemanticsDumpOrder.traversalOrder),
'SemanticsNode#3\n' 'SemanticsNode#3\n'
' │ STALE\n' ' │ STALE\n'
' │ owner: null\n' ' │ owner: null\n'
' │ Rect.fromLTRB(0.0, 0.0, 20.0, 5.0)\n' ' │ Rect.fromLTRB(0.0, 0.0, 20.0, 5.0)\n'
' │\n' ' │\n'
' ├─SemanticsNode#2\n' ' ├─SemanticsNode#1\n'
' │ STALE\n' ' │ STALE\n'
' │ owner: null\n' ' │ owner: null\n'
' │ Rect.fromLTRB(10.0, 0.0, 15.0, 5.0)\n' ' │ Rect.fromLTRB(15.0, 0.0, 20.0, 5.0)\n'
' │\n' ' │\n'
' └─SemanticsNode#1\n' ' └─SemanticsNode#2\n'
' STALE\n' ' STALE\n'
' owner: null\n' ' owner: null\n'
' Rect.fromLTRB(15.0, 0.0, 20.0, 5.0)\n' ' Rect.fromLTRB(10.0, 0.0, 15.0, 5.0)\n'
); );
expect( expect(
...@@ -276,36 +254,36 @@ void main() { ...@@ -276,36 +254,36 @@ void main() {
); );
expect( expect(
rootComplex.toStringDeep(childOrder: DebugSemanticsDumpOrder.geometricOrder), rootComplex.toStringDeep(childOrder: DebugSemanticsDumpOrder.traversalOrder),
'SemanticsNode#7\n' 'SemanticsNode#7\n'
' │ STALE\n' ' │ STALE\n'
' │ owner: null\n' ' │ owner: null\n'
' │ Rect.fromLTRB(0.0, 0.0, 25.0, 5.0)\n' ' │ Rect.fromLTRB(0.0, 0.0, 25.0, 5.0)\n'
' │\n' ' │\n'
' ├─SemanticsNode#4\n' ' ├─SemanticsNode#1\n'
' │ │ STALE\n' ' │ STALE\n'
' │ │ owner: null\n' ' │ owner: null\n'
' │ │ Rect.fromLTRB(0.0, 0.0, 10.0, 5.0)\n' ' │ Rect.fromLTRB(15.0, 0.0, 20.0, 5.0)\n'
' │ │\n'
' │ ├─SemanticsNode#6\n'
' │ │ STALE\n'
' │ │ owner: null\n'
' │ │ Rect.fromLTRB(0.0, 0.0, 5.0, 5.0)\n'
' │ │\n'
' │ └─SemanticsNode#5\n'
' │ STALE\n'
' │ owner: null\n'
' │ Rect.fromLTRB(5.0, 0.0, 10.0, 5.0)\n'
' │\n' ' │\n'
' ├─SemanticsNode#2\n' ' ├─SemanticsNode#2\n'
' │ STALE\n' ' │ STALE\n'
' │ owner: null\n' ' │ owner: null\n'
' │ Rect.fromLTRB(10.0, 0.0, 15.0, 5.0)\n' ' │ Rect.fromLTRB(10.0, 0.0, 15.0, 5.0)\n'
' │\n' ' │\n'
' └─SemanticsNode#1\n' ' └─SemanticsNode#4\n'
' STALE\n' ' │ STALE\n'
' owner: null\n' ' │ owner: null\n'
' Rect.fromLTRB(15.0, 0.0, 20.0, 5.0)\n' ' │ Rect.fromLTRB(0.0, 0.0, 10.0, 5.0)\n'
' │\n'
' ├─SemanticsNode#5\n'
' │ STALE\n'
' │ owner: null\n'
' │ Rect.fromLTRB(5.0, 0.0, 10.0, 5.0)\n'
' │\n'
' └─SemanticsNode#6\n'
' STALE\n'
' owner: null\n'
' Rect.fromLTRB(0.0, 0.0, 5.0, 5.0)\n'
); );
expect( expect(
...@@ -368,8 +346,6 @@ void main() { ...@@ -368,8 +346,6 @@ void main() {
' decreasedValue: ""\n' ' decreasedValue: ""\n'
' hint: ""\n' ' hint: ""\n'
' textDirection: null\n' ' textDirection: null\n'
' nextNodeId: null\n'
' previousNodeId: null\n'
' sortKey: null\n' ' sortKey: null\n'
' scrollExtentMin: null\n' ' scrollExtentMin: null\n'
' scrollPosition: null\n' ' scrollPosition: null\n'
......
...@@ -150,20 +150,16 @@ void _defineTests() { ...@@ -150,20 +150,16 @@ void _defineTests() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics( new TestSemantics(
id: 3, id: 3,
nextNodeId: 4,
previousNodeId: 2,
label: 'background', label: 'background',
rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0),
), ),
new TestSemantics( new TestSemantics(
id: 2, id: 2,
nextNodeId: 3,
label: 'Hello', label: 'Hello',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 600.0),
), ),
new TestSemantics( new TestSemantics(
id: 4, id: 4,
previousNodeId: 3,
label: 'foreground', label: 'foreground',
rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0),
), ),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -600,8 +598,6 @@ void main() { ...@@ -600,8 +598,6 @@ void main() {
flags: <SemanticsFlag>[SemanticsFlag.isTextField, SemanticsFlag.isObscured], flags: <SemanticsFlag>[SemanticsFlag.isTextField, SemanticsFlag.isObscured],
value: expectedValue, value: expectedValue,
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
nextNodeId: -1,
previousNodeId: -1,
), ),
], ],
), ),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -79,12 +77,10 @@ void main() { ...@@ -79,12 +77,10 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics( new TestSemantics(
id: 2, id: 2,
nextNodeId: 3,
label: 'Michael Goderbauer', label: 'Michael Goderbauer',
), ),
new TestSemantics( new TestSemantics(
id: 3, id: 3,
previousNodeId: 2,
label: 'goderbauer@google.com', label: 'goderbauer@google.com',
), ),
], ],
...@@ -235,20 +231,16 @@ void main() { ...@@ -235,20 +231,16 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics( new TestSemantics(
id: 6, id: 6,
nextNodeId: 7,
flags: SemanticsFlag.isSelected.index, flags: SemanticsFlag.isSelected.index,
label: 'node 1', label: 'node 1',
), ),
new TestSemantics( new TestSemantics(
id: 7, id: 7,
previousNodeId: 6,
nextNodeId: 8,
flags: SemanticsFlag.isSelected.index, flags: SemanticsFlag.isSelected.index,
label: 'node 2', label: 'node 2',
), ),
new TestSemantics( new TestSemantics(
id: 8, id: 8,
previousNodeId: 7,
flags: SemanticsFlag.isSelected.index, flags: SemanticsFlag.isSelected.index,
label: 'node 3', label: 'node 3',
), ),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -122,14 +120,12 @@ void main() { ...@@ -122,14 +120,12 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics( new TestSemantics(
id: 2, id: 2,
nextNodeId: 3,
label: 'child1', label: 'child1',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlag.isSelected.index, flags: SemanticsFlag.isSelected.index,
), ),
new TestSemantics( new TestSemantics(
id: 3, id: 3,
previousNodeId: 2,
label: 'child2', label: 'child2',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlag.isSelected.index, flags: SemanticsFlag.isSelected.index,
...@@ -220,14 +216,12 @@ void main() { ...@@ -220,14 +216,12 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics( new TestSemantics(
id: 4, id: 4,
nextNodeId: 3,
label: 'child1', label: 'child1',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlag.isSelected.index, flags: SemanticsFlag.isSelected.index,
), ),
new TestSemantics( new TestSemantics(
id: 3, id: 3,
previousNodeId: 4,
label: 'child2', label: 'child2',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlag.isSelected.index, flags: SemanticsFlag.isSelected.index,
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -58,14 +56,12 @@ void main() { ...@@ -58,14 +56,12 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics( new TestSemantics(
id: 2, id: 2,
nextNodeId: 3,
label: 'child1', label: 'child1',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlag.isSelected.index, flags: SemanticsFlag.isSelected.index,
), ),
new TestSemantics( new TestSemantics(
id: 3, id: 3,
previousNodeId: 2,
label: 'child2', label: 'child2',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlag.isSelected.index, flags: SemanticsFlag.isSelected.index,
...@@ -156,14 +152,12 @@ void main() { ...@@ -156,14 +152,12 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics( new TestSemantics(
id: 4, id: 4,
nextNodeId: 3,
label: 'child1', label: 'child1',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlag.isSelected.index, flags: SemanticsFlag.isSelected.index,
), ),
new TestSemantics( new TestSemantics(
id: 3, id: 3,
previousNodeId: 4,
label: 'child2', label: 'child2',
rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0),
flags: SemanticsFlag.isSelected.index, flags: SemanticsFlag.isSelected.index,
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
...@@ -54,25 +52,21 @@ void main() { ...@@ -54,25 +52,21 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 1, id: 1,
nextNodeId: 2,
label: 'L1', label: 'L1',
rect: TestSemantics.fullScreen, rect: TestSemantics.fullScreen,
), ),
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 2, id: 2,
previousNodeId: 1,
label: 'L2', label: 'L2',
rect: TestSemantics.fullScreen, rect: TestSemantics.fullScreen,
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics( new TestSemantics(
id: 3, id: 3,
nextNodeId: 4,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
rect: TestSemantics.fullScreen, rect: TestSemantics.fullScreen,
), ),
new TestSemantics( new TestSemantics(
id: 4, id: 4,
previousNodeId: 3,
flags: SemanticsFlag.hasCheckedState.index, flags: SemanticsFlag.hasCheckedState.index,
rect: TestSemantics.fullScreen, rect: TestSemantics.fullScreen,
), ),
...@@ -118,13 +112,11 @@ void main() { ...@@ -118,13 +112,11 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 1, id: 1,
nextNodeId: 2,
label: 'L1', label: 'L1',
rect: TestSemantics.fullScreen, rect: TestSemantics.fullScreen,
), ),
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 2, id: 2,
previousNodeId: 1,
label: 'L2', label: 'L2',
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
rect: TestSemantics.fullScreen, rect: TestSemantics.fullScreen,
......
...@@ -37,12 +37,10 @@ void main() { ...@@ -37,12 +37,10 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 1, id: 1,
nextNodeId: 2,
rect: TestSemantics.fullScreen, rect: TestSemantics.fullScreen,
), ),
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 2, id: 2,
previousNodeId: 1,
label: 'label', label: 'label',
rect: TestSemantics.fullScreen, rect: TestSemantics.fullScreen,
), ),
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
...@@ -56,7 +54,6 @@ void main() { ...@@ -56,7 +54,6 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 1, id: 1,
nextNodeId: 4,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
label: label, label: label,
rect: TestSemantics.fullScreen, rect: TestSemantics.fullScreen,
...@@ -64,7 +61,6 @@ void main() { ...@@ -64,7 +61,6 @@ void main() {
// IDs 2 and 3 are used up by the nodes that get merged in // IDs 2 and 3 are used up by the nodes that get merged in
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 4, id: 4,
previousNodeId: 1,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
label: label, label: label,
rect: TestSemantics.fullScreen, rect: TestSemantics.fullScreen,
...@@ -114,7 +110,6 @@ void main() { ...@@ -114,7 +110,6 @@ void main() {
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 1, id: 1,
nextNodeId: 4,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
label: label, label: label,
rect: TestSemantics.fullScreen, rect: TestSemantics.fullScreen,
...@@ -122,7 +117,6 @@ void main() { ...@@ -122,7 +117,6 @@ void main() {
// IDs 2 and 3 are used up by the nodes that get merged in // IDs 2 and 3 are used up by the nodes that get merged in
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 4, id: 4,
previousNodeId: 1,
flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index,
label: label, label: label,
rect: TestSemantics.fullScreen, rect: TestSemantics.fullScreen,
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -44,12 +42,10 @@ void main() { ...@@ -44,12 +42,10 @@ void main() {
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 1, id: 1,
label: 'test1', label: 'test1',
nextNodeId: 2,
), ),
new TestSemantics.rootChild( new TestSemantics.rootChild(
id: 2, id: 2,
label: 'test2', label: 'test2',
previousNodeId: 1,
), ),
], ],
), ),
...@@ -113,8 +109,8 @@ void main() { ...@@ -113,8 +109,8 @@ void main() {
expect(semantics, hasSemantics( expect(semantics, hasSemantics(
new TestSemantics.root( new TestSemantics.root(
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics.rootChild(id: 6, label: 'test1', nextNodeId: 7), new TestSemantics.rootChild(id: 6, label: 'test1'),
new TestSemantics.rootChild(id: 7, label: 'test2', previousNodeId: 6), new TestSemantics.rootChild(id: 7, label: 'test2'),
], ],
), ),
ignoreRect: true, ignoreRect: true,
......
...@@ -674,44 +674,36 @@ void main() { ...@@ -674,44 +674,36 @@ void main() {
new TestSemantics( new TestSemantics(
id: 1, id: 1,
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics(
id: 2,
label: r'Label 1',
textDirection: TextDirection.ltr,
previousNodeId: 3,
),
new TestSemantics(
id: 3,
label: r'Label 2',
textDirection: TextDirection.ltr,
nextNodeId: 2,
previousNodeId: 4,
),
new TestSemantics( new TestSemantics(
id: 4, id: 4,
nextNodeId: 3,
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics( new TestSemantics(
id: 5, id: 7,
label: r'Label 3', label: r'Label 5',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
previousNodeId: 6,
), ),
new TestSemantics( new TestSemantics(
id: 6, id: 6,
label: r'Label 4', label: r'Label 4',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
nextNodeId: 5,
previousNodeId: 7,
), ),
new TestSemantics( new TestSemantics(
id: 7, id: 5,
label: r'Label 5', label: r'Label 3',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
nextNodeId: 6,
), ),
], ],
), ),
new TestSemantics(
id: 3,
label: r'Label 2',
textDirection: TextDirection.ltr,
),
new TestSemantics(
id: 2,
label: r'Label 1',
textDirection: TextDirection.ltr,
),
], ],
), ),
], ],
...@@ -755,24 +747,20 @@ void main() { ...@@ -755,24 +747,20 @@ void main() {
expect(semantics, hasSemantics( expect(semantics, hasSemantics(
new TestSemantics.root( new TestSemantics.root(
children: <TestSemantics>[ children: <TestSemantics>[
new TestSemantics(
id: 1,
label: r'Label 1',
textDirection: TextDirection.ltr,
previousNodeId: 3,
),
new TestSemantics( new TestSemantics(
id: 2, id: 2,
label: r'Label 2', label: r'Label 2',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
nextNodeId: 3,
), ),
new TestSemantics( new TestSemantics(
id: 3, id: 3,
label: r'Label 3', label: r'Label 3',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
nextNodeId: 1, ),
previousNodeId: 2, new TestSemantics(
id: 1,
label: r'Label 1',
textDirection: TextDirection.ltr,
), ),
], ],
), ignoreTransform: true, ignoreRect: true)); ), ignoreTransform: true, ignoreRect: true));
...@@ -818,22 +806,18 @@ void main() { ...@@ -818,22 +806,18 @@ void main() {
new TestSemantics( new TestSemantics(
label: r'Label 2', label: r'Label 2',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
previousNodeId: 1,
), ),
new TestSemantics( new TestSemantics(
label: r'Label 3', label: r'Label 3',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
previousNodeId: 2,
), ),
new TestSemantics( new TestSemantics(
label: r'Label 4', label: r'Label 4',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
previousNodeId: 3,
), ),
new TestSemantics( new TestSemantics(
label: r'Label 5', label: r'Label 5',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
previousNodeId: 4,
), ),
], ],
), ignoreTransform: true, ignoreRect: true, ignoreId: true), ), ignoreTransform: true, ignoreRect: true, ignoreId: true),
...@@ -879,12 +863,10 @@ void main() { ...@@ -879,12 +863,10 @@ void main() {
new TestSemantics( new TestSemantics(
label: r'Label 1', label: r'Label 1',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
previousNodeId: 5,
), ),
new TestSemantics( new TestSemantics(
label: r'Label 2', label: r'Label 2',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
previousNodeId: 1,
), ),
new TestSemantics( new TestSemantics(
label: r'Label 3', label: r'Label 3',
...@@ -893,12 +875,10 @@ void main() { ...@@ -893,12 +875,10 @@ void main() {
new TestSemantics( new TestSemantics(
label: r'Label 4', label: r'Label 4',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
previousNodeId: 3,
), ),
new TestSemantics( new TestSemantics(
label: r'Label 5', label: r'Label 5',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
previousNodeId: 4,
), ),
], ],
), ignoreTransform: true, ignoreRect: true, ignoreId: true), ), ignoreTransform: true, ignoreRect: true, ignoreId: true),
...@@ -986,23 +966,18 @@ void main() { ...@@ -986,23 +966,18 @@ void main() {
), ),
new TestSemantics( new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isButton], flags: <SemanticsFlag>[SemanticsFlag.isButton],
previousNodeId: 5,
), ),
new TestSemantics( new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isButton], flags: <SemanticsFlag>[SemanticsFlag.isButton],
previousNodeId: 6,
), ),
new TestSemantics( new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isButton], flags: <SemanticsFlag>[SemanticsFlag.isButton],
previousNodeId: 3,
), ),
new TestSemantics( new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isButton], flags: <SemanticsFlag>[SemanticsFlag.isButton],
previousNodeId: 4,
), ),
new TestSemantics( new TestSemantics(
flags: <SemanticsFlag>[SemanticsFlag.isButton], flags: <SemanticsFlag>[SemanticsFlag.isButton],
previousNodeId: 1,
), ),
], ],
), ),
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'dart:ui' show SemanticsFlag;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart'; import 'package:flutter/semantics.dart';
...@@ -55,7 +54,7 @@ void _tests() { ...@@ -55,7 +54,7 @@ void _tests() {
final SemanticsTester semantics = new SemanticsTester(tester); final SemanticsTester semantics = new SemanticsTester(tester);
await pumpTestWidget(tester); await pumpTestWidget(tester);
final String code = semantics final String code = semantics
.generateTestSemanticsExpressionForCurrentSemanticsTree() .generateTestSemanticsExpressionForCurrentSemanticsTree(DebugSemanticsDumpOrder.inverseHitTest)
.split('\n') .split('\n')
.map((String line) => line.trim()) .map((String line) => line.trim())
.join('\n') .join('\n')
...@@ -119,7 +118,6 @@ void _tests() { ...@@ -119,7 +118,6 @@ void _tests() {
tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')], tags: <SemanticsTag>[const SemanticsTag('RenderViewport.twoPane')],
label: 'Plain text', label: 'Plain text',
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
nextNodeId: 4,
), ),
new TestSemantics( new TestSemantics(
id: 4, id: 4,
...@@ -132,7 +130,6 @@ void _tests() { ...@@ -132,7 +130,6 @@ void _tests() {
decreasedValue: 'test-decreasedValue', decreasedValue: 'test-decreasedValue',
hint: 'test-hint', hint: 'test-hint',
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
previousNodeId: 3,
), ),
], ],
), ),
......
This diff is collapsed.
...@@ -195,9 +195,9 @@ class FlutterDevice { ...@@ -195,9 +195,9 @@ class FlutterDevice {
await view.uiIsolate.flutterDebugDumpLayerTree(); await view.uiIsolate.flutterDebugDumpLayerTree();
} }
Future<Null> debugDumpSemanticsTreeInGeometricOrder() async { Future<Null> debugDumpSemanticsTreeInTraversalOrder() async {
for (FlutterView view in views) for (FlutterView view in views)
await view.uiIsolate.flutterDebugDumpSemanticsTreeInGeometricOrder(); await view.uiIsolate.flutterDebugDumpSemanticsTreeInTraversalOrder();
} }
Future<Null> debugDumpSemanticsTreeInInverseHitTestOrder() async { Future<Null> debugDumpSemanticsTreeInInverseHitTestOrder() async {
...@@ -505,10 +505,10 @@ abstract class ResidentRunner { ...@@ -505,10 +505,10 @@ abstract class ResidentRunner {
await device.debugDumpLayerTree(); await device.debugDumpLayerTree();
} }
Future<Null> _debugDumpSemanticsTreeInGeometricOrder() async { Future<Null> _debugDumpSemanticsTreeInTraversalOrder() async {
await refreshViews(); await refreshViews();
for (FlutterDevice device in flutterDevices) for (FlutterDevice device in flutterDevices)
await device.debugDumpSemanticsTreeInGeometricOrder(); await device.debugDumpSemanticsTreeInTraversalOrder();
} }
Future<Null> _debugDumpSemanticsTreeInInverseHitTestOrder() async { Future<Null> _debugDumpSemanticsTreeInInverseHitTestOrder() async {
...@@ -691,7 +691,7 @@ abstract class ResidentRunner { ...@@ -691,7 +691,7 @@ abstract class ResidentRunner {
} }
} else if (character == 'S') { } else if (character == 'S') {
if (supportsServiceProtocol) { if (supportsServiceProtocol) {
await _debugDumpSemanticsTreeInGeometricOrder(); await _debugDumpSemanticsTreeInTraversalOrder();
return true; return true;
} }
} else if (character == 'U') { } else if (character == 'U') {
...@@ -832,12 +832,12 @@ abstract class ResidentRunner { ...@@ -832,12 +832,12 @@ abstract class ResidentRunner {
printStatus('You can dump the widget hierarchy of the app (debugDumpApp) by pressing "w".'); printStatus('You can dump the widget hierarchy of the app (debugDumpApp) by pressing "w".');
printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "t".'); printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "t".');
if (isRunningDebug) { if (isRunningDebug) {
printStatus('For layers (debugDumpLayerTree), use "L"; for accessibility (debugDumpSemantics), use "S" (for geometric order) or "U" (for inverse hit test order).'); printStatus('For layers (debugDumpLayerTree), use "L"; for accessibility (debugDumpSemantics), use "S" (for traversal order) or "U" (for inverse hit test order).');
printStatus('To toggle the widget inspector (WidgetsApp.showWidgetInspectorOverride), press "i".'); printStatus('To toggle the widget inspector (WidgetsApp.showWidgetInspectorOverride), press "i".');
printStatus('To toggle the display of construction lines (debugPaintSizeEnabled), press "p".'); printStatus('To toggle the display of construction lines (debugPaintSizeEnabled), press "p".');
printStatus('To simulate different operating systems, (defaultTargetPlatform), press "o".'); printStatus('To simulate different operating systems, (defaultTargetPlatform), press "o".');
} else { } else {
printStatus('To dump the accessibility tree (debugDumpSemantics), press "S" (for geometric order) or "U" (for inverse hit test order).'); printStatus('To dump the accessibility tree (debugDumpSemantics), press "S" (for traversal order) or "U" (for inverse hit test order).');
} }
printStatus('To display the performance overlay (WidgetsApp.showPerformanceOverlay), press "P".'); printStatus('To display the performance overlay (WidgetsApp.showPerformanceOverlay), press "P".');
} }
......
...@@ -1201,8 +1201,8 @@ class Isolate extends ServiceObjectOwner { ...@@ -1201,8 +1201,8 @@ class Isolate extends ServiceObjectOwner {
return invokeFlutterExtensionRpcRaw('ext.flutter.debugDumpLayerTree', timeout: kLongRequestTimeout); return invokeFlutterExtensionRpcRaw('ext.flutter.debugDumpLayerTree', timeout: kLongRequestTimeout);
} }
Future<Map<String, dynamic>> flutterDebugDumpSemanticsTreeInGeometricOrder() { Future<Map<String, dynamic>> flutterDebugDumpSemanticsTreeInTraversalOrder() {
return invokeFlutterExtensionRpcRaw('ext.flutter.debugDumpSemanticsTreeInGeometricOrder', timeout: kLongRequestTimeout); return invokeFlutterExtensionRpcRaw('ext.flutter.debugDumpSemanticsTreeInTraversalOrder', timeout: kLongRequestTimeout);
} }
Future<Map<String, dynamic>> flutterDebugDumpSemanticsTreeInInverseHitTestOrder() { Future<Map<String, dynamic>> flutterDebugDumpSemanticsTreeInInverseHitTestOrder() {
......
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