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

Unified Diff: test/isolate_channel_test.dart

Issue 1638183002: Add IsolateChannel.connect* constructors. (Closed) Base URL: git@github.com:dart-lang/stream_channel.git@master
Patch Set: Created 4 years, 11 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
« lib/src/isolate_channel.dart ('K') | « pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/isolate_channel_test.dart
diff --git a/test/isolate_channel_test.dart b/test/isolate_channel_test.dart
index 9e4fddc954989332717118b62866081f0041ff85..fa4d8d5325525112c4d82cb0a64ac54ffc16ddb9 100644
--- a/test/isolate_channel_test.dart
+++ b/test/isolate_channel_test.dart
@@ -123,4 +123,39 @@ void main() {
channel.sink.add(1);
});
});
+
+ group("connect constructors", () {
+ var connectPort;
+ setUp(() {
+ connectPort = new ReceivePort();
+ });
+
+ tearDown(() {
+ connectPort.close();
+ });
+
+ test("create a connected pair of channels", () {
+ var channel1 = new IsolateChannel.connectReceive(connectPort);
+ var channel2 = new IsolateChannel.connectSend(connectPort.sendPort);
+
+ channel1.sink.add(1);
+ channel1.sink.add(2);
+ channel1.sink.add(3);
+ expect(channel2.stream.take(3).toList(), completion(equals([1, 2, 3])));
+
+ channel2.sink.add(4);
+ channel2.sink.add(5);
+ channel2.sink.add(6);
+ expect(channel1.stream.take(3).toList(), completion(equals([4, 5, 6])));
+ });
+
+ test("the receiving channel produces an error if it gets the wrong message",
+ () {
+ var connectedChannel = new IsolateChannel.connectReceive(connectPort);
+ connectPort.sendPort.send("wrong value");
+
+ expect(connectedChannel.stream.toList(), throwsStateError);
+ expect(connectedChannel.sink.done, completes);
+ });
+ });
}
« lib/src/isolate_channel.dart ('K') | « pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698