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

@@ -16,7 +16,7 @@ void main() {
});
tearDownAll(() async {
driver.close();
driver.close();
});
test('measure', () async {

View File

@@ -16,7 +16,7 @@ void main() {
});
tearDownAll(() async {
driver.close();
driver.close();
});
test('measure', () async {

View File

@@ -14,7 +14,7 @@ void main() {
});
tearDownAll(() async {
driver.close();
driver.close();
});
test('measure', () async {

View File

@@ -17,9 +17,8 @@ import 'run_demos.dart';
//
// These names are reported by the test app, see _handleMessages()
// in transitions_perf.dart.
List<String> _allDemos = kAllGalleryDemos.map(
(GalleryDemo demo) => '${demo.title}@${demo.category.name}',
).toList();
List<String> _allDemos =
kAllGalleryDemos.map((GalleryDemo demo) => '${demo.title}@${demo.category.name}').toList();
Set<String> _unTestedDemos = Set<String>.from(_allDemos);
@@ -36,7 +35,7 @@ class _MessageHandler {
return const JsonEncoder.withIndent(' ').convert(kProfiledDemos);
case 'restDemos':
controller ??= LiveWidgetController(WidgetsBinding.instance);
final List<String> restDemos = _unTestedDemos.toList();
final List<String> restDemos = _unTestedDemos.toList();
await runDemos(restDemos, controller!);
return const JsonEncoder.withIndent(' ').convert(restDemos);
default:

View File

@@ -16,13 +16,13 @@ import 'run_demos.dart';
//
// These names are reported by the test app, see _handleMessages()
// in transitions_perf.dart.
List<String> _allDemos = kAllGalleryDemos.map(
(GalleryDemo demo) => '${demo.title}@${demo.category.name}',
).toList();
List<String> _allDemos =
kAllGalleryDemos.map((GalleryDemo demo) => '${demo.title}@${demo.category.name}').toList();
void main([List<String> args = const <String>[]]) {
final bool withSemantics = args.contains('--with_semantics');
final IntegrationTestWidgetsFlutterBinding binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
final IntegrationTestWidgetsFlutterBinding binding =
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
group('flutter gallery transitions on e2e', () {
testWidgets('find.bySemanticsLabel', (WidgetTester tester) async {
@@ -32,22 +32,17 @@ void main([List<String> args = const <String>[]]) {
expect(id, greaterThan(-1));
}, skip: !withSemantics);
testWidgets(
'all demos',
(WidgetTester tester) async {
runApp(const GalleryApp(testMode: true));
await tester.pumpAndSettle();
// Collect timeline data for just a limited set of demos to avoid OOMs.
await binding.watchPerformance(() async {
await runDemos(kProfiledDemos, tester);
});
testWidgets('all demos', (WidgetTester tester) async {
runApp(const GalleryApp(testMode: true));
await tester.pumpAndSettle();
// Collect timeline data for just a limited set of demos to avoid OOMs.
await binding.watchPerformance(() async {
await runDemos(kProfiledDemos, tester);
});
// Execute the remaining tests.
final Set<String> unprofiledDemos = Set<String>.from(_allDemos)
..removeAll(kProfiledDemos);
await runDemos(unprofiledDemos.toList(), tester);
},
semanticsEnabled: withSemantics,
);
// Execute the remaining tests.
final Set<String> unprofiledDemos = Set<String>.from(_allDemos)..removeAll(kProfiledDemos);
await runDemos(unprofiledDemos.toList(), tester);
}, semanticsEnabled: withSemantics);
});
}

View File

@@ -10,5 +10,5 @@ Future<void> main() => driver.integrationDriver(
data!['performance'] as Map<String, dynamic>,
testOutputFilename: 'e2e_perf_summary',
);
}
},
);

View File

@@ -4,6 +4,5 @@
import 'transitions_perf_test.dart' as transitions_perf_test;
void main([List<String> args = const <String>[]]) => transitions_perf_test.main(
<String>['--hybrid', ...args],
);
void main([List<String> args = const <String>[]]) =>
transitions_perf_test.main(<String>['--hybrid', ...args]);

View File

@@ -71,7 +71,9 @@ Future<void> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
});
if (unexpectedValueCounts.isNotEmpty) {
final StringBuffer error = StringBuffer('Some routes recorded wrong number of values (expected 2 values/route):\n\n');
final StringBuffer error = StringBuffer(
'Some routes recorded wrong number of values (expected 2 values/route):\n\n',
);
// When run with --trace-startup, the VM stores trace events in an endless buffer instead of a ring buffer.
error.write('You must add the --trace-startup parameter to run the test. \n\n');
unexpectedValueCounts.forEach((String routeName, int count) {
@@ -88,9 +90,10 @@ Future<void> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
continue;
}
final String routeName = eventName == 'Start Transition'
? (eventIter.current['args'] as Map<String, dynamic>)['to'] as String
: '';
final String routeName =
eventName == 'Start Transition'
? (eventIter.current['args'] as Map<String, dynamic>)['to'] as String
: '';
if (eventName == lastEventName && routeName == lastRouteName) {
error.write('.');
@@ -138,10 +141,7 @@ Future<void> runDemos(List<String> demos, FlutterDriver driver) async {
currentDemoCategory = demoCategory;
final SerializableFinder demoItem = find.text(demoName);
await driver.scrollUntilVisible(demoList, demoItem,
dyScroll: -48.0,
alignment: 0.5,
);
await driver.scrollUntilVisible(demoList, demoItem, dyScroll: -48.0, alignment: 0.5);
for (int i = 0; i < 2; i += 1) {
await driver.tap(demoItem); // Launch the demo
@@ -178,23 +178,27 @@ void main([List<String> args = const <String>[]]) {
}
// See _handleMessages() in transitions_perf.dart.
_allDemos = List<String>.from(json.decode(await driver.requestData('demoNames')) as List<dynamic>);
_allDemos = List<String>.from(
json.decode(await driver.requestData('demoNames')) as List<dynamic>,
);
if (_allDemos.isEmpty) {
throw 'no demo names found';
}
});
tearDownAll(() async {
await driver.close();
await driver.close();
});
test('find.bySemanticsLabel', () async {
// Assert that we can use semantics related finders in profile mode.
final int id = await driver.getSemanticsId(find.bySemanticsLabel('Material'));
expect(id, greaterThan(-1));
},
skip: !withSemantics, // [intended] test only makes sense when semantics are turned on.
timeout: Timeout.none,
test(
'find.bySemanticsLabel',
() async {
// Assert that we can use semantics related finders in profile mode.
final int id = await driver.getSemanticsId(find.bySemanticsLabel('Material'));
expect(id, greaterThan(-1));
},
skip: !withSemantics, // [intended] test only makes sense when semantics are turned on.
timeout: Timeout.none,
);
test('all demos', () async {
@@ -220,10 +224,14 @@ void main([List<String> args = const <String>[]]) {
// 'Start Transition' event when a demo is launched (see GalleryItem).
final TimelineSummary summary = TimelineSummary.summarize(timeline);
await summary.writeTimelineToFile('transitions', pretty: true);
final String histogramPath = path.join(testOutputsDirectory, 'transition_durations.timeline.json');
final String histogramPath = path.join(
testOutputsDirectory,
'transition_durations.timeline.json',
);
await saveDurationsHistogram(
List<Map<String, dynamic>>.from(timeline.json['traceEvents'] as List<dynamic>),
histogramPath);
List<Map<String, dynamic>>.from(timeline.json['traceEvents'] as List<dynamic>),
histogramPath,
);
// Execute the remaining tests.
if (hybrid) {
@@ -232,7 +240,6 @@ void main([List<String> args = const <String>[]]) {
final Set<String> unprofiledDemos = Set<String>.from(_allDemos)..removeAll(kProfiledDemos);
await runDemos(unprofiledDemos.toList(), driver);
}
}, timeout: Timeout.none);
});
}