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

@@ -3,32 +3,21 @@
// found in the LICENSE file.
import 'package:flutter/services.dart';
import 'package:flutter_api_samples/widgets/shortcuts/callback_shortcuts.0.dart'
as example;
import 'package:flutter_api_samples/widgets/shortcuts/callback_shortcuts.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Verify correct labels are displayed', (WidgetTester tester) async {
await tester.pumpWidget(
const example.CallbackShortcutsApp(),
);
await tester.pumpWidget(const example.CallbackShortcutsApp());
expect(find.text('CallbackShortcuts Sample'), findsOneWidget);
expect(
find.text('Press the up arrow key to add to the counter'),
findsOneWidget,
);
expect(
find.text('Press the down arrow key to subtract from the counter'),
findsOneWidget,
);
expect(find.text('Press the up arrow key to add to the counter'), findsOneWidget);
expect(find.text('Press the down arrow key to subtract from the counter'), findsOneWidget);
expect(find.text('count: 0'), findsOneWidget);
});
testWidgets('Up and down arrow press updates counter', (WidgetTester tester) async {
await tester.pumpWidget(
const example.CallbackShortcutsApp(),
);
await tester.pumpWidget(const example.CallbackShortcutsApp());
int counter = 0;

View File

@@ -4,50 +4,42 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_api_samples/widgets/shortcuts/character_activator.0.dart'
as example;
import 'package:flutter_api_samples/widgets/shortcuts/character_activator.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
group('CharacterActivatorExampleApp', () {
testWidgets('displays correct labels', (WidgetTester tester) async {
await tester.pumpWidget(
const example.CharacterActivatorExampleApp(),
);
await tester.pumpWidget(const example.CharacterActivatorExampleApp());
expect(find.text('CharacterActivator Sample'), findsOneWidget);
expect(find.text('Press question mark for help'), findsOneWidget);
});
testWidgets(
'shows snack bar on question key pressed',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.CharacterActivatorExampleApp(),
);
testWidgets('shows snack bar on question key pressed', (WidgetTester tester) async {
await tester.pumpWidget(const example.CharacterActivatorExampleApp());
final Finder snackBarFinder = find.ancestor(
of: find.text('Keep calm and carry on!'),
matching: find.byType(SnackBar),
);
final Finder snackBarFinder = find.ancestor(
of: find.text('Keep calm and carry on!'),
matching: find.byType(SnackBar),
);
expect(snackBarFinder, findsNothing);
expect(snackBarFinder, findsNothing);
await tester.sendKeyEvent(LogicalKeyboardKey.slash, character: '?');
await tester.sendKeyEvent(LogicalKeyboardKey.slash, character: '?');
// Advance the SnackBar entrance animation to the end.
await tester.pumpAndSettle();
// Advance the SnackBar entrance animation to the end.
await tester.pumpAndSettle();
expect(snackBarFinder, findsOneWidget);
expect(snackBarFinder, findsOneWidget);
// Advance time by default SnackBar display duration.
await tester.pump(const Duration(milliseconds: 4000));
// Advance time by default SnackBar display duration.
await tester.pump(const Duration(milliseconds: 4000));
// Advance the SnackBar exit animation to the end.
await tester.pumpAndSettle();
// Advance the SnackBar exit animation to the end.
await tester.pumpAndSettle();
expect(snackBarFinder, findsNothing);
},
);
expect(snackBarFinder, findsNothing);
});
});
}

View File

