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

Unified Diff: tests/language/await_for_cancel_test.dart

Issue 913713002: Fix test to work on js-shell by avoiding a periodic timer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address reviews Created 5 years, 10 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/language/await_for_cancel_test.dart
diff --git a/tests/language/await_for_cancel_test.dart b/tests/language/await_for_cancel_test.dart
index 42690e5d2d359191a47e5a00c1a8a30dadc00a0a..1374f4b22357d7d73177db63864a0b33f5600352 100644
--- a/tests/language/await_for_cancel_test.dart
+++ b/tests/language/await_for_cancel_test.dart
@@ -6,10 +6,10 @@ import "dart:async";
import "package:expect/expect.dart";
import "package:async_helper/async_helper.dart";
-bool cancelled;
+bool canceled;
test1() async {
- cancelled = false;
+ canceled = false;
try {
StreamController controller = infiniteStreamController();
outer: while(true) {
@@ -20,12 +20,12 @@ test1() async {
}
}
} finally {
- Expect.isTrue(cancelled);
+ Expect.isTrue(canceled);
}
}
test2() async {
- cancelled = false;
+ canceled = false;
try {
StreamController controller = infiniteStreamController();
bool first = true;
@@ -42,7 +42,7 @@ test2() async {
}
}
} finally {
- Expect.isTrue(cancelled);
+ Expect.isTrue(canceled);
}
}
@@ -65,29 +65,27 @@ StreamController infiniteStreamController() {
Timer timer;
int counter = 0;
- void tick(_) {
+ void tick() {
+ if (controller.isPaused) {
+ return;
+ }
+ if (canceled) {
+ return;
+ }
counter++;
controller.add(counter); // Ask stream to send counter values as event.
+ Timer.run(tick);
}
void startTimer() {
- timer = new Timer.periodic(const Duration(milliseconds: 10), tick);
- }
-
- void stopTimer() {
- if (timer != null) {
- timer.cancel();
- timer = null;
- }
+ Timer.run(tick);
}
controller = new StreamController(
onListen: startTimer,
- onPause: stopTimer,
onResume: startTimer,
onCancel: () {
- cancelled = true;
- stopTimer();
+ canceled = true;
});
return controller;
« 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