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

Unified Diff: third_party/pkg/angular/test/animate/animation_loop_spec.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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: third_party/pkg/angular/test/animate/animation_loop_spec.dart
diff --git a/third_party/pkg/angular/test/animate/animation_loop_spec.dart b/third_party/pkg/angular/test/animate/animation_loop_spec.dart
new file mode 100644
index 0000000000000000000000000000000000000000..df79dcb0ad57a6c504727ab2594d0eae964bd797
--- /dev/null
+++ b/third_party/pkg/angular/test/animate/animation_loop_spec.dart
@@ -0,0 +1,99 @@
+library animation_runner_spec;
+
+import 'dart:async';
+import '../_specs.dart';
+
+main() {
+ describe('AnimationLoop', () {
+ TestBed _;
+ AnimationLoop runner;
+ MockAnimationFrame frame;
+ beforeEach(async(inject((TestBed tb, VmTurnZone zone) {
+ _ = tb;
+ frame = new MockAnimationFrame();
+ runner = new AnimationLoop(frame, new Profiler(), zone);
+ })));
+
+ it('should play animations with window animation frames', async(() {
+ var animation = new MockAnimation();
+ animation.when(callsTo('read', anything)).alwaysReturn(null);
+ animation.when(callsTo('update', anything))
+ .thenReturn(true, 2)
+ .thenReturn(false);
+
+ runner.play(animation);
+
+ animation.getLogs(callsTo('read', anything)).verify(happenedExactly(0));
+ animation.getLogs(callsTo('update', anything)).verify(happenedExactly(0));
+ animation.clearLogs();
+
+ frame.frame(0.0);
+ microLeap();
+
+ animation.getLogs(callsTo('read', anything)).verify(happenedExactly(1));
+ animation.getLogs(callsTo('update', anything)).verify(happenedExactly(1));
+ animation.clearLogs();
+
+ frame.frame(0.0);
+ microLeap();
+
+ animation.getLogs(callsTo('read', anything)).verify(happenedExactly(1));
+ animation.getLogs(callsTo('update', anything)).verify(happenedExactly(1));
+ animation.clearLogs();
+
+ frame.frame(0.0);
+ microLeap();
+
+ animation.getLogs(callsTo('read', anything)).verify(happenedExactly(1));
+ animation.getLogs(callsTo('update', anything)).verify(happenedExactly(1));
+ animation.clearLogs();
+
+ frame.frame(0.0);
+ microLeap();
+
+ animation.getLogs(callsTo('read', anything)).verify(happenedExactly(0));
+ animation.getLogs(callsTo('update', anything)).verify(happenedExactly(0));
+ }));
+
+ it('should forget about animations when forget(animation) is called', async(() {
+ var animation = new MockAnimation();
+ animation.when(callsTo('read', anything)).alwaysReturn(null);
+ animation.when(callsTo('update', anything))
+ .thenReturn(true, 2)
+ .thenReturn(false);
+
+ runner.play(animation);
+ runner.forget(animation);
+
+ frame.frame(0.0);
+ microLeap();
+
+ animation.getLogs(callsTo('read', anything)).verify(happenedExactly(0));
+ animation.getLogs(callsTo('update', anything)).verify(happenedExactly(0));
+ }));
+ });
+}
+
+class MockAnimation extends Mock implements LoopedAnimation {
+ final Completer<AnimationResult> onCompletedCompleter = new Completer<AnimationResult>();
+ Future<AnimationResult> get onCompleted => onCompletedCompleter.future;
+
+ noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
+}
+
+class MockAnimationFrame implements AnimationFrame {
+ Completer<num> frameCompleter;
+ Future<num> get animationFrame {
+ if (frameCompleter == null)
+ frameCompleter = new Completer<num>();
+ return frameCompleter.future;
+ }
+
+ frame(num time) {
+ var completer = frameCompleter;
+ frameCompleter = null;
+ if (completer != null) {
+ completer.complete(time);
+ }
+ }
+}
« no previous file with comments | « third_party/pkg/angular/test/angular_spec.dart ('k') | third_party/pkg/angular/test/animate/animation_optimizer_spec.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698