Unverified Commit 1459b1e9 authored by Ben Konyi's avatar Ben Konyi Committed by GitHub

Fixed failing tests caused by introduction of authentication codes (#31315)

parent eaf058d8
...@@ -43,10 +43,11 @@ void main() { ...@@ -43,10 +43,11 @@ void main() {
await device.shellExec('am', <String>['start', '-n', _kActivityId]); await device.shellExec('am', <String>['start', '-n', _kActivityId]);
final String observatoryLine = await device.adb(<String>['logcat', '-e', 'Observatory listening on http:', '-m', '1', '-T', currentTime]); final String observatoryLine = await device.adb(<String>['logcat', '-e', 'Observatory listening on http:', '-m', '1', '-T', currentTime]);
print('Found observatory line: $observatoryLine'); print('Found observatory line: $observatoryLine');
final String observatoryPort = RegExp(r'Observatory listening on http://.*:([0-9]+)').firstMatch(observatoryLine)[1]; final String observatoryUri = RegExp('Observatory listening on ((http|\/\/)[a-zA-Z0-9:/=_\\-\.\\[\\]]+)').firstMatch(observatoryLine)[1];
print('Extracted observatory port: $observatoryPort'); print('Extracted observatory port: $observatoryUri');
final Process attachProcess = final Process attachProcess =
await _run(device: device, command: <String>['attach', '--debug-port', observatoryPort, '--isolate-filter', '$_kSecondIsolateName'], stdoutListener: (String line) { await _run(device: device, command: <String>['attach', '--debug-uri',
observatoryUri, '--isolate-filter', '$_kSecondIsolateName'], stdoutListener: (String line) {
if (line.contains(_kFirstIsolateName)) { if (line.contains(_kFirstIsolateName)) {
firstNameFound.complete(); firstNameFound.complete();
} else if (line.contains(_kSecondIsolateName)) { } else if (line.contains(_kSecondIsolateName)) {
......
...@@ -31,7 +31,7 @@ void main() { ...@@ -31,7 +31,7 @@ void main() {
} }
task(() async { task(() async {
int vmServicePort; Uri vmServiceUri;
String appId; String appId;
final Device device = await devices.workingDevice; final Device device = await devices.workingDevice;
...@@ -60,14 +60,14 @@ void main() { ...@@ -60,14 +60,14 @@ void main() {
final dynamic json = parseFlutterResponse(line); final dynamic json = parseFlutterResponse(line);
if (json != null) { if (json != null) {
if (json['event'] == 'app.debugPort') { if (json['event'] == 'app.debugPort') {
vmServicePort = Uri.parse(json['params']['wsUri']).port; vmServiceUri = Uri.parse(json['params']['wsUri']);
print('service protocol connection available at port $vmServicePort'); print('service protocol connection available at $vmServiceUri');
} else if (json['event'] == 'app.started') { } else if (json['event'] == 'app.started') {
appId = json['params']['appId']; appId = json['params']['appId'];
print('application identifier is $appId'); print('application identifier is $appId');
} }
} }
if (vmServicePort != null && appId != null && !ready.isCompleted) { if (vmServiceUri != null && appId != null && !ready.isCompleted) {
print('run: ready!'); print('run: ready!');
ready.complete(); ready.complete();
ok ??= true; ok ??= true;
...@@ -84,9 +84,7 @@ void main() { ...@@ -84,9 +84,7 @@ void main() {
if (!ok) if (!ok)
throw 'Failed to run test app.'; throw 'Failed to run test app.';
final VMServiceClient client = VMServiceClient.connect( final VMServiceClient client = VMServiceClient.connect(vmServiceUri);
'ws://localhost:$vmServicePort/ws'
);
int id = 1; int id = 1;
Future<Map<String, dynamic>> sendRequest(String method, dynamic params) async { Future<Map<String, dynamic>> sendRequest(String method, dynamic params) async {
......
...@@ -81,7 +81,7 @@ void main() { ...@@ -81,7 +81,7 @@ void main() {
final Future<VMExtensionEvent> navigationFuture = navigationEvents.first; final Future<VMExtensionEvent> navigationFuture = navigationEvents.first;
// This tap triggers a navigation event. // This tap triggers a navigation event.
device.tap(100, 100); device.tap(100, 200);
final VMExtensionEvent navigationEvent = await navigationFuture; final VMExtensionEvent navigationEvent = await navigationFuture;
// Validate that there are not any fields. // Validate that there are not any fields.
expect(navigationEvent.data.isEmpty); expect(navigationEvent.data.isEmpty);
......
...@@ -542,10 +542,11 @@ int parseServicePort(String line, { ...@@ -542,10 +542,11 @@ int parseServicePort(String line, {
Pattern prefix, Pattern prefix,
}) { }) {
prefix ??= _obsRegExp; prefix ??= _obsRegExp;
final Match prefixMatch = prefix.matchAsPrefix(line); final Iterable<Match> matchesIter = prefix.allMatches(line);
if (prefixMatch == null) { if (matchesIter.isEmpty) {
return null; return null;
} }
final Match prefixMatch = matchesIter.first;
final List<Match> matches = final List<Match> matches =
_obsPortRegExp.allMatches(line, prefixMatch.end).toList(); _obsPortRegExp.allMatches(line, prefixMatch.end).toList();
return matches.isEmpty ? null : int.parse(matches[0].group(2)); return matches.isEmpty ? null : int.parse(matches[0].group(2));
...@@ -559,10 +560,11 @@ Uri parseServiceUri(String line, { ...@@ -559,10 +560,11 @@ Uri parseServiceUri(String line, {
Pattern prefix, Pattern prefix,
}) { }) {
prefix ??= _obsRegExp; prefix ??= _obsRegExp;
final Match prefixMatch = prefix.matchAsPrefix(line); final Iterable<Match> matchesIter = prefix.allMatches(line);
if (prefixMatch == null) { if (matchesIter.isEmpty) {
return null; return null;
} }
final Match prefixMatch = matchesIter.first;
final List<Match> matches = final List<Match> matches =
_obsUriRegExp.allMatches(line, prefixMatch.end).toList(); _obsUriRegExp.allMatches(line, prefixMatch.end).toList();
return matches.isEmpty ? null : Uri.parse(matches[0].group(0)); return matches.isEmpty ? null : Uri.parse(matches[0].group(0));
......
...@@ -233,7 +233,7 @@ class AttachCommand extends FlutterCommand { ...@@ -233,7 +233,7 @@ class AttachCommand extends FlutterCommand {
} }
} else { } else {
observatoryUri = await _buildObservatoryUri(device, observatoryUri = await _buildObservatoryUri(device,
debugUri?.host ?? hostname, devicePort, debugUri?.path); debugUri?.host ?? hostname, devicePort ?? debugUri.port, debugUri?.path);
} }
try { try {
final bool useHot = getBuildInfo().isDebug; final bool useHot = getBuildInfo().isDebug;
......
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