Commit 5907a726 authored by Matteo Crippa's avatar Matteo Crippa Committed by Todd Volkert

Fix/ios run simulator (#20262)

parent 6e64cb0a
...@@ -60,7 +60,7 @@ class ProtocolDiscovery { ...@@ -60,7 +60,7 @@ class ProtocolDiscovery {
void _handleLine(String line) { void _handleLine(String line) {
Uri uri; Uri uri;
final RegExp r = new RegExp('${RegExp.escape(serviceName)} listening on (http://[^ \n]+)'); final RegExp r = new RegExp('${RegExp.escape(serviceName)} listening on ((http|\/\/)[a-zA-Z0-9:/=\.\\[\\]]+)');
final Match match = r.firstMatch(line); final Match match = r.firstMatch(line);
if (match != null) { if (match != null) {
......
...@@ -67,9 +67,9 @@ void main() { ...@@ -67,9 +67,9 @@ void main() {
expect('$uri', 'http://127.0.0.1:3333'); expect('$uri', 'http://127.0.0.1:3333');
}); });
testUsingContext('discovers uri even if logs has ESC Ascii', () async { testUsingContext('discovers uri with Ascii Esc code', () async {
initialize(); initialize();
logReader.addLine('Observatory listening on http://127.0.0.1:3333 \x1b['); logReader.addLine('Observatory listening on http://127.0.0.1:3333\x1b[');
final Uri uri = await discoverer.uri; final Uri uri = await discoverer.uri;
expect(uri.port, 3333); expect(uri.port, 3333);
expect('$uri', 'http://127.0.0.1:3333'); expect('$uri', 'http://127.0.0.1:3333');
...@@ -89,7 +89,9 @@ void main() { ...@@ -89,7 +89,9 @@ void main() {
logReader.addLine('Observatory not listening...'); logReader.addLine('Observatory not listening...');
final Uri timeoutUri = Uri.parse('http://timeout'); final Uri timeoutUri = Uri.parse('http://timeout');
final Uri actualUri = await uriFuture.timeout( final Uri actualUri = await uriFuture.timeout(
const Duration(milliseconds: 100), onTimeout: () => timeoutUri); const Duration(milliseconds: 100),
onTimeout: () => timeoutUri,
);
expect(actualUri, timeoutUri); expect(actualUri, timeoutUri);
}); });
...@@ -196,6 +198,26 @@ void main() { ...@@ -196,6 +198,26 @@ void main() {
await discoverer.cancel(); await discoverer.cancel();
logReader.dispose(); logReader.dispose();
}); });
testUsingContext('ipv6 with Ascii Escape code', () async {
final MockDeviceLogReader logReader = new MockDeviceLogReader();
final ProtocolDiscovery discoverer = new ProtocolDiscovery.observatory(
logReader,
portForwarder: new MockPortForwarder(99),
hostPort: 54777,
ipv6: true,
);
// Get next port future.
final Future<Uri> nextUri = discoverer.uri;
logReader.addLine('I/flutter : Observatory listening on http://[::1]:54777/PTwjm8Ii8qg=/\x1b[');
final Uri uri = await nextUri;
expect(uri.port, 54777);
expect('$uri', 'http://[::1]:54777/PTwjm8Ii8qg=/');
discoverer.cancel();
logReader.dispose();
});
}); });
}); });
} }
...@@ -207,8 +229,9 @@ class MockPortForwarder extends DevicePortForwarder { ...@@ -207,8 +229,9 @@ class MockPortForwarder extends DevicePortForwarder {
@override @override
Future<int> forward(int devicePort, {int hostPort}) async { Future<int> forward(int devicePort, {int hostPort}) async {
hostPort ??= 0; hostPort ??= 0;
if (hostPort == 0) if (hostPort == 0) {
return availablePort; return availablePort;
}
return hostPort; return hostPort;
} }
......
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