Update device filtering and introduce isConnected and connectionInterface (#121359)
Update device filtering and introduce isConnected and connectionInterface
This commit is contained in:
committed by
GitHub
parent
c590086bcc
commit
cc26a1aa0c
@@ -207,21 +207,31 @@ class FakeDeviceManager implements DeviceManager {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Device>> getAllConnectedDevices() async => devices;
|
||||
Future<List<Device>> getAllDevices({
|
||||
DeviceDiscoveryFilter? filter,
|
||||
}) async => devices;
|
||||
|
||||
@override
|
||||
Future<List<Device>> refreshAllConnectedDevices({ Duration? timeout }) async => devices;
|
||||
Future<List<Device>> refreshAllDevices({
|
||||
Duration? timeout,
|
||||
DeviceDiscoveryFilter? filter,
|
||||
}) async => devices;
|
||||
|
||||
@override
|
||||
Future<List<Device>> getDevicesById(String deviceId) async {
|
||||
Future<List<Device>> getDevicesById(
|
||||
String deviceId, {
|
||||
DeviceDiscoveryFilter? filter,
|
||||
}) async {
|
||||
return devices.where((Device device) => device.id == deviceId).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Device>> getDevices() {
|
||||
Future<List<Device>> getDevices({
|
||||
DeviceDiscoveryFilter? filter,
|
||||
}) {
|
||||
return hasSpecifiedDeviceId
|
||||
? getDevicesById(specifiedDeviceId!)
|
||||
: getAllConnectedDevices();
|
||||
? getDevicesById(specifiedDeviceId!, filter: filter)
|
||||
: getAllDevices(filter: filter);
|
||||
}
|
||||
|
||||
void addDevice(Device device) => devices.add(device);
|
||||
@@ -236,16 +246,27 @@ class FakeDeviceManager implements DeviceManager {
|
||||
List<DeviceDiscovery> get deviceDiscoverers => <DeviceDiscovery>[];
|
||||
|
||||
@override
|
||||
bool isDeviceSupportedForProject(Device device, FlutterProject? flutterProject) {
|
||||
return device.isSupportedForProject(flutterProject!);
|
||||
Future<List<Device>> findTargetDevices({
|
||||
bool includeDevicesUnsupportedByProject = false,
|
||||
Duration? timeout,
|
||||
bool promptUserToChooseDevice = true,
|
||||
}) async {
|
||||
return devices;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<Device>> findTargetDevices(FlutterProject? flutterProject, { Duration? timeout, bool promptUserToChooseDevice = true }) async {
|
||||
return devices;
|
||||
DeviceDiscoverySupportFilter deviceSupportFilter({
|
||||
bool includeDevicesUnsupportedByProject = false,
|
||||
FlutterProject? flutterProject,
|
||||
}) {
|
||||
return TestDeviceDiscoverySupportFilter();
|
||||
}
|
||||
}
|
||||
|
||||
class TestDeviceDiscoverySupportFilter extends Fake implements DeviceDiscoverySupportFilter {
|
||||
TestDeviceDiscoverySupportFilter();
|
||||
}
|
||||
|
||||
class FakeAndroidLicenseValidator extends Fake implements AndroidLicenseValidator {
|
||||
@override
|
||||
Future<LicensesAccepted> get licensesAccepted async => LicensesAccepted.all;
|
||||
|
||||
@@ -62,6 +62,8 @@ class FakeDevice extends Device {
|
||||
bool ephemeral = true,
|
||||
bool isSupported = true,
|
||||
bool isSupportedForProject = true,
|
||||
this.isConnected = true,
|
||||
this.connectionInterface = DeviceConnectionInterface.attached,
|
||||
PlatformType type = PlatformType.web,
|
||||
LaunchResult? launchResult,
|
||||
}) : _isSupported = isSupported,
|
||||
@@ -118,6 +120,12 @@ class FakeDevice extends Device {
|
||||
@override
|
||||
bool isSupported() => _isSupported;
|
||||
|
||||
@override
|
||||
bool isConnected;
|
||||
|
||||
@override
|
||||
DeviceConnectionInterface connectionInterface;
|
||||
|
||||
@override
|
||||
Future<bool> isLocalEmulator = Future<bool>.value(true);
|
||||
|
||||
@@ -174,7 +182,10 @@ class FakePollingDeviceDiscovery extends PollingDeviceDiscovery {
|
||||
bool discoverDevicesCalled = false;
|
||||
|
||||
@override
|
||||
Future<List<Device>> discoverDevices({Duration? timeout}) {
|
||||
Future<List<Device>> discoverDevices({
|
||||
Duration? timeout,
|
||||
DeviceDiscoveryFilter? filter,
|
||||
}) {
|
||||
discoverDevicesCalled = true;
|
||||
return super.discoverDevices(timeout: timeout);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user