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

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

Issue 23444026: Make async stream test less flaky. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/stream_controller_async_test.dart
diff --git a/tests/lib/async/stream_controller_async_test.dart b/tests/lib/async/stream_controller_async_test.dart
index 2bfb4f016e07f049e03244eee18b9ac0331f18fc..a130b4cc40512611fb9d232c1962f28037f30e0f 100644
--- a/tests/lib/async/stream_controller_async_test.dart
+++ b/tests/lib/async/stream_controller_async_test.dart
@@ -639,11 +639,12 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) {
var stream = asBroadcast ? c.stream.asBroadcastStream() : c.stream;
var actual = new Events();
var sub;
+ var pauseIsDone = false;
sub = stream.listen(
(v) {
if (v == 3) {
sub.pause(new Future.delayed(const Duration(milliseconds: 15),
- () => null));
+ () { pauseIsDone = true; }));
}
actual.add(v);
},
@@ -663,7 +664,15 @@ void testSink({bool sync, bool broadcast, bool asBroadcast}) {
// the done event to the asBroadcastStream controller, which is
// before the final listener gets the event.
// Wait for the pause to end before testing the events.
- return new Future.delayed(const Duration(milliseconds: 50), () {
+ dynamic executeWhenPauseIsDone(Function f) {
+ if (!pauseIsDone) {
+ return new Future.delayed(const Duration(milliseconds: 50), () {
+ return executeWhenPauseIsDone(f);
+ });
+ }
+ return f();
+ }
+ return executeWhenPauseIsDone(() {
Expect.listEquals(expected.events, actual.events);
done();
});
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698