Migrate emulators to null safety (#92738)

This commit is contained in:
Jenn Magder
2021-11-18 22:13:06 -08:00
committed by GitHub
parent 9bff08b79b
commit b460d0ee34
5 changed files with 111 additions and 79 deletions

View File

@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// @dart = 2.8
import 'dart:async';
import 'package:flutter_tools/src/android/android_emulator.dart';
@@ -125,7 +123,7 @@ void main() {
});
group('Android emulator launch ', () {
FakeAndroidSdk mockSdk;
late FakeAndroidSdk mockSdk;
setUp(() {
mockSdk = FakeAndroidSdk();
@@ -198,10 +196,30 @@ void main() {
expect(logger.errorText, isEmpty);
});
testWithoutContext('throws if emulator not found', () async {
mockSdk.emulatorPath = null;
final AndroidEmulator emulator = AndroidEmulator(
emulatorID,
processManager: FakeProcessManager.empty(),
androidSdk: mockSdk,
logger: BufferLogger.test(),
);
await expectLater(
() => emulator.launch(startupDuration: Duration.zero),
throwsA(isException.having(
(Exception exception) => exception.toString(),
'description',
contains('Emulator is missing from the Android SDK'),
)),
);
});
});
}
class FakeAndroidSdk extends Fake implements AndroidSdk {
@override
String emulatorPath;
String? emulatorPath;
}

View File

@@ -97,7 +97,6 @@ void main() {
stdout: 'existing-avd-1',
),
]),
androidSdk: null,
androidWorkflow: AndroidWorkflow(
androidSdk: sdk,
featureFlags: TestFeatureFlags(),