Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ void main() {
await driver.waitUntilFirstFrameRasterized();
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});
Comment on lines +20 to +22

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The closure passed to tearDownAll is marked async but does not await the driver.close() call. This causes the tearDownAll hook to complete before the driver has actually finished closing, which can lead to resource leaks or interference with subsequent tests. It is cleaner to return the Future directly.

    tearDownAll(() => driver.close());


Future<void> testScrollPerf(String listKey, String summaryName) async {
// The slight initial delay avoids starting the timing during a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ void main() {
await driver.waitUntilFirstFrameRasterized();
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});

Future<void> testScrollPerf(String listKey, String summaryName) async {
// The slight initial delay avoids starting the timing during a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ void main() {
driver = await FlutterDriver.connect(printCommunication: true);
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});

test('initial tree creation', () async {
// Let app become fully idle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void main() {
pageDelay: const Duration(seconds: 1),
body: (WidgetController controller) async {
final Finder textfield = find.byKey(const ValueKey<String>('fullscreen-textfield'));
await controller.tap(textfield);
controller.tap(textfield);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

controller.tap() returns a Future. Removing the await here causes the test to proceed to the next instruction (the delay) before the tap event has been processed by the framework. This can lead to inconsistent benchmark results or race conditions.

Suggested change
controller.tap(textfield);
await controller.tap(textfield);

await Future<void>.delayed(const Duration(milliseconds: 5000));
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void main() {
pageDelay: const Duration(seconds: 1),
body: (WidgetController controller) async {
final Finder textfield = find.byKey(const ValueKey<String>('basic-textfield'));
await controller.tap(textfield);
controller.tap(textfield);
// Caret should be cached, so repeated blinking should not require recompute.
await Future<void>.delayed(const Duration(milliseconds: 5000));
},
Expand Down
2 changes: 1 addition & 1 deletion dev/benchmarks/macrobenchmarks/test_driver/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Future<void> runDriverTestForRoute(String routeName, DriverTestCallBack body) as

await body(driver);

await driver.close();
driver.close();
}

void macroPerfTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Future<void> execute() async {
);

// Lists may not be scrolled into frame in landscape.
await SystemChrome.setPreferredOrientations(<DeviceOrientation>[
SystemChrome.setPreferredOrientations(<DeviceOrientation>[
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ void main() {
await driver.waitUntilFirstFrameRasterized();
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});

Future<void> testScrollPerf(String listKey, String summaryName) async {
// The slight initial delay avoids starting the timing during a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ void main() {
await driver.waitUntilFirstFrameRasterized();
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});

Future<void> testScrollPerf(String listKey, String summaryName) async {
// The slight initial delay avoids starting the timing during a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ void main() {
await driver.waitUntilFirstFrameRasterized();
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});

Future<void> testScrollPerf(String listKey, String summaryName) async {
// The slight initial delay avoids starting the timing during a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ void main() {
await driver.waitUntilFirstFrameRasterized();
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});

Future<void> testScrollPerf(String listKey, String summaryName) async {
// The slight initial delay avoids starting the timing during a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ void main() {
await driver.waitUntilFirstFrameRasterized();
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});

Future<void> testScrollPerf(String listKey, String summaryName) async {
// The slight initial delay avoids starting the timing during a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ void main() {
await driver.waitUntilFirstFrameRasterized();
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});

Future<void> testScrollPerf(String listKey, String summaryName) async {
// The slight initial delay avoids starting the timing during a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ void main() {
driver = await FlutterDriver.connect();
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});

