Unverified Commit 5ce7282a authored by Helin Shiah's avatar Helin Shiah Committed by GitHub

Return devtools serve response instead of printing (#62702)

parent 52299fa3
...@@ -256,7 +256,7 @@ The returned `params` will contain: ...@@ -256,7 +256,7 @@ The returned `params` will contain:
#### devtools.serve #### devtools.serve
The `serve()` command starts a DevTools server if one isn't already running and prints out the host and port of the server. The `serve()` command starts a DevTools server if one isn't already running and returns the host and port of the server.
## 'flutter run --machine' and 'flutter attach --machine' ## 'flutter run --machine' and 'flutter attach --machine'
......
...@@ -896,14 +896,14 @@ class DevToolsDomain extends Domain { ...@@ -896,14 +896,14 @@ class DevToolsDomain extends Domain {
DevtoolsLauncher _devtoolsLauncher; DevtoolsLauncher _devtoolsLauncher;
Future<void> serve([ Map<String, dynamic> args ]) async { Future<Map<String, dynamic>> serve([ Map<String, dynamic> args ]) async {
_devtoolsLauncher ??= DevtoolsLauncher.instance; _devtoolsLauncher ??= DevtoolsLauncher.instance;
final HttpServer server = await _devtoolsLauncher.serve(); final HttpServer server = await _devtoolsLauncher.serve();
sendEvent('devtools.serve', <String, dynamic>{ return<String, dynamic>{
'host': server.address.host, 'host': server.address.host,
'port': server.port, 'port': server.port,
}); };
} }
@override @override
......
...@@ -321,10 +321,10 @@ void main() { ...@@ -321,10 +321,10 @@ void main() {
when(mockDevToolsLauncher.serve()).thenAnswer((_) async => mockDevToolsServer); when(mockDevToolsLauncher.serve()).thenAnswer((_) async => mockDevToolsServer);
commands.add(<String, dynamic>{'id': 0, 'method': 'devtools.serve'}); commands.add(<String, dynamic>{'id': 0, 'method': 'devtools.serve'});
final Map<String, dynamic> response = await responses.stream.firstWhere(_isDevToolsEvent); final Map<String, dynamic> response = await responses.stream.firstWhere((Map<String, dynamic> response) => response['id'] == 0);
expect(response['params'], isNotEmpty); expect(response['result'], isNotEmpty);
expect(response['params']['host'], equals('127.0.0.1')); expect(response['result']['host'], equals('127.0.0.1'));
expect(response['params']['port'], equals(1234)); expect(response['result']['port'], equals(1234));
await responses.close(); await responses.close();
await commands.close(); await commands.close();
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
...@@ -466,8 +466,6 @@ bool _notEvent(Map<String, dynamic> map) => map['event'] == null; ...@@ -466,8 +466,6 @@ bool _notEvent(Map<String, dynamic> map) => map['event'] == null;
bool _isConnectedEvent(Map<String, dynamic> map) => map['event'] == 'daemon.connected'; bool _isConnectedEvent(Map<String, dynamic> map) => map['event'] == 'daemon.connected';
bool _isDevToolsEvent(Map<String, dynamic> map) => map['event'] == 'devtools.serve';
class MockFuchsiaWorkflow extends FuchsiaWorkflow { class MockFuchsiaWorkflow extends FuchsiaWorkflow {
MockFuchsiaWorkflow({ this.canListDevices = true }); MockFuchsiaWorkflow({ this.canListDevices = true });
......
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