OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/compositor/layer_animation_sequence.h" | 5 #include "ui/compositor/layer_animation_sequence.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "cc/animation/animation_events.h" | 10 #include "cc/animation/animation_events.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 sequence.set_animation_group_id(starting_group_id); | 87 sequence.set_animation_group_id(starting_group_id); |
88 start_time = effective_start + delta; | 88 start_time = effective_start + delta; |
89 sequence.set_start_time(start_time); | 89 sequence.set_start_time(start_time); |
90 delegate.SetOpacityFromAnimation(start); | 90 delegate.SetOpacityFromAnimation(start); |
91 sequence.Start(&delegate); | 91 sequence.Start(&delegate); |
92 sequence.Progress(start_time, &delegate); | 92 sequence.Progress(start_time, &delegate); |
93 EXPECT_FLOAT_EQ(start, sequence.last_progressed_fraction()); | 93 EXPECT_FLOAT_EQ(start, sequence.last_progressed_fraction()); |
94 effective_start = start_time + delta; | 94 effective_start = start_time + delta; |
95 sequence.OnThreadedAnimationStarted(cc::AnimationEvent( | 95 sequence.OnThreadedAnimationStarted(cc::AnimationEvent( |
96 cc::AnimationEvent::STARTED, 0, sequence.animation_group_id(), | 96 cc::AnimationEvent::STARTED, 0, sequence.animation_group_id(), |
97 cc::Animation::OPACITY, effective_start)); | 97 cc::TargetProperty::OPACITY, effective_start)); |
98 sequence.Progress(effective_start + delta/2, &delegate); | 98 sequence.Progress(effective_start + delta/2, &delegate); |
99 EXPECT_FLOAT_EQ(middle, sequence.last_progressed_fraction()); | 99 EXPECT_FLOAT_EQ(middle, sequence.last_progressed_fraction()); |
100 EXPECT_TRUE(sequence.IsFinished(effective_start + delta)); | 100 EXPECT_TRUE(sequence.IsFinished(effective_start + delta)); |
101 sequence.Progress(effective_start + delta, &delegate); | 101 sequence.Progress(effective_start + delta, &delegate); |
102 EXPECT_FLOAT_EQ(target, sequence.last_progressed_fraction()); | 102 EXPECT_FLOAT_EQ(target, sequence.last_progressed_fraction()); |
103 EXPECT_FLOAT_EQ(target, delegate.GetOpacityForAnimation()); | 103 EXPECT_FLOAT_EQ(target, delegate.GetOpacityForAnimation()); |
104 } | 104 } |
105 | 105 |
106 EXPECT_EQ(static_cast<LayerAnimationElement::AnimatableProperties>( | 106 EXPECT_EQ(static_cast<LayerAnimationElement::AnimatableProperties>( |
107 LayerAnimationElement::OPACITY), | 107 LayerAnimationElement::OPACITY), |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 delegate.SetOpacityFromAnimation(start_opacity); | 141 delegate.SetOpacityFromAnimation(start_opacity); |
142 delegate.SetTransformFromAnimation(start_transform); | 142 delegate.SetTransformFromAnimation(start_transform); |
143 | 143 |
144 sequence.Start(&delegate); | 144 sequence.Start(&delegate); |
145 sequence.Progress(start_time, &delegate); | 145 sequence.Progress(start_time, &delegate); |
146 EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction()); | 146 EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction()); |
147 opacity_effective_start = start_time + delta; | 147 opacity_effective_start = start_time + delta; |
148 EXPECT_EQ(starting_group_id, sequence.animation_group_id()); | 148 EXPECT_EQ(starting_group_id, sequence.animation_group_id()); |
149 sequence.OnThreadedAnimationStarted(cc::AnimationEvent( | 149 sequence.OnThreadedAnimationStarted(cc::AnimationEvent( |
150 cc::AnimationEvent::STARTED, 0, sequence.animation_group_id(), | 150 cc::AnimationEvent::STARTED, 0, sequence.animation_group_id(), |
151 cc::Animation::OPACITY, opacity_effective_start)); | 151 cc::TargetProperty::OPACITY, opacity_effective_start)); |
152 sequence.Progress(opacity_effective_start + delta/2, &delegate); | 152 sequence.Progress(opacity_effective_start + delta/2, &delegate); |
153 EXPECT_FLOAT_EQ(0.5, sequence.last_progressed_fraction()); | 153 EXPECT_FLOAT_EQ(0.5, sequence.last_progressed_fraction()); |
154 sequence.Progress(opacity_effective_start + delta, &delegate); | 154 sequence.Progress(opacity_effective_start + delta, &delegate); |
155 EXPECT_FLOAT_EQ(target_opacity, delegate.GetOpacityForAnimation()); | 155 EXPECT_FLOAT_EQ(target_opacity, delegate.GetOpacityForAnimation()); |
156 | 156 |
157 // Now at the start of the pause. | 157 // Now at the start of the pause. |
158 EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction()); | 158 EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction()); |
159 TestLayerAnimationDelegate copy = delegate; | 159 TestLayerAnimationDelegate copy = delegate; |
160 | 160 |
161 // In the middle of the pause -- nothing should have changed. | 161 // In the middle of the pause -- nothing should have changed. |
162 sequence.Progress(opacity_effective_start + delta + delta/2, | 162 sequence.Progress(opacity_effective_start + delta + delta/2, |
163 &delegate); | 163 &delegate); |
164 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), | 164 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), |
165 copy.GetBoundsForAnimation()); | 165 copy.GetBoundsForAnimation()); |
166 CheckApproximatelyEqual(delegate.GetTransformForAnimation(), | 166 CheckApproximatelyEqual(delegate.GetTransformForAnimation(), |
167 copy.GetTransformForAnimation()); | 167 copy.GetTransformForAnimation()); |
168 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), | 168 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), |
169 copy.GetOpacityForAnimation()); | 169 copy.GetOpacityForAnimation()); |
170 | 170 |
171 sequence.Progress(opacity_effective_start + 2 * delta, &delegate); | 171 sequence.Progress(opacity_effective_start + 2 * delta, &delegate); |
172 CheckApproximatelyEqual(start_transform, | 172 CheckApproximatelyEqual(start_transform, |
173 delegate.GetTransformForAnimation()); | 173 delegate.GetTransformForAnimation()); |
174 EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction()); | 174 EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction()); |
175 transform_effective_start = opacity_effective_start + 3 * delta; | 175 transform_effective_start = opacity_effective_start + 3 * delta; |
176 EXPECT_NE(starting_group_id, sequence.animation_group_id()); | 176 EXPECT_NE(starting_group_id, sequence.animation_group_id()); |
177 sequence.OnThreadedAnimationStarted(cc::AnimationEvent( | 177 sequence.OnThreadedAnimationStarted(cc::AnimationEvent( |
178 cc::AnimationEvent::STARTED, 0, sequence.animation_group_id(), | 178 cc::AnimationEvent::STARTED, 0, sequence.animation_group_id(), |
179 cc::Animation::TRANSFORM, transform_effective_start)); | 179 cc::TargetProperty::TRANSFORM, transform_effective_start)); |
180 sequence.Progress(transform_effective_start + delta/2, &delegate); | 180 sequence.Progress(transform_effective_start + delta/2, &delegate); |
181 EXPECT_FLOAT_EQ(0.5, sequence.last_progressed_fraction()); | 181 EXPECT_FLOAT_EQ(0.5, sequence.last_progressed_fraction()); |
182 EXPECT_TRUE(sequence.IsFinished(transform_effective_start + delta)); | 182 EXPECT_TRUE(sequence.IsFinished(transform_effective_start + delta)); |
183 sequence.Progress(transform_effective_start + delta, &delegate); | 183 sequence.Progress(transform_effective_start + delta, &delegate); |
184 CheckApproximatelyEqual(target_transform, | 184 CheckApproximatelyEqual(target_transform, |
185 delegate.GetTransformForAnimation()); | 185 delegate.GetTransformForAnimation()); |
186 } | 186 } |
187 | 187 |
188 EXPECT_EQ( | 188 EXPECT_EQ( |
189 static_cast<LayerAnimationElement::AnimatableProperties>( | 189 static_cast<LayerAnimationElement::AnimatableProperties>( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 EXPECT_TRUE(!observer.last_ended_sequence()); | 264 EXPECT_TRUE(!observer.last_ended_sequence()); |
265 sequence.Progress(start_time + delta, &delegate); | 265 sequence.Progress(start_time + delta, &delegate); |
266 EXPECT_EQ(observer.last_ended_sequence(), &sequence); | 266 EXPECT_EQ(observer.last_ended_sequence(), &sequence); |
267 sequence.RemoveObserver(&observer); | 267 sequence.RemoveObserver(&observer); |
268 } | 268 } |
269 } | 269 } |
270 | 270 |
271 } // namespace | 271 } // namespace |
272 | 272 |
273 } // namespace ui | 273 } // namespace ui |
OLD | NEW |