Unverified Commit 8e2ea263 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Make the deviceDiscovery API overridable (#27378)

parent 030dc3fa
...@@ -25,21 +25,20 @@ DeviceManager get deviceManager => context[DeviceManager]; ...@@ -25,21 +25,20 @@ DeviceManager get deviceManager => context[DeviceManager];
/// A class to get all available devices. /// A class to get all available devices.
class DeviceManager { class DeviceManager {
/// Constructing DeviceManagers is cheap; they only do expensive work if some /// Constructing DeviceManagers is cheap; they only do expensive work if some
/// of their methods are called. /// of their methods are called.
DeviceManager() { List<DeviceDiscovery> get deviceDiscoverers => _deviceDiscoverers;
// Register the known discoverers. final List<DeviceDiscovery> _deviceDiscoverers = List<DeviceDiscovery>.unmodifiable(<DeviceDiscovery>[
_deviceDiscoverers.add(AndroidDevices()); AndroidDevices(),
_deviceDiscoverers.add(IOSDevices()); IOSDevices(),
_deviceDiscoverers.add(IOSSimulators()); IOSSimulators(),
_deviceDiscoverers.add(FuchsiaDevices()); FuchsiaDevices(),
_deviceDiscoverers.add(FlutterTesterDevices()); FlutterTesterDevices(),
_deviceDiscoverers.add(MacOSDevices()); MacOSDevices(),
_deviceDiscoverers.add(LinuxDevices()); LinuxDevices(),
_deviceDiscoverers.add(WindowsDevices()); WindowsDevices(),
} ]);
final List<DeviceDiscovery> _deviceDiscoverers = <DeviceDiscovery>[];
String _specifiedDeviceId; String _specifiedDeviceId;
...@@ -91,7 +90,7 @@ class DeviceManager { ...@@ -91,7 +90,7 @@ class DeviceManager {
} }
Iterable<DeviceDiscovery> get _platformDiscoverers { Iterable<DeviceDiscovery> get _platformDiscoverers {
return _deviceDiscoverers.where((DeviceDiscovery discoverer) => discoverer.supportsPlatform); return deviceDiscoverers.where((DeviceDiscovery discoverer) => discoverer.supportsPlatform);
} }
/// Return the list of all connected devices. /// Return the list of all connected devices.
......
...@@ -179,6 +179,9 @@ class MockDeviceManager implements DeviceManager { ...@@ -179,6 +179,9 @@ class MockDeviceManager implements DeviceManager {
@override @override
Future<List<String>> getDeviceDiagnostics() async => <String>[]; Future<List<String>> getDeviceDiagnostics() async => <String>[];
@override
List<DeviceDiscovery> get deviceDiscoverers => <DeviceDiscovery>[];
} }
class MockAndroidLicenseValidator extends AndroidLicenseValidator { class MockAndroidLicenseValidator extends AndroidLicenseValidator {
......
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