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

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

Issue 58843004: Add safety margin to timer_isolate_test.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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/timer_isolate_test.dart
diff --git a/tests/lib/async/timer_isolate_test.dart b/tests/lib/async/timer_isolate_test.dart
index 31776c5f5edb009b82cdd31b7ffd5559ed05a0b0..8c6c5fbf7165654b36853f311e6a35f8a7f6dada 100644
--- a/tests/lib/async/timer_isolate_test.dart
+++ b/tests/lib/async/timer_isolate_test.dart
@@ -10,6 +10,11 @@ import '../../../pkg/unittest/lib/unittest.dart';
const Duration TIMEOUT = const Duration(milliseconds: 100);
+// 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) ? 100 : 1;
+
createTimer(replyTo) {
new Timer(TIMEOUT, () {
replyTo.send("timer_fired");
@@ -26,7 +31,7 @@ main() {
port.first.then(expectAsync1((msg) {
expect("timer_fired", msg);
int endTime = (new DateTime.now()).millisecondsSinceEpoch;
- expect(endTime - startTime, greaterThanOrEqualTo(TIMEOUT.inMilliseconds));
+ expect(endTime - startTime + safetyMargin, greaterThanOrEqualTo(TIMEOUT.inMilliseconds));
}));
startTime = (new DateTime.now()).millisecondsSinceEpoch;
« 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