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

@@ -9,16 +9,13 @@ import 'package:flutter_gallery/gallery/themes.dart';
import 'package:flutter_test/flutter_test.dart';
class TestMaterialApp extends StatelessWidget {
const TestMaterialApp({ super.key, required this.home });
const TestMaterialApp({super.key, required this.home});
final Widget home;
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(useMaterial3: false),
home: home,
);
return MaterialApp(theme: ThemeData(useMaterial3: false), home: home);
}
}
@@ -299,12 +296,17 @@ void main() {
handle.dispose();
});
testWidgets('data_table_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(const TestMaterialApp(home: DataTableDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
}, skip: true); // DataTables are not accessible, https://github.com/flutter/flutter/issues/10830
testWidgets(
'data_table_demo',
(WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(const TestMaterialApp(home: DataTableDemo()));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
},
// DataTables are not accessible, https://github.com/flutter/flutter/issues/10830
skip: true,
);
testWidgets('date_and_time_picker_demo', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
@@ -490,15 +492,9 @@ void main() {
});
group('All material demos meet text contrast guidelines', () {
final List<ThemeData> themes = <ThemeData>[
kLightGalleryTheme,
kDarkGalleryTheme,
];
final List<ThemeData> themes = <ThemeData>[kLightGalleryTheme, kDarkGalleryTheme];
const List<String> themeNames = <String>[
'kLightGalleryTheme',
'kDarkGalleryTheme',
];
const List<String> themeNames = <String>['kLightGalleryTheme', 'kDarkGalleryTheme'];
for (int themeIndex = 0; themeIndex < themes.length; themeIndex += 1) {
final ThemeData theme = themes[themeIndex];
@@ -625,9 +621,7 @@ void main() {
testWidgets('modal_bottom_sheet_demo $themeName', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
MaterialApp(theme: theme, home: const ModalBottomSheetDemo())
);
await tester.pumpWidget(MaterialApp(theme: theme, home: const ModalBottomSheetDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
@@ -648,9 +642,7 @@ void main() {
testWidgets('persistent_bottom_sheet_demo $themeName', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
MaterialApp(theme: theme, home: const PersistentBottomSheetDemo())
);
await tester.pumpWidget(MaterialApp(theme: theme, home: const PersistentBottomSheetDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});
@@ -699,9 +691,7 @@ void main() {
testWidgets('snack_bar_demo $themeName', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
MaterialApp(theme: theme, home: const SnackBarDemo())
);
await tester.pumpWidget(MaterialApp(theme: theme, home: const SnackBarDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
handle.dispose();
});

View File

@@ -13,15 +13,12 @@ void main() {
// dependency against in the flutter/cupertino package directly.
final Future<ByteData> font = rootBundle.load(
'packages/cupertino_icons/assets/CupertinoIcons.ttf'
'packages/cupertino_icons/assets/CupertinoIcons.ttf',
);
await (FontLoader('packages/cupertino_icons/CupertinoIcons')..addFont(font))
.load();
await (FontLoader('packages/cupertino_icons/CupertinoIcons')..addFont(font)).load();
await tester.pumpWidget(CupertinoApp(
home: CupertinoNavigationDemo(randomSeed: 123456),
));
await tester.pumpWidget(CupertinoApp(home: CupertinoNavigationDemo(randomSeed: 123456)));
await expectLater(
find.byType(CupertinoNavigationDemo),

View File

@@ -10,7 +10,9 @@ void main() {
testWidgets('Button locations are OK', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/pull/85351
{
await tester.pumpWidget(MaterialApp(theme: ThemeData(useMaterial3: false), home: const ButtonsDemo()));
await tester.pumpWidget(
MaterialApp(theme: ThemeData(useMaterial3: false), home: const ButtonsDemo()),
);
expect(find.byType(ElevatedButton).evaluate().length, 2);
final Offset topLeft1 = tester.getTopLeft(find.byType(ElevatedButton).first);
final Offset topLeft2 = tester.getTopLeft(find.byType(ElevatedButton).last);

View File

@@ -9,30 +9,35 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Chip demo has semantic labels', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS),
home: const ChipDemo(),
));
await tester.pumpWidget(
MaterialApp(theme: ThemeData(platform: TargetPlatform.iOS), home: const ChipDemo()),
);
expect(tester.getSemantics(find.byIcon(Icons.vignette)), matchesSemantics(
isButton: true,
hasEnabledState: true,
isEnabled: true,
isFocusable: true,
hasTapAction: true,
hasFocusAction: true,
label: 'Update border shape',
));
expect(
tester.getSemantics(find.byIcon(Icons.vignette)),
matchesSemantics(
isButton: true,
hasEnabledState: true,
isEnabled: true,
isFocusable: true,
hasTapAction: true,
hasFocusAction: true,
label: 'Update border shape',
),
);
expect(tester.getSemantics(find.byIcon(Icons.refresh)), matchesSemantics(
isButton: true,
hasEnabledState: true,
isEnabled: true,
isFocusable: true,
hasTapAction: true,
hasFocusAction: true,
label: 'Reset chips',
));
expect(
tester.getSemantics(find.byIcon(Icons.refresh)),
matchesSemantics(
isButton: true,
hasEnabledState: true,
isEnabled: true,
isFocusable: true,
hasTapAction: true,
hasFocusAction: true,
label: 'Reset chips',
),
);
handle.dispose();
});

View File

@@ -8,10 +8,9 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Drawer header does not scroll', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS),
home: const DrawerDemo(),
));
await tester.pumpWidget(
MaterialApp(theme: ThemeData(platform: TargetPlatform.iOS), home: const DrawerDemo()),
);
await tester.tap(find.text('Tap here to open the drawer'));
await tester.pump();
@@ -26,6 +25,9 @@ void main() {
expect(tester.getTopLeft(find.byType(UserAccountsDrawerHeader)).dy, 0.0);
expect(tester.getTopLeft(find.text('Drawer item A')).dy, greaterThan(initialTopItemSaneY));
expect(tester.getTopLeft(find.text('Drawer item A')).dy, lessThanOrEqualTo(initialTopItemSaneY + 400.0));
expect(
tester.getTopLeft(find.text('Drawer item A')).dy,
lessThanOrEqualTo(initialTopItemSaneY + 400.0),
);
});
}

View File

@@ -7,7 +7,9 @@ import 'package:flutter_gallery/demo/material/expansion_panels_demo.dart';
import 'package:flutter_test/flutter_test.dart';
Future<void> main() async {
testWidgets('Expansion panel demo: radio tile selection changes on tap', (WidgetTester tester) async {
testWidgets('Expansion panel demo: radio tile selection changes on tap', (
WidgetTester tester,
) async {
await tester.pumpWidget(const MaterialApp(home: ExpansionPanelsDemo()));
expect(_expandIcons, findsNWidgets(3));
@@ -34,22 +36,20 @@ Finder get _expandIcons => find.byType(ExpandIcon);
Widget get _radioPanelExpandIcon => _expandIcons.evaluate().toList()[1].widget;
bool _isRadioSelected(int index) =>
_radios[index].value == _radios[index].groupValue;
bool _isRadioSelected(int index) => _radios[index].value == _radios[index].groupValue;
List<Radio<Location>> get _radios => List<Radio<Location>>.from(
_radioFinder.evaluate().map<Widget>((Element e) => e.widget));
List<Radio<Location>> get _radios =>
List<Radio<Location>>.from(_radioFinder.evaluate().map<Widget>((Element e) => e.widget));
// [find.byType] and [find.widgetWithText] do not match subclasses; `Radio` is
// not sufficient to find a `Radio<_Location>`. Another approach is to grab the
// `runtimeType` of a dummy instance; see
// packages/flutter/test/material/radio_list_tile_test.dart.
Finder get _radioFinder =>
find.byWidgetPredicate((Widget w) => w is Radio<Location>);
Finder get _radioFinder => find.byWidgetPredicate((Widget w) => w is Radio<Location>);
List<RadioListTile<Location>> get _radioListTiles =>
List<RadioListTile<Location>>.from(
_radioListTilesFinder.evaluate().map<Widget>((Element e) => e.widget));
List<RadioListTile<Location>> get _radioListTiles => List<RadioListTile<Location>>.from(
_radioListTilesFinder.evaluate().map<Widget>((Element e) => e.widget),
);
Finder get _radioListTilesFinder =>
find.byWidgetPredicate((Widget w) => w is RadioListTile<Location>);

View File

@@ -8,33 +8,42 @@ import 'package:flutter_gallery/gallery/themes.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Menu icon satisfies accessibility contrast ratio guidelines, light mode', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: kLightGalleryTheme,
home: const MenuDemo(),
));
testWidgets('Menu icon satisfies accessibility contrast ratio guidelines, light mode', (
WidgetTester tester,
) async {
await tester.pumpWidget(MaterialApp(theme: kLightGalleryTheme, home: const MenuDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: find.byWidgetPredicate((Widget widget) => widget is Icon))));
await expectLater(
tester,
meetsGuideline(
CustomMinimumContrastGuideline(
finder: find.byWidgetPredicate((Widget widget) => widget is Icon),
),
),
);
});
testWidgets('Menu icon satisfies accessibility contrast ratio guidelines, dark mode', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: kDarkGalleryTheme,
home: const MenuDemo(),
));
testWidgets('Menu icon satisfies accessibility contrast ratio guidelines, dark mode', (
WidgetTester tester,
) async {
await tester.pumpWidget(MaterialApp(theme: kDarkGalleryTheme, home: const MenuDemo()));
await expectLater(tester, meetsGuideline(textContrastGuideline));
await expectLater(tester, meetsGuideline(CustomMinimumContrastGuideline(finder: find.byWidgetPredicate((Widget widget) => widget is Icon))));
await expectLater(
tester,
meetsGuideline(
CustomMinimumContrastGuideline(
finder: find.byWidgetPredicate((Widget widget) => widget is Icon),
),
),
);
});
testWidgets('The selected menu item update test', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: kDarkGalleryTheme,
home: const MenuDemo(),
));
await tester.pumpWidget(MaterialApp(theme: kDarkGalleryTheme, home: const MenuDemo()));
// Popup the menu.
await tester.tap(find.text('An item with a simple menu'));
@@ -46,6 +55,5 @@ void main() {
// The subtitle updated with the selected item.
expect(find.text('Menu item value three'), findsOneWidget);
});
}

View File

@@ -55,10 +55,14 @@ void main() {
// Switch back to system theme setting: first menu button, choose 'System Default'
await tester.tap(find.byIcon(Icons.arrow_drop_down).first);
await tester.pumpAndSettle();
await tester.tap(find.descendant(
of: find.byWidgetPredicate((Widget widget) => widget.runtimeType.toString() == 'PopupMenuItem<ThemeMode>'),
matching: find.text('System Default')
));
await tester.tap(
find.descendant(
of: find.byWidgetPredicate(
(Widget widget) => widget.runtimeType.toString() == 'PopupMenuItem<ThemeMode>',
),
matching: find.text('System Default'),
),
);
await tester.pumpAndSettle();
app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
expect(app.themeMode, ThemeMode.system);
@@ -76,10 +80,15 @@ void main() {
await tester.tap(find.byIcon(Icons.arrow_drop_down).at(2));
await tester.pumpAndSettle();
await tester.tap(find.descendant(
of: find.byWidgetPredicate((Widget widget) => widget.runtimeType.toString() == 'PopupMenuItem<GalleryVisualDensityValue>'),
matching: find.text('System Default')
));
await tester.tap(
find.descendant(
of: find.byWidgetPredicate(
(Widget widget) =>
widget.runtimeType.toString() == 'PopupMenuItem<GalleryVisualDensityValue>',
),
matching: find.text('System Default'),
),
);
await tester.pumpAndSettle();
app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
expect(app.theme!.visualDensity, equals(VisualDensity.standard));
@@ -110,10 +119,15 @@ void main() {
// Set font scale back to the default.
await tester.tap(find.byIcon(Icons.arrow_drop_down).at(1));
await tester.pumpAndSettle();
await tester.tap(find.descendant(
of: find.byWidgetPredicate((Widget widget) => widget.runtimeType.toString() == 'PopupMenuItem<GalleryTextScaleValue>'),
matching: find.text('System Default')
));
await tester.tap(
find.descendant(
of: find.byWidgetPredicate(
(Widget widget) =>
widget.runtimeType.toString() == 'PopupMenuItem<GalleryTextScaleValue>',
),
matching: find.text('System Default'),
),
);
await tester.pumpAndSettle();
textSize = tester.getSize(find.text('Text size'));
expect(textSize, origTextSize);

View File

@@ -44,7 +44,7 @@ class TestAssetBundle extends AssetBundle {
}
@override
Future<String> loadString(String key, { bool cache = true }) async {
Future<String> loadString(String key, {bool cache = true}) async {
if (key == 'lib/gallery/example_code.dart') {
return testCodeFile;
}

View File

@@ -50,7 +50,8 @@ Future<void> main() async {
try {
// Verify that _kUnsynchronizedDemos and _kSkippedDemos identify
// demos that actually exist.
final List<String> allDemoTitles = kAllGalleryDemos.map((GalleryDemo demo) => demo.title).toList();
final List<String> allDemoTitles =
kAllGalleryDemos.map((GalleryDemo demo) => demo.title).toList();
if (!Set<String>.from(allDemoTitles).containsAll(_kUnsynchronizedDemoTitles)) {
fail('Unrecognized demo titles in _kUnsynchronizedDemosTitles: $_kUnsynchronizedDemoTitles');
}
@@ -134,16 +135,27 @@ class _LiveWidgetController extends LiveWidgetController {
Future<void> scrollIntoView(FinderBase<Element> finder, {required double alignment}) async {
final FinderBase<Element> target = await _waitForElement(finder);
await Scrollable.ensureVisible(target.evaluate().single, duration: const Duration(milliseconds: 100), alignment: alignment);
await Scrollable.ensureVisible(
target.evaluate().single,
duration: const Duration(milliseconds: 100),
alignment: alignment,
);
}
@override
Future<void> tap(FinderBase<Element> finder, {
Future<void> tap(
FinderBase<Element> finder, {
int? pointer,
int buttons = kPrimaryButton,
bool warnIfMissed = true,
PointerDeviceKind kind = PointerDeviceKind.touch,
}) async {
await super.tap(await _waitForElement(finder), pointer: pointer, buttons: buttons, warnIfMissed: warnIfMissed, kind: kind);
await super.tap(
await _waitForElement(finder),
pointer: pointer,
buttons: buttons,
warnIfMissed: warnIfMissed,
kind: kind,
);
}
}

View File

@@ -16,13 +16,7 @@ void main() {
testWidgets('Pesto appbar heroics', (WidgetTester tester) async {
await tester.pumpWidget(
// The bug only manifests itself when the screen's orientation is portrait
const Center(
child: SizedBox(
width: 450.0,
height: 800.0,
child: GalleryApp(testMode: true),
),
)
const Center(child: SizedBox(width: 450.0, height: 800.0, child: GalleryApp(testMode: true))),
);
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
await tester.pump(); // triggers a frame

View File

@@ -12,49 +12,58 @@ void main() {
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
}
testWidgets('Flutter Gallery app simple smoke test', (WidgetTester tester) async {
await tester.pumpWidget(
const GalleryApp(testMode: true) // builds the app and schedules a frame but doesn't trigger one
);
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
await tester.pump(); // triggers a frame
testWidgets(
'Flutter Gallery app simple smoke test',
(WidgetTester tester) async {
await tester.pumpWidget(
const GalleryApp(
testMode: true,
), // builds the app and schedules a frame but doesn't trigger one
);
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
await tester.pump(); // triggers a frame
final Finder showOptionsPageButton = find.byTooltip('Toggle options page');
final Finder showOptionsPageButton = find.byTooltip('Toggle options page');
// Show the options page
await tester.tap(showOptionsPageButton);
await tester.pumpAndSettle();
// Show the options page
await tester.tap(showOptionsPageButton);
await tester.pumpAndSettle();
// Switch to the dark theme: the first switch control
await tester.tap(find.byType(Switch).first);
await tester.pumpAndSettle();
// Switch to the dark theme: the first switch control
await tester.tap(find.byType(Switch).first);
await tester.pumpAndSettle();
// Close the options page
expect(showOptionsPageButton, findsOneWidget);
await tester.tap(showOptionsPageButton);
await tester.pumpAndSettle();
// Close the options page
expect(showOptionsPageButton, findsOneWidget);
await tester.tap(showOptionsPageButton);
await tester.pumpAndSettle();
// Show the studies (aka "vignettes", aka "demos")
await tester.tap(find.text('Studies'));
await tester.pumpAndSettle();
// Show the studies (aka "vignettes", aka "demos")
await tester.tap(find.text('Studies'));
await tester.pumpAndSettle();
// Show the Contact profile demo and scroll it upwards
await tester.tap(find.text('Contact profile'));
await tester.pumpAndSettle();
// Show the Contact profile demo and scroll it upwards
await tester.tap(find.text('Contact profile'));
await tester.pumpAndSettle();
await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200));
await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200));
await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200));
await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200));
await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200));
await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200));
await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200));
await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200));
await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200));
await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200));
await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200));
await tester.drag(find.text('(650) 555-1234'), const Offset(0.0, -50.0));
await tester.pump(const Duration(milliseconds: 200));
await tester.pump(const Duration(hours: 100)); // for testing
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.macOS }));
await tester.pump(const Duration(hours: 100)); // for testing
},
variant: const TargetPlatformVariant(<TargetPlatform>{
TargetPlatform.android,
TargetPlatform.macOS,
}),
);
}

