Ensure that on Windows 7, relaunching the browser via chrome://restart or changing...
[chromium-blink-merge.git] / cc / test / animation_test_common.h
blobeb030df75817a0d19cd469ca560d742b3dba5c47
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"
12 #include "cc/animation/layer_animation_value_provider.h"
13 #include "cc/output/filter_operations.h"
14 #include "cc/test/geometry_test_utils.h"
16 namespace cc {
17 class LayerImpl;
18 class Layer;
21 namespace cc {
23 class FakeFloatAnimationCurve : public FloatAnimationCurve {
24 public:
25 FakeFloatAnimationCurve();
26 explicit FakeFloatAnimationCurve(double duration);
27 virtual ~FakeFloatAnimationCurve();
29 virtual double Duration() const OVERRIDE;
30 virtual float GetValue(double now) const OVERRIDE;
31 virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE;
33 private:
34 double duration_;
37 class FakeTransformTransition : public TransformAnimationCurve {
38 public:
39 explicit FakeTransformTransition(double duration);
40 virtual ~FakeTransformTransition();
42 virtual double Duration() const OVERRIDE;
43 virtual gfx::Transform GetValue(double time) const OVERRIDE;
44 virtual bool AnimatedBoundsForBox(const gfx::BoxF& box,
45 gfx::BoxF* bounds) const OVERRIDE;
46 virtual bool AffectsScale() const OVERRIDE;
47 virtual bool IsTranslation() const OVERRIDE;
48 virtual bool MaximumScale(float* max_scale) const OVERRIDE;
50 virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE;
52 private:
53 double duration_;
56 class FakeFloatTransition : public FloatAnimationCurve {
57 public:
58 FakeFloatTransition(double duration, float from, float to);
59 virtual ~FakeFloatTransition();
61 virtual double Duration() const OVERRIDE;
62 virtual float GetValue(double time) const OVERRIDE;
64 virtual scoped_ptr<AnimationCurve> Clone() const OVERRIDE;
66 private:
67 double duration_;
68 float from_;
69 float to_;
72 class FakeLayerAnimationValueObserver : public LayerAnimationValueObserver {
73 public:
74 FakeLayerAnimationValueObserver();
75 virtual ~FakeLayerAnimationValueObserver();
77 // LayerAnimationValueObserver implementation
78 virtual void OnFilterAnimated(const FilterOperations& filters) OVERRIDE;
79 virtual void OnOpacityAnimated(float opacity) OVERRIDE;
80 virtual void OnTransformAnimated(const gfx::Transform& transform) OVERRIDE;
81 virtual void OnScrollOffsetAnimated(
82 const gfx::Vector2dF& scroll_offset) OVERRIDE;
83 virtual void OnAnimationWaitingForDeletion() OVERRIDE;
84 virtual bool IsActive() const OVERRIDE;
86 const FilterOperations& filters() const { return filters_; }
87 float opacity() const { return opacity_; }
88 const gfx::Transform& transform() const { return transform_; }
89 gfx::Vector2dF scroll_offset() { return scroll_offset_; }
91 bool animation_waiting_for_deletion() {
92 return animation_waiting_for_deletion_;
95 private:
96 FilterOperations filters_;
97 float opacity_;
98 gfx::Transform transform_;
99 gfx::Vector2dF scroll_offset_;
100 bool animation_waiting_for_deletion_;
103 class FakeInactiveLayerAnimationValueObserver
104 : public FakeLayerAnimationValueObserver {
105 public:
106 virtual bool IsActive() const OVERRIDE;
109 class FakeLayerAnimationValueProvider : public LayerAnimationValueProvider {
110 public:
111 virtual gfx::Vector2dF ScrollOffsetForAnimation() const OVERRIDE;
113 void set_scroll_offset(const gfx::Vector2dF& scroll_offset) {
114 scroll_offset_ = scroll_offset;
117 private:
118 gfx::Vector2dF scroll_offset_;
121 int AddOpacityTransitionToController(LayerAnimationController* controller,
122 double duration,
123 float start_opacity,
124 float end_opacity,
125 bool use_timing_function);
127 int AddAnimatedTransformToController(LayerAnimationController* controller,
128 double duration,
129 int delta_x,
130 int delta_y);
132 int AddAnimatedFilterToController(LayerAnimationController* controller,
133 double duration,
134 float start_brightness,
135 float end_brightness);
137 int AddOpacityTransitionToLayer(Layer* layer,
138 double duration,
139 float start_opacity,
140 float end_opacity,
141 bool use_timing_function);
143 int AddOpacityTransitionToLayer(LayerImpl* layer,
144 double duration,
145 float start_opacity,
146 float end_opacity,
147 bool use_timing_function);
149 int AddAnimatedTransformToLayer(Layer* layer,
150 double duration,
151 int delta_x,
152 int delta_y);
154 int AddAnimatedTransformToLayer(LayerImpl* layer,
155 double duration,
156 int delta_x,
157 int delta_y);
159 int AddAnimatedTransformToLayer(Layer* layer,
160 double duration,
161 TransformOperations start_operations,
162 TransformOperations operations);
164 int AddAnimatedTransformToLayer(LayerImpl* layer,
165 double duration,
166 TransformOperations start_operations,
167 TransformOperations operations);
169 int AddAnimatedFilterToLayer(Layer* layer,
170 double duration,
171 float start_brightness,
172 float end_brightness);
174 int AddAnimatedFilterToLayer(LayerImpl* layer,
175 double duration,
176 float start_brightness,
177 float end_brightness);
179 } // namespace cc
181 #endif // CC_TEST_ANIMATION_TEST_COMMON_H_