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

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

Issue 14196003: Change StreamController constructor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments and rebase. Created 7 years, 8 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library stream_state_helper; 5 library stream_state_helper;
6 6
7 import "../../../pkg/unittest/lib/unittest.dart"; 7 import "../../../pkg/unittest/lib/unittest.dart";
8 import "dart:async"; 8 import "dart:async";
9 import "dart:collection"; 9 import "dart:collection";
10 10
11 class StreamProtocolTest { 11 class StreamProtocolTest {
12 StreamController _controller; 12 StreamController _controller;
13 StreamSubscription _subscription; 13 StreamSubscription _subscription;
14 List<Event> _expectations = new List<Event>(); 14 List<Event> _expectations = new List<Event>();
15 int _nextExpectationIndex = 0; 15 int _nextExpectationIndex = 0;
16 Function _onComplete; 16 Function _onComplete;
17 17
18 StreamProtocolTest([bool broadcast = false]) { 18 StreamProtocolTest([bool broadcast = false]) {
19 if (broadcast) { 19 if (broadcast) {
20 _controller = new StreamController.broadcast( 20 _controller = new StreamController.broadcast(
21 onPauseStateChange: _onPause, 21 onListen: _onSubcription,
22 onSubscriptionStateChange: _onSubcription); 22 onPause: _onPause,
23 onResume: _onPause,
24 onCancel: _onSubcription);
23 // TODO(lrn): Make it work with multiple subscribers too. 25 // TODO(lrn): Make it work with multiple subscribers too.
24 } else { 26 } else {
25 _controller = new StreamController( 27 _controller = new StreamController(
26 onPauseStateChange: _onPause, 28 onListen: _onSubcription,
27 onSubscriptionStateChange: _onSubcription); 29 onPause: _onPause,
30 onResume: _onPause,
31 onCancel: _onSubcription);
28 } 32 }
29 _onComplete = expectAsync0((){ 33 _onComplete = expectAsync0((){
30 _onComplete = null; // Being null marks the test to be complete. 34 _onComplete = null; // Being null marks the test to be complete.
31 }); 35 });
32 } 36 }
33 37
34 // Actions on the stream and controller. 38 // Actions on the stream and controller.
35 void add(var data) { _controller.add(data); } 39 void add(var data) { _controller.add(data); }
36 void error(var error) { _controller.addError(error); } 40 void error(var error) { _controller.addError(error); }
37 void close() { _controller.close(); } 41 void close() { _controller.close(); }
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 _actual = "*[Paused:${c.isPaused}]"; 286 _actual = "*[Paused:${c.isPaused}]";
283 return true; 287 return true;
284 } 288 }
285 bool _testSubcribe(StreamController c) { 289 bool _testSubcribe(StreamController c) {
286 _actual = "*[Has listener:${c.hasListener}, Paused:${c.isPaused}]"; 290 _actual = "*[Has listener:${c.hasListener}, Paused:${c.isPaused}]";
287 return true; 291 return true;
288 } 292 }
289 293
290 String toString() => _actual; 294 String toString() => _actual;
291 } 295 }
OLDNEW
« no previous file with comments | « tests/lib/async/slow_consumer_test.dart ('k') | tools/dom/templates/html/impl/impl_Geolocation.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698