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

@@ -34,8 +34,9 @@ void verifyPropertyFaked<TProperty>({
expect(
realValue == fakeValue,
isFalse,
reason: 'Since the real value and fake value are equal, we cannot validate '
'that a property has been faked. Choose a different fake value to test.',
reason:
'Since the real value and fake value are equal, we cannot validate '
'that a property has been faked. Choose a different fake value to test.',
);
expect(propertyBeforeFaking, matcher(realValue));
expect(propertyAfterFaking, matcher(fakeValue));
@@ -81,21 +82,34 @@ class _FakeViewPaddingMatcher extends Matcher {
}
@override
Description describeMismatch(dynamic item, Description mismatchDescription, Map<dynamic, dynamic> matchState, bool verbose) {
Description describeMismatch(
dynamic item,
Description mismatchDescription,
Map<dynamic, dynamic> matchState,
bool verbose,
) {
assert(item is ViewPadding, 'Can only match against implementations of ViewPadding.');
final ViewPadding actual = item as ViewPadding;
if (actual.left != expected.left) {
mismatchDescription.add('actual.left (${actual.left}) did not match expected.left (${expected.left})');
mismatchDescription.add(
'actual.left (${actual.left}) did not match expected.left (${expected.left})',
);
}
if (actual.top != expected.top) {
mismatchDescription.add('actual.top (${actual.top}) did not match expected.top (${expected.top})');
mismatchDescription.add(
'actual.top (${actual.top}) did not match expected.top (${expected.top})',
);
}
if (actual.right != expected.right) {
mismatchDescription.add('actual.right (${actual.right}) did not match expected.right (${expected.right})');
mismatchDescription.add(
'actual.right (${actual.right}) did not match expected.right (${expected.right})',
);
}
if (actual.bottom != expected.bottom) {
mismatchDescription.add('actual.bottom (${actual.bottom}) did not match expected.bottom (${expected.bottom})');
mismatchDescription.add(
'actual.bottom (${actual.bottom}) did not match expected.bottom (${expected.bottom})',
);
}
return mismatchDescription;
@@ -107,8 +121,8 @@ class _FakeViewPaddingMatcher extends Matcher {
final ViewPadding actual = item as ViewPadding;
return actual.left == expected.left &&
actual.top == expected.top &&
actual.right == expected.right &&
actual.bottom == expected.bottom;
actual.top == expected.top &&
actual.right == expected.right &&
actual.bottom == expected.bottom;
}
}

View File

@@ -17,31 +17,27 @@ final List<InstrumentedDisposable> _retainer = <InstrumentedDisposable>[];
final List<LeakTestCase> memoryLeakTests = <LeakTestCase>[
LeakTestCase(
name: 'no leaks',
body: (PumpWidgetsCallback? pumpWidgets,
RunAsyncCallback<dynamic>? runAsync) async {
body: (PumpWidgetsCallback? pumpWidgets, RunAsyncCallback<dynamic>? runAsync) async {
await pumpWidgets!(Container());
},
),
LeakTestCase(
name: 'not disposed disposable',
body: (PumpWidgetsCallback? pumpWidgets,
RunAsyncCallback<dynamic>? runAsync) async {
body: (PumpWidgetsCallback? pumpWidgets, RunAsyncCallback<dynamic>? runAsync) async {
InstrumentedDisposable();
},
notDisposedTotal: 1,
),
LeakTestCase(
name: 'not GCed disposable',
body: (PumpWidgetsCallback? pumpWidgets,
RunAsyncCallback<dynamic>? runAsync) async {
body: (PumpWidgetsCallback? pumpWidgets, RunAsyncCallback<dynamic>? runAsync) async {
_retainer.add(InstrumentedDisposable()..dispose());
},
notGCedTotal: 1,
),
LeakTestCase(
name: 'leaking widget',
body: (PumpWidgetsCallback? pumpWidgets,
RunAsyncCallback<dynamic>? runAsync) async {
body: (PumpWidgetsCallback? pumpWidgets, RunAsyncCallback<dynamic>? runAsync) async {
StatelessLeakingWidget();
},
notDisposedTotal: 1,
@@ -49,16 +45,14 @@ final List<LeakTestCase> memoryLeakTests = <LeakTestCase>[
),
LeakTestCase(
name: 'dispose in tear down',
body: (PumpWidgetsCallback? pumpWidgets,
RunAsyncCallback<dynamic>? runAsync) async {
body: (PumpWidgetsCallback? pumpWidgets, RunAsyncCallback<dynamic>? runAsync) async {
final InstrumentedDisposable myClass = InstrumentedDisposable();
addTearDown(myClass.dispose);
},
),
LeakTestCase(
name: 'pumped leaking widget',
body: (PumpWidgetsCallback? pumpWidgets,
RunAsyncCallback<dynamic>? runAsync) async {
body: (PumpWidgetsCallback? pumpWidgets, RunAsyncCallback<dynamic>? runAsync) async {
await pumpWidgets!(StatelessLeakingWidget());
},
notDisposedTotal: 1,
@@ -66,8 +60,7 @@ final List<LeakTestCase> memoryLeakTests = <LeakTestCase>[
),
LeakTestCase(
name: 'leaking widget in runAsync',
body: (PumpWidgetsCallback? pumpWidgets,
RunAsyncCallback<dynamic>? runAsync) async {
body: (PumpWidgetsCallback? pumpWidgets, RunAsyncCallback<dynamic>? runAsync) async {
await runAsync!(() async {
StatelessLeakingWidget();
});
@@ -77,8 +70,7 @@ final List<LeakTestCase> memoryLeakTests = <LeakTestCase>[
),
LeakTestCase(
name: 'pumped in runAsync',
body: (PumpWidgetsCallback? pumpWidgets,
RunAsyncCallback<dynamic>? runAsync) async {
body: (PumpWidgetsCallback? pumpWidgets, RunAsyncCallback<dynamic>? runAsync) async {
await runAsync!(() async {
await pumpWidgets!(StatelessLeakingWidget());
});
@@ -89,7 +81,5 @@ final List<LeakTestCase> memoryLeakTests = <LeakTestCase>[
];
String memoryLeakTestsFilePath() {
return RegExp(r'(\/[^\/]*.dart):')
.firstMatch(StackTrace.current.toString())!
.group(1).toString();
return RegExp(r'(\/[^\/]*.dart):').firstMatch(StackTrace.current.toString())!.group(1).toString();
}