mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Register flutterVersion service in flutter_tools. (#39524)
* Register getFlutterVersion service in flutter_tools. * Add short revision ids to response. * Rename method and remove obsolete comments. * Fix broken test by adding sendPeerNotifications flag. * Implement mockPeer.sendNotification.
This commit is contained in:
parent
57e6042f68
commit
d50d9c5e60
@ -20,6 +20,7 @@ import 'base/io.dart' as io;
|
|||||||
import 'base/utils.dart';
|
import 'base/utils.dart';
|
||||||
import 'convert.dart' show base64;
|
import 'convert.dart' show base64;
|
||||||
import 'globals.dart';
|
import 'globals.dart';
|
||||||
|
import 'version.dart';
|
||||||
import 'vmservice_record_replay.dart';
|
import 'vmservice_record_replay.dart';
|
||||||
|
|
||||||
/// Override `WebSocketConnector` in [context] to use a different constructor
|
/// Override `WebSocketConnector` in [context] to use a different constructor
|
||||||
@ -138,8 +139,6 @@ class VMService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// If the Flutter Engine doesn't support service registration this will
|
|
||||||
// have no effect
|
|
||||||
_peer.sendNotification('registerService', <String, String>{
|
_peer.sendNotification('registerService', <String, String>{
|
||||||
'service': 'reloadSources',
|
'service': 'reloadSources',
|
||||||
'alias': 'Flutter Tools',
|
'alias': 'Flutter Tools',
|
||||||
@ -164,14 +163,25 @@ class VMService {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// If the Flutter Engine doesn't support service registration this will
|
|
||||||
// have no effect
|
|
||||||
_peer.sendNotification('registerService', <String, String>{
|
_peer.sendNotification('registerService', <String, String>{
|
||||||
'service': 'hotRestart',
|
'service': 'hotRestart',
|
||||||
'alias': 'Flutter Tools',
|
'alias': 'Flutter Tools',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_peer.registerMethod('flutterVersion', (rpc.Parameters params) async {
|
||||||
|
final FlutterVersion version = FlutterVersion();
|
||||||
|
final Map<String, Object> versionJson = version.toJson();
|
||||||
|
versionJson['frameworkRevisionShort'] = version.frameworkRevisionShort;
|
||||||
|
versionJson['engineRevisionShort'] = version.engineRevisionShort;
|
||||||
|
return versionJson;
|
||||||
|
});
|
||||||
|
|
||||||
|
_peer.sendNotification('registerService', <String, String>{
|
||||||
|
'service': 'flutterVersion',
|
||||||
|
'alias': 'Flutter Tools',
|
||||||
|
});
|
||||||
|
|
||||||
if (compileExpression != null) {
|
if (compileExpression != null) {
|
||||||
_peer.registerMethod('compileExpression', (rpc.Parameters params) async {
|
_peer.registerMethod('compileExpression', (rpc.Parameters params) async {
|
||||||
final String isolateId = params['isolateId'].asString;
|
final String isolateId = params['isolateId'].asString;
|
||||||
|
@ -52,9 +52,12 @@ class MockPeer implements rpc.Peer {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void sendNotification(String method, [ dynamic parameters ]) {
|
void sendNotification(String method, [ dynamic parameters ]) {
|
||||||
throw 'unexpected call to sendNotification';
|
// this does get called
|
||||||
|
sentNotifications.putIfAbsent(method, () => <dynamic>[]).add(parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Map<String, List<dynamic>> sentNotifications = <String, List<dynamic>>{};
|
||||||
|
|
||||||
bool isolatesEnabled = false;
|
bool isolatesEnabled = false;
|
||||||
|
|
||||||
Future<void> _getVMLatch;
|
Future<void> _getVMLatch;
|
||||||
@ -192,6 +195,12 @@ void main() {
|
|||||||
final MockPeer mockPeer = MockPeer();
|
final MockPeer mockPeer = MockPeer();
|
||||||
expect(mockPeer.returnedFromSendRequest, 0);
|
expect(mockPeer.returnedFromSendRequest, 0);
|
||||||
final VMService vmService = VMService(mockPeer, null, null, null, null, null);
|
final VMService vmService = VMService(mockPeer, null, null, null, null, null);
|
||||||
|
expect(mockPeer.sentNotifications, contains('registerService'));
|
||||||
|
final List<String> registeredServices =
|
||||||
|
mockPeer.sentNotifications['registerService']
|
||||||
|
.map((dynamic service) => (service as Map<String, String>)['service'])
|
||||||
|
.toList();
|
||||||
|
expect(registeredServices, contains('flutterVersion'));
|
||||||
vmService.getVM().then((void value) { done = true; });
|
vmService.getVM().then((void value) { done = true; });
|
||||||
expect(done, isFalse);
|
expect(done, isFalse);
|
||||||
expect(mockPeer.returnedFromSendRequest, 0);
|
expect(mockPeer.returnedFromSendRequest, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user