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:
Michael Goderbauer
2024-12-19 12:06:21 -08:00
committed by GitHub
parent 8e0993eda8
commit 5491c8c146
4411 changed files with 455108 additions and 415991 deletions

View File

@@ -8,9 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('DropdownMenu', (WidgetTester tester) async {
await tester.pumpWidget(
const example.DropdownMenuExample(),
);
await tester.pumpWidget(const example.DropdownMenuExample());
expect(find.text('You selected a Blue Smile'), findsNothing);
@@ -54,9 +52,7 @@ void main() {
});
testWidgets('DropdownMenu has focus when tapping on the text field', (WidgetTester tester) async {
await tester.pumpWidget(
const example.DropdownMenuExample(),
);
await tester.pumpWidget(const example.DropdownMenuExample());
// Make sure the dropdown menus are there.
final Finder colorMenu = find.byType(DropdownMenu<example.ColorLabel>);

View File

@@ -7,42 +7,41 @@ import 'package:flutter_api_samples/material/dropdown_menu/dropdown_menu.1.dart'
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('The DropdownMenu should display a menu with the list of entries the user can select', (WidgetTester tester) async {
await tester.pumpWidget(
const example.DropdownMenuApp(),
);
testWidgets(
'The DropdownMenu should display a menu with the list of entries the user can select',
(WidgetTester tester) async {
await tester.pumpWidget(const example.DropdownMenuApp());
expect(find.widgetWithText(TextField, 'One'), findsOne);
final Finder menu = find.byType(DropdownMenu<String>);
expect(menu, findsOne);
expect(find.widgetWithText(TextField, 'One'), findsOne);
final Finder menu = find.byType(DropdownMenu<String>);
expect(menu, findsOne);
Finder findMenuItem(String label) {
return find.widgetWithText(MenuItemButton, label).last;
}
Finder findMenuItem(String label) {
return find.widgetWithText(MenuItemButton, label).last;
}
await tester.tap(menu);
await tester.pumpAndSettle();
expect(findMenuItem('One'), findsOne);
expect(findMenuItem('Two'), findsOne);
expect(findMenuItem('Three'), findsOne);
expect(findMenuItem('Four'), findsOne);
await tester.tap(menu);
await tester.pumpAndSettle();
expect(findMenuItem('One'), findsOne);
expect(findMenuItem('Two'), findsOne);
expect(findMenuItem('Three'), findsOne);
expect(findMenuItem('Four'), findsOne);
await tester.tap(findMenuItem('Two'));
await tester.tap(findMenuItem('Two'));
// The DropdownMenu's onSelected callback is delayed
// with SchedulerBinding.instance.addPostFrameCallback
// to give the focus a chance to return to where it was
// before the menu appeared. The pumpAndSettle()
// give the callback a chance to run.
await tester.pumpAndSettle();
// The DropdownMenu's onSelected callback is delayed
// with SchedulerBinding.instance.addPostFrameCallback
// to give the focus a chance to return to where it was
// before the menu appeared. The pumpAndSettle()
// give the callback a chance to run.
await tester.pumpAndSettle();
expect(find.widgetWithText(TextField, 'Two'), findsOne);
});
expect(find.widgetWithText(TextField, 'Two'), findsOne);
},
);
testWidgets('DropdownMenu has focus when tapping on the text field', (WidgetTester tester) async {
await tester.pumpWidget(
const example.DropdownMenuApp(),
);
await tester.pumpWidget(const example.DropdownMenuApp());
// Make sure the dropdown menus are there.
final Finder menu = find.byType(DropdownMenu<String>);

View File

@@ -11,33 +11,46 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('DropdownMenu cursor behavior', (WidgetTester tester) async {
await tester.pumpWidget(
const example.DropdownMenuApp(),
);
await tester.pumpWidget(const example.DropdownMenuApp());
Finder textFieldFinder(int index) {
return find.byType(TextField).at(index);
}
// Hover over the "enabled and requestFocusOnTap set to true" text field.
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse, pointer: 1);
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
pointer: 1,
);
await gesture.moveTo(tester.getCenter(textFieldFinder(0)));
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
SystemMouseCursors.text,
);
// Hover over the "enabled and requestFocusOnTap set to false" text field.
await gesture.moveTo(tester.getCenter(textFieldFinder(1)));
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.click);
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
SystemMouseCursors.click,
);
// Hover over the "disabled and requestFocusOnTap set to true" text field.
await gesture.moveTo(tester.getCenter(textFieldFinder(2)));
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
SystemMouseCursors.basic,
);
// Hover over the "disabled and requestFocusOnTap set to false" text field.
await gesture.moveTo(tester.getCenter(textFieldFinder(3)));
await gesture.moveTo(tester.getCenter(textFieldFinder(3)));
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
SystemMouseCursors.basic,
);
});
}

View File

@@ -3,22 +3,24 @@
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_api_samples/material/dropdown_menu/dropdown_menu_entry_label_widget.0.dart' as example;
import 'package:flutter_api_samples/material/dropdown_menu/dropdown_menu_entry_label_widget.0.dart'
as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('DropdownEntryLabelWidget appears', (WidgetTester tester) async {
await tester.pumpWidget(
const example.DropdownMenuEntryLabelWidgetExampleApp(),
);
await tester.pumpWidget(const example.DropdownMenuEntryLabelWidgetExampleApp());
const String longText = 'is a color that sings of hope, A hue that shines like gold. It is the color of dreams, A shade that never grows old.';
const String longText =
'is a color that sings of hope, A hue that shines like gold. It is the color of dreams, A shade that never grows old.';
Finder findMenuItemText(String label) {
final String labelText = '$label $longText\n';
return find.descendant(
of: find.widgetWithText(MenuItemButton, labelText),
matching: find.byType(Text),
).last;
return find
.descendant(
of: find.widgetWithText(MenuItemButton, labelText),
matching: find.byType(Text),
)
.last;
}
// Open the menu