Use DeviceManager instead of device to determine if device supports project (#36213)
This commit is contained in:
parent
6b17840cbf
commit
b257c33b69
@ -202,7 +202,7 @@ class DeviceManager {
|
|||||||
if (devices.length > 1 && !hasSpecifiedDeviceId) {
|
if (devices.length > 1 && !hasSpecifiedDeviceId) {
|
||||||
devices = <Device>[
|
devices = <Device>[
|
||||||
for (Device device in devices)
|
for (Device device in devices)
|
||||||
if (device.isSupportedForProject(flutterProject))
|
if (isDeviceSupportedForProject(device, flutterProject))
|
||||||
device
|
device
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -224,6 +224,8 @@ class DeviceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the device is supported for the project.
|
/// Returns whether the device is supported for the project.
|
||||||
|
///
|
||||||
|
/// This exists to allow the check to be overriden for google3 clients.
|
||||||
bool isDeviceSupportedForProject(Device device, FlutterProject flutterProject) {
|
bool isDeviceSupportedForProject(Device device, FlutterProject flutterProject) {
|
||||||
return device.isSupportedForProject(flutterProject);
|
return device.isSupportedForProject(flutterProject);
|
||||||
}
|
}
|
||||||
|
@ -116,6 +116,20 @@ void main() {
|
|||||||
nonEphemeralTwo,
|
nonEphemeralTwo,
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testUsingContext('uses DeviceManager.isDeviceSupportedForProject instead of device.isSupportedForProject', () async {
|
||||||
|
final List<Device> devices = <Device>[
|
||||||
|
unsupported,
|
||||||
|
];
|
||||||
|
final TestDeviceManager deviceManager = TestDeviceManager(devices);
|
||||||
|
deviceManager.isAlwaysSupportedOverride = true;
|
||||||
|
|
||||||
|
final List<Device> filtered = await deviceManager.findTargetDevices(FlutterProject.current());
|
||||||
|
|
||||||
|
expect(filtered, <Device>[
|
||||||
|
unsupported,
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,11 +137,20 @@ class TestDeviceManager extends DeviceManager {
|
|||||||
TestDeviceManager(this.allDevices);
|
TestDeviceManager(this.allDevices);
|
||||||
|
|
||||||
final List<Device> allDevices;
|
final List<Device> allDevices;
|
||||||
|
bool isAlwaysSupportedOverride;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<Device> getAllConnectedDevices() {
|
Stream<Device> getAllConnectedDevices() {
|
||||||
return Stream<Device>.fromIterable(allDevices);
|
return Stream<Device>.fromIterable(allDevices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool isDeviceSupportedForProject(Device device, FlutterProject flutterProject) {
|
||||||
|
if (isAlwaysSupportedOverride != null) {
|
||||||
|
return isAlwaysSupportedOverride;
|
||||||
|
}
|
||||||
|
return super.isDeviceSupportedForProject(device, flutterProject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MockDevice extends Device {
|
class _MockDevice extends Device {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user