Auto-format Framework (#160545)
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>
This commit is contained in:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -3,18 +3,13 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/material/navigation_rail/navigation_rail.0.dart'
|
||||
as example;
|
||||
import 'package:flutter_api_samples/material/navigation_rail/navigation_rail.0.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Navigation rail updates destination on tap',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.NavigationRailExampleApp(),
|
||||
);
|
||||
final NavigationRail navigationRailWidget =
|
||||
tester.firstWidget(find.byType(NavigationRail));
|
||||
testWidgets('Navigation rail updates destination on tap', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.NavigationRailExampleApp());
|
||||
final NavigationRail navigationRailWidget = tester.firstWidget(find.byType(NavigationRail));
|
||||
|
||||
/// NavigationRailDestinations must be rendered
|
||||
expect(find.text('First'), findsOneWidget);
|
||||
@@ -36,9 +31,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Navigation rail updates label type', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.NavigationRailExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.NavigationRailExampleApp());
|
||||
|
||||
// initial label type set to all.
|
||||
expect(find.text('Label type: all'), findsOneWidget);
|
||||
@@ -55,9 +48,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Navigation rail updates group alignment', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.NavigationRailExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.NavigationRailExampleApp());
|
||||
|
||||
// initial group alignment set top top.
|
||||
expect(find.text('Group alignment: -1.0'), findsOneWidget);
|
||||
@@ -74,9 +65,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Navigation rail shows leading/trailing widgets', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.NavigationRailExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.NavigationRailExampleApp());
|
||||
|
||||
// Initially leading/trailing widgets are hidden.
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
|
||||
@@ -3,18 +3,13 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/material/navigation_rail/navigation_rail.1.dart'
|
||||
as example;
|
||||
import 'package:flutter_api_samples/material/navigation_rail/navigation_rail.1.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Navigation rail updates destination on tap',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.NavigationRailExampleApp(),
|
||||
);
|
||||
final NavigationRail navigationRailWidget =
|
||||
tester.firstWidget(find.byType(NavigationRail));
|
||||
testWidgets('Navigation rail updates destination on tap', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.NavigationRailExampleApp());
|
||||
final NavigationRail navigationRailWidget = tester.firstWidget(find.byType(NavigationRail));
|
||||
|
||||
/// NavigationRailDestinations must be rendered
|
||||
expect(find.text('First'), findsOneWidget);
|
||||
@@ -36,9 +31,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Navigation rail updates label type', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.NavigationRailExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.NavigationRailExampleApp());
|
||||
|
||||
// initial label type set to all.
|
||||
expect(find.text('Label type: all'), findsOneWidget);
|
||||
@@ -55,9 +48,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Navigation rail updates group alignment', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.NavigationRailExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.NavigationRailExampleApp());
|
||||
|
||||
// initial group alignment set top top.
|
||||
expect(find.text('Group alignment: -1.0'), findsOneWidget);
|
||||
@@ -74,9 +65,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Navigation rail shows leading/trailing widgets', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.NavigationRailExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.NavigationRailExampleApp());
|
||||
|
||||
// Initially leading/trailing widgets are hidden.
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
@@ -96,22 +85,18 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('Destinations have badge', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.NavigationRailExampleApp(),
|
||||
);
|
||||
await tester.pumpWidget(const example.NavigationRailExampleApp());
|
||||
|
||||
// Test badge without label.
|
||||
final Badge notificationBadge = tester.firstWidget(find.ancestor(
|
||||
of: find.byIcon(Icons.bookmark_border),
|
||||
matching: find.byType(Badge),
|
||||
));
|
||||
final Badge notificationBadge = tester.firstWidget(
|
||||
find.ancestor(of: find.byIcon(Icons.bookmark_border), matching: find.byType(Badge)),
|
||||
);
|
||||
expect(notificationBadge.label, null);
|
||||
|
||||
// Test badge with label.
|
||||
final Badge messagesBadge = tester.firstWidget(find.ancestor(
|
||||
of: find.byIcon(Icons.star_border),
|
||||
matching: find.byType(Badge),
|
||||
));
|
||||
final Badge messagesBadge = tester.firstWidget(
|
||||
find.ancestor(of: find.byIcon(Icons.star_border), matching: find.byType(Badge)),
|
||||
);
|
||||
expect(messagesBadge.label, isNotNull);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,58 +8,57 @@ import 'package:flutter_api_samples/material/navigation_rail/navigation_rail.ext
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Navigation rail animates itself between the normal and extended state',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.ExtendedAnimationExampleApp(),
|
||||
);
|
||||
testWidgets('Navigation rail animates itself between the normal and extended state', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const example.ExtendedAnimationExampleApp());
|
||||
|
||||
expect(find.text('Tap on FloatingActionButton to expand'), findsOne);
|
||||
expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne);
|
||||
expect(find.byIcon(Icons.favorite), findsOne);
|
||||
expect(find.text('First'), findsOne);
|
||||
expect(find.byIcon(Icons.bookmark_border), findsOne);
|
||||
expect(find.text('Second'), findsOne);
|
||||
expect(find.byIcon(Icons.star_border), findsOne);
|
||||
expect(find.text('First'), findsOne);
|
||||
expect(find.text('Tap on FloatingActionButton to expand'), findsOne);
|
||||
expect(find.widgetWithIcon(FloatingActionButton, Icons.add), findsOne);
|
||||
expect(find.byIcon(Icons.favorite), findsOne);
|
||||
expect(find.text('First'), findsOne);
|
||||
expect(find.byIcon(Icons.bookmark_border), findsOne);
|
||||
expect(find.text('Second'), findsOne);
|
||||
expect(find.byIcon(Icons.star_border), findsOne);
|
||||
expect(find.text('First'), findsOne);
|
||||
|
||||
// The navigation rail should be in the normal state.
|
||||
expect(
|
||||
tester.getCenter(find.byType(FloatingActionButton)),
|
||||
offsetMoreOrLessEquals(const Offset(40, 36), epsilon: 0.1),
|
||||
);
|
||||
expect(find.widgetWithText(FloatingActionButton, 'CREATE'), findsNothing);
|
||||
// The navigation rail should be in the normal state.
|
||||
expect(
|
||||
tester.getCenter(find.byType(FloatingActionButton)),
|
||||
offsetMoreOrLessEquals(const Offset(40, 36), epsilon: 0.1),
|
||||
);
|
||||
expect(find.widgetWithText(FloatingActionButton, 'CREATE'), findsNothing);
|
||||
|
||||
// Expand the navigation rail.
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pump();
|
||||
await tester.pump(kThemeAnimationDuration * 0.5);
|
||||
expect(
|
||||
tester.getCenter(find.byType(FloatingActionButton)),
|
||||
offsetMoreOrLessEquals(const Offset(128.1, 36), epsilon: 0.1),
|
||||
);
|
||||
// Expand the navigation rail.
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pump();
|
||||
await tester.pump(kThemeAnimationDuration * 0.5);
|
||||
expect(
|
||||
tester.getCenter(find.byType(FloatingActionButton)),
|
||||
offsetMoreOrLessEquals(const Offset(128.1, 36), epsilon: 0.1),
|
||||
);
|
||||
|
||||
await tester.pump(kThemeAnimationDuration * 0.5);
|
||||
expect(
|
||||
tester.getCenter(find.byType(FloatingActionButton)),
|
||||
offsetMoreOrLessEquals(const Offset(132, 36), epsilon: 0.1),
|
||||
);
|
||||
expect(find.widgetWithText(FloatingActionButton, 'CREATE'), findsOne);
|
||||
await tester.pump(kThemeAnimationDuration * 0.5);
|
||||
expect(
|
||||
tester.getCenter(find.byType(FloatingActionButton)),
|
||||
offsetMoreOrLessEquals(const Offset(132, 36), epsilon: 0.1),
|
||||
);
|
||||
expect(find.widgetWithText(FloatingActionButton, 'CREATE'), findsOne);
|
||||
|
||||
// Collapse the navigation rail.
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pump();
|
||||
await tester.pump(kThemeAnimationDuration * 0.5);
|
||||
expect(
|
||||
tester.getCenter(find.byType(FloatingActionButton)),
|
||||
offsetMoreOrLessEquals(const Offset(128.1, 36), epsilon: 0.1),
|
||||
);
|
||||
// Collapse the navigation rail.
|
||||
await tester.tap(find.byType(FloatingActionButton));
|
||||
await tester.pump();
|
||||
await tester.pump(kThemeAnimationDuration * 0.5);
|
||||
expect(
|
||||
tester.getCenter(find.byType(FloatingActionButton)),
|
||||
offsetMoreOrLessEquals(const Offset(128.1, 36), epsilon: 0.1),
|
||||
);
|
||||
|
||||
await tester.pump(kThemeAnimationDuration * 0.5);
|
||||
expect(
|
||||
tester.getCenter(find.byType(FloatingActionButton)),
|
||||
offsetMoreOrLessEquals(const Offset(40, 36), epsilon: 0.1),
|
||||
);
|
||||
expect(find.widgetWithText(FloatingActionButton, 'CREATE'), findsNothing);
|
||||
await tester.pump(kThemeAnimationDuration * 0.5);
|
||||
expect(
|
||||
tester.getCenter(find.byType(FloatingActionButton)),
|
||||
offsetMoreOrLessEquals(const Offset(40, 36), epsilon: 0.1),
|
||||
);
|
||||
expect(find.widgetWithText(FloatingActionButton, 'CREATE'), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user