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'; ...@@ -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/reporting/reporting.dart';
import 'package:flutter_tools/src/version.dart'; import 'package:flutter_tools/src/version.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:mockito/mockito.dart';
import 'common.dart'; import 'common.dart';
import 'fake_http_client.dart'; import 'fake_http_client.dart';
...@@ -113,11 +112,7 @@ void testUsingContext( ...@@ -113,11 +112,7 @@ void testUsingContext(
Doctor: () => FakeDoctor(globals.logger), Doctor: () => FakeDoctor(globals.logger),
FlutterVersion: () => FakeFlutterVersion(), FlutterVersion: () => FakeFlutterVersion(),
HttpClient: () => FakeHttpClient.any(), HttpClient: () => FakeHttpClient.any(),
IOSSimulatorUtils: () { IOSSimulatorUtils: () => const NoopIOSSimulatorUtils(),
final MockIOSSimulatorUtils mock = MockIOSSimulatorUtils();
when(mock.getAttachedDevices()).thenAnswer((Invocation _) async => <IOSSimulator>[]);
return mock;
},
OutputPreferences: () => OutputPreferences.test(), OutputPreferences: () => OutputPreferences.test(),
Logger: () => BufferLogger( Logger: () => BufferLogger(
terminal: globals.terminal, terminal: globals.terminal,
...@@ -125,14 +120,13 @@ void testUsingContext( ...@@ -125,14 +120,13 @@ void testUsingContext(
), ),
OperatingSystemUtils: () => FakeOperatingSystemUtils(), OperatingSystemUtils: () => FakeOperatingSystemUtils(),
PersistentToolState: () => buildPersistentToolState(globals.fs), PersistentToolState: () => buildPersistentToolState(globals.fs),
SimControl: () => MockSimControl(),
Usage: () => TestUsage(), Usage: () => TestUsage(),
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(), XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(),
FileSystem: () => LocalFileSystemBlockingSetCurrentDirectory(), FileSystem: () => LocalFileSystemBlockingSetCurrentDirectory(),
PlistParser: () => FakePlistParser(), PlistParser: () => FakePlistParser(),
Signals: () => FakeSignals(), Signals: () => FakeSignals(),
Pub: () => ThrowingPub(), // prevent accidentally using pub. Pub: () => ThrowingPub(), // prevent accidentally using pub.
CrashReporter: () => MockCrashReporter(), CrashReporter: () => const NoopCrashReporter(),
TemplateRenderer: () => const MustacheTemplateRenderer(), TemplateRenderer: () => const MustacheTemplateRenderer(),
}, },
body: () { body: () {
...@@ -286,13 +280,12 @@ class FakeDoctor extends Doctor { ...@@ -286,13 +280,12 @@ class FakeDoctor extends Doctor {
} }
} }
class MockSimControl extends Mock implements SimControl { class NoopIOSSimulatorUtils implements IOSSimulatorUtils {
MockSimControl() { const NoopIOSSimulatorUtils();
when(getConnectedDevices()).thenAnswer((Invocation _) async => <SimDevice>[]);
}
}
class MockIOSSimulatorUtils extends Mock implements IOSSimulatorUtils {} @override
Future<List<IOSSimulator>> getAttachedDevices() async => <IOSSimulator>[];
}
class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter { class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
@override @override
...@@ -332,7 +325,13 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter { ...@@ -332,7 +325,13 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
List<String> xcrunCommand() => <String>['xcrun']; 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 { class LocalFileSystemBlockingSetCurrentDirectory extends LocalFileSystem {
LocalFileSystemBlockingSetCurrentDirectory() : super.test( 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