[flutter_tools] remove mocks from simcontrol and context (#81433)
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user