@@ -3,15 +3,11 @@
// found in the LICENSE file.
import 'package:flutter/services.dart';
import 'package:flutter_api_samples/widgets/shortcuts/logical_key_set.0.dart'
as example;
import 'package:flutter_api_samples/widgets/shortcuts/logical_key_set.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
Future<void> sendKeyCombination(
WidgetTester tester,
List<LogicalKeyboardKey> keys,
) async {
Future<void> sendKeyCombination(WidgetTester tester, List<LogicalKeyboardKey> keys) async {
for (final LogicalKeyboardKey key in keys) {
await tester.sendKeyDownEvent(key);
}
@@ -21,22 +17,17 @@ void main() {
}
testWidgets('Verify correct labels are displayed', (WidgetTester tester) async {
await tester.pumpWidget(
const example.LogicalKeySetExampleApp(),
);
await tester.pumpWidget(const example.LogicalKeySetExampleApp());
expect(find.text('LogicalKeySet Sample'), findsOneWidget);
expect(
find.text('Add to the counter by pressing Ctrl+C'),
findsOneWidget,
);
expect(find.text('Add to the counter by pressing Ctrl+C'), findsOneWidget);
expect(find.text('count: 0'), findsOneWidget);
});
testWidgets('CtrlLeft+C or C+CtrlLeft key combination updates counter', (WidgetTester tester) async {
await tester.pumpWidget(
const example.LogicalKeySetExampleApp(),
);
testWidgets('CtrlLeft+C or C+CtrlLeft key combination updates counter', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.LogicalKeySetExampleApp());
for (int counter = 0; counter < 10; counter++) {
expect(find.text('count: $counter'), findsOneWidget);
@@ -44,74 +35,53 @@ void main() {
await sendKeyCombination(
tester,
counter.isEven
? <LogicalKeyboardKey>[
LogicalKeyboardKey.controlLeft,
LogicalKeyboardKey.keyC,
]
: <LogicalKeyboardKey>[
LogicalKeyboardKey.keyC,
LogicalKeyboardKey.controlLeft,
],
? <LogicalKeyboardKey>[LogicalKeyboardKey.controlLeft, LogicalKeyboardKey.keyC]
: <LogicalKeyboardKey>[LogicalKeyboardKey.keyC, LogicalKeyboardKey.controlLeft],
);
await tester.pump();
}
});
testWidgets('CtrlRight+C key combination updates counter', (WidgetTester tester) async {
await tester.pumpWidget(
const example.LogicalKeySetExampleApp(),
);
await tester.pumpWidget(const example.LogicalKeySetExampleApp());
for (int counter = 0; counter < 10; counter++) {
expect(find.text('count: $counter'), findsOneWidget);
await sendKeyCombination(
tester,
<LogicalKeyboardKey>[
LogicalKeyboardKey.controlRight,
LogicalKeyboardKey.keyC,
],
);
await sendKeyCombination(tester, <LogicalKeyboardKey>[
LogicalKeyboardKey.controlRight,
LogicalKeyboardKey.keyC,
]);
await tester.pump();
}
});
testWidgets('CtrlLeft+A+C key combination does not update counter', (WidgetTester tester) async {
await tester.pumpWidget(
const example.LogicalKeySetExampleApp(),
);
await tester.pumpWidget(const example.LogicalKeySetExampleApp());
for (int counter = 0; counter < 10; counter++) {
expect(find.text('count: 0'), findsOneWidget);
await sendKeyCombination(
tester,
<LogicalKeyboardKey>[
LogicalKeyboardKey.controlLeft,
LogicalKeyboardKey.keyA,
LogicalKeyboardKey.keyC,
],
);
await sendKeyCombination(tester, <LogicalKeyboardKey>[
LogicalKeyboardKey.controlLeft,
LogicalKeyboardKey.keyA,
LogicalKeyboardKey.keyC,
]);
await tester.pump();
}
});
testWidgets('CtrlRight+A+C key combination does not update counter', (WidgetTester tester) async {
await tester.pumpWidget(
const example.LogicalKeySetExampleApp(),
);
await tester.pumpWidget(const example.LogicalKeySetExampleApp());
for (int counter = 0; counter < 10; counter++) {
expect(find.text('count: 0'), findsOneWidget);
await sendKeyCombination(
tester,
<LogicalKeyboardKey>[
LogicalKeyboardKey.controlRight,
LogicalKeyboardKey.keyA,
LogicalKeyboardKey.keyC,
],
);
await sendKeyCombination(tester, <LogicalKeyboardKey>[
LogicalKeyboardKey.controlRight,
LogicalKeyboardKey.keyA,
LogicalKeyboardKey.keyC,
]);
await tester.pump();
}
});

View File

@@ -3,32 +3,21 @@
// found in the LICENSE file.
import 'package:flutter/services.dart';
import 'package:flutter_api_samples/widgets/shortcuts/shortcuts.0.dart'
as example;
import 'package:flutter_api_samples/widgets/shortcuts/shortcuts.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Verify correct labels are displayed', (WidgetTester tester) async {
await tester.pumpWidget(
const example.ShortcutsExampleApp(),
);
await tester.pumpWidget(const example.ShortcutsExampleApp());
expect(find.text('Shortcuts Sample'), findsOneWidget);
expect(
find.text('Add to the counter by pressing the up arrow key'),
findsOneWidget,
);
expect(
find.text('Subtract from the counter by pressing the down arrow key'),
findsOneWidget,
);
expect(find.text('Add to the counter by pressing the up arrow key'), findsOneWidget);
expect(find.text('Subtract from the counter by pressing the down arrow key'), findsOneWidget);
expect(find.text('count: 0'), findsOneWidget);
});
testWidgets('Up and down arrow press updates counter', (WidgetTester tester) async {
await tester.pumpWidget(
const example.ShortcutsExampleApp(),
);
await tester.pumpWidget(const example.ShortcutsExampleApp());
int counter = 0;

View File

@@ -4,32 +4,21 @@
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_api_samples/widgets/shortcuts/shortcuts.1.dart'
as example;
import 'package:flutter_api_samples/widgets/shortcuts/shortcuts.1.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Verify correct labels are displayed', (WidgetTester tester) async {
await tester.pumpWidget(
const example.ShortcutsExampleApp(),
);
await tester.pumpWidget(const example.ShortcutsExampleApp());
expect(find.text('Shortcuts Sample'), findsOneWidget);
expect(
find.text('Add to the counter by pressing the up arrow key'),
findsOneWidget,
);
expect(
find.text('Subtract from the counter by pressing the down arrow key'),
findsOneWidget,
);
expect(find.text('Add to the counter by pressing the up arrow key'), findsOneWidget);
expect(find.text('Subtract from the counter by pressing the down arrow key'), findsOneWidget);
expect(find.text('count: 0'), findsOneWidget);
});
testWidgets('Up and down arrow press updates counter', (WidgetTester tester) async {
await tester.pumpWidget(
const example.ShortcutsExampleApp(),
);
await tester.pumpWidget(const example.ShortcutsExampleApp());
int counter = 0;
@@ -56,15 +45,10 @@ void main() {
// Regression test for https://github.com/flutter/flutter/issues/156806.
testWidgets('SingleActivator is used instead of LogicalKeySet', (WidgetTester tester) async {
await tester.pumpWidget(
const example.ShortcutsExampleApp(),
);
await tester.pumpWidget(const example.ShortcutsExampleApp());
final Shortcuts shortcuts = tester.firstWidget(
find.descendant(
of: find.byType(example.ShortcutsExample),
matching: find.byType(Shortcuts),
)
find.descendant(of: find.byType(example.ShortcutsExample), matching: find.byType(Shortcuts)),
);
expect(shortcuts.shortcuts.length, 2);

View File

@@ -3,8 +3,7 @@
// found in the LICENSE file.
import 'package:flutter/services.dart';
import 'package:flutter_api_samples/widgets/shortcuts/single_activator.0.dart'
as example;
import 'package:flutter_api_samples/widgets/shortcuts/single_activator.0.dart' as example;
import 'package:flutter_test/flutter_test.dart';
void main() {
@@ -17,31 +16,21 @@ void main() {
group('SingleActivatorExampleApp', () {
testWidgets('displays correct labels', (WidgetTester tester) async {
await tester.pumpWidget(
const example.SingleActivatorExampleApp(),
);
await tester.pumpWidget(const example.SingleActivatorExampleApp());
expect(
find.text('Add to the counter by pressing Ctrl+C'),
findsOneWidget,
);
expect(find.text('Add to the counter by pressing Ctrl+C'), findsOneWidget);
expect(find.text('count: 0'), findsOneWidget);
});
testWidgets(
'updates counter when Ctrl-C combination pressed',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.SingleActivatorExampleApp(),
);
testWidgets('updates counter when Ctrl-C combination pressed', (WidgetTester tester) async {
await tester.pumpWidget(const example.SingleActivatorExampleApp());
for (int counter = 0; counter < 10; counter++) {
expect(find.text('count: $counter'), findsOneWidget);
for (int counter = 0; counter < 10; counter++) {
expect(find.text('count: $counter'), findsOneWidget);
await pressControlC(tester);
await tester.pump();
}
},
);
await pressControlC(tester);
await tester.pump();
}
});
});
}