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

Side by Side Diff: packages/charted/test.disabled/event/timer_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 Google Inc. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style
5 * license that can be found in the LICENSE file or at
6 * https://developers.google.com/open-source/licenses/bsd
7 */
8
9 part of charted.test.event;
10
11 class MockFlag {
12 static const IDLE = 0;
13 static const STARTED = 1;
14 static const FINISHED = 2;
15 int state = IDLE;
16 }
17
18 testTimer() {
19 const TIME_BIAS = 50;
20
21 // Set flag property of a MockFlag to true after a time span.
22 timeSpan(t, MockFlag mock) => (elapse) {
23 if (mock.state == MockFlag.IDLE) mock.state = MockFlag.STARTED;
24 if (elapse < t) return false;
25 mock.state = MockFlag.FINISHED;
26 return true;
27 };
28
29 test('ChartTimer starts a custom animation timer after specific delay', () {
30 MockFlag mock1 = new MockFlag(),
31 mock2 = new MockFlag(),
32 mock3 = new MockFlag();
33 // Timer with 200 duration of execution.
34 new ChartTimer(timeSpan(200, mock1));
35 // Timer with 200 duration of execution and 200 delay.
36 new ChartTimer(timeSpan(200, mock2), 200);
37 // Timer with 200 duration of execution and 200 delay after 200 from now.
38 new ChartTimer(timeSpan(200, mock3), 200,
39 new DateTime.now().add(new Duration(milliseconds: 200)));
40 new Timer(new Duration(milliseconds:200 - TIME_BIAS), expectAsync(() {
41 expect(mock1.state, equals(MockFlag.STARTED));
42 expect(mock2.state, equals(MockFlag.IDLE));
43 expect(mock3.state, equals(MockFlag.IDLE));
44 }));
45 new Timer(new Duration(milliseconds:200 + TIME_BIAS), expectAsync(() {
46 expect(mock1.state, equals(MockFlag.FINISHED));
47 expect(mock2.state, equals(MockFlag.STARTED));
48 expect(mock3.state, equals(MockFlag.IDLE));
49 }));
50 new Timer(new Duration(milliseconds:400 + TIME_BIAS), expectAsync(() {
51 expect(mock1.state, equals(MockFlag.FINISHED));
52 expect(mock2.state, equals(MockFlag.FINISHED));
53 expect(mock3.state, equals(MockFlag.STARTED));
54 }));
55 new Timer(new Duration(milliseconds:600 + TIME_BIAS), expectAsync(() {
56 expect(mock1.state, equals(MockFlag.FINISHED));
57 expect(mock2.state, equals(MockFlag.FINISHED));
58 expect(mock3.state, equals(MockFlag.FINISHED));
59 }));
60 });
61 }
OLDNEW
« no previous file with comments | « packages/charted/test.disabled/event/event_test.dart ('k') | packages/charted/test.disabled/format/format_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698