Unverified Commit 5ac54a6b authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] remove mocks from simcontrol and context (#81433)

parent ba4177f6
......@@ -36,7 +36,6 @@ import 'package:flutter_tools/src/reporting/crash_reporting.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:meta/meta.dart';
import 'package:mockito/mockito.dart';
import 'common.dart';
import 'fake_http_client.dart';
......@@ -113,11 +112,7 @@ void testUsingContext(
Doctor: () => FakeDoctor(globals.logger),
FlutterVersion: () => FakeFlutterVersion(),
HttpClient: () => FakeHttpClient.any(),
IOSSimulatorUtils: () {
final MockIOSSimulatorUtils mock = MockIOSSimulatorUtils();
when(mock.getAttachedDevices()).thenAnswer((Invocation _) async => <IOSSimulator>[]);
return mock;
},
IOSSimulatorUtils: () => const NoopIOSSimulatorUtils(),
OutputPreferences: () => OutputPreferences.test(),
Logger: () => BufferLogger(
terminal: globals.terminal,
......@@ -125,14 +120,13 @@ void testUsingContext(
),
OperatingSystemUtils: () => FakeOperatingSystemUtils(),
PersistentToolState: () => buildPersistentToolState(globals.fs),
SimControl: () => MockSimControl(),
Usage: () => TestUsage(),
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(),
FileSystem: () => LocalFileSystemBlockingSetCurrentDirectory(),
PlistParser: () => FakePlistParser(),
Signals: () => FakeSignals(),
Pub: () => ThrowingPub(), // prevent accidentally using pub.
CrashReporter: () => MockCrashReporter(),
CrashReporter: () => const NoopCrashReporter(),
TemplateRenderer: () => const MustacheTemplateRenderer(),
},
body: () {
......@@ -286,13 +280,12 @@ class FakeDoctor extends Doctor {
}
}
class MockSimControl extends Mock implements SimControl {
MockSimControl() {
when(getConnectedDevices()).thenAnswer((Invocation _) async => <SimDevice>[]);
}
}
class NoopIOSSimulatorUtils implements IOSSimulatorUtils {
const NoopIOSSimulatorUtils();
class MockIOSSimulatorUtils extends Mock implements IOSSimulatorUtils {}
@override
Future<List<IOSSimulator>> getAttachedDevices() async => <IOSSimulator>[];
}
class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
@override
......@@ -332,7 +325,13 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
List<String> xcrunCommand() => <String>['xcrun'];
}
class MockCrashReporter extends Mock implements CrashReporter {}
/// Prevent test crashest from being reported to the crash backend.
class NoopCrashReporter implements CrashReporter {
const NoopCrashReporter();
@override
Future<void> informUser(CrashDetails details, File crashFile) async { }
}
class LocalFileSystemBlockingSetCurrentDirectory extends LocalFileSystem {
LocalFileSystemBlockingSetCurrentDirectory() : super.test(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment