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

@@ -47,31 +47,42 @@ void main() {
bool called = false;
Future<ui.Codec> decode(ui.ImmutableBuffer buffer, {ui.TargetImageSizeCallback? getTargetSize}) {
return PaintingBinding.instance.instantiateImageCodecWithSize(buffer, getTargetSize: (int intrinsicWidth, int intrinsicHeight) {
expect(getTargetSize, isNotNull);
final ui.TargetImageSize targetSize = getTargetSize!(intrinsicWidth, intrinsicHeight);
expect(targetSize.width, expectedCacheWidth);
expect(targetSize.height, expectedCacheHeight);
called = true;
return targetSize;
});
Future<ui.Codec> decode(
ui.ImmutableBuffer buffer, {
ui.TargetImageSizeCallback? getTargetSize,
}) {
return PaintingBinding.instance.instantiateImageCodecWithSize(
buffer,
getTargetSize: (int intrinsicWidth, int intrinsicHeight) {
expect(getTargetSize, isNotNull);
final ui.TargetImageSize targetSize = getTargetSize!(intrinsicWidth, intrinsicHeight);
expect(targetSize.width, expectedCacheWidth);
expect(targetSize.height, expectedCacheHeight);
called = true;
return targetSize;
},
);
}
final ImageProvider resizeImage = image.image;
expect(image.image, isA<ResizeImage>());
final LoadTestImageProvider testProvider = LoadTestImageProvider(image.image);
final ImageStreamCompleter streamCompleter = testProvider.testLoad(await resizeImage.obtainKey(ImageConfiguration.empty), decode);
final ImageStreamCompleter streamCompleter = testProvider.testLoad(
await resizeImage.obtainKey(ImageConfiguration.empty),
decode,
);
final Completer<void> completer = Completer<void>();
int? imageInfoCachedWidth;
int? imageInfoCachedHeight;
streamCompleter.addListener(ImageStreamListener((ImageInfo imageInfo, bool syncCall) {
imageInfoCachedWidth = imageInfo.image.width;
imageInfoCachedHeight = imageInfo.image.height;
completer.complete();
}));
streamCompleter.addListener(
ImageStreamListener((ImageInfo imageInfo, bool syncCall) {
imageInfoCachedWidth = imageInfo.image.width;
imageInfoCachedHeight = imageInfo.image.height;
completer.complete();
}),
);
await completer.future;
expect(imageInfoCachedHeight, isNotNull);

View File

@@ -5,6 +5,7 @@
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();

View File

@@ -9,8 +9,9 @@ import 'package:web_e2e_tests/profile_diagnostics_main.dart' as app;
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('App build method exception should form valid FlutterErrorDetails',
(WidgetTester tester) async {
testWidgets('App build method exception should form valid FlutterErrorDetails', (
WidgetTester tester,
) async {
app.main();
await tester.pumpAndSettle();
final dynamic appError = tester.takeException();

View File

@@ -21,9 +21,6 @@ void main() {
await tester.tap(finder);
await tester.pumpAndSettle();
await expectLater(
find.byType(app.MyApp),
matchesGoldenFile('scroll_wheel_by_line'),
);
await expectLater(find.byType(app.MyApp), matchesGoldenFile('scroll_wheel_by_line'));
});
}

View File

@@ -15,8 +15,7 @@ import 'package:web_e2e_tests/text_editing_main.dart' as app;
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets('Focused text field creates a native input element',
(WidgetTester tester) async {
testWidgets('Focused text field creates a native input element', (WidgetTester tester) async {
app.main();
await tester.pumpAndSettle();
@@ -39,8 +38,7 @@ void main() {
expect(input.value, 'New Value');
}, semanticsEnabled: false);
testWidgets('Input field with no initial value works',
(WidgetTester tester) async {
testWidgets('Input field with no initial value works', (WidgetTester tester) async {
app.main();
await tester.pumpAndSettle();
@@ -63,8 +61,7 @@ void main() {
expect(input.value, 'New Value');
}, semanticsEnabled: false);
testWidgets('Pressing enter on the text field triggers submit',
(WidgetTester tester) async {
testWidgets('Pressing enter on the text field triggers submit', (WidgetTester tester) async {
app.main();
await tester.pumpAndSettle();
@@ -100,8 +97,7 @@ void main() {
expect(text2.data, 'enter pressed');
}, semanticsEnabled: false);
testWidgets('Jump between TextFormFields with tab key',
(WidgetTester tester) async {
testWidgets('Jump between TextFormFields with tab key', (WidgetTester tester) async {
app.main();
await tester.pumpAndSettle();
@@ -140,7 +136,9 @@ void main() {
expect(input2.value, 'Text2');
}, semanticsEnabled: false);
testWidgets('Jump between TextFormFields with tab key after CapsLock is activated', (WidgetTester tester) async {
testWidgets('Jump between TextFormFields with tab key after CapsLock is activated', (
WidgetTester tester,
) async {
app.main();
await tester.pumpAndSettle();
@@ -205,12 +203,10 @@ void main() {
expect(finder, findsOneWidget);
final RenderBox selectable = tester.renderObject(finder);
final Offset topLeft = selectable.localToGlobal(Offset.zero);
final Offset topRight =
selectable.localToGlobal(Offset(selectable.size.width, 0.0));
final Offset topRight = selectable.localToGlobal(Offset(selectable.size.width, 0.0));
// Drag by mouse to select the entire selectable text.
TestGesture gesture =
await tester.startGesture(topLeft, kind: PointerDeviceKind.mouse);
TestGesture gesture = await tester.startGesture(topLeft, kind: PointerDeviceKind.mouse);
await gesture.moveTo(topRight);
await gesture.up();
@@ -223,16 +219,12 @@ void main() {
expect(input.hasAttribute('readonly'), isTrue);
// Make sure the entire text is selected.
TextRange? range =
TextRange(start: input.selectionStart, end: input.selectionEnd);
TextRange? range = TextRange(start: input.selectionStart, end: input.selectionEnd);
expect(range.textInside(text), text);
// Double tap to select the first word.
final Offset firstWordOffset = topLeft.translate(10.0, 0.0);
gesture = await tester.startGesture(
firstWordOffset,
kind: PointerDeviceKind.mouse,
);
gesture = await tester.startGesture(firstWordOffset, kind: PointerDeviceKind.mouse);
await gesture.up();
await gesture.down(firstWordOffset);
await gesture.up();
@@ -241,10 +233,7 @@ void main() {
// Double tap to select the last word.
final Offset lastWordOffset = topRight.translate(-10.0, 0.0);
gesture = await tester.startGesture(
lastWordOffset,
kind: PointerDeviceKind.mouse,
);
gesture = await tester.startGesture(lastWordOffset, kind: PointerDeviceKind.mouse);
await gesture.up();
await gesture.down(lastWordOffset);
await gesture.up();
@@ -254,15 +243,15 @@ void main() {
}
web.KeyboardEvent dispatchKeyboardEvent(
web.EventTarget target, String type, Map<String, dynamic> args) {
web.EventTarget target,
String type,
Map<String, dynamic> args,
) {
final Object jsKeyboardEvent = js_util.getProperty(web.window, 'KeyboardEvent') as Object;
final List<dynamic> eventArgs = <dynamic>[
type,
args,
];
final web.KeyboardEvent event = js_util.callConstructor(
jsKeyboardEvent, js_util.jsify(eventArgs) as List<dynamic>)
as web.KeyboardEvent;
final List<dynamic> eventArgs = <dynamic>[type, args];
final web.KeyboardEvent event =
js_util.callConstructor(jsKeyboardEvent, js_util.jsify(eventArgs) as List<dynamic>)
as web.KeyboardEvent;
target.dispatchEvent(event);
return event;

View File

@@ -52,8 +52,8 @@ class TestUrlStrategy extends UrlStrategy {
/// Creates an instance of [TestUrlStrategy] and populates it with a list
/// that has [initialEntry] as the only item.
TestUrlStrategy.fromEntry(TestHistoryEntry initialEntry)
: _currentEntryIndex = 0,
history = <TestHistoryEntry>[initialEntry];
: _currentEntryIndex = 0,
history = <TestHistoryEntry>[initialEntry];
@override
String getPath() => currentEntry.url;