Update proxied devices to handle connection interface and diagnostics. (#145061)
Also improve the performance of daemon device discovery by parallelizing the calls.
This commit is contained in:
@@ -459,6 +459,8 @@ void main() {
|
||||
'ephemeral': false,
|
||||
'emulatorId': 'device',
|
||||
'sdk': 'Android 12',
|
||||
'isConnected': true,
|
||||
'connectionInterface': 'attached',
|
||||
'capabilities': <String, Object?>{
|
||||
'hotReload': true,
|
||||
'hotRestart': true,
|
||||
@@ -479,6 +481,8 @@ void main() {
|
||||
'ephemeral': false,
|
||||
'emulatorId': null,
|
||||
'sdk': 'preview',
|
||||
'isConnected': true,
|
||||
'connectionInterface': 'attached',
|
||||
'capabilities': <String, Object?>{
|
||||
'hotReload': true,
|
||||
'hotRestart': true,
|
||||
@@ -725,6 +729,31 @@ void main() {
|
||||
expect(device.dds.shutdownCalled, true);
|
||||
});
|
||||
|
||||
testUsingContext('device.getDiagnostics returns correct value', () async {
|
||||
daemon = Daemon(
|
||||
daemonConnection,
|
||||
notifyingLogger: notifyingLogger,
|
||||
);
|
||||
final FakePollingDeviceDiscovery discoverer1 = FakePollingDeviceDiscovery();
|
||||
discoverer1.diagnostics = <String>['fake diagnostic 1', 'fake diagnostic 2'];
|
||||
final FakePollingDeviceDiscovery discoverer2 = FakePollingDeviceDiscovery();
|
||||
discoverer2.diagnostics = <String>['fake diagnostic 3', 'fake diagnostic 4'];
|
||||
daemon.deviceDomain.addDeviceDiscoverer(discoverer1);
|
||||
daemon.deviceDomain.addDeviceDiscoverer(discoverer2);
|
||||
daemonStreams.inputs.add(DaemonMessage(<String, Object?>{
|
||||
'id': 0,
|
||||
'method': 'device.getDiagnostics',
|
||||
}));
|
||||
final DaemonMessage response = await daemonStreams.outputs.stream.firstWhere(_notEvent);
|
||||
expect(response.data['id'], 0);
|
||||
expect(response.data['result'], <String>[
|
||||
'fake diagnostic 1',
|
||||
'fake diagnostic 2',
|
||||
'fake diagnostic 3',
|
||||
'fake diagnostic 4',
|
||||
]);
|
||||
});
|
||||
|
||||
testUsingContext('emulator.launch without an emulatorId should report an error', () async {
|
||||
daemon = Daemon(
|
||||
daemonConnection,
|
||||
@@ -1128,6 +1157,9 @@ class FakeAndroidDevice extends Fake implements AndroidDevice {
|
||||
@override
|
||||
final bool isConnected = true;
|
||||
|
||||
@override
|
||||
final DeviceConnectionInterface connectionInterface = DeviceConnectionInterface.attached;
|
||||
|
||||
@override
|
||||
Future<String> get sdkNameAndVersion async => 'Android 12';
|
||||
|
||||
|
||||
@@ -274,6 +274,9 @@ class FakeAndroidDevice extends Fake implements AndroidDevice {
|
||||
@override
|
||||
bool get isConnected => true;
|
||||
|
||||
@override
|
||||
final DeviceConnectionInterface connectionInterface = DeviceConnectionInterface.attached;
|
||||
|
||||
@override
|
||||
Future<String> get sdkNameAndVersion async => 'Android 12';
|
||||
|
||||
|
||||
@@ -562,6 +562,44 @@ void main() {
|
||||
expect(devicesAdded[0].id, fakeDevice['id']);
|
||||
expect(devicesAdded[1].id, fakeDevice2['id']);
|
||||
});
|
||||
|
||||
testWithoutContext('handles getDiagnostics', () async {
|
||||
bufferLogger = BufferLogger.test();
|
||||
final ProxiedDevices proxiedDevices = ProxiedDevices(
|
||||
clientDaemonConnection,
|
||||
logger: bufferLogger,
|
||||
);
|
||||
|
||||
final Future<List<String>> resultFuture = proxiedDevices.getDiagnostics();
|
||||
|
||||
final DaemonMessage message = await serverDaemonConnection.incomingCommands.first;
|
||||
expect(message.data['id'], isNotNull);
|
||||
expect(message.data['method'], 'device.getDiagnostics');
|
||||
|
||||
serverDaemonConnection.sendResponse(message.data['id']!, <String>['1', '2']);
|
||||
|
||||
final List<String> result = await resultFuture;
|
||||
expect(result, <String>['1', '2']);
|
||||
});
|
||||
|
||||
testWithoutContext('returns empty result when daemon does not understand getDiagnostics', () async {
|
||||
bufferLogger = BufferLogger.test();
|
||||
final ProxiedDevices proxiedDevices = ProxiedDevices(
|
||||
clientDaemonConnection,
|
||||
logger: bufferLogger,
|
||||
);
|
||||
|
||||
final Future<List<String>> resultFuture = proxiedDevices.getDiagnostics();
|
||||
|
||||
final DaemonMessage message = await serverDaemonConnection.incomingCommands.first;
|
||||
expect(message.data['id'], isNotNull);
|
||||
expect(message.data['method'], 'device.getDiagnostics');
|
||||
|
||||
serverDaemonConnection.sendErrorResponse(message.data['id']!, 'command not understood: device.getDiagnostics', StackTrace.current);
|
||||
|
||||
final List<String> result = await resultFuture;
|
||||
expect(result, isEmpty);
|
||||
});
|
||||
});
|
||||
|
||||
group('ProxiedDartDevelopmentService', () {
|
||||
|
||||
@@ -269,6 +269,11 @@ class FakePollingDeviceDiscovery extends PollingDeviceDiscovery {
|
||||
|
||||
@override
|
||||
List<String> wellKnownIds = <String>[];
|
||||
|
||||
List<String> diagnostics = <String>[];
|
||||
|
||||
@override
|
||||
Future<List<String>> getDiagnostics() => Future<List<String>>.value(diagnostics);
|
||||
}
|
||||
|
||||
/// A fake implementation of the [DeviceLogReader].
|
||||
|
||||
Reference in New Issue
Block a user