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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: packages/charted/test.disabled/event/timer_test.dart
diff --git a/packages/charted/test.disabled/event/timer_test.dart b/packages/charted/test.disabled/event/timer_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..f7eba69a2c3bb73d15294c507bf54e52a4598c80
--- /dev/null
+++ b/packages/charted/test.disabled/event/timer_test.dart
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2014 Google Inc. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style
+ * license that can be found in the LICENSE file or at
+ * https://developers.google.com/open-source/licenses/bsd
+ */
+
+part of charted.test.event;
+
+class MockFlag {
+ static const IDLE = 0;
+ static const STARTED = 1;
+ static const FINISHED = 2;
+ int state = IDLE;
+}
+
+testTimer() {
+ const TIME_BIAS = 50;
+
+ // Set flag property of a MockFlag to true after a time span.
+ timeSpan(t, MockFlag mock) => (elapse) {
+ if (mock.state == MockFlag.IDLE) mock.state = MockFlag.STARTED;
+ if (elapse < t) return false;
+ mock.state = MockFlag.FINISHED;
+ return true;
+ };
+
+ test('ChartTimer starts a custom animation timer after specific delay', () {
+ MockFlag mock1 = new MockFlag(),
+ mock2 = new MockFlag(),
+ mock3 = new MockFlag();
+ // Timer with 200 duration of execution.
+ new ChartTimer(timeSpan(200, mock1));
+ // Timer with 200 duration of execution and 200 delay.
+ new ChartTimer(timeSpan(200, mock2), 200);
+ // Timer with 200 duration of execution and 200 delay after 200 from now.
+ new ChartTimer(timeSpan(200, mock3), 200,
+ new DateTime.now().add(new Duration(milliseconds: 200)));
+ new Timer(new Duration(milliseconds:200 - TIME_BIAS), expectAsync(() {
+ expect(mock1.state, equals(MockFlag.STARTED));
+ expect(mock2.state, equals(MockFlag.IDLE));
+ expect(mock3.state, equals(MockFlag.IDLE));
+ }));
+ new Timer(new Duration(milliseconds:200 + TIME_BIAS), expectAsync(() {
+ expect(mock1.state, equals(MockFlag.FINISHED));
+ expect(mock2.state, equals(MockFlag.STARTED));
+ expect(mock3.state, equals(MockFlag.IDLE));
+ }));
+ new Timer(new Duration(milliseconds:400 + TIME_BIAS), expectAsync(() {
+ expect(mock1.state, equals(MockFlag.FINISHED));
+ expect(mock2.state, equals(MockFlag.FINISHED));
+ expect(mock3.state, equals(MockFlag.STARTED));
+ }));
+ new Timer(new Duration(milliseconds:600 + TIME_BIAS), expectAsync(() {
+ expect(mock1.state, equals(MockFlag.FINISHED));
+ expect(mock2.state, equals(MockFlag.FINISHED));
+ expect(mock3.state, equals(MockFlag.FINISHED));
+ }));
+ });
+}
« 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