View File

@@ -26,14 +26,22 @@ int toStringErrors = 0;
// If you change navigation behavior in the Gallery or in the framework, make
// sure all 3 are covered.
void reportToStringError(String name, String route, int lineNumber, List<String> lines, String message) {
void reportToStringError(
String name,
String route,
int lineNumber,
List<String> lines,
String message,
) {
// If you're on line 12, then it has index 11.
// If you want 1 line before and 1 line after, then you want lines with index 10, 11, and 12.
// That's (lineNumber-1)-margin .. (lineNumber-1)+margin, or lineNumber-(margin+1) .. lineNumber+(margin-1)
const int margin = 5;
final int firstLine = math.max(0, lineNumber - margin);
final int lastLine = math.min(lines.length, lineNumber + margin);
print('$name : $route : line $lineNumber of ${lines.length} : $message; nearby lines were:\n ${lines.sublist(firstLine, lastLine).join("\n ")}');
print(
'$name : $route : line $lineNumber of ${lines.length} : $message; nearby lines were:\n ${lines.sublist(firstLine, lastLine).join("\n ")}',
);
toStringErrors += 1;
}
@@ -48,7 +56,13 @@ void verifyToStringOutput(String name, String route, String testString) {
if (line == '' && lineNumber != lines.length) {
reportToStringError(name, route, lineNumber, lines, 'found empty line');
} else if (line.contains('Instance of ')) {
reportToStringError(name, route, lineNumber, lines, 'found a class that does not have its own toString');
reportToStringError(
name,
route,
lineNumber,
lines,
'found a class that does not have its own toString',
);
} else if (line.endsWith(' ')) {
reportToStringError(name, route, lineNumber, lines, 'found a line with trailing whitespace');
}
@@ -78,10 +92,26 @@ Future<void> smokeDemo(WidgetTester tester, GalleryDemo demo) async {
// Verify that the dumps are pretty.
final String routeName = demo.routeName;
verifyToStringOutput('debugDumpApp', routeName, WidgetsBinding.instance.rootElement!.toStringDeep());
verifyToStringOutput('debugDumpRenderTree', routeName, RendererBinding.instance.renderViews.single.toStringDeep());
verifyToStringOutput('debugDumpLayerTree', routeName, RendererBinding.instance.renderViews.single.debugLayer?.toStringDeep() ?? '');
verifyToStringOutput('debugDumpFocusTree', routeName, WidgetsBinding.instance.focusManager.toStringDeep());
verifyToStringOutput(
'debugDumpApp',
routeName,
WidgetsBinding.instance.rootElement!.toStringDeep(),
);
verifyToStringOutput(
'debugDumpRenderTree',
routeName,
RendererBinding.instance.renderViews.single.toStringDeep(),
);
verifyToStringOutput(
'debugDumpLayerTree',
routeName,
RendererBinding.instance.renderViews.single.debugLayer?.toStringDeep() ?? '',
);
verifyToStringOutput(
'debugDumpFocusTree',
routeName,
WidgetsBinding.instance.focusManager.toStringDeep(),
);
// Scroll the demo around a bit more.
await tester.flingFrom(const Offset(400.0, 300.0), const Offset(0.0, 400.0), 1000.0);
@@ -120,7 +150,10 @@ Future<void> smokeOptionsPage(WidgetTester tester) async {
// Switch back to system theme setting: first menu button, choose 'System Default'
await tester.tap(find.byIcon(Icons.arrow_drop_down).first);
await tester.pumpAndSettle();
await tester.tap(find.text('System Default').at(1), warnIfMissed: false); // https://github.com/flutter/flutter/issues/82908
await tester.tap(
find.text('System Default').at(1),
warnIfMissed: false,
); // https://github.com/flutter/flutter/issues/82908
await tester.pumpAndSettle();
// Switch text direction: first switch
@@ -166,7 +199,9 @@ Future<void> smokeGallery(WidgetTester tester) async {
for (final GalleryDemo demo in kGalleryCategoryToDemos[category]!) {
await Scrollable.ensureVisible(tester.element(find.text(demo.title)));
await smokeDemo(tester, demo);
tester.binding.debugAssertNoTransientCallbacks('A transient callback was still active after running $demo');
tester.binding.debugAssertNoTransientCallbacks(
'A transient callback was still active after running $demo',
);
}
await tester.pageBack();
await tester.pumpAndSettle();
@@ -181,7 +216,10 @@ void main() {
testWidgets(
'Flutter Gallery app smoke test',
smokeGallery,
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.android, TargetPlatform.macOS }),
variant: const TargetPlatformVariant(<TargetPlatform>{
TargetPlatform.android,
TargetPlatform.macOS,
}),
);
testWidgets('Flutter Gallery app smoke test with semantics', (WidgetTester tester) async {

View File

@@ -19,10 +19,7 @@ void main() {
// Regression test for https://github.com/flutter/flutter/pull/5168
testWidgets('update dialog', (WidgetTester tester) async {
await tester.pumpWidget(
const GalleryApp(
testMode: true,
updateUrlFetcher: mockUpdateUrlFetcher,
)
const GalleryApp(testMode: true, updateUrlFetcher: mockUpdateUrlFetcher),
);
await tester.pump(); // see https://github.com/flutter/flutter/issues/1865
await tester.pump(); // triggers a frame