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

@@ -21,28 +21,20 @@ void main() {
});
}
testWidgets(
'FilterChip displays the correct border when selected',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.MaterialStateBorderSideExampleApp(),
);
testWidgets('FilterChip displays the correct border when selected', (WidgetTester tester) async {
await tester.pumpWidget(const example.MaterialStateBorderSideExampleApp());
expect(findBorderColor(Colors.red), findsOne);
},
);
expect(findBorderColor(Colors.red), findsOne);
});
testWidgets(
'FilterChip displays the correct border when not selected',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.MaterialStateBorderSideExampleApp(),
);
testWidgets('FilterChip displays the correct border when not selected', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.MaterialStateBorderSideExampleApp());
await tester.tap(find.byType(FilterChip));
await tester.pumpAndSettle();
await tester.tap(find.byType(FilterChip));
await tester.pumpAndSettle();
expect(findBorderColor(const Color(0xffcac4d0)), findsOne);
},
);
expect(findBorderColor(const Color(0xffcac4d0)), findsOne);
});
}

View File

@@ -11,67 +11,44 @@ import 'package:flutter_api_samples/material/material_state/material_state_mouse
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets(
'MaterialStateMouseCursorExampleApp displays ListTile',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.MaterialStateMouseCursorExampleApp(),
);
testWidgets('MaterialStateMouseCursorExampleApp displays ListTile', (WidgetTester tester) async {
await tester.pumpWidget(const example.MaterialStateMouseCursorExampleApp());
expect(find.byType(ListTile), findsOneWidget);
expect(find.text('ListTile'), findsOneWidget);
},
);
expect(find.byType(ListTile), findsOneWidget);
expect(find.text('ListTile'), findsOneWidget);
});
testWidgets(
'ListTile displays correct mouse cursor when enabled',
(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: example.MaterialStateMouseCursorExample(enabled: true),
),
),
);
testWidgets('ListTile displays correct mouse cursor when enabled', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(body: example.MaterialStateMouseCursorExample(enabled: true)),
),
);
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer(
location: tester.getCenter(find.byType(ListTile)),
);
addTearDown(gesture.removePointer);
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(location: tester.getCenter(find.byType(ListTile)));
addTearDown(gesture.removePointer);
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
SystemMouseCursors.click,
);
},
);
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
SystemMouseCursors.click,
);
});
testWidgets(
'ListTile displays correct mouse cursor when disabled',
(WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
body: example.MaterialStateMouseCursorExample(enabled: false),
),
),
);
testWidgets('ListTile displays correct mouse cursor when disabled', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(body: example.MaterialStateMouseCursorExample(enabled: false)),
),
);
final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse,
);
await gesture.addPointer(
location: tester.getCenter(find.byType(ListTile)),
);
addTearDown(gesture.removePointer);
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(location: tester.getCenter(find.byType(ListTile)));
addTearDown(gesture.removePointer);
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
SystemMouseCursors.forbidden,
);
},
);
expect(
RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1),
SystemMouseCursors.forbidden,
);
});
}

View File

@@ -20,39 +20,31 @@ void main() {
);
}
testWidgets(
'FilterChip displays the correct border when selected',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.MaterialStateOutlinedBorderExampleApp(),
);
testWidgets('FilterChip displays the correct border when selected', (WidgetTester tester) async {
await tester.pumpWidget(const example.MaterialStateOutlinedBorderExampleApp());
expect(
findBorderShape(const RoundedRectangleBorder(
side: BorderSide(color: Colors.transparent),
)),
findsOne,
);
},
);
expect(
findBorderShape(const RoundedRectangleBorder(side: BorderSide(color: Colors.transparent))),
findsOne,
);
});
testWidgets(
'FilterChip displays the correct border when not selected',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.MaterialStateOutlinedBorderExampleApp(),
);
testWidgets('FilterChip displays the correct border when not selected', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.MaterialStateOutlinedBorderExampleApp());
await tester.tap(find.byType(FilterChip));
await tester.pumpAndSettle();
await tester.tap(find.byType(FilterChip));
await tester.pumpAndSettle();
expect(
findBorderShape(RoundedRectangleBorder(
expect(
findBorderShape(
RoundedRectangleBorder(
side: const BorderSide(color: Color(0xFFCAC4D0)),
borderRadius: BorderRadius.circular(8),
)),
findsOne,
);
},
);
),
),
findsOne,
);
});
}

View File

@@ -13,35 +13,29 @@ void main() {
final Material widget = tester.widget(
find.descendant(
of: find.byType(example.MaterialStatePropertyExample),
matching:find.widgetWithText(Material, 'TextButton'),
matching: find.widgetWithText(Material, 'TextButton'),
),
);
return widget.textStyle!.color!;
}
testWidgets(
'The foreground color of the TextButton should be red by default',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.MaterialStatePropertyExampleApp(),
);
testWidgets('The foreground color of the TextButton should be red by default', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.MaterialStatePropertyExampleApp());
expect(getButtonForegroundColor(tester), Colors.red);
},
);
expect(getButtonForegroundColor(tester), Colors.red);
});
testWidgets(
'The foreground color of the TextButton should be blue when hovered',
(WidgetTester tester) async {
await tester.pumpWidget(
const example.MaterialStatePropertyExampleApp(),
);
testWidgets('The foreground color of the TextButton should be blue when hovered', (
WidgetTester tester,
) async {
await tester.pumpWidget(const example.MaterialStatePropertyExampleApp());
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(location: tester.getCenter(find.byType(TextButton)));
await tester.pump();
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(location: tester.getCenter(find.byType(TextButton)));
await tester.pump();
expect(getButtonForegroundColor(tester), Colors.blue);
},
);
expect(getButtonForegroundColor(tester), Colors.blue);
});
}