1 // Copyright 2012 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.
5 #ifndef CC_TEST_ANIMATION_TEST_COMMON_H_
6 #define CC_TEST_ANIMATION_TEST_COMMON_H_
8 #include "cc/animation/animation.h"
9 #include "cc/animation/animation_curve.h"
10 #include "cc/animation/layer_animation_controller.h"
11 #include "cc/animation/layer_animation_value_observer.h"
20 class FakeFloatAnimationCurve
: public FloatAnimationCurve
{
22 FakeFloatAnimationCurve();
23 explicit FakeFloatAnimationCurve(double duration
);
24 virtual ~FakeFloatAnimationCurve();
26 virtual double Duration() const OVERRIDE
;
27 virtual float GetValue(double now
) const OVERRIDE
;
28 virtual scoped_ptr
<AnimationCurve
> Clone() const OVERRIDE
;
34 class FakeTransformTransition
: public TransformAnimationCurve
{
36 explicit FakeTransformTransition(double duration
);
37 virtual ~FakeTransformTransition();
39 virtual double Duration() const OVERRIDE
;
40 virtual gfx::Transform
GetValue(double time
) const OVERRIDE
;
42 virtual scoped_ptr
<AnimationCurve
> Clone() const OVERRIDE
;
48 class FakeFloatTransition
: public FloatAnimationCurve
{
50 FakeFloatTransition(double duration
, float from
, float to
);
51 virtual ~FakeFloatTransition();
53 virtual double Duration() const OVERRIDE
;
54 virtual float GetValue(double time
) const OVERRIDE
;
56 virtual scoped_ptr
<AnimationCurve
> Clone() const OVERRIDE
;
64 class FakeLayerAnimationValueObserver
: public LayerAnimationValueObserver
{
66 FakeLayerAnimationValueObserver();
67 virtual ~FakeLayerAnimationValueObserver();
69 // LayerAnimationValueObserver implementation
70 virtual void OnOpacityAnimated(float opacity
) OVERRIDE
;
71 virtual void OnTransformAnimated(const gfx::Transform
& transform
) OVERRIDE
;
72 virtual bool IsActive() const OVERRIDE
;
74 float opacity() const { return opacity_
; }
75 const gfx::Transform
& transform() const { return transform_
; }
79 gfx::Transform transform_
;
82 int AddOpacityTransitionToController(LayerAnimationController
* controller
,
86 bool use_timing_function
);
88 int AddAnimatedTransformToController(LayerAnimationController
* controller
,
93 int AddOpacityTransitionToLayer(Layer
* layer
,
97 bool use_timing_function
);
99 int AddOpacityTransitionToLayer(LayerImpl
* layer
,
103 bool use_timing_function
);
105 int AddAnimatedTransformToLayer(Layer
* layer
,
110 int AddAnimatedTransformToLayer(LayerImpl
* layer
,
117 #endif // CC_TEST_ANIMATION_TEST_COMMON_H_