Skip to content

Commit 90ca958

Browse files
authored
Rename "observatoryUri" to "vmServiceUri" for test.startedProcess (#8328)
This is due to the removal of Observatory support from Dart SDKs and Flutter which made the tests never unpause on recent versions of Flutter. This fixes #8233. The URI pointing to Observatory is no longer given in `test.startedProcess`. Now, the URI to the VM Service for DevTools is present and can be used as a drop-in replacement to achieve the same functionality.
1 parent 79cbfe1 commit 90ca958

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

flutter-idea/src/io/flutter/run/test/FlutterTestEventsConverter.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,19 @@ private static JsonElement getValue(@NotNull JsonElement element, @NotNull Strin
5454

5555
@Override
5656
protected boolean process(@NotNull JsonArray array) {
57-
// Consume (and don't print) observatoryUri output, e.g.,
58-
// [{"event":"test.startedProcess","params":{"observatoryUri":"http://127.0.0.1:51770/"}}]
57+
// Consume (and don't print) observatoryUri/vmServiceUri output, e.g.,
58+
// [{"event":"test.startedProcess","params":{"vmServiceUri":"http://127.0.0.1:62047/VFPfi0PrluM=/"}}]
59+
// [{"event":"test.startedProcess","params":{"observatoryUri":"http://127.0.0.1:51770/"}}] (deprecated)
60+
// Both fields may be present on Flutter versions older than 3.34.
5961
if (array.size() == 1) {
6062
final JsonElement element = array.get(0);
6163
final JsonElement event = getValue(element, "event");
6264
if (event != null) {
6365
if (Objects.equals(event.getAsString(), "test.startedProcess")) {
6466
final JsonElement params = getValue(element, "params");
6567
if (params != null) {
66-
final JsonElement uri = getValue(params, "observatoryUri");
67-
return uri != null;
68+
return getValue(params, "vmServiceUri") != null
69+
|| getValue(params, "observatoryUri") != null;
6870
}
6971
}
7072
}

flutter-idea/src/io/flutter/run/test/FlutterTestRunner.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,20 @@ private void dispatchJson(String json) {
323323
}
324324

325325
if (eventName.equals("test.startedProcess")) {
326-
final JsonPrimitive primUri = params.getAsJsonPrimitive("observatoryUri");
327-
if (primUri != null) {
328-
observatoryUri = primUri.getAsString();
326+
// Since Flutter release 3.34, "observatoryUri" is no longer available due to the removal of
327+
// Observatory in favor of DevTools/VM Service.
328+
// Since then, only the field "vmServiceUri" is given in this event (contrary to both fields
329+
// on earlier versions).
330+
final JsonPrimitive primVmServiceUri = params.getAsJsonPrimitive("vmServiceUri");
331+
332+
if (primVmServiceUri != null) {
333+
observatoryUri = primVmServiceUri.getAsString();
334+
} else {
335+
final JsonPrimitive primObservatoryUri = params.getAsJsonPrimitive("observatoryUri");
336+
337+
if (primObservatoryUri != null) {
338+
observatoryUri = primObservatoryUri.getAsString();
339+
}
329340
}
330341
}
331342
}

0 commit comments

Comments
 (0)