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

Side by Side Diff: tests/lib/async/stream_controller_test.dart

Issue 12610006: Renamed StreamSink to EventSink. Renamed signalError to addError. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Changed inheritance back! Now create StreamSink instead of EventSink where we create them. Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 // Test the basic StreamController and StreamController.singleSubscription. 5 // Test the basic StreamController and StreamController.singleSubscription.
6 library stream_controller_test; 6 library stream_controller_test;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'event_helper.dart'; 9 import 'event_helper.dart';
10 10
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 sentEvents.replay(c); 87 sentEvents.replay(c);
88 Expect.listEquals(expectedEvents.events, actualEvents.events); 88 Expect.listEquals(expectedEvents.events, actualEvents.events);
89 89
90 // Test transform. 90 // Test transform.
91 c = new StreamController.broadcast(); 91 c = new StreamController.broadcast();
92 sentEvents = new Events()..add("a")..error(42)..add("b")..close(); 92 sentEvents = new Events()..add("a")..error(42)..add("b")..close();
93 expectedEvents = 93 expectedEvents =
94 new Events()..error("a")..add(42)..error("b")..add("foo")..close(); 94 new Events()..error("a")..add(42)..error("b")..add("foo")..close();
95 actualEvents = new Events.capture(c.stream.transform( 95 actualEvents = new Events.capture(c.stream.transform(
96 new StreamTransformer( 96 new StreamTransformer(
97 handleData: (v, s) { s.signalError(new AsyncError(v)); }, 97 handleData: (v, s) { s.addError(new AsyncError(v)); },
98 handleError: (e, s) { s.add(e.error); }, 98 handleError: (e, s) { s.add(e.error); },
99 handleDone: (s) { 99 handleDone: (s) {
100 s.add("foo"); 100 s.add("foo");
101 s.close(); 101 s.close();
102 }))); 102 })));
103 sentEvents.replay(c); 103 sentEvents.replay(c);
104 Expect.listEquals(expectedEvents.events, actualEvents.events); 104 Expect.listEquals(expectedEvents.events, actualEvents.events);
105 105
106 // Test multiple filters. 106 // Test multiple filters.
107 c = new StreamController.broadcast(); 107 c = new StreamController.broadcast();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 sentEvents.replay(c); 276 sentEvents.replay(c);
277 } 277 }
278 278
279 // Test transform. 279 // Test transform.
280 c = new StreamController(); 280 c = new StreamController();
281 sentEvents = new Events()..add("a")..error(42)..add("b")..close(); 281 sentEvents = new Events()..add("a")..error(42)..add("b")..close();
282 expectedEvents = 282 expectedEvents =
283 new Events()..error("a")..add(42)..error("b")..add("foo")..close(); 283 new Events()..error("a")..add(42)..error("b")..add("foo")..close();
284 actualEvents = new Events.capture(c.stream.transform( 284 actualEvents = new Events.capture(c.stream.transform(
285 new StreamTransformer( 285 new StreamTransformer(
286 handleData: (v, s) { s.signalError(new AsyncError(v)); }, 286 handleData: (v, s) { s.addError(new AsyncError(v)); },
287 handleError: (e, s) { s.add(e.error); }, 287 handleError: (e, s) { s.add(e.error); },
288 handleDone: (s) { 288 handleDone: (s) {
289 s.add("foo"); 289 s.add("foo");
290 s.close(); 290 s.close();
291 }))); 291 })));
292 sentEvents.replay(c); 292 sentEvents.replay(c);
293 Expect.listEquals(expectedEvents.events, actualEvents.events); 293 Expect.listEquals(expectedEvents.events, actualEvents.events);
294 294
295 // Test multiple filters. 295 // Test multiple filters.
296 c = new StreamController(); 296 c = new StreamController();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 sentEvents.replay(c); 391 sentEvents.replay(c);
392 Expect.listEquals(expectedEvents.events, actualEvents.events); 392 Expect.listEquals(expectedEvents.events, actualEvents.events);
393 } 393 }
394 394
395 testClosed() { 395 testClosed() {
396 for (StreamController c in [new StreamController(), 396 for (StreamController c in [new StreamController(),
397 new StreamController.broadcast()]) { 397 new StreamController.broadcast()]) {
398 Expect.isFalse(c.isClosed); 398 Expect.isFalse(c.isClosed);
399 c.add(42); 399 c.add(42);
400 Expect.isFalse(c.isClosed); 400 Expect.isFalse(c.isClosed);
401 c.signalError("bad"); 401 c.addError("bad");
402 Expect.isFalse(c.isClosed); 402 Expect.isFalse(c.isClosed);
403 c.close(); 403 c.close();
404 Expect.isTrue(c.isClosed); 404 Expect.isTrue(c.isClosed);
405 } 405 }
406 } 406 }
407 407
408 main() { 408 main() {
409 testMultiController(); 409 testMultiController();
410 testSingleController(); 410 testSingleController();
411 testExtraMethods(); 411 testExtraMethods();
412 testClosed(); 412 testClosed();
413 } 413 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698