Fix Linux_android_emu tests late initialization errors (#152932)

This does not fix the issue underlying
https://github.com/flutter/flutter/issues/152684, but may prevent `adb
logcat` from ending before we've captured the logs that explain why the
app or emulator are potentially crashing.

Fixes Fixes https://github.com/flutter/flutter/issues/152899
This commit is contained in:
Zachary Anderson
2024-08-06 14:48:50 -07:00
committed by GitHub
parent 521b0b327c
commit c4e19962bb
5 changed files with 39 additions and 37 deletions

View File

@@ -24,8 +24,8 @@ Future<void> _main() async {
// To generate golden files locally, uncomment the following line.
// autoUpdateGoldenFiles = true;
late FlutterDriver flutterDriver;
late NativeDriver nativeDriver;
FlutterDriver? flutterDriver;
NativeDriver? nativeDriver;
setUpAll(() async {
flutterDriver = await FlutterDriver.connect(
@@ -38,14 +38,14 @@ Future<void> _main() async {
});
tearDownAll(() async {
await nativeDriver.close();
await flutterDriver.close();
await nativeDriver?.close();
await flutterDriver?.close();
});
test('should screenshot and match a full-screen blue rectangle', () async {
await flutterDriver.waitFor(find.byType('DecoratedBox'));
await flutterDriver?.waitFor(find.byType('DecoratedBox'));
await expectLater(
nativeDriver.screenshot(),
nativeDriver?.screenshot(),
matchesGoldenFile('android_driver_test.BlueRectangle.png'),
);
}, timeout: Timeout.none);