@@ -21,6 +21,7 @@ import '../convert.dart';
21
21
import '../device.dart' ;
22
22
import '../globals.dart' as globals;
23
23
import '../project.dart' ;
24
+ import '../resident_runner.dart' ;
24
25
import '../vmservice.dart' ;
25
26
26
27
import 'font_config_manager.dart' ;
@@ -72,6 +73,7 @@ class FlutterTesterTestDevice extends TestDevice {
72
73
73
74
Process ? _process;
74
75
HttpServer ? _server;
76
+ DevtoolsLauncher ? _devToolsLauncher;
75
77
76
78
/// Starts the device.
77
79
///
@@ -163,9 +165,11 @@ class FlutterTesterTestDevice extends TestDevice {
163
165
debuggingOptions.hostVmServicePort == detectedUri.port);
164
166
165
167
Uri ? forwardingUri;
168
+ DartDevelopmentService ? dds;
169
+
166
170
if (debuggingOptions.enableDds) {
167
171
logger.printTrace ('test $id : Starting Dart Development Service' );
168
- final DartDevelopmentService dds = await startDds (
172
+ dds = await startDds (
169
173
detectedUri,
170
174
uriConverter: uriConverter,
171
175
);
@@ -193,10 +197,10 @@ class FlutterTesterTestDevice extends TestDevice {
193
197
}));
194
198
195
199
if (debuggingOptions.startPaused && ! machine! ) {
196
- logger.printStatus ('The test process has been started. ' );
197
- logger. printStatus ( 'You can now connect to it using vmService. To connect, load the following Web site in your browser:' );
198
- logger.printStatus (' $ forwardingUri ' );
199
- logger.printStatus ('You should first set appropriate breakpoints, then resume the test in the debugger.' );
200
+ logger.printStatus ('The Dart VM service is listening on $ forwardingUri ' );
201
+ await _startDevTools (forwardingUri, dds );
202
+ logger.printStatus ('' );
203
+ logger.printStatus ('The test process has been started. Set any relevant breakpoints and then resume the test in the debugger.' );
200
204
}
201
205
_gotProcessVmServiceUri.complete (forwardingUri);
202
206
},
@@ -215,6 +219,9 @@ class FlutterTesterTestDevice extends TestDevice {
215
219
logger.printTrace ('test $id : Terminating flutter_tester process' );
216
220
_process? .kill (io.ProcessSignal .sigkill);
217
221
222
+ logger.printTrace ('test $id : Shutting down DevTools server' );
223
+ await _devToolsLauncher? .close ();
224
+
218
225
logger.printTrace ('test $id : Shutting down test harness socket server' );
219
226
await _server? .close (force: true );
220
227
await finished;
@@ -261,6 +268,29 @@ class FlutterTesterTestDevice extends TestDevice {
261
268
);
262
269
}
263
270
271
+ Future <void > _startDevTools (Uri forwardingUri, DartDevelopmentService ? dds) async {
272
+ _devToolsLauncher = DevtoolsLauncher .instance;
273
+ logger.printTrace ('test $id : Serving DevTools...' );
274
+ final DevToolsServerAddress ? devToolsServerAddress = await _devToolsLauncher? .serve ();
275
+
276
+ if (devToolsServerAddress == null ) {
277
+ logger.printTrace ('test $id : Failed to start DevTools' );
278
+ return ;
279
+ }
280
+ await _devToolsLauncher? .ready;
281
+ logger.printTrace ('test $id : DevTools is being served at ${devToolsServerAddress .uri }' );
282
+
283
+ // Notify the DDS instance that there's a DevTools instance available so it can correctly
284
+ // redirect DevTools related requests.
285
+ dds? .setExternalDevToolsUri (devToolsServerAddress.uri! );
286
+
287
+ final Uri devToolsUri = devToolsServerAddress.uri! .replace (
288
+ // Use query instead of queryParameters to avoid unnecessary encoding.
289
+ query: 'uri=$forwardingUri ' ,
290
+ );
291
+ logger.printStatus ('The Flutter DevTools debugger and profiler is available at: $devToolsUri ' );
292
+ }
293
+
264
294
/// Binds an [HttpServer] serving from `host` on `port` .
265
295
///
266
296
/// Only intended to be overridden in tests.
0 commit comments