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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 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
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();
+ });
}

Powered by Google App Engine
This is Rietveld 408576698