Unverified Commit feaaa5d7 authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tool] Add analytics events for ios-mdns fallback success/failure (#41482)

parent 618fac92
......@@ -377,7 +377,7 @@ class IOSDevice extends Device {
return LaunchResult.succeeded(observatoryUri: localUri);
}
} catch (error) {
printError('Failed to establish a debug connection with $id: $error');
printError('Failed to establish a debug connection with $id using mdns: $error');
}
// Fallback to manual protocol discovery.
......@@ -387,13 +387,15 @@ class IOSDevice extends Device {
printTrace('Waiting for observatory port.');
localUri = await observatoryDiscovery.uri;
if (localUri != null) {
UsageEvent('ios-mdns', 'fallback-success').send();
return LaunchResult.succeeded(observatoryUri: localUri);
}
} catch (error) {
printError('Failed to establish a debug connection with $id: $error');
printError('Failed to establish a debug connection with $id using logs: $error');
} finally {
await observatoryDiscovery?.cancel();
}
UsageEvent('ios-mdns', 'fallback-failure').send();
return LaunchResult.failed();
} finally {
installStatus.stop();
......
......@@ -219,6 +219,7 @@ void main() {
platformArgs: <String, dynamic>{},
);
verify(mockUsage.sendEvent('ios-mdns', 'failure')).called(1);
verify(mockUsage.sendEvent('ios-mdns', 'fallback-success')).called(1);
expect(launchResult.started, isTrue);
expect(launchResult.hasObservatory, isTrue);
expect(await device.stopApp(mockApp), isFalse);
......@@ -250,6 +251,8 @@ void main() {
debuggingOptions: DebuggingOptions.enabled(const BuildInfo(BuildMode.debug, null)),
platformArgs: <String, dynamic>{},
);
verify(mockUsage.sendEvent('ios-mdns', 'failure')).called(1);
verify(mockUsage.sendEvent('ios-mdns', 'fallback-failure')).called(1);
expect(launchResult.started, isFalse);
expect(launchResult.hasObservatory, isFalse);
}, overrides: <Type, Generator>{
......@@ -259,6 +262,7 @@ void main() {
MDnsObservatoryDiscovery: () => mockMDnsObservatoryDiscovery,
Platform: () => macPlatform,
ProcessManager: () => mockProcessManager,
Usage: () => mockUsage,
});
testUsingContext(' succeeds in release mode', () 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