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

Unified Diff: tests/lib/async/slow_consumer3_test.dart

Issue 13680002: StreamConsumer has an addStream and a close functions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/lib/async/slow_consumer2_test.dart ('k') | tests/lib/async/slow_consumer_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/slow_consumer3_test.dart
diff --git a/tests/lib/async/slow_consumer3_test.dart b/tests/lib/async/slow_consumer3_test.dart
index 6def12fd8b72993f45afec138064ac107afd2dff..8dde39919d18dacc7f38f142704ae91694f24612 100644
--- a/tests/lib/async/slow_consumer3_test.dart
+++ b/tests/lib/async/slow_consumer3_test.dart
@@ -19,10 +19,15 @@ class SlowConsumer extends StreamConsumer {
final int bufferSize;
final List bufferedData = [];
int usedBufferSize = 0;
+ int finalCount;
SlowConsumer(int this.bytesPerSecond, int this.bufferSize);
Future consume(Stream stream) {
+ return addStream(stream).then((_) => close());
+ }
+
+ Future addStream(Stream stream) {
Completer result = new Completer();
var subscription;
subscription = stream.listen(
@@ -44,9 +49,16 @@ class SlowConsumer extends StreamConsumer {
});
}
},
- onDone: () { result.complete(receivedCount); });
+ onDone: () {
+ finalCount = receivedCount;
+ result.complete(receivedCount);
+ });
return result.future;
}
+
+ Future close() {
+ return new Future.immediate(finalCount);
+ }
}
Stream<List> dataGenerator(int bytesTotal, int chunkSize) {
« no previous file with comments | « tests/lib/async/slow_consumer2_test.dart ('k') | tests/lib/async/slow_consumer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698