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/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 for (int i = 0; i < 2; ++i) { | 85 for (int i = 0; i < 2; ++i) { |
86 int starting_group_id = 1; | 86 int starting_group_id = 1; |
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( |
96 cc::AnimationEvent::Started, | 96 cc::AnimationEvent(cc::AnimationEvent::Started, |
97 0, | 97 0, |
98 sequence.animation_group_id(), | 98 sequence.animation_group_id(), |
99 cc::Animation::Opacity, | 99 cc::Animation::Opacity, |
100 (effective_start - base::TimeTicks()).InSecondsF())); | 100 effective_start)); |
101 sequence.Progress(effective_start + delta/2, &delegate); | 101 sequence.Progress(effective_start + delta/2, &delegate); |
102 EXPECT_FLOAT_EQ(middle, sequence.last_progressed_fraction()); | 102 EXPECT_FLOAT_EQ(middle, sequence.last_progressed_fraction()); |
103 EXPECT_TRUE(sequence.IsFinished(effective_start + delta)); | 103 EXPECT_TRUE(sequence.IsFinished(effective_start + delta)); |
104 sequence.Progress(effective_start + delta, &delegate); | 104 sequence.Progress(effective_start + delta, &delegate); |
105 EXPECT_FLOAT_EQ(target, sequence.last_progressed_fraction()); | 105 EXPECT_FLOAT_EQ(target, sequence.last_progressed_fraction()); |
106 EXPECT_FLOAT_EQ(target, delegate.GetOpacityForAnimation()); | 106 EXPECT_FLOAT_EQ(target, delegate.GetOpacityForAnimation()); |
107 } | 107 } |
108 | 108 |
109 EXPECT_EQ(static_cast<LayerAnimationElement::AnimatableProperties>( | 109 EXPECT_EQ(static_cast<LayerAnimationElement::AnimatableProperties>( |
110 LayerAnimationElement::OPACITY), | 110 LayerAnimationElement::OPACITY), |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 start_time = opacity_effective_start + 4 * delta; | 142 start_time = opacity_effective_start + 4 * delta; |
143 sequence.set_start_time(start_time); | 143 sequence.set_start_time(start_time); |
144 delegate.SetOpacityFromAnimation(start_opacity); | 144 delegate.SetOpacityFromAnimation(start_opacity); |
145 delegate.SetTransformFromAnimation(start_transform); | 145 delegate.SetTransformFromAnimation(start_transform); |
146 | 146 |
147 sequence.Start(&delegate); | 147 sequence.Start(&delegate); |
148 sequence.Progress(start_time, &delegate); | 148 sequence.Progress(start_time, &delegate); |
149 EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction()); | 149 EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction()); |
150 opacity_effective_start = start_time + delta; | 150 opacity_effective_start = start_time + delta; |
151 EXPECT_EQ(starting_group_id, sequence.animation_group_id()); | 151 EXPECT_EQ(starting_group_id, sequence.animation_group_id()); |
152 sequence.OnThreadedAnimationStarted(cc::AnimationEvent( | 152 sequence.OnThreadedAnimationStarted( |
153 cc::AnimationEvent::Started, | 153 cc::AnimationEvent(cc::AnimationEvent::Started, |
154 0, | 154 0, |
155 sequence.animation_group_id(), | 155 sequence.animation_group_id(), |
156 cc::Animation::Opacity, | 156 cc::Animation::Opacity, |
157 (opacity_effective_start - base::TimeTicks()).InSecondsF())); | 157 opacity_effective_start)); |
158 sequence.Progress(opacity_effective_start + delta/2, &delegate); | 158 sequence.Progress(opacity_effective_start + delta/2, &delegate); |
159 EXPECT_FLOAT_EQ(0.5, sequence.last_progressed_fraction()); | 159 EXPECT_FLOAT_EQ(0.5, sequence.last_progressed_fraction()); |
160 sequence.Progress(opacity_effective_start + delta, &delegate); | 160 sequence.Progress(opacity_effective_start + delta, &delegate); |
161 EXPECT_FLOAT_EQ(target_opacity, delegate.GetOpacityForAnimation()); | 161 EXPECT_FLOAT_EQ(target_opacity, delegate.GetOpacityForAnimation()); |
162 | 162 |
163 // Now at the start of the pause. | 163 // Now at the start of the pause. |
164 EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction()); | 164 EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction()); |
165 TestLayerAnimationDelegate copy = delegate; | 165 TestLayerAnimationDelegate copy = delegate; |
166 | 166 |
167 // In the middle of the pause -- nothing should have changed. | 167 // In the middle of the pause -- nothing should have changed. |
168 sequence.Progress(opacity_effective_start + delta + delta/2, | 168 sequence.Progress(opacity_effective_start + delta + delta/2, |
169 &delegate); | 169 &delegate); |
170 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), | 170 CheckApproximatelyEqual(delegate.GetBoundsForAnimation(), |
171 copy.GetBoundsForAnimation()); | 171 copy.GetBoundsForAnimation()); |
172 CheckApproximatelyEqual(delegate.GetTransformForAnimation(), | 172 CheckApproximatelyEqual(delegate.GetTransformForAnimation(), |
173 copy.GetTransformForAnimation()); | 173 copy.GetTransformForAnimation()); |
174 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), | 174 EXPECT_FLOAT_EQ(delegate.GetOpacityForAnimation(), |
175 copy.GetOpacityForAnimation()); | 175 copy.GetOpacityForAnimation()); |
176 | 176 |
177 sequence.Progress(opacity_effective_start + 2 * delta, &delegate); | 177 sequence.Progress(opacity_effective_start + 2 * delta, &delegate); |
178 CheckApproximatelyEqual(start_transform, | 178 CheckApproximatelyEqual(start_transform, |
179 delegate.GetTransformForAnimation()); | 179 delegate.GetTransformForAnimation()); |
180 EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction()); | 180 EXPECT_FLOAT_EQ(0.0, sequence.last_progressed_fraction()); |
181 transform_effective_start = opacity_effective_start + 3 * delta; | 181 transform_effective_start = opacity_effective_start + 3 * delta; |
182 EXPECT_NE(starting_group_id, sequence.animation_group_id()); | 182 EXPECT_NE(starting_group_id, sequence.animation_group_id()); |
183 sequence.OnThreadedAnimationStarted(cc::AnimationEvent( | 183 sequence.OnThreadedAnimationStarted( |
184 cc::AnimationEvent::Started, | 184 cc::AnimationEvent(cc::AnimationEvent::Started, |
185 0, | 185 0, |
186 sequence.animation_group_id(), | 186 sequence.animation_group_id(), |
187 cc::Animation::Transform, | 187 cc::Animation::Transform, |
188 (transform_effective_start - base::TimeTicks()).InSecondsF())); | 188 transform_effective_start)); |
189 sequence.Progress(transform_effective_start + delta/2, &delegate); | 189 sequence.Progress(transform_effective_start + delta/2, &delegate); |
190 EXPECT_FLOAT_EQ(0.5, sequence.last_progressed_fraction()); | 190 EXPECT_FLOAT_EQ(0.5, sequence.last_progressed_fraction()); |
191 EXPECT_TRUE(sequence.IsFinished(transform_effective_start + delta)); | 191 EXPECT_TRUE(sequence.IsFinished(transform_effective_start + delta)); |
192 sequence.Progress(transform_effective_start + delta, &delegate); | 192 sequence.Progress(transform_effective_start + delta, &delegate); |
193 CheckApproximatelyEqual(target_transform, | 193 CheckApproximatelyEqual(target_transform, |
194 delegate.GetTransformForAnimation()); | 194 delegate.GetTransformForAnimation()); |
195 } | 195 } |
196 | 196 |
197 EXPECT_EQ( | 197 EXPECT_EQ( |
198 static_cast<LayerAnimationElement::AnimatableProperties>( | 198 static_cast<LayerAnimationElement::AnimatableProperties>( |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 EXPECT_TRUE(!observer.last_ended_sequence()); | 273 EXPECT_TRUE(!observer.last_ended_sequence()); |
274 sequence.Progress(start_time + delta, &delegate); | 274 sequence.Progress(start_time + delta, &delegate); |
275 EXPECT_EQ(observer.last_ended_sequence(), &sequence); | 275 EXPECT_EQ(observer.last_ended_sequence(), &sequence); |
276 sequence.RemoveObserver(&observer); | 276 sequence.RemoveObserver(&observer); |
277 } | 277 } |
278 } | 278 } |
279 | 279 |
280 } // namespace | 280 } // namespace |
281 | 281 |
282 } // namespace ui | 282 } // namespace ui |
OLD | NEW |