Unverified Commit 9e30d51a authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] start fixing command tests (#60172)

parent 77bc1ee5
...@@ -34,7 +34,7 @@ void main() { ...@@ -34,7 +34,7 @@ void main() {
expect(testLogger.statusText, containsIgnoringWhitespace('No devices detected')); expect(testLogger.statusText, containsIgnoringWhitespace('No devices detected'));
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
AndroidSdk: () => null, AndroidSdk: () => null,
DeviceManager: () => DeviceManager(), DeviceManager: () => NoDevicesManager(),
ProcessManager: () => MockProcessManager(), ProcessManager: () => MockProcessManager(),
}); });
...@@ -160,3 +160,12 @@ class _FakeDeviceManager extends DeviceManager { ...@@ -160,3 +160,12 @@ class _FakeDeviceManager extends DeviceManager {
<String>['Cannot connect to device ABC'] <String>['Cannot connect to device ABC']
); );
} }
class NoDevicesManager extends DeviceManager {
@override
Future<List<Device>> getAllConnectedDevices() async => <Device>[];
@override
Future<List<Device>> refreshAllConnectedDevices({Duration timeout}) =>
getAllConnectedDevices();
}
...@@ -43,6 +43,11 @@ final Map<Type, Generator> noColorTerminalOverride = <Type, Generator>{ ...@@ -43,6 +43,11 @@ final Map<Type, Generator> noColorTerminalOverride = <Type, Generator>{
Platform: _kNoColorOutputPlatform, Platform: _kNoColorOutputPlatform,
}; };
final Platform macPlatform = FakePlatform(
operatingSystem: 'macos',
environment: <String, String>{'HOME': '/foo/bar'}
);
void main() { void main() {
MockProcessManager mockProcessManager; MockProcessManager mockProcessManager;
MockFlutterVersion mockFlutterVersion; MockFlutterVersion mockFlutterVersion;
...@@ -93,11 +98,14 @@ void main() { ...@@ -93,11 +98,14 @@ void main() {
expect(validator.plistFile, '/path/to/app/Contents/Info.plist'); expect(validator.plistFile, '/path/to/app/Contents/Info.plist');
expect(validator.pluginsPath, pluginsDirectory.path); expect(validator.pluginsPath, pluginsDirectory.path);
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Platform: () => FakePlatform() Platform: () => macPlatform,
..environment = <String, String>{'HOME': '/foo/bar'},
PlistParser: () => mockPlistParser, PlistParser: () => mockPlistParser,
FileSystem: () => fileSystem, FileSystem: () => fileSystem,
ProcessManager: () => mockProcessManager, ProcessManager: () => mockProcessManager,
FileSystemUtils: () => FileSystemUtils(
fileSystem: fileSystem,
platform: macPlatform,
)
}); });
testUsingContext('legacy intellij plugins path checking on mac', () async { testUsingContext('legacy intellij plugins path checking on mac', () async {
...@@ -106,9 +114,14 @@ void main() { ...@@ -106,9 +114,14 @@ void main() {
final IntelliJValidatorOnMac validator = IntelliJValidatorOnMac('Test', 'TestID', '/foo'); final IntelliJValidatorOnMac validator = IntelliJValidatorOnMac('Test', 'TestID', '/foo');
expect(validator.pluginsPath, '/foo/bar/Library/Application Support/TestID2020.10'); expect(validator.pluginsPath, '/foo/bar/Library/Application Support/TestID2020.10');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Platform: () => FakePlatform() Platform: () => macPlatform,
..environment = <String, String>{'HOME': '/foo/bar'},
PlistParser: () => mockPlistParser, PlistParser: () => mockPlistParser,
FileSystem: () => fileSystem,
FileSystemUtils: () => FileSystemUtils(
fileSystem: fileSystem,
platform: macPlatform,
),
ProcessManager: () => FakeProcessManager.any(),
}); });
testUsingContext('intellij plugins path checking on mac with override', () async { testUsingContext('intellij plugins path checking on mac with override', () async {
...@@ -118,6 +131,13 @@ void main() { ...@@ -118,6 +131,13 @@ void main() {
expect(validator.pluginsPath, '/path/to/JetBrainsToolboxApp.plugins'); expect(validator.pluginsPath, '/path/to/JetBrainsToolboxApp.plugins');
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
PlistParser: () => mockPlistParser, PlistParser: () => mockPlistParser,
Platform: () => macPlatform,
FileSystem: () => fileSystem,
FileSystemUtils: () => FileSystemUtils(
fileSystem: fileSystem,
platform: macPlatform,
),
ProcessManager: () => FakeProcessManager.any(),
}); });
testUsingContext('vs code validator when both installed', () async { testUsingContext('vs code validator when both installed', () async {
......
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