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:
committed by
GitHub
parent
8e0993eda8
commit
5491c8c146
@@ -3,25 +3,23 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/material/bottom_app_bar/bottom_app_bar.1.dart'
|
||||
as example;
|
||||
import 'package:flutter_api_samples/material/bottom_app_bar/bottom_app_bar.1.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'BottomAppBarDemo shows FloatingActionButton and responds to toggle',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.BottomAppBarDemo());
|
||||
testWidgets('BottomAppBarDemo shows FloatingActionButton and responds to toggle', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const example.BottomAppBarDemo());
|
||||
|
||||
expect(find.byType(FloatingActionButton), findsOneWidget);
|
||||
expect(find.byType(FloatingActionButton), findsOneWidget);
|
||||
|
||||
// Tap the 'Floating Action Button' switch to hide the FAB.
|
||||
await tester.tap(find.byType(SwitchListTile).first);
|
||||
await tester.pumpAndSettle();
|
||||
// Tap the 'Floating Action Button' switch to hide the FAB.
|
||||
await tester.tap(find.byType(SwitchListTile).first);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
},
|
||||
);
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Notch can be toggled on and off', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.BottomAppBarDemo());
|
||||
@@ -41,26 +39,18 @@ void main() {
|
||||
testWidgets('FAB location can be changed', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.BottomAppBarDemo());
|
||||
|
||||
final Offset initialPosition =
|
||||
tester.getCenter(find.byType(FloatingActionButton));
|
||||
final Offset initialPosition = tester.getCenter(find.byType(FloatingActionButton));
|
||||
|
||||
// Verify the initial position is near the right side (docked to the end).
|
||||
final Size screenSize = tester.getSize(
|
||||
find.byType(Scaffold),
|
||||
);
|
||||
expect(
|
||||
initialPosition.dx,
|
||||
greaterThan(screenSize.width * 0.5),
|
||||
);
|
||||
final Size screenSize = tester.getSize(find.byType(Scaffold));
|
||||
expect(initialPosition.dx, greaterThan(screenSize.width * 0.5));
|
||||
|
||||
// Tap the radio button to move the FAB to centerDocked.
|
||||
await tester.tap(find.text('Docked - Center'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Get the new FAB position (centerDocked).
|
||||
final Offset newPosition = tester.getCenter(
|
||||
find.byType(FloatingActionButton),
|
||||
);
|
||||
final Offset newPosition = tester.getCenter(find.byType(FloatingActionButton));
|
||||
|
||||
expect(
|
||||
newPosition.dx,
|
||||
|
||||
@@ -3,93 +3,71 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_api_samples/material/bottom_app_bar/bottom_app_bar.2.dart'
|
||||
as example;
|
||||
import 'package:flutter_api_samples/material/bottom_app_bar/bottom_app_bar.2.dart' as example;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets(
|
||||
'Floating Action Button visibility can be toggled',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.BottomAppBarDemo(),
|
||||
);
|
||||
testWidgets('Floating Action Button visibility can be toggled', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.BottomAppBarDemo());
|
||||
|
||||
expect(find.byType(FloatingActionButton), findsOneWidget);
|
||||
expect(find.byType(FloatingActionButton), findsOneWidget);
|
||||
|
||||
// Tap the switch to hide the FAB.
|
||||
await tester.tap(find.byType(SwitchListTile).first);
|
||||
await tester.pumpAndSettle();
|
||||
// Tap the switch to hide the FAB.
|
||||
await tester.tap(find.byType(SwitchListTile).first);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
},
|
||||
);
|
||||
expect(find.byType(FloatingActionButton), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('BottomAppBar elevation can be toggled',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('BottomAppBar elevation can be toggled', (WidgetTester tester) async {
|
||||
// Build the app.
|
||||
await tester.pumpWidget(const example.BottomAppBarDemo());
|
||||
|
||||
// Verify the BottomAppBar has elevation initially.
|
||||
BottomAppBar bottomAppBar = tester.widget(
|
||||
find.byType(BottomAppBar),
|
||||
);
|
||||
BottomAppBar bottomAppBar = tester.widget(find.byType(BottomAppBar));
|
||||
expect(bottomAppBar.elevation, isNot(0.0));
|
||||
|
||||
await tester.tap(find.text('Bottom App Bar Elevation'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
bottomAppBar = tester.widget(
|
||||
find.byType(BottomAppBar),
|
||||
);
|
||||
bottomAppBar = tester.widget(find.byType(BottomAppBar));
|
||||
expect(bottomAppBar.elevation, equals(0.0));
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'BottomAppBar hides on scroll down and shows on scroll up',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.BottomAppBarDemo());
|
||||
testWidgets('BottomAppBar hides on scroll down and shows on scroll up', (
|
||||
WidgetTester tester,
|
||||
) async {
|
||||
await tester.pumpWidget(const example.BottomAppBarDemo());
|
||||
|
||||
// Ensure the BottomAppBar is visible initially.
|
||||
expect(find.byType(BottomAppBar), findsOneWidget);
|
||||
// Ensure the BottomAppBar is visible initially.
|
||||
expect(find.byType(BottomAppBar), findsOneWidget);
|
||||
|
||||
// Scroll down to hide the BottomAppBar.
|
||||
await tester.drag(
|
||||
find.byType(ListView),
|
||||
const Offset(0, -300),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
// Scroll down to hide the BottomAppBar.
|
||||
await tester.drag(find.byType(ListView), const Offset(0, -300));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify the BottomAppBar is hidden.
|
||||
final Size hiddenSize = tester.getSize(
|
||||
find.byType(AnimatedContainer),
|
||||
);
|
||||
expect(hiddenSize.height, equals(0.0)); // AnimatedContainer's height
|
||||
// Verify the BottomAppBar is hidden.
|
||||
final Size hiddenSize = tester.getSize(find.byType(AnimatedContainer));
|
||||
expect(hiddenSize.height, equals(0.0)); // AnimatedContainer's height
|
||||
|
||||
// Scroll up to show the BottomAppBar again.
|
||||
await tester.drag(find.byType(ListView), const Offset(0, 300));
|
||||
await tester.pumpAndSettle();
|
||||
// Scroll up to show the BottomAppBar again.
|
||||
await tester.drag(find.byType(ListView), const Offset(0, 300));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
// Verify the BottomAppBar is visible again.
|
||||
final Size visibleSize = tester.getSize(
|
||||
find.byType(AnimatedContainer),
|
||||
);
|
||||
expect(visibleSize.height, equals(80.0));
|
||||
},
|
||||
);
|
||||
// Verify the BottomAppBar is visible again.
|
||||
final Size visibleSize = tester.getSize(find.byType(AnimatedContainer));
|
||||
expect(visibleSize.height, equals(80.0));
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'SnackBar is shown when Open popup menu is pressed',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.BottomAppBarDemo());
|
||||
testWidgets('SnackBar is shown when Open popup menu is pressed', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const example.BottomAppBarDemo());
|
||||
|
||||
// Trigger the SnackBar.
|
||||
await tester.tap(find.byTooltip('Open popup menu'));
|
||||
await tester.pump();
|
||||
// Trigger the SnackBar.
|
||||
await tester.tap(find.byTooltip('Open popup menu'));
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Yay! A SnackBar!'), findsOneWidget);
|
||||
expect(find.text('Yay! A SnackBar!'), findsOneWidget);
|
||||
|
||||
expect(find.text('Undo'), findsOneWidget);
|
||||
},
|
||||
);
|
||||
expect(find.text('Undo'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user