Ensure to close connection to VM after collecting coverage (#50943)

This commit is contained in:
Martin Kustermann
2020-02-18 21:39:37 +01:00
committed by GitHub
parent 11589ca20d
commit d2947571bd
3 changed files with 17 additions and 5 deletions

View File

@@ -33,13 +33,11 @@ class MockPeer implements rpc.Peer {
}
@override
bool get isClosed {
throw 'unexpected call to isClosed';
}
bool get isClosed => _isClosed;
@override
Future<dynamic> close() async {
throw 'unexpected call to close()';
_isClosed = true;
}
@override
@@ -70,6 +68,7 @@ class MockPeer implements rpc.Peer {
List<String> registeredMethods = <String>[];
bool isolatesEnabled = false;
bool _isClosed = false;
Future<void> _getVMLatch;
Completer<void> _currentGetVMLatchCompleter;
@@ -213,6 +212,14 @@ void main() {
WebSocketConnector: () => (String url, {CompressionOptions compression}) async => throw const SocketException('test'),
});
testUsingContext('closing VMService closes Peer', () async {
final MockPeer mockPeer = MockPeer();
final VMService vmService = VMService(mockPeer, null, null, null, null, null, MockDevice(), null);
expect(mockPeer.isClosed, equals(false));
await vmService.close();
expect(mockPeer.isClosed, equals(true));
});
testUsingContext('refreshViews', () {
FakeAsync().run((FakeAsync time) {
bool done = false;