Unverified Commit 716a672b authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tools] Adds tests of mdns analytics events (#41410)

parent 8a2f8adf
......@@ -23,6 +23,7 @@ import 'package:flutter_tools/src/ios/ios_workflow.dart';
import 'package:flutter_tools/src/macos/xcode.dart';
import 'package:flutter_tools/src/mdns_discovery.dart';
import 'package:flutter_tools/src/project.dart';
import 'package:flutter_tools/src/reporting/reporting.dart';
import 'package:meta/meta.dart';
import 'package:mockito/mockito.dart';
import 'package:platform/platform.dart';
......@@ -44,6 +45,7 @@ class MockMDnsObservatoryDiscovery extends Mock implements MDnsObservatoryDiscov
class MockXcode extends Mock implements Xcode {}
class MockFile extends Mock implements File {}
class MockPortForwarder extends Mock implements DevicePortForwarder {}
class MockUsage extends Mock implements Usage {}
void main() {
final FakePlatform macPlatform = FakePlatform.fromPlatform(const LocalPlatform());
......@@ -84,6 +86,7 @@ void main() {
MockPortForwarder mockPortForwarder;
MockIMobileDevice mockIMobileDevice;
MockIOSDeploy mockIosDeploy;
MockUsage mockUsage;
Directory tempDir;
Directory projectDir;
......@@ -115,6 +118,7 @@ void main() {
mockPortForwarder = MockPortForwarder();
mockIMobileDevice = MockIMobileDevice();
mockIosDeploy = MockIOSDeploy();
mockUsage = MockUsage();
tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_create_test.');
projectDir = tempDir.childDirectory('flutter_project');
......@@ -183,6 +187,7 @@ void main() {
debuggingOptions: DebuggingOptions.enabled(const BuildInfo(BuildMode.debug, null)),
platformArgs: <String, dynamic>{},
);
verify(mockUsage.sendEvent('ios-mdns', 'success')).called(1);
expect(launchResult.started, isTrue);
expect(launchResult.hasObservatory, isTrue);
expect(await device.stopApp(mockApp), isFalse);
......@@ -193,6 +198,7 @@ void main() {
MDnsObservatoryDiscovery: () => mockMDnsObservatoryDiscovery,
Platform: () => macPlatform,
ProcessManager: () => mockProcessManager,
Usage: () => mockUsage,
});
testUsingContext(' succeeds in debug mode when mDNS fails by falling back to manual protocol discovery', () async {
......@@ -212,6 +218,7 @@ void main() {
debuggingOptions: DebuggingOptions.enabled(const BuildInfo(BuildMode.debug, null)),
platformArgs: <String, dynamic>{},
);
verify(mockUsage.sendEvent('ios-mdns', 'failure')).called(1);
expect(launchResult.started, isTrue);
expect(launchResult.hasObservatory, isTrue);
expect(await device.stopApp(mockApp), isFalse);
......@@ -222,6 +229,7 @@ void main() {
MDnsObservatoryDiscovery: () => mockMDnsObservatoryDiscovery,
Platform: () => macPlatform,
ProcessManager: () => mockProcessManager,
Usage: () => mockUsage,
});
testUsingContext(' fails in debug mode when mDNS fails and when Observatory URI is malformed', () 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