From 1459b1e91fe425ce249fbef2c90b0162aa04bf63 Mon Sep 17 00:00:00 2001 From: Ben Konyi Date: Fri, 19 Apr 2019 11:45:53 -0700 Subject: [PATCH] Fixed failing tests caused by introduction of authentication codes (#31315) --- dev/devicelab/bin/tasks/named_isolates_test.dart | 7 ++++--- .../bin/tasks/run_machine_concurrent_hot_reload.dart | 12 +++++------- dev/devicelab/bin/tasks/service_extensions_test.dart | 2 +- dev/devicelab/lib/framework/utils.dart | 10 ++++++---- packages/flutter_tools/lib/src/commands/attach.dart | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/dev/devicelab/bin/tasks/named_isolates_test.dart b/dev/devicelab/bin/tasks/named_isolates_test.dart index 9ebe3b84a8..9fb6796271 100644 --- a/dev/devicelab/bin/tasks/named_isolates_test.dart +++ b/dev/devicelab/bin/tasks/named_isolates_test.dart @@ -43,10 +43,11 @@ void main() { await device.shellExec('am', ['start', '-n', _kActivityId]); final String observatoryLine = await device.adb(['logcat', '-e', 'Observatory listening on http:', '-m', '1', '-T', currentTime]); print('Found observatory line: $observatoryLine'); - final String observatoryPort = RegExp(r'Observatory listening on http://.*:([0-9]+)').firstMatch(observatoryLine)[1]; - print('Extracted observatory port: $observatoryPort'); + final String observatoryUri = RegExp('Observatory listening on ((http|\/\/)[a-zA-Z0-9:/=_\\-\.\\[\\]]+)').firstMatch(observatoryLine)[1]; + print('Extracted observatory port: $observatoryUri'); final Process attachProcess = - await _run(device: device, command: ['attach', '--debug-port', observatoryPort, '--isolate-filter', '$_kSecondIsolateName'], stdoutListener: (String line) { + await _run(device: device, command: ['attach', '--debug-uri', + observatoryUri, '--isolate-filter', '$_kSecondIsolateName'], stdoutListener: (String line) { if (line.contains(_kFirstIsolateName)) { firstNameFound.complete(); } else if (line.contains(_kSecondIsolateName)) { diff --git a/dev/devicelab/bin/tasks/run_machine_concurrent_hot_reload.dart b/dev/devicelab/bin/tasks/run_machine_concurrent_hot_reload.dart index 817fbad007..1b683cb660 100644 --- a/dev/devicelab/bin/tasks/run_machine_concurrent_hot_reload.dart +++ b/dev/devicelab/bin/tasks/run_machine_concurrent_hot_reload.dart @@ -31,7 +31,7 @@ void main() { } task(() async { - int vmServicePort; + Uri vmServiceUri; String appId; final Device device = await devices.workingDevice; @@ -60,14 +60,14 @@ void main() { final dynamic json = parseFlutterResponse(line); if (json != null) { if (json['event'] == 'app.debugPort') { - vmServicePort = Uri.parse(json['params']['wsUri']).port; - print('service protocol connection available at port $vmServicePort'); + vmServiceUri = Uri.parse(json['params']['wsUri']); + print('service protocol connection available at $vmServiceUri'); } else if (json['event'] == 'app.started') { appId = json['params']['appId']; print('application identifier is $appId'); } } - if (vmServicePort != null && appId != null && !ready.isCompleted) { + if (vmServiceUri != null && appId != null && !ready.isCompleted) { print('run: ready!'); ready.complete(); ok ??= true; @@ -84,9 +84,7 @@ void main() { if (!ok) throw 'Failed to run test app.'; - final VMServiceClient client = VMServiceClient.connect( - 'ws://localhost:$vmServicePort/ws' - ); + final VMServiceClient client = VMServiceClient.connect(vmServiceUri); int id = 1; Future> sendRequest(String method, dynamic params) async { diff --git a/dev/devicelab/bin/tasks/service_extensions_test.dart b/dev/devicelab/bin/tasks/service_extensions_test.dart index 728cc33332..ad44964fb2 100644 --- a/dev/devicelab/bin/tasks/service_extensions_test.dart +++ b/dev/devicelab/bin/tasks/service_extensions_test.dart @@ -81,7 +81,7 @@ void main() { final Future navigationFuture = navigationEvents.first; // This tap triggers a navigation event. - device.tap(100, 100); + device.tap(100, 200); final VMExtensionEvent navigationEvent = await navigationFuture; // Validate that there are not any fields. expect(navigationEvent.data.isEmpty); diff --git a/dev/devicelab/lib/framework/utils.dart b/dev/devicelab/lib/framework/utils.dart index 72067a8fd6..1b0f293702 100644 --- a/dev/devicelab/lib/framework/utils.dart +++ b/dev/devicelab/lib/framework/utils.dart @@ -542,10 +542,11 @@ int parseServicePort(String line, { Pattern prefix, }) { prefix ??= _obsRegExp; - final Match prefixMatch = prefix.matchAsPrefix(line); - if (prefixMatch == null) { + final Iterable matchesIter = prefix.allMatches(line); + if (matchesIter.isEmpty) { return null; } + final Match prefixMatch = matchesIter.first; final List matches = _obsPortRegExp.allMatches(line, prefixMatch.end).toList(); return matches.isEmpty ? null : int.parse(matches[0].group(2)); @@ -559,10 +560,11 @@ Uri parseServiceUri(String line, { Pattern prefix, }) { prefix ??= _obsRegExp; - final Match prefixMatch = prefix.matchAsPrefix(line); - if (prefixMatch == null) { + final Iterable matchesIter = prefix.allMatches(line); + if (matchesIter.isEmpty) { return null; } + final Match prefixMatch = matchesIter.first; final List matches = _obsUriRegExp.allMatches(line, prefixMatch.end).toList(); return matches.isEmpty ? null : Uri.parse(matches[0].group(0)); diff --git a/packages/flutter_tools/lib/src/commands/attach.dart b/packages/flutter_tools/lib/src/commands/attach.dart index 4703d971d7..4985d7c1ec 100644 --- a/packages/flutter_tools/lib/src/commands/attach.dart +++ b/packages/flutter_tools/lib/src/commands/attach.dart @@ -233,7 +233,7 @@ class AttachCommand extends FlutterCommand { } } else { observatoryUri = await _buildObservatoryUri(device, - debugUri?.host ?? hostname, devicePort, debugUri?.path); + debugUri?.host ?? hostname, devicePort ?? debugUri.port, debugUri?.path); } try { final bool useHot = getBuildInfo().isDebug;