Unverified Commit a99fba01 authored by Jenn Magder's avatar Jenn Magder Committed by GitHub

Move FakeOperatingSystemUtils from context.dart to fakes.dart (#80916)

parent 77504823
...@@ -24,6 +24,7 @@ import 'package:process/process.dart'; ...@@ -24,6 +24,7 @@ import 'package:process/process.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/context.dart';
import '../../src/fakes.dart';
import '../../src/test_flutter_command_runner.dart'; import '../../src/test_flutter_command_runner.dart';
final Platform _kNoColorTerminalPlatform = FakePlatform(stdoutSupportsAnsi: false); final Platform _kNoColorTerminalPlatform = FakePlatform(stdoutSupportsAnsi: false);
......
...@@ -17,7 +17,6 @@ import 'package:flutter_tools/src/doctor_validator.dart'; ...@@ -17,7 +17,6 @@ import 'package:flutter_tools/src/doctor_validator.dart';
import 'package:mockito/mockito.dart'; import 'package:mockito/mockito.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/fakes.dart'; import '../../src/fakes.dart';
import '../../src/mocks.dart' show MockAndroidSdk, MockProcessManager; import '../../src/mocks.dart' show MockAndroidSdk, MockProcessManager;
......
...@@ -12,7 +12,8 @@ import 'package:flutter_tools/src/base/platform.dart'; ...@@ -12,7 +12,8 @@ import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/fake_process_manager.dart';
import '../../src/fakes.dart';
void main() { void main() {
group('injectGradleWrapperIfNeeded', () { group('injectGradleWrapperIfNeeded', () {
......
...@@ -13,7 +13,8 @@ import 'package:flutter_tools/src/build_info.dart'; ...@@ -13,7 +13,8 @@ import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import '../src/common.dart'; import '../src/common.dart';
import '../src/context.dart'; import '../src/fake_process_manager.dart';
import '../src/fakes.dart';
void main() { void main() {
group('CachedArtifacts', () { group('CachedArtifacts', () {
......
...@@ -21,9 +21,9 @@ import 'package:mockito/mockito.dart'; ...@@ -21,9 +21,9 @@ import 'package:mockito/mockito.dart';
import 'package:package_config/package_config.dart'; import 'package:package_config/package_config.dart';
import '../src/common.dart'; import '../src/common.dart';
import '../src/context.dart';
import '../src/fake_http_client.dart'; import '../src/fake_http_client.dart';
import '../src/fake_vm_services.dart'; import '../src/fake_vm_services.dart';
import '../src/fakes.dart';
final FakeVmServiceRequest createDevFSRequest = FakeVmServiceRequest( final FakeVmServiceRequest createDevFSRequest = FakeVmServiceRequest(
method: '_createDevFS', method: '_createDevFS',
......
...@@ -42,6 +42,7 @@ import 'package:vm_service/vm_service.dart' as vm_service; ...@@ -42,6 +42,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/fake_vm_services.dart'; import '../../src/fake_vm_services.dart';
import '../../src/fakes.dart';
final vm_service.Isolate fakeIsolate = vm_service.Isolate( final vm_service.Isolate fakeIsolate = vm_service.Isolate(
id: '1', id: '1',
......
...@@ -8,8 +8,8 @@ import 'package:flutter_tools/src/base/logger.dart'; ...@@ -8,8 +8,8 @@ import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/ios/devices.dart'; import 'package:flutter_tools/src/ios/devices.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart';
import '../../src/fake_process_manager.dart'; import '../../src/fake_process_manager.dart';
import '../../src/fakes.dart';
const Map<String, String> kDyLdLibEntry = <String, String>{ const Map<String, String> kDyLdLibEntry = <String, String>{
'DYLD_LIBRARY_PATH': '/path/to/libs', 'DYLD_LIBRARY_PATH': '/path/to/libs',
......
...@@ -10,19 +10,18 @@ import 'package:flutter_tools/src/artifacts.dart'; ...@@ -10,19 +10,18 @@ import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart'; import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/base/process.dart'; import 'package:flutter_tools/src/base/process.dart';
import 'package:flutter_tools/src/build_info.dart';
import 'package:flutter_tools/src/cache.dart'; import 'package:flutter_tools/src/cache.dart';
import 'package:flutter_tools/src/ios/devices.dart'; import 'package:flutter_tools/src/ios/devices.dart';
import 'package:flutter_tools/src/ios/mac.dart'; import 'package:flutter_tools/src/ios/mac.dart';
import 'package:flutter_tools/src/project.dart'; import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart'; import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:mockito/mockito.dart'; import 'package:test/fake.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/fake_process_manager.dart'; import '../../src/fake_process_manager.dart';
import '../../src/fakes.dart'; import '../../src/fakes.dart';
class MockIosProject extends Mock implements IosProject {}
void main() { void main() {
BufferLogger logger; BufferLogger logger;
...@@ -414,12 +413,9 @@ Exited (sigterm)''', ...@@ -414,12 +413,9 @@ Exited (sigterm)''',
'another line'; 'another line';
testWithoutContext('upgradePbxProjWithFlutterAssets', () async { testWithoutContext('upgradePbxProjWithFlutterAssets', () async {
final MockIosProject project = MockIosProject();
final File pbxprojFile = MemoryFileSystem.test().file('project.pbxproj') final File pbxprojFile = MemoryFileSystem.test().file('project.pbxproj')
..writeAsStringSync(flutterAssetPbxProjLines); ..writeAsStringSync(flutterAssetPbxProjLines);
final FakeIosProject project = FakeIosProject(pbxprojFile);
when(project.xcodeProjectInfoFile).thenReturn(pbxprojFile);
when(project.hostAppBundleName(any)).thenAnswer((_) => Future<String>.value('UnitTestRunner.app'));
bool result = upgradePbxProjWithFlutterAssets(project, logger); bool result = upgradePbxProjWithFlutterAssets(project, logger);
expect(result, true); expect(result, true);
...@@ -488,3 +484,15 @@ Exited (sigterm)''', ...@@ -488,3 +484,15 @@ Exited (sigterm)''',
}); });
}); });
} }
class FakeIosProject extends Fake implements IosProject {
FakeIosProject(this.xcodeProjectInfoFile);
@override
final File xcodeProjectInfoFile;
@override
Future<String> hostAppBundleName(BuildInfo buildInfo) async => 'UnitTestRunner.app';
@override
final Directory xcodeProject = null;
}
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/base/file_system.dart'; import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/convert.dart'; import 'package:flutter_tools/src/convert.dart';
...@@ -241,8 +239,8 @@ const String _kApacheLicense = r''' ...@@ -241,8 +239,8 @@ const String _kApacheLicense = r'''
'''; ''';
void main() { void main() {
FileSystem fileSystem; late FileSystem fileSystem;
LicenseCollector licenseCollector; late LicenseCollector licenseCollector;
setUp(() { setUp(() {
fileSystem = MemoryFileSystem.test(); fileSystem = MemoryFileSystem.test();
......
...@@ -25,8 +25,8 @@ import 'package:mockito/mockito.dart'; ...@@ -25,8 +25,8 @@ import 'package:mockito/mockito.dart';
import 'package:yaml/yaml.dart'; import 'package:yaml/yaml.dart';
import '../src/common.dart'; import '../src/common.dart';
import '../src/context.dart' hide FakeOperatingSystemUtils; import '../src/context.dart';
import '../src/fakes.dart'; import '../src/fakes.dart' hide FakeOperatingSystemUtils;
import '../src/pubspec_schema.dart'; import '../src/pubspec_schema.dart';
void main() { void main() {
......
...@@ -2,8 +2,6 @@ ...@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// @dart = 2.8
import 'dart:async'; import 'dart:async';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
...@@ -14,7 +12,8 @@ import 'package:flutter_tools/src/base/platform.dart'; ...@@ -14,7 +12,8 @@ import 'package:flutter_tools/src/base/platform.dart';
import 'package:flutter_tools/src/web/chrome.dart'; import 'package:flutter_tools/src/web/chrome.dart';
import '../../src/common.dart'; import '../../src/common.dart';
import '../../src/context.dart'; import '../../src/fake_process_manager.dart';
import '../../src/fakes.dart';
const List<String> kChromeArgs = <String>[ const List<String> kChromeArgs = <String>[
'--disable-background-timer-throttling', '--disable-background-timer-throttling',
...@@ -30,12 +29,12 @@ const List<String> kChromeArgs = <String>[ ...@@ -30,12 +29,12 @@ const List<String> kChromeArgs = <String>[
const String kDevtoolsStderr = '\n\nDevTools listening\n\n'; const String kDevtoolsStderr = '\n\nDevTools listening\n\n';
void main() { void main() {
FileExceptionHandler exceptionHandler; late FileExceptionHandler exceptionHandler;
ChromiumLauncher chromeLauncher; late ChromiumLauncher chromeLauncher;
FileSystem fileSystem; late FileSystem fileSystem;
Platform platform; late Platform platform;
FakeProcessManager processManager; late FakeProcessManager processManager;
OperatingSystemUtils operatingSystemUtils; late OperatingSystemUtils operatingSystemUtils;
setUp(() { setUp(() {
exceptionHandler = FileExceptionHandler(); exceptionHandler = FileExceptionHandler();
......
...@@ -296,46 +296,6 @@ class MockSimControl extends Mock implements SimControl { ...@@ -296,46 +296,6 @@ class MockSimControl extends Mock implements SimControl {
} }
} }
class FakeOperatingSystemUtils implements OperatingSystemUtils {
FakeOperatingSystemUtils({this.hostPlatform = HostPlatform.linux_x64});
@override
ProcessResult makeExecutable(File file) => null;
@override
HostPlatform hostPlatform = HostPlatform.linux_x64;
@override
void chmod(FileSystemEntity entity, String mode) { }
@override
File which(String execName) => null;
@override
List<File> whichAll(String execName) => <File>[];
@override
File makePipe(String path) => null;
@override
void unzip(File file, Directory targetDirectory) { }
@override
void unpack(File gzippedTarFile, Directory targetDirectory) { }
@override
Stream<List<int>> gzipLevel1Stream(Stream<List<int>> stream) => stream;
@override
String get name => 'fake OS name and version';
@override
String get pathVarSeparator => ';';
@override
Future<int> findFreePort({bool ipv6 = false}) async => 12345;
}
class MockIOSSimulatorUtils extends Mock implements IOSSimulatorUtils {} class MockIOSSimulatorUtils extends Mock implements IOSSimulatorUtils {}
class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter { class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
......
...@@ -15,6 +15,7 @@ import 'package:flutter_tools/src/convert.dart'; ...@@ -15,6 +15,7 @@ import 'package:flutter_tools/src/convert.dart';
import 'package:flutter_tools/src/features.dart'; import 'package:flutter_tools/src/features.dart';
import 'package:flutter_tools/src/ios/plist_parser.dart'; import 'package:flutter_tools/src/ios/plist_parser.dart';
import 'package:flutter_tools/src/version.dart'; import 'package:flutter_tools/src/version.dart';
import 'package:test/fake.dart';
/// Environment with DYLD_LIBRARY_PATH=/path/to/libraries /// Environment with DYLD_LIBRARY_PATH=/path/to/libraries
class FakeDyldEnvironmentArtifact extends ArtifactSet { class FakeDyldEnvironmentArtifact extends ArtifactSet {
...@@ -493,3 +494,40 @@ class FakeStatusLogger extends DelegatingLogger { ...@@ -493,3 +494,40 @@ class FakeStatusLogger extends DelegatingLogger {
int progressIndicatorPadding = kDefaultStatusPadding, int progressIndicatorPadding = kDefaultStatusPadding,
}) => status; }) => status;
} }
class FakeOperatingSystemUtils extends Fake implements OperatingSystemUtils {
FakeOperatingSystemUtils({this.hostPlatform = HostPlatform.linux_x64});
@override
void makeExecutable(File file) { }
@override
HostPlatform hostPlatform = HostPlatform.linux_x64;
@override
void chmod(FileSystemEntity entity, String mode) { }
@override
File? which(String execName) => null;
@override
List<File> whichAll(String execName) => <File>[];
@override
void unzip(File file, Directory targetDirectory) { }
@override
void unpack(File gzippedTarFile, Directory targetDirectory) { }
@override
Stream<List<int>> gzipLevel1Stream(Stream<List<int>> stream) => stream;
@override
String get name => 'fake OS name and version';
@override
String get pathVarSeparator => ';';
@override
Future<int> findFreePort({bool ipv6 = false}) async => 12345;
}
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