Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / src / tracing / timeline_display_transform_animations_test.js
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.
4
5 'use strict';
6
7 tvcm.require('tracing.timeline_display_transform');
8 tvcm.require('tracing.timeline_display_transform_animations');
9 tvcm.require('tvcm.ui.animation_controller');
10
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;
17
18   test('panBasic', function() {
19     var target = new TimelineDisplayTransform();
20     target.cloneAnimationState = function() {
21       return this.clone();
22     };
23
24     var a = new TimelineDisplayTransformPanAnimation(10, 0, 100);
25
26     var controller = new tvcm.ui.AnimationController();
27     controller.target = target;
28     controller.queueAnimation(a, 0);
29
30     tvcm.forcePendingRAFTasksToRun(50);
31     assertTrue(target.panX > 0);
32     tvcm.forcePendingRAFTasksToRun(100);
33     assertFalse(controller.hasActiveAnimation);
34     assertEquals(10, target.panX);
35   });
36
37   test('panTakeover', function() {
38     var target = new TimelineDisplayTransform();
39     target.cloneAnimationState = function() {
40       return this.clone();
41     };
42
43     var b = new TimelineDisplayTransformPanAnimation(10, 0, 100);
44     var a = new TimelineDisplayTransformPanAnimation(10, 0, 100);
45
46     var controller = new tvcm.ui.AnimationController();
47     controller.target = target;
48     controller.queueAnimation(a, 0);
49
50     tvcm.forcePendingRAFTasksToRun(50);
51     controller.queueAnimation(b, 50);
52
53     tvcm.forcePendingRAFTasksToRun(100);
54     assertTrue(controller.hasActiveAnimation);
55
56     tvcm.forcePendingRAFTasksToRun(150);
57     assertFalse(controller.hasActiveAnimation);
58     assertEquals(20, target.panX);
59   });
60
61 });