| Index: pkg/analysis_server/test/channel_test.dart
|
| diff --git a/pkg/analysis_server/test/channel_test.dart b/pkg/analysis_server/test/channel_test.dart
|
| index 3c31b8502b5cb90b31bb9519cca32998a559c5ec..95e9cc655a8b73d08fdf9dc1043aebba47523ca7 100644
|
| --- a/pkg/analysis_server/test/channel_test.dart
|
| +++ b/pkg/analysis_server/test/channel_test.dart
|
| @@ -28,6 +28,7 @@ main() {
|
| });
|
| group('ByteStreamClientChannel', () {
|
| setUp(ByteStreamClientChannelTest.setUp);
|
| + test('close', ByteStreamClientChannelTest.close);
|
| test('listen_notification', ByteStreamClientChannelTest.listen_notification);
|
| test('listen_response', ByteStreamClientChannelTest.listen_response);
|
| test('sendRequest', ByteStreamClientChannelTest.sendRequest);
|
| @@ -184,11 +185,16 @@ class ByteStreamClientChannelTest {
|
|
|
| /**
|
| * Sink that may be used to deliver data to the channel, as though it's
|
| - * coming from the client.
|
| + * coming from the server.
|
| */
|
| static IOSink inputSink;
|
|
|
| /**
|
| + * Sink through which the channel delivers data to the server.
|
| + */
|
| + static IOSink outputSink;
|
| +
|
| + /**
|
| * Stream of lines sent back to the client by the channel.
|
| */
|
| static Stream<String> outputLineStream;
|
| @@ -199,10 +205,27 @@ class ByteStreamClientChannelTest {
|
| var outputStream = new StreamController<List<int>>();
|
| outputLineStream = outputStream.stream.transform((new Utf8Codec()).decoder
|
| ).transform(new LineSplitter());
|
| - var outputSink = new IOSink(outputStream);
|
| + outputSink = new IOSink(outputStream);
|
| channel = new ByteStreamClientChannel(inputStream.stream, outputSink);
|
| }
|
|
|
| + static Future close() {
|
| + bool doneCalled = false;
|
| + bool closeCalled = false;
|
| + // add listener so that outputSink will trigger done/close futures
|
| + outputLineStream.listen((_) { /* no-op */ });
|
| + outputSink.done.then((_) {
|
| + doneCalled = true;
|
| + });
|
| + channel.close().then((_) {
|
| + closeCalled = true;
|
| + });
|
| + return pumpEventQueue().then((_) {
|
| + expect(doneCalled, isTrue);
|
| + expect(closeCalled, isTrue);
|
| + });
|
| + }
|
| +
|
| static Future listen_notification() {
|
| List<Notification> notifications = [];
|
| channel.notificationStream.forEach((n) => notifications.add(n));
|
|
|