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

Unified Diff: tests/lib/async/stream_state_helper.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/stream_state_helper.dart
diff --git a/tests/lib/async/stream_state_helper.dart b/tests/lib/async/stream_state_helper.dart
index 0ba61fc9e69aa060601c1c86c7ab0531cb773ad1..eda69b92cc8a635c65ee810a93552c5c61153828 100644
--- a/tests/lib/async/stream_state_helper.dart
+++ b/tests/lib/async/stream_state_helper.dart
@@ -57,20 +57,20 @@ class StreamProtocolTest {
int _subscriptionIdCounter = 0;
Function _onComplete;
- StreamProtocolTest.broadcast({ bool sync: false })
- : isBroadcast = true, isAsBroadcast = false {
+ StreamProtocolTest.broadcast({bool sync: false})
+ : isBroadcast = true,
+ isAsBroadcast = false {
_controller = new StreamController.broadcast(
- sync: sync,
- onListen: _onListen,
- onCancel: _onCancel);
+ sync: sync, onListen: _onListen, onCancel: _onCancel);
_controllerStream = _controller.stream;
- _onComplete = expectAsync((){
- _onComplete = null; // Being null marks the test as being complete.
+ _onComplete = expectAsync(() {
+ _onComplete = null; // Being null marks the test as being complete.
});
}
- StreamProtocolTest({ bool sync: false })
- : isBroadcast = false, isAsBroadcast = false {
+ StreamProtocolTest({bool sync: false})
+ : isBroadcast = false,
+ isAsBroadcast = false {
_controller = new StreamController(
sync: sync,
onListen: _onListen,
@@ -78,13 +78,14 @@ class StreamProtocolTest {
onResume: _onResume,
onCancel: _onCancel);
_controllerStream = _controller.stream;
- _onComplete = expectAsync((){
- _onComplete = null; // Being null marks the test as being complete.
+ _onComplete = expectAsync(() {
+ _onComplete = null; // Being null marks the test as being complete.
});
}
- StreamProtocolTest.asBroadcast({ bool sync: false })
- : isBroadcast = false, isAsBroadcast = true {
+ StreamProtocolTest.asBroadcast({bool sync: false})
+ : isBroadcast = false,
+ isAsBroadcast = true {
_controller = new StreamController(
sync: sync,
onListen: _onListen,
@@ -92,26 +93,35 @@ class StreamProtocolTest {
onResume: _onResume,
onCancel: _onCancel);
_controllerStream = _controller.stream.asBroadcastStream(
- onListen: _onBroadcastListen,
- onCancel: _onBroadcastCancel);
- _onComplete = expectAsync((){
- _onComplete = null; // Being null marks the test as being complete.
+ onListen: _onBroadcastListen, onCancel: _onBroadcastCancel);
+ _onComplete = expectAsync(() {
+ _onComplete = null; // Being null marks the test as being complete.
});
}
// Actions on the stream and controller.
- void add(var data) { _controller.add(data); }
- void error(var error) { _controller.addError(error); }
- void close() { _controller.close(); }
+ void add(var data) {
+ _controller.add(data);
+ }
+
+ void error(var error) {
+ _controller.addError(error);
+ }
+
+ void close() {
+ _controller.close();
+ }
- SubscriptionProtocolTest listen({bool cancelOnError : false}) {
+ SubscriptionProtocolTest listen({bool cancelOnError: false}) {
int subscriptionId = _subscriptionIdCounter++;
- StreamSubscription subscription = _controllerStream.listen(
- (var data) { _onData(subscriptionId, data); },
- onError: (Object error) { _onError(subscriptionId, error); },
- onDone: () { _onDone(subscriptionId); },
- cancelOnError: cancelOnError);
+ StreamSubscription subscription = _controllerStream.listen((var data) {
+ _onData(subscriptionId, data);
+ }, onError: (Object error) {
+ _onError(subscriptionId, error);
+ }, onDone: () {
+ _onDone(subscriptionId);
+ }, cancelOnError: cancelOnError);
_latestSubscription =
new SubscriptionProtocolTest(subscriptionId, subscription, this);
if (trace) {
@@ -141,7 +151,7 @@ class StreamProtocolTest {
if (_nextExpectationIndex != _expectations.length) {
_withNextExpectation((Event expect) {
_fail("Expected: $expect\n"
- "Found : Early termination.\n${expect._stackTrace}");
+ "Found : Early termination.\n${expect._stackTrace}");
});
}
_onComplete();
@@ -153,7 +163,7 @@ class StreamProtocolTest {
_withNextExpectation((Event expect) {
if (!expect.matchData(id, data)) {
_fail("Expected: $expect\n"
- "Found : [Data#$id: $data]\n${expect._stackTrace}");
+ "Found : [Data#$id: $data]\n${expect._stackTrace}");
}
});
}
@@ -163,7 +173,7 @@ class StreamProtocolTest {
_withNextExpectation((Event expect) {
if (!expect.matchError(id, error)) {
_fail("Expected: $expect\n"
- "Found : [Error#$id: ${error}]\n${expect._stackTrace}");
+ "Found : [Error#$id: ${error}]\n${expect._stackTrace}");
}
});
}
@@ -173,7 +183,7 @@ class StreamProtocolTest {
_withNextExpectation((Event expect) {
if (!expect.matchDone(id)) {
_fail("Expected: $expect\n"
- "Found : [Done#$id]\n${expect._stackTrace}");
+ "Found : [Done#$id]\n${expect._stackTrace}");
}
});
}
@@ -183,7 +193,7 @@ class StreamProtocolTest {
_withNextExpectation((Event expect) {
if (!expect.matchPause()) {
_fail("Expected: $expect\n"
- "Found : [Paused]\n${expect._stackTrace}");
+ "Found : [Paused]\n${expect._stackTrace}");
}
});
}
@@ -193,7 +203,7 @@ class StreamProtocolTest {
_withNextExpectation((Event expect) {
if (!expect.matchResume()) {
_fail("Expected: $expect\n"
- "Found : [Resumed]\n${expect._stackTrace}");
+ "Found : [Resumed]\n${expect._stackTrace}");
}
});
}
@@ -203,7 +213,7 @@ class StreamProtocolTest {
_withNextExpectation((Event expect) {
if (!expect.matchSubscribe()) {
_fail("Expected: $expect\n"
- "Found: [Subscribed]\n${expect._stackTrace}");
+ "Found: [Subscribed]\n${expect._stackTrace}");
}
});
}
@@ -213,7 +223,7 @@ class StreamProtocolTest {
_withNextExpectation((Event expect) {
if (!expect.matchCancel()) {
_fail("Expected: $expect\n"
- "Found: [Cancelled]\n${expect._stackTrace}");
+ "Found: [Cancelled]\n${expect._stackTrace}");
}
});
}
@@ -223,7 +233,7 @@ class StreamProtocolTest {
_withNextExpectation((Event expect) {
if (!expect.matchBroadcastListen(sub)) {
_fail("Expected: $expect\n"
- "Found: [BroadcastListen]\n${expect._stackTrace}");
+ "Found: [BroadcastListen]\n${expect._stackTrace}");
}
});
}
@@ -233,7 +243,7 @@ class StreamProtocolTest {
_withNextExpectation((Event expect) {
if (!expect.matchBroadcastCancel(sub)) {
_fail("Expected: $expect\n"
- "Found: [BroadcastCancel]\n${expect._stackTrace}");
+ "Found: [BroadcastCancel]\n${expect._stackTrace}");
}
});
}
@@ -307,16 +317,14 @@ class StreamProtocolTest {
if (_onComplete == null) {
_fail("Adding expectation after completing");
}
- _expectations.add(
- new SubscriptionCallbackEvent(action));
+ _expectations.add(new SubscriptionCallbackEvent(action));
}
void expectCancel([void action()]) {
if (_onComplete == null) {
_fail("Adding expectation after completing");
}
- _expectations.add(
- new CancelCallbackEvent(action));
+ _expectations.add(new CancelCallbackEvent(action));
}
void expectBroadcastListen([void action(StreamSubscription sub)]) {
@@ -374,11 +382,19 @@ class Event {
StackTrace _stackTrace;
Event(void action())
: _action = (action == null) ? null : expectAsync(action) {
- try { throw 0; } catch (_, s) { _stackTrace = s; }
+ try {
+ throw 0;
+ } catch (_, s) {
+ _stackTrace = s;
+ }
}
Event.broadcast(void action(StreamSubscription sub))
: _action = (action == null) ? null : expectAsync(action) {
- try { throw 0; } catch (_, s) { _stackTrace = s; }
+ try {
+ throw 0;
+ } catch (_, s) {
+ _stackTrace = s;
+ }
}
bool matchData(int id, var data) {
@@ -521,14 +537,14 @@ class CancelCallbackEvent extends Event {
class BroadcastCancelCallbackEvent extends Event {
BroadcastCancelCallbackEvent(void action(StreamSubscription sub))
- : super.broadcast(action);
+ : super.broadcast(action);
bool _testBroadcastCancel() => true;
String toString() => "[BroadcastCancel]";
}
class BroadcastListenCallbackEvent extends Event {
BroadcastListenCallbackEvent(void action(StreamSubscription sub))
- : super.broadcast(action);
+ : super.broadcast(action);
bool _testBroadcastListen() => true;
String toString() => "[BroadcastListen]";
}

Powered by Google App Engine
This is Rietveld 408576698