Index: tests/lib/async/stream_state_helper.dart |
diff --git a/tests/lib/async/stream_state_helper.dart b/tests/lib/async/stream_state_helper.dart |
index b982d9d23be4e82fd13fec277e913907f31fbeac..a2881fe9b3aa0adacd7ed6f4683bd544bc184a70 100644 |
--- a/tests/lib/async/stream_state_helper.dart |
+++ b/tests/lib/async/stream_state_helper.dart |
@@ -10,21 +10,21 @@ import "dart:collection"; |
class StreamProtocolTest { |
StreamController _controller; |
+ Stream _controllerStream; |
StreamSubscription _subscription; |
List<Event> _expectations = new List<Event>(); |
int _nextExpectationIndex = 0; |
Function _onComplete; |
StreamProtocolTest([bool broadcast = false]) { |
+ _controller = new StreamController( |
+ onPauseStateChange: _onPause, |
+ onSubscriptionStateChange: _onSubcription); |
+ // TODO(lrn): Make it work with multiple subscribers too. |
if (broadcast) { |
- _controller = new StreamController.broadcast( |
- onPauseStateChange: _onPause, |
- onSubscriptionStateChange: _onSubcription); |
- // TODO(lrn): Make it work with multiple subscribers too. |
+ _controllerStream = _controller.stream.asBroadcastStream(); |
} else { |
- _controller = new StreamController( |
- onPauseStateChange: _onPause, |
- onSubscriptionStateChange: _onSubcription); |
+ _controllerStream = _controller.stream; |
} |
_onComplete = expectAsync0((){ |
_onComplete = null; // Being null marks the test to be complete. |
@@ -40,11 +40,11 @@ class StreamProtocolTest { |
// TODO(lrn): Handle more subscriptions (e.g., a subscription-id |
// per subscription, and an id on event _expectations). |
if (_subscription != null) throw new StateError("Already subscribed"); |
- _subscription = _controller.stream.listen(_onData, |
- onError: _onError, |
- onDone: _onDone, |
- unsubscribeOnError: |
- unsubscribeOnError); |
+ _subscription = _controllerStream.listen(_onData, |
+ onError: _onError, |
+ onDone: _onDone, |
+ unsubscribeOnError: |
+ unsubscribeOnError); |
} |
void pause([Future resumeSignal]) { |