OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 "cc/animation/layer_animation_controller.h" | 5 #include "cc/animation/layer_animation_controller.h" |
6 | 6 |
7 #include "cc/animation/animation.h" | 7 #include "cc/animation/animation.h" |
8 #include "cc/animation/animation_curve.h" | 8 #include "cc/animation/animation_curve.h" |
9 #include "cc/animation/keyframed_animation_curve.h" | 9 #include "cc/animation/keyframed_animation_curve.h" |
10 #include "cc/animation/transform_operations.h" | 10 #include "cc/animation/transform_operations.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, | 22 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, |
23 int id, | 23 int id, |
24 Animation::TargetProperty property) { | 24 Animation::TargetProperty property) { |
25 return Animation::Create(curve.Pass(), 0, id, property); | 25 return Animation::Create(curve.Pass(), 0, id, property); |
26 } | 26 } |
27 | 27 |
28 TEST(LayerAnimationControllerTest, SyncNewAnimation) { | 28 TEST(LayerAnimationControllerTest, SyncNewAnimation) { |
29 FakeLayerAnimationValueObserver dummy_impl; | 29 FakeLayerAnimationValueObserver dummy_impl; |
30 scoped_refptr<LayerAnimationController> controller_impl( | 30 scoped_refptr<LayerAnimationController> controller_impl( |
31 LayerAnimationController::Create(0)); | 31 LayerAnimationController::Create(0)); |
32 controller_impl->AddObserver(&dummy_impl); | 32 controller_impl->AddValueObserver(&dummy_impl); |
33 FakeLayerAnimationValueObserver dummy; | 33 FakeLayerAnimationValueObserver dummy; |
34 scoped_refptr<LayerAnimationController> controller( | 34 scoped_refptr<LayerAnimationController> controller( |
35 LayerAnimationController::Create(0)); | 35 LayerAnimationController::Create(0)); |
36 controller->AddObserver(&dummy); | 36 controller->AddValueObserver(&dummy); |
37 | 37 |
38 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); | 38 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); |
39 | 39 |
40 AddOpacityTransitionToController(controller, 1, 0, 1, false); | 40 AddOpacityTransitionToController(controller, 1, 0, 1, false); |
41 | 41 |
42 controller->PushAnimationUpdatesTo(controller_impl.get()); | 42 controller->PushAnimationUpdatesTo(controller_impl.get()); |
43 | 43 |
44 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); | 44 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); |
45 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 45 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
46 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); | 46 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); |
47 } | 47 } |
48 | 48 |
49 // If an animation is started on the impl thread before it is ticked on the main | 49 // If an animation is started on the impl thread before it is ticked on the main |
50 // thread, we must be sure to respect the synchronized start time. | 50 // thread, we must be sure to respect the synchronized start time. |
51 TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) { | 51 TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) { |
52 FakeLayerAnimationValueObserver dummy_impl; | 52 FakeLayerAnimationValueObserver dummy_impl; |
53 scoped_refptr<LayerAnimationController> controller_impl( | 53 scoped_refptr<LayerAnimationController> controller_impl( |
54 LayerAnimationController::Create(0)); | 54 LayerAnimationController::Create(0)); |
55 controller_impl->AddObserver(&dummy_impl); | 55 controller_impl->AddValueObserver(&dummy_impl); |
56 FakeLayerAnimationValueObserver dummy; | 56 FakeLayerAnimationValueObserver dummy; |
57 scoped_refptr<LayerAnimationController> controller( | 57 scoped_refptr<LayerAnimationController> controller( |
58 LayerAnimationController::Create(0)); | 58 LayerAnimationController::Create(0)); |
59 controller->AddObserver(&dummy); | 59 controller->AddValueObserver(&dummy); |
60 | 60 |
61 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); | 61 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); |
62 | 62 |
63 AddOpacityTransitionToController(controller, 1, 0, 1, false); | 63 AddOpacityTransitionToController(controller, 1, 0, 1, false); |
64 | 64 |
65 controller->PushAnimationUpdatesTo(controller_impl.get()); | 65 controller->PushAnimationUpdatesTo(controller_impl.get()); |
66 | 66 |
67 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); | 67 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); |
68 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 68 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
69 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); | 69 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); |
70 | 70 |
71 AnimationEventsVector events; | 71 AnimationEventsVector events; |
72 controller_impl->Animate(1.0); | 72 controller_impl->Animate(1.0); |
73 controller_impl->UpdateState(true, &events); | 73 controller_impl->UpdateState(true, &events); |
74 | 74 |
75 // Synchronize the start times. | 75 // Synchronize the start times. |
76 EXPECT_EQ(1u, events.size()); | 76 EXPECT_EQ(1u, events.size()); |
77 controller->OnAnimationStarted(events[0]); | 77 controller->NotifyAnimationStarted(events[0], 0.0); |
78 EXPECT_EQ(controller->GetAnimation(0, Animation::Opacity)->start_time(), | 78 EXPECT_EQ(controller->GetAnimation(0, Animation::Opacity)->start_time(), |
79 controller_impl->GetAnimation(0, Animation::Opacity)->start_time()); | 79 controller_impl->GetAnimation(0, Animation::Opacity)->start_time()); |
80 | 80 |
81 // Start the animation on the main thread. Should not affect the start time. | 81 // Start the animation on the main thread. Should not affect the start time. |
82 controller->Animate(1.5); | 82 controller->Animate(1.5); |
83 controller->UpdateState(true, NULL); | 83 controller->UpdateState(true, NULL); |
84 EXPECT_EQ(controller->GetAnimation(0, Animation::Opacity)->start_time(), | 84 EXPECT_EQ(controller->GetAnimation(0, Animation::Opacity)->start_time(), |
85 controller_impl->GetAnimation(0, Animation::Opacity)->start_time()); | 85 controller_impl->GetAnimation(0, Animation::Opacity)->start_time()); |
86 } | 86 } |
87 | 87 |
88 TEST(LayerAnimationControllerTest, SyncPauseAndResume) { | 88 TEST(LayerAnimationControllerTest, SyncPauseAndResume) { |
89 FakeLayerAnimationValueObserver dummy_impl; | 89 FakeLayerAnimationValueObserver dummy_impl; |
90 scoped_refptr<LayerAnimationController> controller_impl( | 90 scoped_refptr<LayerAnimationController> controller_impl( |
91 LayerAnimationController::Create(0)); | 91 LayerAnimationController::Create(0)); |
92 controller_impl->AddObserver(&dummy_impl); | 92 controller_impl->AddValueObserver(&dummy_impl); |
93 FakeLayerAnimationValueObserver dummy; | 93 FakeLayerAnimationValueObserver dummy; |
94 scoped_refptr<LayerAnimationController> controller( | 94 scoped_refptr<LayerAnimationController> controller( |
95 LayerAnimationController::Create(0)); | 95 LayerAnimationController::Create(0)); |
96 controller->AddObserver(&dummy); | 96 controller->AddValueObserver(&dummy); |
97 | 97 |
98 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); | 98 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); |
99 | 99 |
100 AddOpacityTransitionToController(controller, 1, 0, 1, false); | 100 AddOpacityTransitionToController(controller, 1, 0, 1, false); |
101 | 101 |
102 controller->PushAnimationUpdatesTo(controller_impl.get()); | 102 controller->PushAnimationUpdatesTo(controller_impl.get()); |
103 | 103 |
104 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); | 104 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); |
105 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 105 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
106 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); | 106 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); |
(...skipping 27 matching lines...) Expand all Loading... |
134 // The pause run state change should make it to the impl thread controller. | 134 // The pause run state change should make it to the impl thread controller. |
135 controller->PushAnimationUpdatesTo(controller_impl.get()); | 135 controller->PushAnimationUpdatesTo(controller_impl.get()); |
136 EXPECT_EQ(Animation::Running, | 136 EXPECT_EQ(Animation::Running, |
137 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); | 137 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); |
138 } | 138 } |
139 | 139 |
140 TEST(LayerAnimationControllerTest, DoNotSyncFinishedAnimation) { | 140 TEST(LayerAnimationControllerTest, DoNotSyncFinishedAnimation) { |
141 FakeLayerAnimationValueObserver dummy_impl; | 141 FakeLayerAnimationValueObserver dummy_impl; |
142 scoped_refptr<LayerAnimationController> controller_impl( | 142 scoped_refptr<LayerAnimationController> controller_impl( |
143 LayerAnimationController::Create(0)); | 143 LayerAnimationController::Create(0)); |
144 controller_impl->AddObserver(&dummy_impl); | 144 controller_impl->AddValueObserver(&dummy_impl); |
145 FakeLayerAnimationValueObserver dummy; | 145 FakeLayerAnimationValueObserver dummy; |
146 scoped_refptr<LayerAnimationController> controller( | 146 scoped_refptr<LayerAnimationController> controller( |
147 LayerAnimationController::Create(0)); | 147 LayerAnimationController::Create(0)); |
148 controller->AddObserver(&dummy); | 148 controller->AddValueObserver(&dummy); |
149 | 149 |
150 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); | 150 EXPECT_FALSE(controller_impl->GetAnimation(0, Animation::Opacity)); |
151 | 151 |
152 int animation_id = | 152 int animation_id = |
153 AddOpacityTransitionToController(controller, 1, 0, 1, false); | 153 AddOpacityTransitionToController(controller, 1, 0, 1, false); |
154 | 154 |
155 controller->PushAnimationUpdatesTo(controller_impl.get()); | 155 controller->PushAnimationUpdatesTo(controller_impl.get()); |
156 | 156 |
157 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); | 157 EXPECT_TRUE(controller_impl->GetAnimation(0, Animation::Opacity)); |
158 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 158 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
159 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); | 159 controller_impl->GetAnimation(0, Animation::Opacity)->run_state()); |
160 | 160 |
161 // Notify main thread controller that the animation has started. | 161 // Notify main thread controller that the animation has started. |
162 AnimationEvent animation_started_event( | 162 AnimationEvent animation_started_event( |
163 AnimationEvent::Started, 0, 0, Animation::Opacity, 0); | 163 AnimationEvent::Started, 0, 0, Animation::Opacity, 0); |
164 controller->OnAnimationStarted(animation_started_event); | 164 controller->NotifyAnimationStarted(animation_started_event, 0.0); |
165 | 165 |
166 // Force animation to complete on impl thread. | 166 // Force animation to complete on impl thread. |
167 controller_impl->RemoveAnimation(animation_id); | 167 controller_impl->RemoveAnimation(animation_id); |
168 | 168 |
169 EXPECT_FALSE(controller_impl->GetAnimation(animation_id, Animation::Opacity)); | 169 EXPECT_FALSE(controller_impl->GetAnimation(animation_id, Animation::Opacity)); |
170 | 170 |
171 controller->PushAnimationUpdatesTo(controller_impl.get()); | 171 controller->PushAnimationUpdatesTo(controller_impl.get()); |
172 | 172 |
173 // Even though the main thread has a 'new' animation, it should not be pushed | 173 // Even though the main thread has a 'new' animation, it should not be pushed |
174 // because the animation has already completed on the impl thread. | 174 // because the animation has already completed on the impl thread. |
175 EXPECT_FALSE(controller_impl->GetAnimation(animation_id, Animation::Opacity)); | 175 EXPECT_FALSE(controller_impl->GetAnimation(animation_id, Animation::Opacity)); |
176 } | 176 } |
177 | 177 |
| 178 // Ensure that a finished animation is eventually deleted by both the |
| 179 // main-thread and the impl-thread controllers. |
| 180 TEST(LayerAnimationControllerTest, AnimationsAreDeleted) { |
| 181 FakeLayerAnimationValueObserver dummy; |
| 182 FakeLayerAnimationValueObserver dummy_impl; |
| 183 scoped_ptr<AnimationEventsVector> events( |
| 184 make_scoped_ptr(new AnimationEventsVector)); |
| 185 scoped_refptr<LayerAnimationController> controller( |
| 186 LayerAnimationController::Create(0)); |
| 187 scoped_refptr<LayerAnimationController> controller_impl( |
| 188 LayerAnimationController::Create(0)); |
| 189 controller->AddValueObserver(&dummy); |
| 190 controller_impl->AddValueObserver(&dummy_impl); |
| 191 |
| 192 AddOpacityTransitionToController(controller, 1.0, 0.0f, 1.0f, false); |
| 193 controller->Animate(0.0); |
| 194 controller->UpdateState(true, NULL); |
| 195 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 196 |
| 197 controller_impl->Animate(0.5); |
| 198 controller_impl->UpdateState(true, events.get()); |
| 199 |
| 200 // There should be a Started event for the animation. |
| 201 EXPECT_EQ(1u, events->size()); |
| 202 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
| 203 controller->NotifyAnimationStarted((*events)[0], 0.0); |
| 204 |
| 205 controller->Animate(1.0); |
| 206 controller->UpdateState(true, NULL); |
| 207 |
| 208 events.reset(new AnimationEventsVector); |
| 209 controller_impl->Animate(2.0); |
| 210 controller_impl->UpdateState(true, events.get()); |
| 211 |
| 212 // There should be a Finished event for the animation. |
| 213 EXPECT_EQ(1u, events->size()); |
| 214 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
| 215 |
| 216 // Neither controller should have deleted the animation yet. |
| 217 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); |
| 218 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity)); |
| 219 |
| 220 controller->NotifyAnimationFinished((*events)[0], 0.0); |
| 221 |
| 222 controller->Animate(3.0); |
| 223 controller->UpdateState(true, NULL); |
| 224 |
| 225 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 226 |
| 227 // Both controllers should now have deleted the animation. |
| 228 EXPECT_FALSE(controller->has_any_animation()); |
| 229 EXPECT_FALSE(controller_impl->has_any_animation()); |
| 230 } |
| 231 |
| 232 TEST(LayerAnimationControllerTest, TransferAnimationsTo) { |
| 233 FakeLayerAnimationValueObserver dummy; |
| 234 scoped_refptr<LayerAnimationController> controller( |
| 235 LayerAnimationController::Create(0)); |
| 236 scoped_refptr<LayerAnimationController> other_controller( |
| 237 LayerAnimationController::Create(1)); |
| 238 controller->AddValueObserver(&dummy); |
| 239 |
| 240 int opacity_animation_id = |
| 241 AddOpacityTransitionToController(controller, 1.0, 0.0f, 1.0f, false); |
| 242 |
| 243 int transform_animation_id = |
| 244 AddAnimatedTransformToController(controller, 1.0, 10, 10); |
| 245 |
| 246 controller->Animate(1.0); |
| 247 |
| 248 // Both animations should now be Starting. |
| 249 EXPECT_EQ(Animation::Starting, |
| 250 controller->GetAnimation(Animation::Opacity)->run_state()); |
| 251 EXPECT_EQ(Animation::Starting, |
| 252 controller->GetAnimation(Animation::Transform)->run_state()); |
| 253 |
| 254 controller->TransferAnimationsTo(other_controller); |
| 255 |
| 256 // Ensure both animations have been transfered. |
| 257 EXPECT_FALSE(controller->has_any_animation()); |
| 258 EXPECT_EQ(other_controller->GetAnimation(Animation::Opacity)->id(), |
| 259 opacity_animation_id); |
| 260 EXPECT_EQ(other_controller->GetAnimation(Animation::Transform)->id(), |
| 261 transform_animation_id); |
| 262 |
| 263 // Ensure that the run state of the transferred animations has been |
| 264 // preserved. |
| 265 EXPECT_EQ(Animation::Starting, |
| 266 other_controller->GetAnimation(Animation::Opacity)->run_state()); |
| 267 EXPECT_EQ(Animation::Starting, |
| 268 other_controller->GetAnimation(Animation::Transform)->run_state()); |
| 269 } |
| 270 |
178 // Tests that transitioning opacity from 0 to 1 works as expected. | 271 // Tests that transitioning opacity from 0 to 1 works as expected. |
179 | 272 |
180 static const AnimationEvent* GetMostRecentPropertyUpdateEvent( | 273 static const AnimationEvent* GetMostRecentPropertyUpdateEvent( |
181 const AnimationEventsVector* events) { | 274 const AnimationEventsVector* events) { |
182 const AnimationEvent* event = 0; | 275 const AnimationEvent* event = 0; |
183 for (size_t i = 0; i < events->size(); ++i) | 276 for (size_t i = 0; i < events->size(); ++i) |
184 if ((*events)[i].type == AnimationEvent::PropertyUpdate) | 277 if ((*events)[i].type == AnimationEvent::PropertyUpdate) |
185 event = &(*events)[i]; | 278 event = &(*events)[i]; |
186 | 279 |
187 return event; | 280 return event; |
188 } | 281 } |
189 | 282 |
190 TEST(LayerAnimationControllerTest, TrivialTransition) { | 283 TEST(LayerAnimationControllerTest, TrivialTransition) { |
191 scoped_ptr<AnimationEventsVector> events( | 284 scoped_ptr<AnimationEventsVector> events( |
192 make_scoped_ptr(new AnimationEventsVector)); | 285 make_scoped_ptr(new AnimationEventsVector)); |
193 FakeLayerAnimationValueObserver dummy; | 286 FakeLayerAnimationValueObserver dummy; |
194 scoped_refptr<LayerAnimationController> controller( | 287 scoped_refptr<LayerAnimationController> controller( |
195 LayerAnimationController::Create(0)); | 288 LayerAnimationController::Create(0)); |
196 controller->AddObserver(&dummy); | 289 controller->AddValueObserver(&dummy); |
197 | 290 |
198 scoped_ptr<Animation> to_add(CreateAnimation( | 291 scoped_ptr<Animation> to_add(CreateAnimation( |
199 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 292 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
200 1, | 293 1, |
201 Animation::Opacity)); | 294 Animation::Opacity)); |
202 | 295 |
203 controller->AddAnimation(to_add.Pass()); | 296 controller->AddAnimation(to_add.Pass()); |
204 controller->Animate(0.0); | 297 controller->Animate(0.0); |
205 controller->UpdateState(true, events.get()); | 298 controller->UpdateState(true, events.get()); |
206 EXPECT_TRUE(controller->HasActiveAnimation()); | 299 EXPECT_TRUE(controller->HasActiveAnimation()); |
207 EXPECT_EQ(0.f, dummy.opacity()); | 300 EXPECT_EQ(0.f, dummy.opacity()); |
208 // A non-impl-only animation should not generate property updates. | 301 // A non-impl-only animation should not generate property updates. |
209 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 302 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
210 EXPECT_FALSE(event); | 303 EXPECT_FALSE(event); |
211 controller->Animate(1.0); | 304 controller->Animate(1.0); |
212 controller->UpdateState(true, events.get()); | 305 controller->UpdateState(true, events.get()); |
213 EXPECT_EQ(1.f, dummy.opacity()); | 306 EXPECT_EQ(1.f, dummy.opacity()); |
214 EXPECT_FALSE(controller->HasActiveAnimation()); | 307 EXPECT_FALSE(controller->HasActiveAnimation()); |
215 event = GetMostRecentPropertyUpdateEvent(events.get()); | 308 event = GetMostRecentPropertyUpdateEvent(events.get()); |
216 EXPECT_FALSE(event); | 309 EXPECT_FALSE(event); |
217 } | 310 } |
218 | 311 |
219 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { | 312 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { |
220 scoped_ptr<AnimationEventsVector> events( | 313 scoped_ptr<AnimationEventsVector> events( |
221 make_scoped_ptr(new AnimationEventsVector)); | 314 make_scoped_ptr(new AnimationEventsVector)); |
222 FakeLayerAnimationValueObserver dummy_impl; | 315 FakeLayerAnimationValueObserver dummy_impl; |
223 scoped_refptr<LayerAnimationController> controller_impl( | 316 scoped_refptr<LayerAnimationController> controller_impl( |
224 LayerAnimationController::Create(0)); | 317 LayerAnimationController::Create(0)); |
225 controller_impl->AddObserver(&dummy_impl); | 318 controller_impl->AddValueObserver(&dummy_impl); |
226 | 319 |
227 scoped_ptr<Animation> to_add(CreateAnimation( | 320 scoped_ptr<Animation> to_add(CreateAnimation( |
228 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 321 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
229 1, | 322 1, |
230 Animation::Opacity)); | 323 Animation::Opacity)); |
231 to_add->set_is_impl_only(true); | 324 to_add->set_is_impl_only(true); |
232 | 325 |
233 controller_impl->AddAnimation(to_add.Pass()); | 326 controller_impl->AddAnimation(to_add.Pass()); |
234 controller_impl->Animate(0.0); | 327 controller_impl->Animate(0.0); |
235 controller_impl->UpdateState(true, events.get()); | 328 controller_impl->UpdateState(true, events.get()); |
(...skipping 13 matching lines...) Expand all Loading... |
249 GetMostRecentPropertyUpdateEvent(events.get()); | 342 GetMostRecentPropertyUpdateEvent(events.get()); |
250 EXPECT_EQ(1.f, end_opacity_event->opacity); | 343 EXPECT_EQ(1.f, end_opacity_event->opacity); |
251 } | 344 } |
252 | 345 |
253 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { | 346 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { |
254 scoped_ptr<AnimationEventsVector> events( | 347 scoped_ptr<AnimationEventsVector> events( |
255 make_scoped_ptr(new AnimationEventsVector)); | 348 make_scoped_ptr(new AnimationEventsVector)); |
256 FakeLayerAnimationValueObserver dummy_impl; | 349 FakeLayerAnimationValueObserver dummy_impl; |
257 scoped_refptr<LayerAnimationController> controller_impl( | 350 scoped_refptr<LayerAnimationController> controller_impl( |
258 LayerAnimationController::Create(0)); | 351 LayerAnimationController::Create(0)); |
259 controller_impl->AddObserver(&dummy_impl); | 352 controller_impl->AddValueObserver(&dummy_impl); |
260 | 353 |
261 // Choose different values for x and y to avoid coincidental values in the | 354 // Choose different values for x and y to avoid coincidental values in the |
262 // observed transforms. | 355 // observed transforms. |
263 const float delta_x = 3; | 356 const float delta_x = 3; |
264 const float delta_y = 4; | 357 const float delta_y = 4; |
265 | 358 |
266 scoped_ptr<KeyframedTransformAnimationCurve> curve( | 359 scoped_ptr<KeyframedTransformAnimationCurve> curve( |
267 KeyframedTransformAnimationCurve::Create()); | 360 KeyframedTransformAnimationCurve::Create()); |
268 | 361 |
269 // Create simple Transform animation. | 362 // Create simple Transform animation. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 | 398 |
306 // Tests animations that are waiting for a synchronized start time do not | 399 // Tests animations that are waiting for a synchronized start time do not |
307 // finish. | 400 // finish. |
308 TEST(LayerAnimationControllerTest, | 401 TEST(LayerAnimationControllerTest, |
309 AnimationsWaitingForStartTimeDoNotFinishIfTheyWaitLongerToStartThanTheirDur
ation) { | 402 AnimationsWaitingForStartTimeDoNotFinishIfTheyWaitLongerToStartThanTheirDur
ation) { |
310 scoped_ptr<AnimationEventsVector> events( | 403 scoped_ptr<AnimationEventsVector> events( |
311 make_scoped_ptr(new AnimationEventsVector)); | 404 make_scoped_ptr(new AnimationEventsVector)); |
312 FakeLayerAnimationValueObserver dummy; | 405 FakeLayerAnimationValueObserver dummy; |
313 scoped_refptr<LayerAnimationController> controller( | 406 scoped_refptr<LayerAnimationController> controller( |
314 LayerAnimationController::Create(0)); | 407 LayerAnimationController::Create(0)); |
315 controller->AddObserver(&dummy); | 408 controller->AddValueObserver(&dummy); |
316 | 409 |
317 scoped_ptr<Animation> to_add(CreateAnimation( | 410 scoped_ptr<Animation> to_add(CreateAnimation( |
318 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 411 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
319 1, | 412 1, |
320 Animation::Opacity)); | 413 Animation::Opacity)); |
321 to_add->set_needs_synchronized_start_time(true); | 414 to_add->set_needs_synchronized_start_time(true); |
322 | 415 |
323 // We should pause at the first keyframe indefinitely waiting for that | 416 // We should pause at the first keyframe indefinitely waiting for that |
324 // animation to start. | 417 // animation to start. |
325 controller->AddAnimation(to_add.Pass()); | 418 controller->AddAnimation(to_add.Pass()); |
326 controller->Animate(0.0); | 419 controller->Animate(0.0); |
327 controller->UpdateState(true, events.get()); | 420 controller->UpdateState(true, events.get()); |
328 EXPECT_TRUE(controller->HasActiveAnimation()); | 421 EXPECT_TRUE(controller->HasActiveAnimation()); |
329 EXPECT_EQ(0.f, dummy.opacity()); | 422 EXPECT_EQ(0.f, dummy.opacity()); |
330 controller->Animate(1.0); | 423 controller->Animate(1.0); |
331 controller->UpdateState(true, events.get()); | 424 controller->UpdateState(true, events.get()); |
332 EXPECT_TRUE(controller->HasActiveAnimation()); | 425 EXPECT_TRUE(controller->HasActiveAnimation()); |
333 EXPECT_EQ(0.f, dummy.opacity()); | 426 EXPECT_EQ(0.f, dummy.opacity()); |
334 controller->Animate(2.0); | 427 controller->Animate(2.0); |
335 controller->UpdateState(true, events.get()); | 428 controller->UpdateState(true, events.get()); |
336 EXPECT_TRUE(controller->HasActiveAnimation()); | 429 EXPECT_TRUE(controller->HasActiveAnimation()); |
337 EXPECT_EQ(0.f, dummy.opacity()); | 430 EXPECT_EQ(0.f, dummy.opacity()); |
338 | 431 |
339 // Send the synchronized start time. | 432 // Send the synchronized start time. |
340 controller->OnAnimationStarted(AnimationEvent( | 433 controller->NotifyAnimationStarted( |
341 AnimationEvent::Started, 0, 1, Animation::Opacity, 2)); | 434 AnimationEvent(AnimationEvent::Started, 0, 1, Animation::Opacity, 2), |
| 435 0.0); |
342 controller->Animate(5.0); | 436 controller->Animate(5.0); |
343 controller->UpdateState(true, events.get()); | 437 controller->UpdateState(true, events.get()); |
344 EXPECT_EQ(1.f, dummy.opacity()); | 438 EXPECT_EQ(1.f, dummy.opacity()); |
345 EXPECT_FALSE(controller->HasActiveAnimation()); | 439 EXPECT_FALSE(controller->HasActiveAnimation()); |
346 } | 440 } |
347 | 441 |
348 // Tests that two queued animations affecting the same property run in sequence. | 442 // Tests that two queued animations affecting the same property run in sequence. |
349 TEST(LayerAnimationControllerTest, TrivialQueuing) { | 443 TEST(LayerAnimationControllerTest, TrivialQueuing) { |
350 scoped_ptr<AnimationEventsVector> events( | 444 scoped_ptr<AnimationEventsVector> events( |
351 make_scoped_ptr(new AnimationEventsVector)); | 445 make_scoped_ptr(new AnimationEventsVector)); |
352 FakeLayerAnimationValueObserver dummy; | 446 FakeLayerAnimationValueObserver dummy; |
353 scoped_refptr<LayerAnimationController> controller( | 447 scoped_refptr<LayerAnimationController> controller( |
354 LayerAnimationController::Create(0)); | 448 LayerAnimationController::Create(0)); |
355 controller->AddObserver(&dummy); | 449 controller->AddValueObserver(&dummy); |
356 | 450 |
357 controller->AddAnimation(CreateAnimation( | 451 controller->AddAnimation(CreateAnimation( |
358 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 452 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
359 1, | 453 1, |
360 Animation::Opacity)); | 454 Animation::Opacity)); |
361 controller->AddAnimation(CreateAnimation( | 455 controller->AddAnimation(CreateAnimation( |
362 scoped_ptr<AnimationCurve>( | 456 scoped_ptr<AnimationCurve>( |
363 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), | 457 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), |
364 2, | 458 2, |
365 Animation::Opacity)); | 459 Animation::Opacity)); |
(...skipping 12 matching lines...) Expand all Loading... |
378 EXPECT_FALSE(controller->HasActiveAnimation()); | 472 EXPECT_FALSE(controller->HasActiveAnimation()); |
379 } | 473 } |
380 | 474 |
381 // Tests interrupting a transition with another transition. | 475 // Tests interrupting a transition with another transition. |
382 TEST(LayerAnimationControllerTest, Interrupt) { | 476 TEST(LayerAnimationControllerTest, Interrupt) { |
383 scoped_ptr<AnimationEventsVector> events( | 477 scoped_ptr<AnimationEventsVector> events( |
384 make_scoped_ptr(new AnimationEventsVector)); | 478 make_scoped_ptr(new AnimationEventsVector)); |
385 FakeLayerAnimationValueObserver dummy; | 479 FakeLayerAnimationValueObserver dummy; |
386 scoped_refptr<LayerAnimationController> controller( | 480 scoped_refptr<LayerAnimationController> controller( |
387 LayerAnimationController::Create(0)); | 481 LayerAnimationController::Create(0)); |
388 controller->AddObserver(&dummy); | 482 controller->AddValueObserver(&dummy); |
389 controller->AddAnimation(CreateAnimation( | 483 controller->AddAnimation(CreateAnimation( |
390 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 484 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
391 1, | 485 1, |
392 Animation::Opacity)); | 486 Animation::Opacity)); |
393 controller->Animate(0.0); | 487 controller->Animate(0.0); |
394 controller->UpdateState(true, events.get()); | 488 controller->UpdateState(true, events.get()); |
395 EXPECT_TRUE(controller->HasActiveAnimation()); | 489 EXPECT_TRUE(controller->HasActiveAnimation()); |
396 EXPECT_EQ(0.f, dummy.opacity()); | 490 EXPECT_EQ(0.f, dummy.opacity()); |
397 | 491 |
398 scoped_ptr<Animation> to_add(CreateAnimation( | 492 scoped_ptr<Animation> to_add(CreateAnimation( |
(...skipping 17 matching lines...) Expand all Loading... |
416 } | 510 } |
417 | 511 |
418 // Tests scheduling two animations to run together when only one property is | 512 // Tests scheduling two animations to run together when only one property is |
419 // free. | 513 // free. |
420 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { | 514 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { |
421 scoped_ptr<AnimationEventsVector> events( | 515 scoped_ptr<AnimationEventsVector> events( |
422 make_scoped_ptr(new AnimationEventsVector)); | 516 make_scoped_ptr(new AnimationEventsVector)); |
423 FakeLayerAnimationValueObserver dummy; | 517 FakeLayerAnimationValueObserver dummy; |
424 scoped_refptr<LayerAnimationController> controller( | 518 scoped_refptr<LayerAnimationController> controller( |
425 LayerAnimationController::Create(0)); | 519 LayerAnimationController::Create(0)); |
426 controller->AddObserver(&dummy); | 520 controller->AddValueObserver(&dummy); |
427 | 521 |
428 controller->AddAnimation(CreateAnimation( | 522 controller->AddAnimation(CreateAnimation( |
429 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), | 523 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), |
430 1, | 524 1, |
431 Animation::Transform)); | 525 Animation::Transform)); |
432 controller->AddAnimation(CreateAnimation( | 526 controller->AddAnimation(CreateAnimation( |
433 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), | 527 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), |
434 2, | 528 2, |
435 Animation::Transform)); | 529 Animation::Transform)); |
436 controller->AddAnimation(CreateAnimation( | 530 controller->AddAnimation(CreateAnimation( |
(...skipping 19 matching lines...) Expand all Loading... |
456 | 550 |
457 // Tests scheduling two animations to run together with different lengths and | 551 // Tests scheduling two animations to run together with different lengths and |
458 // another animation queued to start when the shorter animation finishes (should | 552 // another animation queued to start when the shorter animation finishes (should |
459 // wait for both to finish). | 553 // wait for both to finish). |
460 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { | 554 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { |
461 scoped_ptr<AnimationEventsVector> events( | 555 scoped_ptr<AnimationEventsVector> events( |
462 make_scoped_ptr(new AnimationEventsVector)); | 556 make_scoped_ptr(new AnimationEventsVector)); |
463 FakeLayerAnimationValueObserver dummy; | 557 FakeLayerAnimationValueObserver dummy; |
464 scoped_refptr<LayerAnimationController> controller( | 558 scoped_refptr<LayerAnimationController> controller( |
465 LayerAnimationController::Create(0)); | 559 LayerAnimationController::Create(0)); |
466 controller->AddObserver(&dummy); | 560 controller->AddValueObserver(&dummy); |
467 | 561 |
468 controller->AddAnimation(CreateAnimation( | 562 controller->AddAnimation(CreateAnimation( |
469 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2)).Pass(), | 563 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2)).Pass(), |
470 1, | 564 1, |
471 Animation::Transform)); | 565 Animation::Transform)); |
472 controller->AddAnimation(CreateAnimation( | 566 controller->AddAnimation(CreateAnimation( |
473 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 567 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
474 1, | 568 1, |
475 Animation::Opacity)); | 569 Animation::Opacity)); |
476 controller->AddAnimation(CreateAnimation( | 570 controller->AddAnimation(CreateAnimation( |
(...skipping 24 matching lines...) Expand all Loading... |
501 EXPECT_FALSE(controller->HasActiveAnimation()); | 595 EXPECT_FALSE(controller->HasActiveAnimation()); |
502 } | 596 } |
503 | 597 |
504 // Tests scheduling an animation to start in the future. | 598 // Tests scheduling an animation to start in the future. |
505 TEST(LayerAnimationControllerTest, ScheduleAnimation) { | 599 TEST(LayerAnimationControllerTest, ScheduleAnimation) { |
506 scoped_ptr<AnimationEventsVector> events( | 600 scoped_ptr<AnimationEventsVector> events( |
507 make_scoped_ptr(new AnimationEventsVector)); | 601 make_scoped_ptr(new AnimationEventsVector)); |
508 FakeLayerAnimationValueObserver dummy; | 602 FakeLayerAnimationValueObserver dummy; |
509 scoped_refptr<LayerAnimationController> controller( | 603 scoped_refptr<LayerAnimationController> controller( |
510 LayerAnimationController::Create(0)); | 604 LayerAnimationController::Create(0)); |
511 controller->AddObserver(&dummy); | 605 controller->AddValueObserver(&dummy); |
512 | 606 |
513 scoped_ptr<Animation> to_add(CreateAnimation( | 607 scoped_ptr<Animation> to_add(CreateAnimation( |
514 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 608 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
515 1, | 609 1, |
516 Animation::Opacity)); | 610 Animation::Opacity)); |
517 to_add->SetRunState(Animation::WaitingForStartTime, 0); | 611 to_add->SetRunState(Animation::WaitingForStartTime, 0); |
518 to_add->set_start_time(1.f); | 612 to_add->set_start_time(1.f); |
519 controller->AddAnimation(to_add.Pass()); | 613 controller->AddAnimation(to_add.Pass()); |
520 | 614 |
521 controller->Animate(0.0); | 615 controller->Animate(0.0); |
(...skipping 12 matching lines...) Expand all Loading... |
534 | 628 |
535 // Tests scheduling an animation to start in the future that's interrupting a | 629 // Tests scheduling an animation to start in the future that's interrupting a |
536 // running animation. | 630 // running animation. |
537 TEST(LayerAnimationControllerTest, | 631 TEST(LayerAnimationControllerTest, |
538 ScheduledAnimationInterruptsRunningAnimation) { | 632 ScheduledAnimationInterruptsRunningAnimation) { |
539 scoped_ptr<AnimationEventsVector> events( | 633 scoped_ptr<AnimationEventsVector> events( |
540 make_scoped_ptr(new AnimationEventsVector)); | 634 make_scoped_ptr(new AnimationEventsVector)); |
541 FakeLayerAnimationValueObserver dummy; | 635 FakeLayerAnimationValueObserver dummy; |
542 scoped_refptr<LayerAnimationController> controller( | 636 scoped_refptr<LayerAnimationController> controller( |
543 LayerAnimationController::Create(0)); | 637 LayerAnimationController::Create(0)); |
544 controller->AddObserver(&dummy); | 638 controller->AddValueObserver(&dummy); |
545 | 639 |
546 controller->AddAnimation(CreateAnimation( | 640 controller->AddAnimation(CreateAnimation( |
547 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), | 641 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), |
548 1, | 642 1, |
549 Animation::Opacity)); | 643 Animation::Opacity)); |
550 | 644 |
551 scoped_ptr<Animation> to_add(CreateAnimation( | 645 scoped_ptr<Animation> to_add(CreateAnimation( |
552 scoped_ptr<AnimationCurve>( | 646 scoped_ptr<AnimationCurve>( |
553 new FakeFloatTransition(1.0, 0.5f, 0.f)).Pass(), | 647 new FakeFloatTransition(1.0, 0.5f, 0.f)).Pass(), |
554 2, | 648 2, |
(...skipping 23 matching lines...) Expand all Loading... |
578 | 672 |
579 // Tests scheduling an animation to start in the future that interrupts a | 673 // Tests scheduling an animation to start in the future that interrupts a |
580 // running animation and there is yet another animation queued to start later. | 674 // running animation and there is yet another animation queued to start later. |
581 TEST(LayerAnimationControllerTest, | 675 TEST(LayerAnimationControllerTest, |
582 ScheduledAnimationInterruptsRunningAnimationWithAnimInQueue) { | 676 ScheduledAnimationInterruptsRunningAnimationWithAnimInQueue) { |
583 scoped_ptr<AnimationEventsVector> events( | 677 scoped_ptr<AnimationEventsVector> events( |
584 make_scoped_ptr(new AnimationEventsVector)); | 678 make_scoped_ptr(new AnimationEventsVector)); |
585 FakeLayerAnimationValueObserver dummy; | 679 FakeLayerAnimationValueObserver dummy; |
586 scoped_refptr<LayerAnimationController> controller( | 680 scoped_refptr<LayerAnimationController> controller( |
587 LayerAnimationController::Create(0)); | 681 LayerAnimationController::Create(0)); |
588 controller->AddObserver(&dummy); | 682 controller->AddValueObserver(&dummy); |
589 | 683 |
590 controller->AddAnimation(CreateAnimation( | 684 controller->AddAnimation(CreateAnimation( |
591 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), | 685 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), |
592 1, | 686 1, |
593 Animation::Opacity)); | 687 Animation::Opacity)); |
594 | 688 |
595 scoped_ptr<Animation> to_add(CreateAnimation( | 689 scoped_ptr<Animation> to_add(CreateAnimation( |
596 scoped_ptr<AnimationCurve>( | 690 scoped_ptr<AnimationCurve>( |
597 new FakeFloatTransition(2.0, 0.5f, 0.f)).Pass(), | 691 new FakeFloatTransition(2.0, 0.5f, 0.f)).Pass(), |
598 2, | 692 2, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 EXPECT_FALSE(controller->HasActiveAnimation()); | 725 EXPECT_FALSE(controller->HasActiveAnimation()); |
632 } | 726 } |
633 | 727 |
634 // Test that a looping animation loops and for the correct number of iterations. | 728 // Test that a looping animation loops and for the correct number of iterations. |
635 TEST(LayerAnimationControllerTest, TrivialLooping) { | 729 TEST(LayerAnimationControllerTest, TrivialLooping) { |
636 scoped_ptr<AnimationEventsVector> events( | 730 scoped_ptr<AnimationEventsVector> events( |
637 make_scoped_ptr(new AnimationEventsVector)); | 731 make_scoped_ptr(new AnimationEventsVector)); |
638 FakeLayerAnimationValueObserver dummy; | 732 FakeLayerAnimationValueObserver dummy; |
639 scoped_refptr<LayerAnimationController> controller( | 733 scoped_refptr<LayerAnimationController> controller( |
640 LayerAnimationController::Create(0)); | 734 LayerAnimationController::Create(0)); |
641 controller->AddObserver(&dummy); | 735 controller->AddValueObserver(&dummy); |
642 | 736 |
643 scoped_ptr<Animation> to_add(CreateAnimation( | 737 scoped_ptr<Animation> to_add(CreateAnimation( |
644 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 738 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
645 1, | 739 1, |
646 Animation::Opacity)); | 740 Animation::Opacity)); |
647 to_add->set_iterations(3); | 741 to_add->set_iterations(3); |
648 controller->AddAnimation(to_add.Pass()); | 742 controller->AddAnimation(to_add.Pass()); |
649 | 743 |
650 controller->Animate(0.0); | 744 controller->Animate(0.0); |
651 controller->UpdateState(true, events.get()); | 745 controller->UpdateState(true, events.get()); |
(...skipping 26 matching lines...) Expand all Loading... |
678 EXPECT_EQ(1.f, dummy.opacity()); | 772 EXPECT_EQ(1.f, dummy.opacity()); |
679 } | 773 } |
680 | 774 |
681 // Test that an infinitely looping animation does indeed go until aborted. | 775 // Test that an infinitely looping animation does indeed go until aborted. |
682 TEST(LayerAnimationControllerTest, InfiniteLooping) { | 776 TEST(LayerAnimationControllerTest, InfiniteLooping) { |
683 scoped_ptr<AnimationEventsVector> events( | 777 scoped_ptr<AnimationEventsVector> events( |
684 make_scoped_ptr(new AnimationEventsVector)); | 778 make_scoped_ptr(new AnimationEventsVector)); |
685 FakeLayerAnimationValueObserver dummy; | 779 FakeLayerAnimationValueObserver dummy; |
686 scoped_refptr<LayerAnimationController> controller( | 780 scoped_refptr<LayerAnimationController> controller( |
687 LayerAnimationController::Create(0)); | 781 LayerAnimationController::Create(0)); |
688 controller->AddObserver(&dummy); | 782 controller->AddValueObserver(&dummy); |
689 | 783 |
690 const int id = 1; | 784 const int id = 1; |
691 scoped_ptr<Animation> to_add(CreateAnimation( | 785 scoped_ptr<Animation> to_add(CreateAnimation( |
692 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 786 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
693 id, | 787 id, |
694 Animation::Opacity)); | 788 Animation::Opacity)); |
695 to_add->set_iterations(-1); | 789 to_add->set_iterations(-1); |
696 controller->AddAnimation(to_add.Pass()); | 790 controller->AddAnimation(to_add.Pass()); |
697 | 791 |
698 controller->Animate(0.0); | 792 controller->Animate(0.0); |
(...skipping 25 matching lines...) Expand all Loading... |
724 EXPECT_EQ(0.75f, dummy.opacity()); | 818 EXPECT_EQ(0.75f, dummy.opacity()); |
725 } | 819 } |
726 | 820 |
727 // Test that pausing and resuming work as expected. | 821 // Test that pausing and resuming work as expected. |
728 TEST(LayerAnimationControllerTest, PauseResume) { | 822 TEST(LayerAnimationControllerTest, PauseResume) { |
729 scoped_ptr<AnimationEventsVector> events( | 823 scoped_ptr<AnimationEventsVector> events( |
730 make_scoped_ptr(new AnimationEventsVector)); | 824 make_scoped_ptr(new AnimationEventsVector)); |
731 FakeLayerAnimationValueObserver dummy; | 825 FakeLayerAnimationValueObserver dummy; |
732 scoped_refptr<LayerAnimationController> controller( | 826 scoped_refptr<LayerAnimationController> controller( |
733 LayerAnimationController::Create(0)); | 827 LayerAnimationController::Create(0)); |
734 controller->AddObserver(&dummy); | 828 controller->AddValueObserver(&dummy); |
735 | 829 |
736 const int id = 1; | 830 const int id = 1; |
737 controller->AddAnimation(CreateAnimation( | 831 controller->AddAnimation(CreateAnimation( |
738 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 832 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
739 id, | 833 id, |
740 Animation::Opacity)); | 834 Animation::Opacity)); |
741 | 835 |
742 controller->Animate(0.0); | 836 controller->Animate(0.0); |
743 controller->UpdateState(true, events.get()); | 837 controller->UpdateState(true, events.get()); |
744 EXPECT_TRUE(controller->HasActiveAnimation()); | 838 EXPECT_TRUE(controller->HasActiveAnimation()); |
(...skipping 25 matching lines...) Expand all Loading... |
770 EXPECT_FALSE(controller->HasActiveAnimation()); | 864 EXPECT_FALSE(controller->HasActiveAnimation()); |
771 EXPECT_EQ(1.f, dummy.opacity()); | 865 EXPECT_EQ(1.f, dummy.opacity()); |
772 } | 866 } |
773 | 867 |
774 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { | 868 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { |
775 scoped_ptr<AnimationEventsVector> events( | 869 scoped_ptr<AnimationEventsVector> events( |
776 make_scoped_ptr(new AnimationEventsVector)); | 870 make_scoped_ptr(new AnimationEventsVector)); |
777 FakeLayerAnimationValueObserver dummy; | 871 FakeLayerAnimationValueObserver dummy; |
778 scoped_refptr<LayerAnimationController> controller( | 872 scoped_refptr<LayerAnimationController> controller( |
779 LayerAnimationController::Create(0)); | 873 LayerAnimationController::Create(0)); |
780 controller->AddObserver(&dummy); | 874 controller->AddValueObserver(&dummy); |
781 | 875 |
782 const int id = 1; | 876 const int id = 1; |
783 controller->AddAnimation(CreateAnimation( | 877 controller->AddAnimation(CreateAnimation( |
784 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), | 878 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), |
785 id, | 879 id, |
786 Animation::Transform)); | 880 Animation::Transform)); |
787 controller->AddAnimation(CreateAnimation( | 881 controller->AddAnimation(CreateAnimation( |
788 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), | 882 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), |
789 id, | 883 id, |
790 Animation::Opacity)); | 884 Animation::Opacity)); |
(...skipping 22 matching lines...) Expand all Loading... |
813 controller->Animate(2.0); | 907 controller->Animate(2.0); |
814 controller->UpdateState(true, events.get()); | 908 controller->UpdateState(true, events.get()); |
815 EXPECT_TRUE(!controller->HasActiveAnimation()); | 909 EXPECT_TRUE(!controller->HasActiveAnimation()); |
816 EXPECT_EQ(0.75f, dummy.opacity()); | 910 EXPECT_EQ(0.75f, dummy.opacity()); |
817 } | 911 } |
818 | 912 |
819 TEST(LayerAnimationControllerTest, ForceSyncWhenSynchronizedStartTimeNeeded) { | 913 TEST(LayerAnimationControllerTest, ForceSyncWhenSynchronizedStartTimeNeeded) { |
820 FakeLayerAnimationValueObserver dummy_impl; | 914 FakeLayerAnimationValueObserver dummy_impl; |
821 scoped_refptr<LayerAnimationController> controller_impl( | 915 scoped_refptr<LayerAnimationController> controller_impl( |
822 LayerAnimationController::Create(0)); | 916 LayerAnimationController::Create(0)); |
823 controller_impl->AddObserver(&dummy_impl); | 917 controller_impl->AddValueObserver(&dummy_impl); |
824 scoped_ptr<AnimationEventsVector> events( | 918 scoped_ptr<AnimationEventsVector> events( |
825 make_scoped_ptr(new AnimationEventsVector)); | 919 make_scoped_ptr(new AnimationEventsVector)); |
826 FakeLayerAnimationValueObserver dummy; | 920 FakeLayerAnimationValueObserver dummy; |
827 scoped_refptr<LayerAnimationController> controller( | 921 scoped_refptr<LayerAnimationController> controller( |
828 LayerAnimationController::Create(0)); | 922 LayerAnimationController::Create(0)); |
829 controller->AddObserver(&dummy); | 923 controller->AddValueObserver(&dummy); |
830 | 924 |
831 scoped_ptr<Animation> to_add(CreateAnimation( | 925 scoped_ptr<Animation> to_add(CreateAnimation( |
832 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), | 926 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), |
833 0, | 927 0, |
834 Animation::Opacity)); | 928 Animation::Opacity)); |
835 to_add->set_needs_synchronized_start_time(true); | 929 to_add->set_needs_synchronized_start_time(true); |
836 controller->AddAnimation(to_add.Pass()); | 930 controller->AddAnimation(to_add.Pass()); |
837 | 931 |
838 controller->Animate(0.0); | 932 controller->Animate(0.0); |
839 controller->UpdateState(true, events.get()); | 933 controller->UpdateState(true, events.get()); |
(...skipping 12 matching lines...) Expand all Loading... |
852 active_animation->run_state()); | 946 active_animation->run_state()); |
853 } | 947 } |
854 | 948 |
855 // Tests that skipping a call to UpdateState works as expected. | 949 // Tests that skipping a call to UpdateState works as expected. |
856 TEST(LayerAnimationControllerTest, SkipUpdateState) { | 950 TEST(LayerAnimationControllerTest, SkipUpdateState) { |
857 scoped_ptr<AnimationEventsVector> events( | 951 scoped_ptr<AnimationEventsVector> events( |
858 make_scoped_ptr(new AnimationEventsVector)); | 952 make_scoped_ptr(new AnimationEventsVector)); |
859 FakeLayerAnimationValueObserver dummy; | 953 FakeLayerAnimationValueObserver dummy; |
860 scoped_refptr<LayerAnimationController> controller( | 954 scoped_refptr<LayerAnimationController> controller( |
861 LayerAnimationController::Create(0)); | 955 LayerAnimationController::Create(0)); |
862 controller->AddObserver(&dummy); | 956 controller->AddValueObserver(&dummy); |
863 | 957 |
864 controller->AddAnimation(CreateAnimation( | 958 controller->AddAnimation(CreateAnimation( |
865 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), | 959 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), |
866 1, | 960 1, |
867 Animation::Transform)); | 961 Animation::Transform)); |
868 | 962 |
869 controller->Animate(0.0); | 963 controller->Animate(0.0); |
870 controller->UpdateState(true, events.get()); | 964 controller->UpdateState(true, events.get()); |
871 | 965 |
872 controller->AddAnimation(CreateAnimation( | 966 controller->AddAnimation(CreateAnimation( |
(...skipping 19 matching lines...) Expand all Loading... |
892 controller->Animate(3.0); | 986 controller->Animate(3.0); |
893 controller->UpdateState(true, events.get()); | 987 controller->UpdateState(true, events.get()); |
894 | 988 |
895 // The float tranisition should now be done. | 989 // The float tranisition should now be done. |
896 EXPECT_EQ(1.f, dummy.opacity()); | 990 EXPECT_EQ(1.f, dummy.opacity()); |
897 EXPECT_FALSE(controller->HasActiveAnimation()); | 991 EXPECT_FALSE(controller->HasActiveAnimation()); |
898 } | 992 } |
899 | 993 |
900 } // namespace | 994 } // namespace |
901 } // namespace cc | 995 } // namespace cc |
OLD | NEW |