forked from firka/flutter
Ensure that cache dirs and files have appropriate permissions (#28090)
This is a partial re-application of #24669, which was reverted due to Fuchsia breakages. https://github.com/flutter/flutter/issues/24413
This commit is contained in:
@@ -33,8 +33,8 @@ export 'package:flutter_tools/src/base/context.dart' show Generator;
|
||||
/// Return the test logger. This assumes that the current Logger is a BufferLogger.
|
||||
BufferLogger get testLogger => context.get<Logger>();
|
||||
|
||||
MockDeviceManager get testDeviceManager => context.get<DeviceManager>();
|
||||
MockDoctor get testDoctor => context.get<Doctor>();
|
||||
FakeDeviceManager get testDeviceManager => context.get<DeviceManager>();
|
||||
FakeDoctor get testDoctor => context.get<Doctor>();
|
||||
|
||||
typedef ContextInitializer = void Function(AppContext testContext);
|
||||
|
||||
@@ -71,8 +71,8 @@ void testUsingContext(
|
||||
name: 'mocks',
|
||||
overrides: <Type, Generator>{
|
||||
Config: () => buildConfig(fs),
|
||||
DeviceManager: () => MockDeviceManager(),
|
||||
Doctor: () => MockDoctor(),
|
||||
DeviceManager: () => FakeDeviceManager(),
|
||||
Doctor: () => FakeDoctor(),
|
||||
FlutterVersion: () => MockFlutterVersion(),
|
||||
HttpClient: () => MockHttpClient(),
|
||||
IOSSimulatorUtils: () {
|
||||
@@ -82,10 +82,10 @@ void testUsingContext(
|
||||
},
|
||||
OutputPreferences: () => OutputPreferences(showColor: false),
|
||||
Logger: () => BufferLogger(),
|
||||
OperatingSystemUtils: () => MockOperatingSystemUtils(),
|
||||
OperatingSystemUtils: () => FakeOperatingSystemUtils(),
|
||||
SimControl: () => MockSimControl(),
|
||||
Usage: () => MockUsage(),
|
||||
XcodeProjectInterpreter: () => MockXcodeProjectInterpreter(),
|
||||
Usage: () => FakeUsage(),
|
||||
XcodeProjectInterpreter: () => FakeXcodeProjectInterpreter(),
|
||||
FileSystem: () => LocalFileSystemBlockingSetCurrentDirectory(),
|
||||
TimeoutConfiguration: () => const TimeoutConfiguration(),
|
||||
},
|
||||
@@ -135,7 +135,7 @@ void _printBufferedErrors(AppContext testContext) {
|
||||
}
|
||||
}
|
||||
|
||||
class MockDeviceManager implements DeviceManager {
|
||||
class FakeDeviceManager implements DeviceManager {
|
||||
List<Device> devices = <Device>[];
|
||||
|
||||
String _specifiedDeviceId;
|
||||
@@ -198,12 +198,12 @@ class MockDeviceManager implements DeviceManager {
|
||||
}
|
||||
}
|
||||
|
||||
class MockAndroidLicenseValidator extends AndroidLicenseValidator {
|
||||
class FakeAndroidLicenseValidator extends AndroidLicenseValidator {
|
||||
@override
|
||||
Future<LicensesAccepted> get licensesAccepted async => LicensesAccepted.all;
|
||||
}
|
||||
|
||||
class MockDoctor extends Doctor {
|
||||
class FakeDoctor extends Doctor {
|
||||
// True for testing.
|
||||
@override
|
||||
bool get canListAnything => true;
|
||||
@@ -220,7 +220,7 @@ class MockDoctor extends Doctor {
|
||||
final List<DoctorValidator> superValidators = super.validators;
|
||||
return superValidators.map<DoctorValidator>((DoctorValidator v) {
|
||||
if (v is AndroidLicenseValidator) {
|
||||
return MockAndroidLicenseValidator();
|
||||
return FakeAndroidLicenseValidator();
|
||||
}
|
||||
return v;
|
||||
}).toList();
|
||||
@@ -233,10 +233,13 @@ class MockSimControl extends Mock implements SimControl {
|
||||
}
|
||||
}
|
||||
|
||||
class MockOperatingSystemUtils implements OperatingSystemUtils {
|
||||
class FakeOperatingSystemUtils implements OperatingSystemUtils {
|
||||
@override
|
||||
ProcessResult makeExecutable(File file) => null;
|
||||
|
||||
@override
|
||||
void chmod(FileSystemEntity entity, String mode) { }
|
||||
|
||||
@override
|
||||
File which(String execName) => null;
|
||||
|
||||
@@ -273,7 +276,7 @@ class MockOperatingSystemUtils implements OperatingSystemUtils {
|
||||
|
||||
class MockIOSSimulatorUtils extends Mock implements IOSSimulatorUtils {}
|
||||
|
||||
class MockUsage implements Usage {
|
||||
class FakeUsage implements Usage {
|
||||
@override
|
||||
bool get isFirstRun => false;
|
||||
|
||||
@@ -314,7 +317,7 @@ class MockUsage implements Usage {
|
||||
void printWelcome() { }
|
||||
}
|
||||
|
||||
class MockXcodeProjectInterpreter implements XcodeProjectInterpreter {
|
||||
class FakeXcodeProjectInterpreter implements XcodeProjectInterpreter {
|
||||
@override
|
||||
bool get isInstalled => true;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:file/memory.dart';
|
||||
import 'package:flutter_tools/src/base/io.dart';
|
||||
import 'package:flutter_tools/src/base/os.dart';
|
||||
import 'package:flutter_tools/src/base/platform.dart';
|
||||
import 'package:flutter_tools/src/base/context.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
@@ -33,6 +34,7 @@ final Map<Type, Generator> _testbedDefaults = <Type, Generator>{
|
||||
? FileSystemStyle.windows
|
||||
: FileSystemStyle.posix),
|
||||
Logger: () => BufferLogger(), // Allows reading logs and prevents stdout.
|
||||
OperatingSystemUtils: () => FakeOperatingSystemUtils(),
|
||||
OutputPreferences: () => OutputPreferences(showColor: false), // configures BufferLogger to avoid color codes.
|
||||
Usage: () => NoOpUsage(), // prevent addition of analytics from burdening test mocks
|
||||
FlutterVersion: () => FakeFlutterVersion() // prevent requirement to mock git for test runner.
|
||||
|
||||
Reference in New Issue
Block a user