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

Unified Diff: tests/lib_strong/async/slow_consumer2_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_strong/async/slow_consumer2_test.dart
diff --git a/tests/lib_strong/async/slow_consumer2_test.dart b/tests/lib_strong/async/slow_consumer2_test.dart
index f631a77a441862bc45973ea239be97b4c727e5af..460c9209ef7cf16f711e2d2b51266b043a3bf30d 100644
--- a/tests/lib_strong/async/slow_consumer2_test.dart
+++ b/tests/lib_strong/async/slow_consumer2_test.dart
@@ -31,29 +31,27 @@ class SlowConsumer extends StreamConsumer {
Future addStream(Stream stream) {
Completer result = new Completer();
var subscription;
- subscription = stream.listen(
- (List<int> data) {
- receivedCount += data.length;
- usedBufferSize += data.length;
- bufferedData.add(data);
- int currentBufferedDataLength = bufferedData.length;
- if (usedBufferSize > bufferSize) {
- subscription.pause();
- usedBufferSize = 0;
- int ms = data.length * 1000 ~/ bytesPerSecond;
- Duration duration = new Duration(milliseconds: ms);
- new Timer(duration, () {
- for (int i = 0; i < currentBufferedDataLength; i++) {
- bufferedData[i] = null;
- }
- subscription.resume();
- });
- }
- },
- onDone: () {
- finalCount = receivedCount;
- result.complete(receivedCount);
- });
+ subscription = stream.listen((List<int> data) {
+ receivedCount += data.length;
+ usedBufferSize += data.length;
+ bufferedData.add(data);
+ int currentBufferedDataLength = bufferedData.length;
+ if (usedBufferSize > bufferSize) {
+ subscription.pause();
+ usedBufferSize = 0;
+ int ms = data.length * 1000 ~/ bytesPerSecond;
+ Duration duration = new Duration(milliseconds: ms);
+ new Timer(duration, () {
+ for (int i = 0; i < currentBufferedDataLength; i++) {
+ bufferedData[i] = null;
+ }
+ subscription.resume();
+ });
+ }
+ }, onDone: () {
+ finalCount = receivedCount;
+ result.complete(receivedCount);
+ });
return result.future;
}
@@ -71,9 +69,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);
}
@@ -115,10 +111,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, 5 * MB))
- .then((count) {
- Expect.equals(100 * MB, count);
- asyncEnd();
- });
+ new DataProvider(800 * MB, 100 * MB, 1 * MB)
+ .stream
+ .pipe(new SlowConsumer(200 * MB, 5 * MB))
+ .then((count) {
+ Expect.equals(100 * MB, count);
+ asyncEnd();
+ });
}

Powered by Google App Engine
This is Rietveld 408576698