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

Unified Diff: tests/isolate/timer_isolate_test.dart

Issue 1683233003: Use Stopwatch instead of DateTime to measure elapsed time in tests. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 | tests/lib/async/timer_repeat_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/timer_isolate_test.dart
diff --git a/tests/isolate/timer_isolate_test.dart b/tests/isolate/timer_isolate_test.dart
index 7513dadc1caa12630e15129c831500436bd55908..cb8fcbbfadc3290f5f2aff83503a5a738e06caad 100644
--- a/tests/isolate/timer_isolate_test.dart
+++ b/tests/isolate/timer_isolate_test.dart
@@ -23,18 +23,16 @@ createTimer(replyTo) {
main() {
test("timer in isolate", () {
- int startTime;
- int endTime;
-
+ Stopwatch stopwatch = new Stopwatch();
ReceivePort port = new ReceivePort();
port.first.then(expectAsync((msg) {
expect("timer_fired", msg);
- int endTime = (new DateTime.now()).millisecondsSinceEpoch;
- expect(endTime - startTime + safetyMargin, greaterThanOrEqualTo(TIMEOUT.inMilliseconds));
+ expect(stopwatch.elapsedMilliseconds + safetyMargin,
+ greaterThanOrEqualTo(TIMEOUT.inMilliseconds));
}));
- startTime = (new DateTime.now()).millisecondsSinceEpoch;
+ stopwatch.start();
var remote = Isolate.spawn(createTimer, port.sendPort);
});
}
« no previous file with comments | « no previous file | tests/lib/async/timer_repeat_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698