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

Side by Side Diff: tests/lib/async/multiple_timer_test.dart

Issue 16310006: Revert "Try out 15 ms safety margin." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/lib/async/timer_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library multiple_timer_test; 5 library multiple_timer_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import '../../../pkg/unittest/lib/unittest.dart'; 8 import '../../../pkg/unittest/lib/unittest.dart';
9 9
10 const Duration TIMEOUT1 = const Duration(seconds: 1); 10 const Duration TIMEOUT1 = const Duration(seconds: 1);
11 const Duration TIMEOUT2 = const Duration(seconds: 2); 11 const Duration TIMEOUT2 = const Duration(seconds: 2);
12 const Duration TIMEOUT3 = const Duration(milliseconds: 500); 12 const Duration TIMEOUT3 = const Duration(milliseconds: 500);
13 const Duration TIMEOUT4 = const Duration(milliseconds: 1500); 13 const Duration TIMEOUT4 = const Duration(milliseconds: 1500);
14 14
15 // The stopwatch is more precise than the Timer. It can happen that 15 // The stopwatch is more precise than the Timer. It can happen that
16 // the TIMEOUT triggers *slightly* too early on the VM. So we add a millisecond 16 // the TIMEOUT triggers *slightly* too early on the VM. So we add a millisecond
17 // as safetymargin. 17 // as safetymargin.
18 // Some browsers (Firefox and IE so far) can trigger too early. So we add more 18 // Some browsers (Firefox and IE so far) can trigger too early. So we add more
19 // margin. We use identical(1, 1.0) as an easy way to know if the test is 19 // margin. We use identical(1, 1.0) as an easy way to know if the test is
20 // compiled by dart2js. 20 // compiled by dart2js.
21 // NOTE: 15 ms seems to be resolution of Stopwatch implementation on Windows. 21 int get safetyMargin => identical(1, 1.0) ? 100 : 1;
22 int get safetyMargin => identical(1, 1.0) ? 100 : 15;
23 22
24 main() { 23 main() {
25 test("multiple timer test", () { 24 test("multiple timer test", () {
26 Stopwatch _stopwatch1 = new Stopwatch(); 25 Stopwatch _stopwatch1 = new Stopwatch();
27 Stopwatch _stopwatch2 = new Stopwatch(); 26 Stopwatch _stopwatch2 = new Stopwatch();
28 Stopwatch _stopwatch3 = new Stopwatch(); 27 Stopwatch _stopwatch3 = new Stopwatch();
29 Stopwatch _stopwatch4 = new Stopwatch(); 28 Stopwatch _stopwatch4 = new Stopwatch();
30 List<int> _order; 29 List<int> _order;
31 int _message; 30 int _message;
32 31
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 _stopwatch1.start(); 67 _stopwatch1.start();
69 new Timer(TIMEOUT1, expectAsync0(timeoutHandler1)); 68 new Timer(TIMEOUT1, expectAsync0(timeoutHandler1));
70 _stopwatch2.start(); 69 _stopwatch2.start();
71 new Timer(TIMEOUT2, expectAsync0(timeoutHandler2)); 70 new Timer(TIMEOUT2, expectAsync0(timeoutHandler2));
72 _stopwatch3.start(); 71 _stopwatch3.start();
73 new Timer(TIMEOUT3, expectAsync0(timeoutHandler3)); 72 new Timer(TIMEOUT3, expectAsync0(timeoutHandler3));
74 _stopwatch4.start(); 73 _stopwatch4.start();
75 new Timer(TIMEOUT4, expectAsync0(timeoutHandler4)); 74 new Timer(TIMEOUT4, expectAsync0(timeoutHandler4));
76 }); 75 });
77 } 76 }
OLDNEW
« no previous file with comments | « no previous file | tests/lib/async/timer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698