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

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

Issue 12855003: Add safetymargin for timer tests in browsers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix return type. Created 7 years, 9 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 | « tests/lib/async/multiple_timer_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/lib/async/timer_test.dart
diff --git a/tests/lib/async/timer_test.dart b/tests/lib/async/timer_test.dart
index 89b38ece5d7adbd847acca084a7aa84356c5bf3a..327dc18a0b7bf33cb0d9422ed7d4033b3e5d8830 100644
--- a/tests/lib/async/timer_test.dart
+++ b/tests/lib/async/timer_test.dart
@@ -15,9 +15,14 @@ int startTime;
int timeout;
int iteration;
+// Some browsers (Firefox and IE so far) can trigger too early. Add a safety
+// margin. We use identical(1, 1.0) as an easy way to know if the test is
+// compiled by dart2js.
+int get safetyMargin => identical(1, 1.0) ? 0 : 100;
+
void timeoutHandler() {
int endTime = (new DateTime.now()).millisecondsSinceEpoch;
- expect(endTime - startTime, greaterThanOrEqualTo(timeout));
+ expect(endTime - startTime + safetyMargin, greaterThanOrEqualTo(timeout));
if (iteration < ITERATIONS) {
iteration++;
timeout = timeout - DECREASE;
« no previous file with comments | « tests/lib/async/multiple_timer_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698