mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This auto-formats all *.dart files in the repository outside of the `engine` subdirectory and enforces that these files stay formatted with a presubmit check. **Reviewers:** Please carefully review all the commits except for the one titled "formatted". The "formatted" commit was auto-generated by running `dev/tools/format.sh -a -f`. The other commits were hand-crafted to prepare the repo for the formatting change. I recommend reviewing the commits one-by-one via the "Commits" tab and avoiding Github's "Files changed" tab as it will likely slow down your browser because of the size of this PR. --------- Co-authored-by: Kate Lovett <katelovett@google.com> Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
225 lines
6.3 KiB
Dart
225 lines
6.3 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter/widgets.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'semantics_tester.dart';
|
|
|
|
void main() {
|
|
testWidgets('Implicit Semantics merge behavior', (WidgetTester tester) async {
|
|
final SemanticsTester semantics = SemanticsTester(tester);
|
|
|
|
await tester.pumpWidget(
|
|
Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: Semantics(
|
|
container: true,
|
|
child: const Column(
|
|
children: <Widget>[Text('Michael Goderbauer'), Text('goderbauer@google.com')],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
// SemanticsNode#0()
|
|
// └SemanticsNode#1(label: "Michael Goderbauer\ngoderbauer@google.com", textDirection: ltr)
|
|
expect(
|
|
semantics,
|
|
hasSemantics(
|
|
TestSemantics.root(
|
|
children: <TestSemantics>[
|
|
TestSemantics.rootChild(id: 1, label: 'Michael Goderbauer\ngoderbauer@google.com'),
|
|
],
|
|
),
|
|
ignoreRect: true,
|
|
ignoreTransform: true,
|
|
),
|
|
);
|
|
|
|
await tester.pumpWidget(
|
|
Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: Semantics(
|
|
container: true,
|
|
explicitChildNodes: true,
|
|
child: const Column(
|
|
children: <Widget>[Text('Michael Goderbauer'), Text('goderbauer@google.com')],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
// SemanticsNode#0()
|
|
// └SemanticsNode#1()
|
|
// ├SemanticsNode#2(label: "Michael Goderbauer", textDirection: ltr)
|
|
// └SemanticsNode#3(label: "goderbauer@google.com", textDirection: ltr)
|
|
expect(
|
|
semantics,
|
|
hasSemantics(
|
|
TestSemantics.root(
|
|
children: <TestSemantics>[
|
|
TestSemantics.rootChild(
|
|
id: 1,
|
|
children: <TestSemantics>[
|
|
TestSemantics(id: 2, label: 'Michael Goderbauer'),
|
|
TestSemantics(id: 3, label: 'goderbauer@google.com'),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
ignoreRect: true,
|
|
ignoreTransform: true,
|
|
),
|
|
);
|
|
|
|
await tester.pumpWidget(
|
|
Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: Semantics(
|
|
container: true,
|
|
explicitChildNodes: true,
|
|
child: Semantics(
|
|
label: 'Signed in as',
|
|
child: const Column(
|
|
children: <Widget>[Text('Michael Goderbauer'), Text('goderbauer@google.com')],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
// SemanticsNode#0()
|
|
// └SemanticsNode#1()
|
|
// └SemanticsNode#4(label: "Signed in as\nMichael Goderbauer\ngoderbauer@google.com", textDirection: ltr)
|
|
expect(
|
|
semantics,
|
|
hasSemantics(
|
|
TestSemantics.root(
|
|
children: <TestSemantics>[
|
|
TestSemantics.rootChild(
|
|
id: 1,
|
|
children: <TestSemantics>[
|
|
TestSemantics(
|
|
id: 4,
|
|
label: 'Signed in as\nMichael Goderbauer\ngoderbauer@google.com',
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
ignoreRect: true,
|
|
ignoreTransform: true,
|
|
),
|
|
);
|
|
|
|
await tester.pumpWidget(
|
|
Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: Semantics(
|
|
container: true,
|
|
child: Semantics(
|
|
label: 'Signed in as',
|
|
child: const Column(
|
|
children: <Widget>[Text('Michael Goderbauer'), Text('goderbauer@google.com')],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
// SemanticsNode#0()
|
|
// └SemanticsNode#1(label: "Signed in as\nMichael Goderbauer\ngoderbauer@google.com", textDirection: ltr)
|
|
expect(
|
|
semantics,
|
|
hasSemantics(
|
|
TestSemantics.root(
|
|
children: <TestSemantics>[
|
|
TestSemantics.rootChild(
|
|
id: 1,
|
|
label: 'Signed in as\nMichael Goderbauer\ngoderbauer@google.com',
|
|
),
|
|
],
|
|
),
|
|
ignoreRect: true,
|
|
ignoreTransform: true,
|
|
),
|
|
);
|
|
|
|
semantics.dispose();
|
|
});
|
|
|
|
testWidgets('Do not merge with conflicts', (WidgetTester tester) async {
|
|
final SemanticsTester semantics = SemanticsTester(tester);
|
|
|
|
await tester.pumpWidget(
|
|
Directionality(
|
|
textDirection: TextDirection.ltr,
|
|
child: Semantics(
|
|
container: true,
|
|
child: Column(
|
|
children: <Widget>[
|
|
Semantics(
|
|
label: 'node 1',
|
|
selected: true,
|
|
child: const SizedBox(width: 10.0, height: 10.0),
|
|
),
|
|
Semantics(
|
|
label: 'node 2',
|
|
selected: true,
|
|
child: const SizedBox(width: 10.0, height: 10.0),
|
|
),
|
|
Semantics(
|
|
label: 'node 3',
|
|
selected: true,
|
|
child: const SizedBox(width: 10.0, height: 10.0),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
// SemanticsNode#0()
|
|
// └SemanticsNode#1()
|
|
// ├SemanticsNode#2(selected, label: "node 1", textDirection: ltr)
|
|
// ├SemanticsNode#3(selected, label: "node 2", textDirection: ltr)
|
|
// └SemanticsNode#4(selected, label: "node 3", textDirection: ltr)
|
|
expect(
|
|
semantics,
|
|
hasSemantics(
|
|
TestSemantics.root(
|
|
children: <TestSemantics>[
|
|
TestSemantics.rootChild(
|
|
id: 1,
|
|
children: <TestSemantics>[
|
|
TestSemantics(
|
|
id: 2,
|
|
flags: <SemanticsFlag>[SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected],
|
|
label: 'node 1',
|
|
),
|
|
TestSemantics(
|
|
id: 3,
|
|
flags: <SemanticsFlag>[SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected],
|
|
label: 'node 2',
|
|
),
|
|
TestSemantics(
|
|
id: 4,
|
|
flags: <SemanticsFlag>[SemanticsFlag.hasSelectedState, SemanticsFlag.isSelected],
|
|
label: 'node 3',
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
ignoreRect: true,
|
|
ignoreTransform: true,
|
|
),
|
|
);
|
|
|
|
semantics.dispose();
|
|
});
|
|
}
|