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

Side by Side Diff: tests/isolate/timer_repeat_test.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | « tests/isolate/timer_cancel_test.dart ('k') | tests/isolate/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 timer_repeat_test; 5 library timer_repeat_test;
6 6
7 import 'dart:isolate'; 7 import 'dart:async';
8 import '../../pkg/unittest/lib/unittest.dart'; 8 import '../../pkg/unittest/lib/unittest.dart';
9 9
10 const int TIMEOUT = 500; 10 const int TIMEOUT = 500;
11 const int ITERATIONS = 5; 11 const int ITERATIONS = 5;
12 12
13 Timer timer; 13 Timer timer;
14 int startTime; 14 int startTime;
15 int iteration; 15 int iteration;
16 16
17 void timeoutHandler(Timer timer) { 17 void timeoutHandler(Timer timer) {
18 int endTime = (new Date.now()).millisecondsSinceEpoch; 18 int endTime = (new Date.now()).millisecondsSinceEpoch;
19 iteration++; 19 iteration++;
20 if (iteration < ITERATIONS) { 20 if (iteration < ITERATIONS) {
21 startTime = (new Date.now()).millisecondsSinceEpoch; 21 startTime = (new Date.now()).millisecondsSinceEpoch;
22 } else { 22 } else {
23 expect(iteration, ITERATIONS); 23 expect(iteration, ITERATIONS);
24 timer.cancel(); 24 timer.cancel();
25 } 25 }
26 } 26 }
27 27
28 main() { 28 main() {
29 test("timer_repeat", () { 29 test("timer_repeat", () {
30 iteration = 0; 30 iteration = 0;
31 startTime = new Date.now().millisecondsSinceEpoch; 31 startTime = new Date.now().millisecondsSinceEpoch;
32 timer = new Timer.repeating(TIMEOUT, 32 timer = new Timer.repeating(TIMEOUT,
33 expectAsync1(timeoutHandler, count: ITERATIONS)); 33 expectAsync1(timeoutHandler, count: ITERATIONS));
34 }); 34 });
35 } 35 }
OLDNEW
« no previous file with comments | « tests/isolate/timer_cancel_test.dart ('k') | tests/isolate/timer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698