1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 tvcm.require('tracing.timeline_display_transform');
8 tvcm.require('tracing.timeline_display_transform_animations');
9 tvcm.require('tvcm.ui.animation_controller');
11 tvcm.unittest.testSuite('tracing.timeline_display_transform_animations_test', function() { // @suppress longLineCheck
12 var TimelineDisplayTransform = tracing.TimelineDisplayTransform;
13 var TimelineDisplayTransformPanAnimation =
14 tracing.TimelineDisplayTransformPanAnimation;
15 var TimelineDisplayTransformZoomToAnimation =
16 tracing.TimelineDisplayTransformZoomToAnimation;
18 test('panBasic', function() {
19 var target = new TimelineDisplayTransform();
20 target.cloneAnimationState = function() {
24 var a = new TimelineDisplayTransformPanAnimation(10, 0, 100);
26 var controller = new tvcm.ui.AnimationController();
27 controller.target = target;
28 controller.queueAnimation(a, 0);
30 tvcm.forcePendingRAFTasksToRun(50);
31 assertTrue(target.panX > 0);
32 tvcm.forcePendingRAFTasksToRun(100);
33 assertFalse(controller.hasActiveAnimation);
34 assertEquals(10, target.panX);
37 test('panTakeover', function() {
38 var target = new TimelineDisplayTransform();
39 target.cloneAnimationState = function() {
43 var b = new TimelineDisplayTransformPanAnimation(10, 0, 100);
44 var a = new TimelineDisplayTransformPanAnimation(10, 0, 100);
46 var controller = new tvcm.ui.AnimationController();
47 controller.target = target;
48 controller.queueAnimation(a, 0);
50 tvcm.forcePendingRAFTasksToRun(50);
51 controller.queueAnimation(b, 50);
53 tvcm.forcePendingRAFTasksToRun(100);
54 assertTrue(controller.hasActiveAnimation);
56 tvcm.forcePendingRAFTasksToRun(150);
57 assertFalse(controller.hasActiveAnimation);
58 assertEquals(20, target.panX);