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

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: 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
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..d82f2266ca93c6710ec7c002870519834cf2e9d8 100644
--- a/tests/lib/async/timer_test.dart
+++ b/tests/lib/async/timer_test.dart
@@ -15,9 +15,15 @@ int startTime;
int timeout;
int iteration;
+// Easy way to know if the test is compiled by dart2js.
+bool get isCompiledByDart2Js => identical(1, 1.0);
+
void timeoutHandler() {
int endTime = (new DateTime.now()).millisecondsSinceEpoch;
- expect(endTime - startTime, greaterThanOrEqualTo(timeout));
+ // Some browsers (Firefox and IE so far) can trigger too early. Add a safety
+ // margin.
+ int safetyMargin = isCompiledByDart2Js ? 100 : 0;
+ expect(endTime - startTime + safetyMargin, greaterThanOrEqualTo(timeout));
if (iteration < ITERATIONS) {
iteration++;
timeout = timeout - DECREASE;
« tests/lib/async/multiple_timer_test.dart ('K') | « 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