| Index: tests/lib/async/slow_consumer_test.dart
|
| diff --git a/tests/lib/async/slow_consumer_test.dart b/tests/lib/async/slow_consumer_test.dart
|
| index 8fd6d8feed3ea9bc38a44405ecb786fb8da74dc4..9cd3b9404ebbe91226962e3c41269c3626b9b41d 100644
|
| --- a/tests/lib/async/slow_consumer_test.dart
|
| +++ b/tests/lib/async/slow_consumer_test.dart
|
| @@ -29,28 +29,25 @@ class SlowConsumer extends StreamConsumer {
|
| bool done = false;
|
| Completer completer = new Completer();
|
| var subscription;
|
| - subscription = stream.listen(
|
| - (List<int> data) {
|
| - current = current
|
| - .then((count) {
|
| - // Simulated amount of time it takes to handle the data.
|
| - int ms = data.length * 1000 ~/ bytesPerSecond;
|
| - Duration duration = new Duration(milliseconds: ms);
|
| - if (!done) subscription.pause();
|
| - return new Future.delayed(duration, () {
|
| - if (!done) subscription.resume();
|
| - // Make sure we use data here to keep tracking it.
|
| - return count + data.length;
|
| - });
|
| - });
|
| - },
|
| - onDone: () {
|
| - done = true;
|
| - current.then((count) {
|
| - finalCount = count;
|
| - completer.complete(count);
|
| + subscription = stream.listen((List<int> data) {
|
| + current = current.then((count) {
|
| + // Simulated amount of time it takes to handle the data.
|
| + int ms = data.length * 1000 ~/ bytesPerSecond;
|
| + Duration duration = new Duration(milliseconds: ms);
|
| + if (!done) subscription.pause();
|
| + return new Future.delayed(duration, () {
|
| + if (!done) subscription.resume();
|
| + // Make sure we use data here to keep tracking it.
|
| + return count + data.length;
|
| });
|
| });
|
| + }, onDone: () {
|
| + done = true;
|
| + current.then((count) {
|
| + finalCount = count;
|
| + completer.complete(count);
|
| + });
|
| + });
|
| return completer.future;
|
| }
|
|
|
| @@ -69,9 +66,7 @@ class DataProvider {
|
|
|
| DataProvider(int this.bytesPerSecond, int this.targetCount, this.chunkSize) {
|
| controller = new StreamController(
|
| - sync: true,
|
| - onPause: onPauseStateChange,
|
| - onResume: onPauseStateChange);
|
| + sync: true, onPause: onPauseStateChange, onResume: onPauseStateChange);
|
| Timer.run(send);
|
| }
|
|
|
| @@ -118,10 +113,11 @@ main() {
|
| // file). If the consumer doesn't pause the data-provider it will run out of
|
| // heap-space.
|
|
|
| - new DataProvider(800 * MB, 100 * MB, 1 * MB).stream
|
| - .pipe(new SlowConsumer(200 * MB))
|
| - .then((count) {
|
| - Expect.equals(100 * MB, count);
|
| - asyncEnd();
|
| - });
|
| + new DataProvider(800 * MB, 100 * MB, 1 * MB)
|
| + .stream
|
| + .pipe(new SlowConsumer(200 * MB))
|
| + .then((count) {
|
| + Expect.equals(100 * MB, count);
|
| + asyncEnd();
|
| + });
|
| }
|
|
|