Unverified Commit 72170271 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] replace MockFlutterVersion usage with fake where possible,...

[flutter_tools] replace MockFlutterVersion usage with fake where possible, move from context (#77390)
parent db162a47
...@@ -720,7 +720,7 @@ class FlutterValidator extends DoctorValidator { ...@@ -720,7 +720,7 @@ class FlutterValidator extends DoctorValidator {
messages.add(ValidationMessage(_userMessages.flutterRevision( messages.add(ValidationMessage(_userMessages.flutterRevision(
version.frameworkRevisionShort, version.frameworkRevisionShort,
version.frameworkAge, version.frameworkAge,
version.frameworkDate, version.frameworkCommitDate,
))); )));
messages.add(ValidationMessage(_userMessages.engineRevision(version.engineRevisionShort))); messages.add(ValidationMessage(_userMessages.engineRevision(version.engineRevisionShort)));
messages.add(ValidationMessage(_userMessages.dartRevision(version.dartSdkVersion))); messages.add(ValidationMessage(_userMessages.dartRevision(version.dartSdkVersion)));
......
...@@ -144,8 +144,6 @@ class FlutterVersion { ...@@ -144,8 +144,6 @@ class FlutterVersion {
String _frameworkVersion; String _frameworkVersion;
String get frameworkVersion => _frameworkVersion; String get frameworkVersion => _frameworkVersion;
String get frameworkDate => frameworkCommitDate;
String get dartSdkVersion => globals.cache.dartSdkVersion; String get dartSdkVersion => globals.cache.dartSdkVersion;
String get engineRevision => globals.cache.engineRevision; String get engineRevision => globals.cache.engineRevision;
...@@ -181,6 +179,8 @@ class FlutterVersion { ...@@ -181,6 +179,8 @@ class FlutterVersion {
'dartSdkVersion': dartSdkVersion, 'dartSdkVersion': dartSdkVersion,
}; };
String get frameworkDate => frameworkCommitDate;
/// A date String describing the last framework commit. /// A date String describing the last framework commit.
/// ///
/// If a git command fails, this will return a placeholder date. /// If a git command fails, this will return a placeholder date.
......
...@@ -53,12 +53,12 @@ final Platform macPlatform = FakePlatform( ...@@ -53,12 +53,12 @@ final Platform macPlatform = FakePlatform(
); );
void main() { void main() {
MockFlutterVersion mockFlutterVersion; FakeFlutterVersion flutterVersion;
BufferLogger logger; BufferLogger logger;
FakeProcessManager fakeProcessManager; FakeProcessManager fakeProcessManager;
setUp(() { setUp(() {
mockFlutterVersion = MockFlutterVersion(); flutterVersion = FakeFlutterVersion();
logger = BufferLogger.test(); logger = BufferLogger.test();
fakeProcessManager = FakeProcessManager.list(<FakeCommand>[]); fakeProcessManager = FakeProcessManager.list(<FakeCommand>[]);
}); });
...@@ -667,13 +667,12 @@ void main() { ...@@ -667,13 +667,12 @@ void main() {
await commandRunner.run(<String>['doctor']); await commandRunner.run(<String>['doctor']);
verify(mockFlutterVersion.fetchTagsAndUpdate()).called(1); expect(flutterVersion.didFetchTagsAndUpdate, true);
Cache.enableLocking(); Cache.enableLocking();
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
FileSystem: () => MemoryFileSystem.test(), FileSystem: () => MemoryFileSystem.test(),
FlutterVersion: () => mockFlutterVersion, FlutterVersion: () => flutterVersion,
Doctor: () => NoOpDoctor(), Doctor: () => NoOpDoctor(),
}, initializeFlutterRoot: false); }, initializeFlutterRoot: false);
......
...@@ -17,6 +17,7 @@ import 'package:mockito/mockito.dart'; ...@@ -17,6 +17,7 @@ import 'package:mockito/mockito.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
import '../../src/mocks.dart';
void main() { void main() {
FileSystem fileSystem; FileSystem fileSystem;
......
...@@ -20,6 +20,7 @@ import 'package:process/process.dart'; ...@@ -20,6 +20,7 @@ import 'package:process/process.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
import '../../src/fake_process_manager.dart'; import '../../src/fake_process_manager.dart';
import '../../src/mocks.dart';
void main() { void main() {
group('UpgradeCommandRunner', () { group('UpgradeCommandRunner', () {
......
...@@ -14,6 +14,7 @@ import 'package:flutter_tools/src/build_info.dart'; ...@@ -14,6 +14,7 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/drive/drive_service.dart'; import 'package:flutter_tools/src/drive/drive_service.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:flutter_tools/src/vmservice.dart'; import 'package:flutter_tools/src/vmservice.dart';
import 'package:package_config/package_config_types.dart'; import 'package:package_config/package_config_types.dart';
import 'package:test/fake.dart'; import 'package:test/fake.dart';
...@@ -21,6 +22,7 @@ import 'package:vm_service/vm_service.dart' as vm_service; ...@@ -21,6 +22,7 @@ import 'package:vm_service/vm_service.dart' as vm_service;
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
import '../../src/fakes.dart';
final vm_service.Isolate fakeUnpausedIsolate = vm_service.Isolate( final vm_service.Isolate fakeUnpausedIsolate = vm_service.Isolate(
...@@ -288,9 +290,13 @@ void main() { ...@@ -288,9 +290,13 @@ void main() {
expect(json.decode(fileSystem.file('out.json').readAsStringSync()), <String, Object>{ expect(json.decode(fileSystem.file('out.json').readAsStringSync()), <String, Object>{
'platform': 'android', 'platform': 'android',
'name': 'test', 'name': 'test',
'engineRevision': null, 'engineRevision': 'abcdefghijklmnopqrstuvwxyz',
'data': <String, Object>{'A': 'B'} 'data': <String, Object>{'A': 'B'}
}); });
}, overrides: <Type, Generator>{
FlutterVersion: () => FakeFlutterVersion(
engineRevision: 'abcdefghijklmnopqrstuvwxyz',
)
}); });
testWithoutContext('Can connect to existing application and stop it during cleanup', () async { testWithoutContext('Can connect to existing application and stop it during cleanup', () async {
......
...@@ -15,11 +15,14 @@ import 'package:mockito/mockito.dart'; ...@@ -15,11 +15,14 @@ import 'package:mockito/mockito.dart';
import '../src/common.dart'; import '../src/common.dart';
import '../src/context.dart'; import '../src/context.dart';
import '../src/fakes.dart';
void main() { void main() {
testWithoutContext('FlutterValidator shows an error message if gen_snapshot is ' testWithoutContext('FlutterValidator shows an error message if gen_snapshot is '
'downloaded and exits with code 1', () async { 'downloaded and exits with code 1', () async {
final MockFlutterVersion flutterVersion = MockFlutterVersion(); final FakeFlutterVersion flutterVersion = FakeFlutterVersion(
frameworkVersion: '1.0.0',
);
final MemoryFileSystem fileSystem = MemoryFileSystem.test(); final MemoryFileSystem fileSystem = MemoryFileSystem.test();
final Artifacts artifacts = Artifacts.test(); final Artifacts artifacts = Artifacts.test();
final FlutterValidator flutterValidator = FlutterValidator( final FlutterValidator flutterValidator = FlutterValidator(
...@@ -46,7 +49,7 @@ void main() { ...@@ -46,7 +49,7 @@ void main() {
expect(await flutterValidator.validate(), matchDoctorValidation( expect(await flutterValidator.validate(), matchDoctorValidation(
validationType: ValidationType.partial, validationType: ValidationType.partial,
statusInfo: 'Channel unknown, Unknown, on Linux, locale en_US.UTF-8', statusInfo: 'Channel unknown, 1.0.0, on Linux, locale en_US.UTF-8',
messages: containsAll(const <ValidationMessage>[ messages: containsAll(const <ValidationMessage>[
ValidationMessage.error( ValidationMessage.error(
'Downloaded executables cannot execute on host.\n' 'Downloaded executables cannot execute on host.\n'
...@@ -60,13 +63,16 @@ void main() { ...@@ -60,13 +63,16 @@ void main() {
}); });
testWithoutContext('FlutterValidator does not run gen_snapshot binary check if it is not already downloaded', () async { testWithoutContext('FlutterValidator does not run gen_snapshot binary check if it is not already downloaded', () async {
final FakeFlutterVersion flutterVersion = FakeFlutterVersion(
frameworkVersion: '1.0.0',
);
final FlutterValidator flutterValidator = FlutterValidator( final FlutterValidator flutterValidator = FlutterValidator(
platform: FakePlatform( platform: FakePlatform(
operatingSystem: 'windows', operatingSystem: 'windows',
localeName: 'en_US.UTF-8', localeName: 'en_US.UTF-8',
environment: <String, String>{}, environment: <String, String>{},
), ),
flutterVersion: () => MockFlutterVersion(), flutterVersion: () => flutterVersion,
userMessages: UserMessages(), userMessages: UserMessages(),
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
fileSystem: MemoryFileSystem.test(), fileSystem: MemoryFileSystem.test(),
...@@ -79,16 +85,15 @@ void main() { ...@@ -79,16 +85,15 @@ void main() {
// fail if the gen_snapshot binary is not present. // fail if the gen_snapshot binary is not present.
expect(await flutterValidator.validate(), matchDoctorValidation( expect(await flutterValidator.validate(), matchDoctorValidation(
validationType: ValidationType.installed, validationType: ValidationType.installed,
statusInfo: 'Channel unknown, Unknown, on Windows, locale en_US.UTF-8', statusInfo: 'Channel unknown, 1.0.0, on Windows, locale en_US.UTF-8',
messages: anything, messages: anything,
)); ));
}); });
testWithoutContext('FlutterValidator handles exception thrown by version checking', () async { testWithoutContext('FlutterValidator handles exception thrown by version checking', () async {
final MockFlutterVersion flutterVersion = MockFlutterVersion();
final FlutterValidator flutterValidator = FlutterValidator( final FlutterValidator flutterValidator = FlutterValidator(
platform: FakePlatform(operatingSystem: 'windows', localeName: 'en_US.UTF-8'), platform: FakePlatform(operatingSystem: 'windows', localeName: 'en_US.UTF-8'),
flutterVersion: () => flutterVersion, flutterVersion: () => FakeThrowingFlutterVersion(),
userMessages: UserMessages(), userMessages: UserMessages(),
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
fileSystem: MemoryFileSystem.test(), fileSystem: MemoryFileSystem.test(),
...@@ -97,10 +102,6 @@ void main() { ...@@ -97,10 +102,6 @@ void main() {
flutterRoot: () => 'sdk/flutter', flutterRoot: () => 'sdk/flutter',
); );
when(flutterVersion.channel).thenReturn('unknown');
when(flutterVersion.frameworkVersion).thenReturn('0.0.0');
when(flutterVersion.frameworkDate).thenThrow(VersionCheckError('version error'));
expect(await flutterValidator.validate(), matchDoctorValidation( expect(await flutterValidator.validate(), matchDoctorValidation(
validationType: ValidationType.partial, validationType: ValidationType.partial,
statusInfo: 'Channel unknown, 0.0.0, on Windows, locale en_US.UTF-8', statusInfo: 'Channel unknown, 0.0.0, on Windows, locale en_US.UTF-8',
...@@ -112,6 +113,9 @@ void main() { ...@@ -112,6 +113,9 @@ void main() {
}); });
testWithoutContext('FlutterValidator shows mirrors on pub and flutter cloud storage', () async { testWithoutContext('FlutterValidator shows mirrors on pub and flutter cloud storage', () async {
final FakeFlutterVersion flutterVersion = FakeFlutterVersion(
frameworkVersion: '1.0.0',
);
final Platform platform = FakePlatform( final Platform platform = FakePlatform(
operatingSystem: 'windows', operatingSystem: 'windows',
localeName: 'en_US.UTF-8', localeName: 'en_US.UTF-8',
...@@ -120,7 +124,6 @@ void main() { ...@@ -120,7 +124,6 @@ void main() {
'FLUTTER_STORAGE_BASE_URL': 'https://example.com/flutter', 'FLUTTER_STORAGE_BASE_URL': 'https://example.com/flutter',
}, },
); );
final MockFlutterVersion flutterVersion = MockFlutterVersion();
final MemoryFileSystem fileSystem = MemoryFileSystem.test(); final MemoryFileSystem fileSystem = MemoryFileSystem.test();
final Artifacts artifacts = Artifacts.test(); final Artifacts artifacts = Artifacts.test();
final FlutterValidator flutterValidator = FlutterValidator( final FlutterValidator flutterValidator = FlutterValidator(
...@@ -136,7 +139,7 @@ void main() { ...@@ -136,7 +139,7 @@ void main() {
expect(await flutterValidator.validate(), matchDoctorValidation( expect(await flutterValidator.validate(), matchDoctorValidation(
validationType: ValidationType.installed, validationType: ValidationType.installed,
statusInfo: 'Channel unknown, Unknown, on Windows, locale en_US.UTF-8', statusInfo: 'Channel unknown, 1.0.0, on Windows, locale en_US.UTF-8',
messages: containsAll(const <ValidationMessage>[ messages: containsAll(const <ValidationMessage>[
ValidationMessage('Pub download mirror https://example.com/pub'), ValidationMessage('Pub download mirror https://example.com/pub'),
ValidationMessage('Flutter download mirror https://example.com/flutter'), ValidationMessage('Flutter download mirror https://example.com/flutter'),
...@@ -145,10 +148,16 @@ void main() { ...@@ -145,10 +148,16 @@ void main() {
}); });
} }
class MockFlutterVersion extends Mock implements FlutterVersion {}
class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils { class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
FakeOperatingSystemUtils({this.name}); FakeOperatingSystemUtils({this.name});
@override @override
final String name; final String name;
} }
class FakeThrowingFlutterVersion extends FakeFlutterVersion {
@override
String get frameworkCommitDate {
throw VersionCheckError('version error');
}
}
...@@ -44,7 +44,7 @@ void main() { ...@@ -44,7 +44,7 @@ void main() {
MockWindowsProject windowsProject; MockWindowsProject windowsProject;
MockLinuxProject linuxProject; MockLinuxProject linuxProject;
FakeSystemClock systemClock; FakeSystemClock systemClock;
FlutterVersion mockVersion; FlutterVersion flutterVersion;
// A Windows-style filesystem. This is not populated by default, so tests // A Windows-style filesystem. This is not populated by default, so tests
// using it instead of fs must re-run any necessary setup (e.g., // using it instead of fs must re-run any necessary setup (e.g.,
// setUpProject). // setUpProject).
...@@ -126,15 +126,11 @@ void main() { ...@@ -126,15 +126,11 @@ void main() {
fsWindows = MemoryFileSystem(style: FileSystemStyle.windows); fsWindows = MemoryFileSystem(style: FileSystemStyle.windows);
systemClock = FakeSystemClock() systemClock = FakeSystemClock()
..currentTime = DateTime(1970, 1, 1); ..currentTime = DateTime(1970, 1, 1);
mockVersion = MockFlutterVersion(); flutterVersion = FakeFlutterVersion(frameworkVersion: '1.0.0');
// Add basic properties to the Flutter project and subprojects // Add basic properties to the Flutter project and subprojects
setUpProject(fs); setUpProject(fs);
flutterProject.directory.childFile('.packages').createSync(recursive: true); flutterProject.directory.childFile('.packages').createSync(recursive: true);
when(mockVersion.frameworkVersion).thenAnswer(
(Invocation _) => '1.0.0'
);
}); });
// Makes fake plugin packages for each plugin, adds them to flutterProject, // Makes fake plugin packages for each plugin, adds them to flutterProject,
...@@ -436,10 +432,6 @@ dependencies: ...@@ -436,10 +432,6 @@ dependencies:
final DateTime dateCreated = DateTime(1970, 1, 1); final DateTime dateCreated = DateTime(1970, 1, 1);
systemClock.currentTime = dateCreated; systemClock.currentTime = dateCreated;
const String version = '1.0.0';
when(mockVersion.frameworkVersion).thenAnswer(
(Invocation _) => version
);
await refreshPluginsList(flutterProject); await refreshPluginsList(flutterProject);
...@@ -510,7 +502,7 @@ dependencies: ...@@ -510,7 +502,7 @@ dependencies:
expect(jsonContent['dependencyGraph'], expectedDependencyGraph); expect(jsonContent['dependencyGraph'], expectedDependencyGraph);
expect(jsonContent['date_created'], dateCreated.toString()); expect(jsonContent['date_created'], dateCreated.toString());
expect(jsonContent['version'], version); expect(jsonContent['version'], '1.0.0');
// Make sure tests are updated if a new object is added/removed. // Make sure tests are updated if a new object is added/removed.
final List<String> expectedKeys = <String>[ final List<String> expectedKeys = <String>[
...@@ -525,7 +517,7 @@ dependencies: ...@@ -525,7 +517,7 @@ dependencies:
FileSystem: () => fs, FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
SystemClock: () => systemClock, SystemClock: () => systemClock,
FlutterVersion: () => mockVersion FlutterVersion: () => flutterVersion
}); });
testUsingContext('Changes to the plugin list invalidates the Cocoapod lockfiles', () async { testUsingContext('Changes to the plugin list invalidates the Cocoapod lockfiles', () async {
...@@ -542,7 +534,7 @@ dependencies: ...@@ -542,7 +534,7 @@ dependencies:
FileSystem: () => fs, FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
SystemClock: () => systemClock, SystemClock: () => systemClock,
FlutterVersion: () => mockVersion FlutterVersion: () => flutterVersion
}); });
testUsingContext('No changes to the plugin list does not invalidate the Cocoapod lockfiles', () async { testUsingContext('No changes to the plugin list does not invalidate the Cocoapod lockfiles', () async {
...@@ -565,7 +557,7 @@ dependencies: ...@@ -565,7 +557,7 @@ dependencies:
FileSystem: () => fs, FileSystem: () => fs,
ProcessManager: () => FakeProcessManager.any(), ProcessManager: () => FakeProcessManager.any(),
SystemClock: () => systemClock, SystemClock: () => systemClock,
FlutterVersion: () => mockVersion FlutterVersion: () => flutterVersion
}); });
}); });
......
...@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/base/dds.dart'; ...@@ -11,6 +11,7 @@ import 'package:flutter_tools/src/base/dds.dart';
import 'package:flutter_tools/src/base/platform.dart'; import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/resident_devtools_handler.dart'; import 'package:flutter_tools/src/resident_devtools_handler.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:package_config/package_config.dart'; import 'package:package_config/package_config.dart';
import 'package:vm_service/vm_service.dart' as vm_service; import 'package:vm_service/vm_service.dart' as vm_service;
...@@ -1585,7 +1586,7 @@ void main() { ...@@ -1585,7 +1586,7 @@ void main() {
expect(json.decode(globals.fs.file('flutter_01.sksl.json').readAsStringSync()), <String, Object>{ expect(json.decode(globals.fs.file('flutter_01.sksl.json').readAsStringSync()), <String, Object>{
'platform': 'android', 'platform': 'android',
'name': 'FakeDevice', 'name': 'FakeDevice',
'engineRevision': '42.2', // From FakeFlutterVersion 'engineRevision': 'abcdefg',
'data': <String, Object>{'A': 'B'} 'data': <String, Object>{'A': 'B'}
}); });
expect(fakeVmServiceHost.hasRemainingExpectations, false); expect(fakeVmServiceHost.hasRemainingExpectations, false);
...@@ -1593,7 +1594,8 @@ void main() { ...@@ -1593,7 +1594,8 @@ void main() {
FileSystemUtils: () => FileSystemUtils( FileSystemUtils: () => FileSystemUtils(
fileSystem: globals.fs, fileSystem: globals.fs,
platform: globals.platform, platform: globals.platform,
) ),
FlutterVersion: () => FakeFlutterVersion(engineRevision: 'abcdefg')
})); }));
testUsingContext('ResidentRunner ignores DevToolsLauncher when attaching with enableDevTools: false', () => testbed.run(() async { testUsingContext('ResidentRunner ignores DevToolsLauncher when attaching with enableDevTools: false', () => testbed.run(() async {
......
...@@ -16,8 +16,6 @@ import 'package:flutter_tools/src/build_info.dart'; ...@@ -16,8 +16,6 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/build_system/build_system.dart'; import 'package:flutter_tools/src/build_system/build_system.dart';
import 'package:flutter_tools/src/device.dart'; import 'package:flutter_tools/src/device.dart';
import 'package:flutter_tools/src/tester/flutter_tester.dart'; import 'package:flutter_tools/src/tester/flutter_tester.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
...@@ -100,7 +98,7 @@ void main() { ...@@ -100,7 +98,7 @@ void main() {
artifacts: Artifacts.test(), artifacts: Artifacts.test(),
buildDirectory: 'build', buildDirectory: 'build',
logger: BufferLogger.test(), logger: BufferLogger.test(),
flutterVersion: MockFlutterVersion(), flutterVersion: FakeFlutterVersion(),
operatingSystemUtils: FakeOperatingSystemUtils(), operatingSystemUtils: FakeOperatingSystemUtils(),
); );
logLines = <String>[]; logLines = <String>[];
...@@ -183,9 +181,7 @@ FlutterTesterDevices setUpFlutterTesterDevices() { ...@@ -183,9 +181,7 @@ FlutterTesterDevices setUpFlutterTesterDevices() {
processManager: FakeProcessManager.any(), processManager: FakeProcessManager.any(),
fileSystem: MemoryFileSystem.test(), fileSystem: MemoryFileSystem.test(),
config: Config.test(), config: Config.test(),
flutterVersion: MockFlutterVersion(), flutterVersion: FakeFlutterVersion(),
operatingSystemUtils: FakeOperatingSystemUtils(), operatingSystemUtils: FakeOperatingSystemUtils(),
); );
} }
class MockFlutterVersion extends Mock implements FlutterVersion {}
...@@ -112,7 +112,7 @@ void testUsingContext( ...@@ -112,7 +112,7 @@ void testUsingContext(
Config: () => buildConfig(globals.fs), Config: () => buildConfig(globals.fs),
DeviceManager: () => FakeDeviceManager(), DeviceManager: () => FakeDeviceManager(),
Doctor: () => FakeDoctor(globals.logger), Doctor: () => FakeDoctor(globals.logger),
FlutterVersion: () => MockFlutterVersion(), FlutterVersion: () => FakeFlutterVersion(),
HttpClient: () => FakeHttpClient.any(), HttpClient: () => FakeHttpClient.any(),
IOSSimulatorUtils: () { IOSSimulatorUtils: () {
final MockIOSSimulatorUtils mock = MockIOSSimulatorUtils(); final MockIOSSimulatorUtils mock = MockIOSSimulatorUtils();
...@@ -377,8 +377,6 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter { ...@@ -377,8 +377,6 @@ class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
List<String> xcrunCommand() => <String>['xcrun']; List<String> xcrunCommand() => <String>['xcrun'];
} }
class MockFlutterVersion extends Mock implements FlutterVersion {}
class MockCrashReporter extends Mock implements CrashReporter {} class MockCrashReporter extends Mock implements CrashReporter {}
class LocalFileSystemBlockingSetCurrentDirectory extends LocalFileSystem { class LocalFileSystemBlockingSetCurrentDirectory extends LocalFileSystem {
......
...@@ -448,52 +448,80 @@ class FakePub extends Fake implements Pub { ...@@ -448,52 +448,80 @@ class FakePub extends Fake implements Pub {
} }
class FakeFlutterVersion implements FlutterVersion { class FakeFlutterVersion implements FlutterVersion {
FakeFlutterVersion({
this.channel = 'unknown',
this.dartSdkVersion = '12',
this.engineRevision = 'abcdefghijklmnopqrstuvwxyz',
this.engineRevisionShort = 'abcde',
this.repositoryUrl = 'https://github.com/flutter/flutter.git',
this.frameworkVersion = '0.0.0',
this.frameworkRevision = '11111111111111111111',
this.frameworkRevisionShort = '11111',
this.frameworkAge = '0 hours ago',
this.frameworkCommitDate = '12/01/01'
});
bool get didFetchTagsAndUpdate => _didFetchTagsAndUpdate;
bool _didFetchTagsAndUpdate = false;
bool get didCheckFlutterVersionFreshness => _didCheckFlutterVersionFreshness;
bool _didCheckFlutterVersionFreshness = false;
@override @override
void fetchTagsAndUpdate() { } final String channel;
@override @override
String get channel => 'master'; final String dartSdkVersion;
@override @override
Future<void> checkFlutterVersionFreshness() async { } final String engineRevision;
@override @override
bool checkRevisionAncestry({String tentativeDescendantRevision, String tentativeAncestorRevision}) { final String engineRevisionShort;
throw UnimplementedError();
}
@override @override
String get dartSdkVersion => '12'; final String repositoryUrl;
@override @override
String get engineRevision => '42.2'; final String frameworkVersion;
@override @override
String get engineRevisionShort => '42'; final String frameworkRevision;
@override @override
Future<void> ensureVersionFile() async { } final String frameworkRevisionShort;
@override
final String frameworkAge;
@override @override
String get frameworkAge => null; final String frameworkCommitDate;
@override @override
String get frameworkCommitDate => null; String get frameworkDate => frameworkCommitDate;
@override @override
String get frameworkDate => null; void fetchTagsAndUpdate() {
_didFetchTagsAndUpdate = true;
}
@override @override
String get frameworkRevision => null; Future<void> checkFlutterVersionFreshness() async {
_didCheckFlutterVersionFreshness = true;
}
@override @override
String get frameworkRevisionShort => null; bool checkRevisionAncestry({String tentativeDescendantRevision, String tentativeAncestorRevision}) {
throw UnimplementedError();
}
@override @override
String get frameworkVersion => null; GitTagVersion get gitTagVersion {
throw UnimplementedError();
}
@override @override
GitTagVersion get gitTagVersion => null; Future<void> ensureVersionFile() async { }
@override @override
String getBranchName({bool redactUnknownBranches = false}) { String getBranchName({bool redactUnknownBranches = false}) {
...@@ -505,12 +533,9 @@ class FakeFlutterVersion implements FlutterVersion { ...@@ -505,12 +533,9 @@ class FakeFlutterVersion implements FlutterVersion {
return 'v0.0.0'; return 'v0.0.0';
} }
@override
String get repositoryUrl => null;
@override @override
Map<String, Object> toJson() { Map<String, Object> toJson() {
return null; return <String, Object>{};
} }
} }
......
...@@ -15,6 +15,7 @@ import 'package:flutter_tools/src/build_info.dart'; ...@@ -15,6 +15,7 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/globals.dart' as globals; import 'package:flutter_tools/src/globals.dart' as globals;
import 'package:flutter_tools/src/ios/devices.dart'; import 'package:flutter_tools/src/ios/devices.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/version.dart';
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
...@@ -232,3 +233,4 @@ class MockStdIn extends Mock implements IOSink { ...@@ -232,3 +233,4 @@ class MockStdIn extends Mock implements IOSink {
} }
class MockStream extends Mock implements Stream<List<int>> {} class MockStream extends Mock implements Stream<List<int>> {}
class MockFlutterVersion extends Mock implements FlutterVersion {}
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