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:
#### 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'
......
......@@ -896,14 +896,14 @@ class DevToolsDomain extends Domain {
DevtoolsLauncher _devtoolsLauncher;
Future<void> serve([ Map<String, dynamic> args ]) async {
Future<Map<String, dynamic>> serve([ Map<String, dynamic> args ]) async {
_devtoolsLauncher ??= DevtoolsLauncher.instance;
final HttpServer server = await _devtoolsLauncher.serve();
sendEvent('devtools.serve', <String, dynamic>{
return<String, dynamic>{
'host': server.address.host,
'port': server.port,
});
};
}
@override
......
......@@ -321,10 +321,10 @@ void main() {
when(mockDevToolsLauncher.serve()).thenAnswer((_) async => mockDevToolsServer);
commands.add(<String, dynamic>{'id': 0, 'method': 'devtools.serve'});
final Map<String, dynamic> response = await responses.stream.firstWhere(_isDevToolsEvent);
expect(response['params'], isNotEmpty);
expect(response['params']['host'], equals('127.0.0.1'));
expect(response['params']['port'], equals(1234));
final Map<String, dynamic> response = await responses.stream.firstWhere((Map<String, dynamic> response) => response['id'] == 0);
expect(response['result'], isNotEmpty);
expect(response['result']['host'], equals('127.0.0.1'));
expect(response['result']['port'], equals(1234));
await responses.close();
await commands.close();
}, overrides: <Type, Generator>{
......@@ -466,8 +466,6 @@ bool _notEvent(Map<String, dynamic> map) => map['event'] == null;
bool _isConnectedEvent(Map<String, dynamic> map) => map['event'] == 'daemon.connected';
bool _isDevToolsEvent(Map<String, dynamic> map) => map['event'] == 'devtools.serve';
class MockFuchsiaWorkflow extends FuchsiaWorkflow {
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