@@ -21,6 +21,7 @@ import '../convert.dart';
2121import '../device.dart' ;
2222import '../globals.dart' as globals;
2323import '../project.dart' ;
24+ import '../resident_runner.dart' ;
2425import '../vmservice.dart' ;
2526
2627import 'font_config_manager.dart' ;
@@ -72,6 +73,7 @@ class FlutterTesterTestDevice extends TestDevice {
7273
7374 Process ? _process;
7475 HttpServer ? _server;
76+ DevtoolsLauncher ? _devToolsLauncher;
7577
7678 /// Starts the device.
7779 ///
@@ -163,9 +165,11 @@ class FlutterTesterTestDevice extends TestDevice {
163165 debuggingOptions.hostVmServicePort == detectedUri.port);
164166
165167 Uri ? forwardingUri;
168+ DartDevelopmentService ? dds;
169+
166170 if (debuggingOptions.enableDds) {
167171 logger.printTrace ('test $id : Starting Dart Development Service' );
168- final DartDevelopmentService dds = await startDds (
172+ dds = await startDds (
169173 detectedUri,
170174 uriConverter: uriConverter,
171175 );
@@ -193,10 +197,10 @@ class FlutterTesterTestDevice extends TestDevice {
193197 }));
194198
195199 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.' );
200204 }
201205 _gotProcessVmServiceUri.complete (forwardingUri);
202206 },
@@ -215,6 +219,9 @@ class FlutterTesterTestDevice extends TestDevice {
215219 logger.printTrace ('test $id : Terminating flutter_tester process' );
216220 _process? .kill (io.ProcessSignal .sigkill);
217221
222+ logger.printTrace ('test $id : Shutting down DevTools server' );
223+ await _devToolsLauncher? .close ();
224+
218225 logger.printTrace ('test $id : Shutting down test harness socket server' );
219226 await _server? .close (force: true );
220227 await finished;
@@ -261,6 +268,29 @@ class FlutterTesterTestDevice extends TestDevice {
261268 );
262269 }
263270
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+
264294 /// Binds an [HttpServer] serving from `host` on `port` .
265295 ///
266296 /// Only intended to be overridden in tests.
0 commit comments