test('measure', () async {
final Timeline timeline = await driver.traceAction(() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ void main() {
driver = await FlutterDriver.connect();
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});

test('Stock list is shown', () async {
final SerializableFinder stockList = find.byValueKey('stock-list');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main() async {
enableFlutterDriverExtension(commands: <CommandExtension>[nativeDriverCommands]);

// Run on full screen.
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);

// Fetch the texture ID.
final Future<int> textureId = _fetchTexture(512, 512);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main() async {
enableFlutterDriverExtension(commands: <CommandExtension>[nativeDriverCommands]);

// Run on full screen.
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);

// Fetch the texture ID.
final Future<int> textureId = _fetchTexture(512, 512);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import 'package:flutter_driver/driver_extension.dart';

import 'src/allow_list_devices.dart';

void main() async {
void main() {
ensureAndroidDevice();
enableFlutterDriverExtension(commands: <CommandExtension>[nativeDriverCommands]);

// Run on full screen.
await SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);

runApp(const MainApp());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Future<void> main() async {
driver = await FlutterDriver.connect();
});

tearDownAll(driver.close);
tearDownAll(() {
driver.close();
});

test('verified input', () async {
// Wait for the PlatformView to show up.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Future<void> main() async {
driver = await FlutterDriver.connect();
});

tearDownAll(() async {
await driver?.close();
tearDownAll(() {
driver?.close();
});

// Each test below must return back to the home page after finishing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Future<void> main() async {
driver = await FlutterDriver.connect();
});

tearDownAll(driver.close);
tearDownAll(() {
driver.close();
});

// Run `run_release_test.sh` to also test release engine deferred components code. This
// drive test runs as debug and thus only tests framework side deferred components handling.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ void main() {
);
});

tearDown(() async {
tearDown(() {
// After each test reset to device perfered orientations to avoid
// test pollution.
await SystemChrome.setPreferredOrientations(<DeviceOrientation>[]);
SystemChrome.setPreferredOrientations(<DeviceOrientation>[]);
});
});
}
Expand All @@ -116,7 +116,7 @@ Future<void> setOrientationAndWaitUntilRotation(
WidgetTester tester,
DeviceOrientation orientation,
) async {
await SystemChrome.setPreferredOrientations(<DeviceOrientation>[orientation]);
SystemChrome.setPreferredOrientations(<DeviceOrientation>[orientation]);
Orientation expectedOrientation;
switch (orientation) {
case DeviceOrientation.portraitUp:
Expand Down
4 changes: 3 additions & 1 deletion dev/integration_tests/flavors/test_driver/main_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ void main() {
expect(flavor, 'paid');
}, timeout: Timeout.none);

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class FullScreenDialogDemoState extends State<FullScreenDialogDemo> {
// the SystemNavigator. If this wasn't the root route, then
// Navigator.maybePop could be used instead.
// See https://github.com/flutter/flutter/issues/11490
await SystemNavigator.pop();
SystemNavigator.pop();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class TextFormFieldDemoState extends State<TextFormFieldDemo> {
// the SystemNavigator. If this wasn't the root route, then
// Navigator.maybePop could be used instead.
// See https://github.com/flutter/flutter/issues/11490
await SystemNavigator.pop();
SystemNavigator.pop();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ void main() {
await driver.waitUntilFirstFrameRasterized();
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});

test('measure', () async {
final Timeline timeline = await driver.traceAction(() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ void main() {
await driver.waitUntilFirstFrameRasterized();
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});

test('measure', () async {
final Timeline timeline = await driver.traceAction(() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ void main() {
driver = await FlutterDriver.connect();
});

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});

test('measure', () async {
await driver.tap(find.text('Material'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ void main([List<String> args = const <String>[]]) {
}
});

tearDownAll(driver.close);
tearDownAll(() async {
await driver.close();
});

test(
'find.bySemanticsLabel',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Future<void> main() async {
driver = await FlutterDriver.connect();
});

tearDownAll(driver.close);
tearDownAll(() {
driver.close();
});

// Each test below must return back to the home page after finishing.
test('MotionEvent recomposition', () async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void main() {
driver = await FlutterDriver.connect();
});

tearDownAll(driver.close);
tearDownAll(() => driver.close());

test('Merge thread to create and remove platform views should not crash', () async {
// Start pushing in a page with platform view, merge threads.
Expand Down
4 changes: 2 additions & 2 deletions dev/integration_tests/new_gallery/lib/pages/backdrop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ class _SettingsIcon extends AnimatedWidget {
: Theme.of(context).colorScheme.secondaryContainer,
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: () async {
onTap: () {
toggleSettings();
await SemanticsService.sendAnnouncement(
SemanticsService.sendAnnouncement(
View.of(context),
_settingsSemanticLabel(isSettingsOpenNotifier.value, context),
GalleryOptions.of(context).resolvedTextDirection()!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ void main() {
}
}, timeout: Timeout.none);

tearDownAll(driver.close);
tearDownAll(() async {
driver.close();
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ void main() {
driver = await FlutterDriver.connect();
});

tearDownAll(driver.close);
tearDownAll(() async {
await driver.close();
});

test('check that we are painting in debugPaintSize mode', () async {
expect(await driver.requestData('status'), 'log: paint debugPaintSize');
Expand Down
4 changes: 3 additions & 1 deletion dev/integration_tests/ui/test_driver/commands_none_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ void main() {
driver = await FlutterDriver.connect();
});

tearDownAll(driver.close);
tearDownAll(() async {
await driver.close();
});

test('check that we are in normal mode', () async {
expect(await driver.requestData('status'), 'log: paint');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ void main() {
driver = await FlutterDriver.connect();
});

tearDownAll(driver.close);
tearDownAll(() async {
await driver.close();
});

test('check that we are showing the performance overlay', () async {
await driver.requestData('status'); // force a reassemble
Expand Down
Loading