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

Side by Side 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 unified diff | Download patch
« lib/src/isolate_channel.dart ('K') | « pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:isolate'; 6 import 'dart:isolate';
7 7
8 import 'package:stream_channel/stream_channel.dart'; 8 import 'package:stream_channel/stream_channel.dart';
9 import 'package:test/test.dart'; 9 import 'package:test/test.dart';
10 10
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 controller.addError("oh no"); 116 controller.addError("oh no");
117 expect(channel.sink.done, throwsA("oh no")); 117 expect(channel.sink.done, throwsA("oh no"));
118 await pumpEventQueue(); 118 await pumpEventQueue();
119 expect(canceled, isTrue); 119 expect(canceled, isTrue);
120 120
121 // Even though the sink is closed, this shouldn't throw an error because 121 // Even though the sink is closed, this shouldn't throw an error because
122 // the user didn't explicitly close it. 122 // the user didn't explicitly close it.
123 channel.sink.add(1); 123 channel.sink.add(1);
124 }); 124 });
125 }); 125 });
126
127 group("connect constructors", () {
128 var connectPort;
129 setUp(() {
130 connectPort = new ReceivePort();
131 });
132
133 tearDown(() {
134 connectPort.close();
135 });
136
137 test("create a connected pair of channels", () {
138 var channel1 = new IsolateChannel.connectReceive(connectPort);
139 var channel2 = new IsolateChannel.connectSend(connectPort.sendPort);
140
141 channel1.sink.add(1);
142 channel1.sink.add(2);
143 channel1.sink.add(3);
144 expect(channel2.stream.take(3).toList(), completion(equals([1, 2, 3])));
145
146 channel2.sink.add(4);
147 channel2.sink.add(5);
148 channel2.sink.add(6);
149 expect(channel1.stream.take(3).toList(), completion(equals([4, 5, 6])));
150 });
151
152 test("the receiving channel produces an error if it gets the wrong message",
153 () {
154 var connectedChannel = new IsolateChannel.connectReceive(connectPort);
155 connectPort.sendPort.send("wrong value");
156
157 expect(connectedChannel.stream.toList(), throwsStateError);
158 expect(connectedChannel.sink.done, completes);
159 });
160 });
126 } 161 }
OLDNEW
« 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