Revert of Refactor OS X sandbox processing and audit sandbox files (patchset #6 id...
[chromium-blink-merge.git] / cc / test / animation_test_common.h
blob6f4b6cbf390821104858aa256e8c86420ec35fcd
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 ~FakeFloatAnimationCurve() override;
29 base::TimeDelta Duration() const override;
30 float GetValue(base::TimeDelta now) const override;
31 scoped_ptr<AnimationCurve> Clone() const override;
33 private:
34 base::TimeDelta duration_;
37 class FakeTransformTransition : public TransformAnimationCurve {
38 public:
39 explicit FakeTransformTransition(double duration);
40 ~FakeTransformTransition() override;
42 base::TimeDelta Duration() const override;
43 gfx::Transform GetValue(base::TimeDelta time) const override;
44 bool AnimatedBoundsForBox(const gfx::BoxF& box,
45 gfx::BoxF* bounds) const override;
46 bool AffectsScale() const override;
47 bool IsTranslation() const override;
48 bool PreservesAxisAlignment() const override;
49 bool AnimationStartScale(bool forward_direction,
50 float* start_scale) const override;
51 bool MaximumTargetScale(bool forward_direction,
52 float* max_scale) const override;
54 scoped_ptr<AnimationCurve> Clone() const override;
56 private:
57 base::TimeDelta duration_;
60 class FakeFloatTransition : public FloatAnimationCurve {
61 public:
62 FakeFloatTransition(double duration, float from, float to);
63 ~FakeFloatTransition() override;
65 base::TimeDelta Duration() const override;
66 float GetValue(base::TimeDelta time) const override;
68 scoped_ptr<AnimationCurve> Clone() const override;
70 private:
71 base::TimeDelta duration_;
72 float from_;
73 float to_;
76 class FakeLayerAnimationValueObserver : public LayerAnimationValueObserver {
77 public:
78 FakeLayerAnimationValueObserver();
79 ~FakeLayerAnimationValueObserver() override;
81 // LayerAnimationValueObserver implementation
82 void OnFilterAnimated(const FilterOperations& filters) override;
83 void OnOpacityAnimated(float opacity) override;
84 void OnTransformAnimated(const gfx::Transform& transform) override;
85 void OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) override;
86 void OnAnimationWaitingForDeletion() override;
87 bool IsActive() const override;
89 const FilterOperations& filters() const { return filters_; }
90 float opacity() const { return opacity_; }
91 const gfx::Transform& transform() const { return transform_; }
92 gfx::ScrollOffset scroll_offset() { return scroll_offset_; }
94 bool animation_waiting_for_deletion() {
95 return animation_waiting_for_deletion_;
98 private:
99 FilterOperations filters_;
100 float opacity_;
101 gfx::Transform transform_;
102 gfx::ScrollOffset scroll_offset_;
103 bool animation_waiting_for_deletion_;
106 class FakeInactiveLayerAnimationValueObserver
107 : public FakeLayerAnimationValueObserver {
108 public:
109 bool IsActive() const override;
112 class FakeLayerAnimationValueProvider : public LayerAnimationValueProvider {
113 public:
114 gfx::ScrollOffset ScrollOffsetForAnimation() const override;
116 void set_scroll_offset(const gfx::ScrollOffset& scroll_offset) {
117 scroll_offset_ = scroll_offset;
120 private:
121 gfx::ScrollOffset scroll_offset_;
124 int AddOpacityTransitionToController(LayerAnimationController* controller,
125 double duration,
126 float start_opacity,
127 float end_opacity,
128 bool use_timing_function);
130 int AddAnimatedTransformToController(LayerAnimationController* controller,
131 double duration,
132 int delta_x,
133 int delta_y);
135 int AddAnimatedFilterToController(LayerAnimationController* controller,
136 double duration,
137 float start_brightness,
138 float end_brightness);
140 int AddOpacityTransitionToLayer(Layer* layer,
141 double duration,
142 float start_opacity,
143 float end_opacity,
144 bool use_timing_function);
146 int AddOpacityTransitionToLayer(LayerImpl* layer,
147 double duration,
148 float start_opacity,
149 float end_opacity,
150 bool use_timing_function);
152 int AddAnimatedTransformToLayer(Layer* layer,
153 double duration,
154 int delta_x,
155 int delta_y);
157 int AddAnimatedTransformToLayer(LayerImpl* layer,
158 double duration,
159 int delta_x,
160 int delta_y);
162 int AddAnimatedTransformToLayer(Layer* layer,
163 double duration,
164 TransformOperations start_operations,
165 TransformOperations operations);
167 int AddAnimatedTransformToLayer(LayerImpl* layer,
168 double duration,
169 TransformOperations start_operations,
170 TransformOperations operations);
172 int AddAnimatedFilterToLayer(Layer* layer,
173 double duration,
174 float start_brightness,
175 float end_brightness);
177 int AddAnimatedFilterToLayer(LayerImpl* layer,
178 double duration,
179 float start_brightness,
180 float end_brightness);
182 } // namespace cc
184 #endif // CC_TEST_ANIMATION_TEST_COMMON_H_