Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Unified Diff: pkg/analysis_server/test/channel_test.dart

Issue 284353002: implement ByteStreamClientChannel close (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analysis_server/lib/src/channel.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
« no previous file with comments | « pkg/analysis_server/lib/src/channel.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698