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/animation_delegate.h" | 9 #include "cc/animation/animation_delegate.h" |
10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 TEST(LayerAnimationControllerTest, SyncNewAnimation) { | 42 TEST(LayerAnimationControllerTest, SyncNewAnimation) { |
43 FakeLayerAnimationValueObserver dummy_impl; | 43 FakeLayerAnimationValueObserver dummy_impl; |
44 scoped_refptr<LayerAnimationController> controller_impl( | 44 scoped_refptr<LayerAnimationController> controller_impl( |
45 LayerAnimationController::Create(0)); | 45 LayerAnimationController::Create(0)); |
46 controller_impl->AddValueObserver(&dummy_impl); | 46 controller_impl->AddValueObserver(&dummy_impl); |
47 FakeLayerAnimationValueObserver dummy; | 47 FakeLayerAnimationValueObserver dummy; |
48 scoped_refptr<LayerAnimationController> controller( | 48 scoped_refptr<LayerAnimationController> controller( |
49 LayerAnimationController::Create(0)); | 49 LayerAnimationController::Create(0)); |
50 controller->AddValueObserver(&dummy); | 50 controller->AddValueObserver(&dummy); |
51 | 51 |
52 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY)); | 52 EXPECT_FALSE(controller_impl->GetAnimation(Animation::Opacity)); |
53 | 53 |
54 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); | 54 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); |
55 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing()); | 55 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing()); |
56 | 56 |
57 int animation_id = | 57 int animation_id = |
58 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 58 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
59 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); | 59 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); |
60 | 60 |
61 controller->PushAnimationUpdatesTo(controller_impl.get()); | 61 controller->PushAnimationUpdatesTo(controller_impl.get()); |
62 EXPECT_TRUE(controller_impl->needs_to_start_animations_for_testing()); | 62 EXPECT_TRUE(controller_impl->needs_to_start_animations_for_testing()); |
63 controller_impl->ActivateAnimations(); | 63 controller_impl->ActivateAnimations(); |
64 | 64 |
65 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 65 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
66 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 66 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
67 controller_impl->GetAnimationById(animation_id)->run_state()); | 67 controller_impl->GetAnimationById(animation_id)->run_state()); |
68 } | 68 } |
69 | 69 |
70 // If an animation is started on the impl thread before it is ticked on the main | 70 // If an animation is started on the impl thread before it is ticked on the main |
71 // thread, we must be sure to respect the synchronized start time. | 71 // thread, we must be sure to respect the synchronized start time. |
72 TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) { | 72 TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) { |
73 FakeLayerAnimationValueObserver dummy_impl; | 73 FakeLayerAnimationValueObserver dummy_impl; |
74 scoped_refptr<LayerAnimationController> controller_impl( | 74 scoped_refptr<LayerAnimationController> controller_impl( |
75 LayerAnimationController::Create(0)); | 75 LayerAnimationController::Create(0)); |
76 controller_impl->AddValueObserver(&dummy_impl); | 76 controller_impl->AddValueObserver(&dummy_impl); |
77 FakeLayerAnimationValueObserver dummy; | 77 FakeLayerAnimationValueObserver dummy; |
78 scoped_refptr<LayerAnimationController> controller( | 78 scoped_refptr<LayerAnimationController> controller( |
79 LayerAnimationController::Create(0)); | 79 LayerAnimationController::Create(0)); |
80 controller->AddValueObserver(&dummy); | 80 controller->AddValueObserver(&dummy); |
81 | 81 |
82 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY)); | 82 EXPECT_FALSE(controller_impl->GetAnimation(Animation::Opacity)); |
83 | 83 |
84 int animation_id = | 84 int animation_id = |
85 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 85 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
86 | 86 |
87 controller->PushAnimationUpdatesTo(controller_impl.get()); | 87 controller->PushAnimationUpdatesTo(controller_impl.get()); |
88 controller_impl->ActivateAnimations(); | 88 controller_impl->ActivateAnimations(); |
89 | 89 |
90 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 90 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
91 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 91 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
92 controller_impl->GetAnimationById(animation_id)->run_state()); | 92 controller_impl->GetAnimationById(animation_id)->run_state()); |
93 | 93 |
94 AnimationEventsVector events; | 94 AnimationEventsVector events; |
95 controller_impl->Animate(kInitialTickTime); | 95 controller_impl->Animate(kInitialTickTime); |
96 controller_impl->UpdateState(true, &events); | 96 controller_impl->UpdateState(true, &events); |
97 | 97 |
98 // Synchronize the start times. | 98 // Synchronize the start times. |
99 EXPECT_EQ(1u, events.size()); | 99 EXPECT_EQ(1u, events.size()); |
100 controller->NotifyAnimationStarted(events[0]); | 100 controller->NotifyAnimationStarted(events[0]); |
101 EXPECT_EQ(controller->GetAnimationById(animation_id)->start_time(), | 101 EXPECT_EQ(controller->GetAnimationById(animation_id)->start_time(), |
(...skipping 13 matching lines...) Expand all Loading... |
115 controller_impl->AddValueObserver(&dummy_impl); | 115 controller_impl->AddValueObserver(&dummy_impl); |
116 FakeLayerAnimationValueObserver dummy; | 116 FakeLayerAnimationValueObserver dummy; |
117 scoped_refptr<LayerAnimationController> controller( | 117 scoped_refptr<LayerAnimationController> controller( |
118 LayerAnimationController::Create(0)); | 118 LayerAnimationController::Create(0)); |
119 controller->AddValueObserver(&dummy); | 119 controller->AddValueObserver(&dummy); |
120 | 120 |
121 int animation_id = | 121 int animation_id = |
122 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 122 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
123 | 123 |
124 const TimeTicks start_time = TicksFromSecondsF(123); | 124 const TimeTicks start_time = TicksFromSecondsF(123); |
125 controller->GetAnimation(Animation::OPACITY)->set_start_time(start_time); | 125 controller->GetAnimation(Animation::Opacity)->set_start_time(start_time); |
126 | 126 |
127 controller->PushAnimationUpdatesTo(controller_impl.get()); | 127 controller->PushAnimationUpdatesTo(controller_impl.get()); |
128 controller_impl->ActivateAnimations(); | 128 controller_impl->ActivateAnimations(); |
129 | 129 |
130 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 130 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
131 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 131 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
132 controller_impl->GetAnimationById(animation_id)->run_state()); | 132 controller_impl->GetAnimationById(animation_id)->run_state()); |
133 | 133 |
134 AnimationEventsVector events; | 134 AnimationEventsVector events; |
135 controller_impl->Animate(kInitialTickTime); | 135 controller_impl->Animate(kInitialTickTime); |
136 controller_impl->UpdateState(true, &events); | 136 controller_impl->UpdateState(true, &events); |
137 | 137 |
138 // Synchronize the start times. | 138 // Synchronize the start times. |
139 EXPECT_EQ(1u, events.size()); | 139 EXPECT_EQ(1u, events.size()); |
140 controller->NotifyAnimationStarted(events[0]); | 140 controller->NotifyAnimationStarted(events[0]); |
141 | 141 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 196 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
197 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); | 197 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); |
198 | 198 |
199 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 199 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
200 controller->UpdateState(true, nullptr); | 200 controller->UpdateState(true, nullptr); |
201 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 201 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
202 | 202 |
203 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 203 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
204 controller->UpdateState(true, nullptr); | 204 controller->UpdateState(true, nullptr); |
205 EXPECT_EQ(Animation::FINISHED, | 205 EXPECT_EQ(Animation::Finished, |
206 controller->GetAnimation(Animation::OPACITY)->run_state()); | 206 controller->GetAnimation(Animation::Opacity)->run_state()); |
207 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 207 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
208 | 208 |
209 events.reset(new AnimationEventsVector); | 209 events.reset(new AnimationEventsVector); |
210 controller_impl->Animate(kInitialTickTime + | 210 controller_impl->Animate(kInitialTickTime + |
211 TimeDelta::FromMilliseconds(1500)); | 211 TimeDelta::FromMilliseconds(1500)); |
212 controller_impl->UpdateState(true, events.get()); | 212 controller_impl->UpdateState(true, events.get()); |
213 | 213 |
214 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 214 EXPECT_EQ(Animation::WaitingForDeletion, |
215 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); | 215 controller_impl->GetAnimation(Animation::Opacity)->run_state()); |
216 // The impl thread controller should have de-activated. | 216 // The impl thread controller should have de-activated. |
217 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); | 217 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); |
218 | 218 |
219 EXPECT_EQ(1u, events->size()); | 219 EXPECT_EQ(1u, events->size()); |
220 controller->NotifyAnimationFinished((*events)[0]); | 220 controller->NotifyAnimationFinished((*events)[0]); |
221 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); | 221 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); |
222 controller->UpdateState(true, nullptr); | 222 controller->UpdateState(true, nullptr); |
223 | 223 |
224 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 224 EXPECT_EQ(Animation::WaitingForDeletion, |
225 controller->GetAnimation(Animation::OPACITY)->run_state()); | 225 controller->GetAnimation(Animation::Opacity)->run_state()); |
226 // The main thread controller should have de-activated. | 226 // The main thread controller should have de-activated. |
227 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); | 227 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); |
228 | 228 |
229 controller->PushAnimationUpdatesTo(controller_impl.get()); | 229 controller->PushAnimationUpdatesTo(controller_impl.get()); |
230 controller_impl->ActivateAnimations(); | 230 controller_impl->ActivateAnimations(); |
231 EXPECT_FALSE(controller->has_any_animation()); | 231 EXPECT_FALSE(controller->has_any_animation()); |
232 EXPECT_FALSE(controller_impl->has_any_animation()); | 232 EXPECT_FALSE(controller_impl->has_any_animation()); |
233 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); | 233 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); |
234 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); | 234 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); |
235 | 235 |
236 controller->SetAnimationRegistrar(nullptr); | 236 controller->SetAnimationRegistrar(nullptr); |
237 controller_impl->SetAnimationRegistrar(nullptr); | 237 controller_impl->SetAnimationRegistrar(nullptr); |
238 } | 238 } |
239 | 239 |
240 TEST(LayerAnimationControllerTest, SyncPause) { | 240 TEST(LayerAnimationControllerTest, SyncPause) { |
241 FakeLayerAnimationValueObserver dummy_impl; | 241 FakeLayerAnimationValueObserver dummy_impl; |
242 scoped_refptr<LayerAnimationController> controller_impl( | 242 scoped_refptr<LayerAnimationController> controller_impl( |
243 LayerAnimationController::Create(0)); | 243 LayerAnimationController::Create(0)); |
244 controller_impl->AddValueObserver(&dummy_impl); | 244 controller_impl->AddValueObserver(&dummy_impl); |
245 FakeLayerAnimationValueObserver dummy; | 245 FakeLayerAnimationValueObserver dummy; |
246 scoped_refptr<LayerAnimationController> controller( | 246 scoped_refptr<LayerAnimationController> controller( |
247 LayerAnimationController::Create(0)); | 247 LayerAnimationController::Create(0)); |
248 controller->AddValueObserver(&dummy); | 248 controller->AddValueObserver(&dummy); |
249 | 249 |
250 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY)); | 250 EXPECT_FALSE(controller_impl->GetAnimation(Animation::Opacity)); |
251 | 251 |
252 int animation_id = | 252 int animation_id = |
253 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 253 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
254 | 254 |
255 controller->PushAnimationUpdatesTo(controller_impl.get()); | 255 controller->PushAnimationUpdatesTo(controller_impl.get()); |
256 controller_impl->ActivateAnimations(); | 256 controller_impl->ActivateAnimations(); |
257 | 257 |
258 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 258 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
259 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 259 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
260 controller_impl->GetAnimationById(animation_id)->run_state()); | 260 controller_impl->GetAnimationById(animation_id)->run_state()); |
261 | 261 |
262 // Start the animations on each controller. | 262 // Start the animations on each controller. |
263 AnimationEventsVector events; | 263 AnimationEventsVector events; |
264 controller_impl->Animate(kInitialTickTime); | 264 controller_impl->Animate(kInitialTickTime); |
265 controller_impl->UpdateState(true, &events); | 265 controller_impl->UpdateState(true, &events); |
266 controller->Animate(kInitialTickTime); | 266 controller->Animate(kInitialTickTime); |
267 controller->UpdateState(true, nullptr); | 267 controller->UpdateState(true, nullptr); |
268 EXPECT_EQ(Animation::RUNNING, | 268 EXPECT_EQ(Animation::Running, |
269 controller_impl->GetAnimationById(animation_id)->run_state()); | 269 controller_impl->GetAnimationById(animation_id)->run_state()); |
270 EXPECT_EQ(Animation::RUNNING, | 270 EXPECT_EQ(Animation::Running, |
271 controller->GetAnimationById(animation_id)->run_state()); | 271 controller->GetAnimationById(animation_id)->run_state()); |
272 | 272 |
273 // Pause the main-thread animation. | 273 // Pause the main-thread animation. |
274 controller->PauseAnimation( | 274 controller->PauseAnimation( |
275 animation_id, | 275 animation_id, |
276 TimeDelta::FromMilliseconds(1000) + TimeDelta::FromMilliseconds(1000)); | 276 TimeDelta::FromMilliseconds(1000) + TimeDelta::FromMilliseconds(1000)); |
277 EXPECT_EQ(Animation::PAUSED, | 277 EXPECT_EQ(Animation::Paused, |
278 controller->GetAnimationById(animation_id)->run_state()); | 278 controller->GetAnimationById(animation_id)->run_state()); |
279 | 279 |
280 // The pause run state change should make it to the impl thread controller. | 280 // The pause run state change should make it to the impl thread controller. |
281 controller->PushAnimationUpdatesTo(controller_impl.get()); | 281 controller->PushAnimationUpdatesTo(controller_impl.get()); |
282 controller_impl->ActivateAnimations(); | 282 controller_impl->ActivateAnimations(); |
283 EXPECT_EQ(Animation::PAUSED, | 283 EXPECT_EQ(Animation::Paused, |
284 controller_impl->GetAnimationById(animation_id)->run_state()); | 284 controller_impl->GetAnimationById(animation_id)->run_state()); |
285 } | 285 } |
286 | 286 |
287 TEST(LayerAnimationControllerTest, DoNotSyncFinishedAnimation) { | 287 TEST(LayerAnimationControllerTest, DoNotSyncFinishedAnimation) { |
288 FakeLayerAnimationValueObserver dummy_impl; | 288 FakeLayerAnimationValueObserver dummy_impl; |
289 scoped_refptr<LayerAnimationController> controller_impl( | 289 scoped_refptr<LayerAnimationController> controller_impl( |
290 LayerAnimationController::Create(0)); | 290 LayerAnimationController::Create(0)); |
291 controller_impl->AddValueObserver(&dummy_impl); | 291 controller_impl->AddValueObserver(&dummy_impl); |
292 FakeLayerAnimationValueObserver dummy; | 292 FakeLayerAnimationValueObserver dummy; |
293 scoped_refptr<LayerAnimationController> controller( | 293 scoped_refptr<LayerAnimationController> controller( |
294 LayerAnimationController::Create(0)); | 294 LayerAnimationController::Create(0)); |
295 controller->AddValueObserver(&dummy); | 295 controller->AddValueObserver(&dummy); |
296 | 296 |
297 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY)); | 297 EXPECT_FALSE(controller_impl->GetAnimation(Animation::Opacity)); |
298 | 298 |
299 int animation_id = | 299 int animation_id = |
300 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 300 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
301 int group_id = controller->GetAnimationById(animation_id)->group(); | 301 int group_id = controller->GetAnimationById(animation_id)->group(); |
302 | 302 |
303 controller->PushAnimationUpdatesTo(controller_impl.get()); | 303 controller->PushAnimationUpdatesTo(controller_impl.get()); |
304 controller_impl->ActivateAnimations(); | 304 controller_impl->ActivateAnimations(); |
305 | 305 |
306 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 306 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
307 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 307 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
308 controller_impl->GetAnimationById(animation_id)->run_state()); | 308 controller_impl->GetAnimationById(animation_id)->run_state()); |
309 | 309 |
310 // Notify main thread controller that the animation has started. | 310 // Notify main thread controller that the animation has started. |
311 AnimationEvent animation_started_event(AnimationEvent::STARTED, 0, group_id, | 311 AnimationEvent animation_started_event(AnimationEvent::Started, |
312 Animation::OPACITY, kInitialTickTime); | 312 0, |
| 313 group_id, |
| 314 Animation::Opacity, |
| 315 kInitialTickTime); |
313 controller->NotifyAnimationStarted(animation_started_event); | 316 controller->NotifyAnimationStarted(animation_started_event); |
314 | 317 |
315 // Force animation to complete on impl thread. | 318 // Force animation to complete on impl thread. |
316 controller_impl->RemoveAnimation(animation_id); | 319 controller_impl->RemoveAnimation(animation_id); |
317 | 320 |
318 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); | 321 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); |
319 | 322 |
320 controller->PushAnimationUpdatesTo(controller_impl.get()); | 323 controller->PushAnimationUpdatesTo(controller_impl.get()); |
321 controller_impl->ActivateAnimations(); | 324 controller_impl->ActivateAnimations(); |
322 | 325 |
(...skipping 18 matching lines...) Expand all Loading... |
341 | 344 |
342 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false); | 345 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false); |
343 controller->Animate(kInitialTickTime); | 346 controller->Animate(kInitialTickTime); |
344 controller->UpdateState(true, nullptr); | 347 controller->UpdateState(true, nullptr); |
345 controller->PushAnimationUpdatesTo(controller_impl.get()); | 348 controller->PushAnimationUpdatesTo(controller_impl.get()); |
346 controller_impl->ActivateAnimations(); | 349 controller_impl->ActivateAnimations(); |
347 | 350 |
348 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 351 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
349 controller_impl->UpdateState(true, events.get()); | 352 controller_impl->UpdateState(true, events.get()); |
350 | 353 |
351 // There should be a STARTED event for the animation. | 354 // There should be a Started event for the animation. |
352 EXPECT_EQ(1u, events->size()); | 355 EXPECT_EQ(1u, events->size()); |
353 EXPECT_EQ(AnimationEvent::STARTED, (*events)[0].type); | 356 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
354 controller->NotifyAnimationStarted((*events)[0]); | 357 controller->NotifyAnimationStarted((*events)[0]); |
355 | 358 |
356 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 359 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
357 controller->UpdateState(true, nullptr); | 360 controller->UpdateState(true, nullptr); |
358 | 361 |
359 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 362 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
360 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 363 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
361 | 364 |
362 events.reset(new AnimationEventsVector); | 365 events.reset(new AnimationEventsVector); |
363 controller_impl->Animate(kInitialTickTime + | 366 controller_impl->Animate(kInitialTickTime + |
364 TimeDelta::FromMilliseconds(2000)); | 367 TimeDelta::FromMilliseconds(2000)); |
365 controller_impl->UpdateState(true, events.get()); | 368 controller_impl->UpdateState(true, events.get()); |
366 | 369 |
367 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); | 370 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); |
368 | 371 |
369 // There should be a FINISHED event for the animation. | 372 // There should be a Finished event for the animation. |
370 EXPECT_EQ(1u, events->size()); | 373 EXPECT_EQ(1u, events->size()); |
371 EXPECT_EQ(AnimationEvent::FINISHED, (*events)[0].type); | 374 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
372 | 375 |
373 // Neither controller should have deleted the animation yet. | 376 // Neither controller should have deleted the animation yet. |
374 EXPECT_TRUE(controller->GetAnimation(Animation::OPACITY)); | 377 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); |
375 EXPECT_TRUE(controller_impl->GetAnimation(Animation::OPACITY)); | 378 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity)); |
376 | 379 |
377 controller->NotifyAnimationFinished((*events)[0]); | 380 controller->NotifyAnimationFinished((*events)[0]); |
378 | 381 |
379 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); | 382 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
380 controller->UpdateState(true, nullptr); | 383 controller->UpdateState(true, nullptr); |
381 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 384 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
382 | 385 |
383 controller->PushAnimationUpdatesTo(controller_impl.get()); | 386 controller->PushAnimationUpdatesTo(controller_impl.get()); |
384 | 387 |
385 // Both controllers should now have deleted the animation. The impl controller | 388 // Both controllers should now have deleted the animation. The impl controller |
386 // should have deleted the animation even though activation has not occurred, | 389 // should have deleted the animation even though activation has not occurred, |
387 // since the animation was already waiting for deletion when | 390 // since the animation was already waiting for deletion when |
388 // PushAnimationUpdatesTo was called. | 391 // PushAnimationUpdatesTo was called. |
389 EXPECT_FALSE(controller->has_any_animation()); | 392 EXPECT_FALSE(controller->has_any_animation()); |
390 EXPECT_FALSE(controller_impl->has_any_animation()); | 393 EXPECT_FALSE(controller_impl->has_any_animation()); |
391 } | 394 } |
392 | 395 |
393 // Tests that transitioning opacity from 0 to 1 works as expected. | 396 // Tests that transitioning opacity from 0 to 1 works as expected. |
394 | 397 |
395 static const AnimationEvent* GetMostRecentPropertyUpdateEvent( | 398 static const AnimationEvent* GetMostRecentPropertyUpdateEvent( |
396 const AnimationEventsVector* events) { | 399 const AnimationEventsVector* events) { |
397 const AnimationEvent* event = 0; | 400 const AnimationEvent* event = 0; |
398 for (size_t i = 0; i < events->size(); ++i) | 401 for (size_t i = 0; i < events->size(); ++i) |
399 if ((*events)[i].type == AnimationEvent::PROPERTY_UPDATE) | 402 if ((*events)[i].type == AnimationEvent::PropertyUpdate) |
400 event = &(*events)[i]; | 403 event = &(*events)[i]; |
401 | 404 |
402 return event; | 405 return event; |
403 } | 406 } |
404 | 407 |
405 TEST(LayerAnimationControllerTest, TrivialTransition) { | 408 TEST(LayerAnimationControllerTest, TrivialTransition) { |
406 scoped_ptr<AnimationEventsVector> events( | 409 scoped_ptr<AnimationEventsVector> events( |
407 make_scoped_ptr(new AnimationEventsVector)); | 410 make_scoped_ptr(new AnimationEventsVector)); |
408 FakeLayerAnimationValueObserver dummy; | 411 FakeLayerAnimationValueObserver dummy; |
409 scoped_refptr<LayerAnimationController> controller( | 412 scoped_refptr<LayerAnimationController> controller( |
410 LayerAnimationController::Create(0)); | 413 LayerAnimationController::Create(0)); |
411 controller->AddValueObserver(&dummy); | 414 controller->AddValueObserver(&dummy); |
412 | 415 |
413 scoped_ptr<Animation> to_add(CreateAnimation( | 416 scoped_ptr<Animation> to_add(CreateAnimation( |
414 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 417 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
415 1, Animation::OPACITY)); | 418 1, |
| 419 Animation::Opacity)); |
416 | 420 |
417 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); | 421 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); |
418 controller->AddAnimation(to_add.Pass()); | 422 controller->AddAnimation(to_add.Pass()); |
419 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); | 423 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); |
420 controller->Animate(kInitialTickTime); | 424 controller->Animate(kInitialTickTime); |
421 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); | 425 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); |
422 controller->UpdateState(true, events.get()); | 426 controller->UpdateState(true, events.get()); |
423 EXPECT_TRUE(controller->HasActiveAnimation()); | 427 EXPECT_TRUE(controller->HasActiveAnimation()); |
424 EXPECT_EQ(0.f, dummy.opacity()); | 428 EXPECT_EQ(0.f, dummy.opacity()); |
425 // A non-impl-only animation should not generate property updates. | 429 // A non-impl-only animation should not generate property updates. |
(...skipping 10 matching lines...) Expand all Loading... |
436 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { | 440 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { |
437 scoped_ptr<AnimationEventsVector> events( | 441 scoped_ptr<AnimationEventsVector> events( |
438 make_scoped_ptr(new AnimationEventsVector)); | 442 make_scoped_ptr(new AnimationEventsVector)); |
439 FakeLayerAnimationValueObserver dummy_impl; | 443 FakeLayerAnimationValueObserver dummy_impl; |
440 scoped_refptr<LayerAnimationController> controller_impl( | 444 scoped_refptr<LayerAnimationController> controller_impl( |
441 LayerAnimationController::Create(0)); | 445 LayerAnimationController::Create(0)); |
442 controller_impl->AddValueObserver(&dummy_impl); | 446 controller_impl->AddValueObserver(&dummy_impl); |
443 | 447 |
444 scoped_ptr<Animation> to_add(CreateAnimation( | 448 scoped_ptr<Animation> to_add(CreateAnimation( |
445 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 449 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
446 1, Animation::OPACITY)); | 450 1, |
| 451 Animation::Opacity)); |
447 to_add->set_is_impl_only(true); | 452 to_add->set_is_impl_only(true); |
448 | 453 |
449 controller_impl->AddAnimation(to_add.Pass()); | 454 controller_impl->AddAnimation(to_add.Pass()); |
450 controller_impl->Animate(kInitialTickTime); | 455 controller_impl->Animate(kInitialTickTime); |
451 controller_impl->UpdateState(true, events.get()); | 456 controller_impl->UpdateState(true, events.get()); |
452 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 457 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
453 EXPECT_EQ(0.f, dummy_impl.opacity()); | 458 EXPECT_EQ(0.f, dummy_impl.opacity()); |
454 EXPECT_EQ(1u, events->size()); | 459 EXPECT_EQ(1u, events->size()); |
455 const AnimationEvent* start_opacity_event = | 460 const AnimationEvent* start_opacity_event = |
456 GetMostRecentPropertyUpdateEvent(events.get()); | 461 GetMostRecentPropertyUpdateEvent(events.get()); |
(...skipping 19 matching lines...) Expand all Loading... |
476 controller_impl->AddValueObserver(&dummy_impl); | 481 controller_impl->AddValueObserver(&dummy_impl); |
477 | 482 |
478 // Choose different values for x and y to avoid coincidental values in the | 483 // Choose different values for x and y to avoid coincidental values in the |
479 // observed transforms. | 484 // observed transforms. |
480 const float delta_x = 3; | 485 const float delta_x = 3; |
481 const float delta_y = 4; | 486 const float delta_y = 4; |
482 | 487 |
483 scoped_ptr<KeyframedTransformAnimationCurve> curve( | 488 scoped_ptr<KeyframedTransformAnimationCurve> curve( |
484 KeyframedTransformAnimationCurve::Create()); | 489 KeyframedTransformAnimationCurve::Create()); |
485 | 490 |
486 // Create simple TRANSFORM animation. | 491 // Create simple Transform animation. |
487 TransformOperations operations; | 492 TransformOperations operations; |
488 curve->AddKeyframe( | 493 curve->AddKeyframe( |
489 TransformKeyframe::Create(base::TimeDelta(), operations, nullptr)); | 494 TransformKeyframe::Create(base::TimeDelta(), operations, nullptr)); |
490 operations.AppendTranslate(delta_x, delta_y, 0); | 495 operations.AppendTranslate(delta_x, delta_y, 0); |
491 curve->AddKeyframe(TransformKeyframe::Create( | 496 curve->AddKeyframe(TransformKeyframe::Create( |
492 base::TimeDelta::FromSecondsD(1.0), operations, nullptr)); | 497 base::TimeDelta::FromSecondsD(1.0), operations, nullptr)); |
493 | 498 |
494 scoped_ptr<Animation> animation( | 499 scoped_ptr<Animation> animation( |
495 Animation::Create(curve.Pass(), 1, 0, Animation::TRANSFORM)); | 500 Animation::Create(curve.Pass(), 1, 0, Animation::Transform)); |
496 animation->set_is_impl_only(true); | 501 animation->set_is_impl_only(true); |
497 controller_impl->AddAnimation(animation.Pass()); | 502 controller_impl->AddAnimation(animation.Pass()); |
498 | 503 |
499 // Run animation. | 504 // Run animation. |
500 controller_impl->Animate(kInitialTickTime); | 505 controller_impl->Animate(kInitialTickTime); |
501 controller_impl->UpdateState(true, events.get()); | 506 controller_impl->UpdateState(true, events.get()); |
502 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 507 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
503 EXPECT_EQ(gfx::Transform(), dummy_impl.transform()); | 508 EXPECT_EQ(gfx::Transform(), dummy_impl.transform()); |
504 EXPECT_EQ(1u, events->size()); | 509 EXPECT_EQ(1u, events->size()); |
505 const AnimationEvent* start_transform_event = | 510 const AnimationEvent* start_transform_event = |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 FilterOperations start_filters; | 542 FilterOperations start_filters; |
538 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); | 543 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); |
539 curve->AddKeyframe( | 544 curve->AddKeyframe( |
540 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); | 545 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); |
541 FilterOperations end_filters; | 546 FilterOperations end_filters; |
542 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); | 547 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); |
543 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), | 548 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), |
544 end_filters, nullptr)); | 549 end_filters, nullptr)); |
545 | 550 |
546 scoped_ptr<Animation> animation( | 551 scoped_ptr<Animation> animation( |
547 Animation::Create(curve.Pass(), 1, 0, Animation::FILTER)); | 552 Animation::Create(curve.Pass(), 1, 0, Animation::Filter)); |
548 controller->AddAnimation(animation.Pass()); | 553 controller->AddAnimation(animation.Pass()); |
549 | 554 |
550 controller->Animate(kInitialTickTime); | 555 controller->Animate(kInitialTickTime); |
551 controller->UpdateState(true, events.get()); | 556 controller->UpdateState(true, events.get()); |
552 EXPECT_TRUE(controller->HasActiveAnimation()); | 557 EXPECT_TRUE(controller->HasActiveAnimation()); |
553 EXPECT_EQ(start_filters, dummy.filters()); | 558 EXPECT_EQ(start_filters, dummy.filters()); |
554 // A non-impl-only animation should not generate property updates. | 559 // A non-impl-only animation should not generate property updates. |
555 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 560 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
556 EXPECT_FALSE(event); | 561 EXPECT_FALSE(event); |
557 | 562 |
(...skipping 17 matching lines...) Expand all Loading... |
575 scoped_ptr<AnimationEventsVector> events( | 580 scoped_ptr<AnimationEventsVector> events( |
576 make_scoped_ptr(new AnimationEventsVector)); | 581 make_scoped_ptr(new AnimationEventsVector)); |
577 FakeLayerAnimationValueObserver dummy_impl; | 582 FakeLayerAnimationValueObserver dummy_impl; |
578 scoped_refptr<LayerAnimationController> controller_impl( | 583 scoped_refptr<LayerAnimationController> controller_impl( |
579 LayerAnimationController::Create(0)); | 584 LayerAnimationController::Create(0)); |
580 controller_impl->AddValueObserver(&dummy_impl); | 585 controller_impl->AddValueObserver(&dummy_impl); |
581 | 586 |
582 scoped_ptr<KeyframedFilterAnimationCurve> curve( | 587 scoped_ptr<KeyframedFilterAnimationCurve> curve( |
583 KeyframedFilterAnimationCurve::Create()); | 588 KeyframedFilterAnimationCurve::Create()); |
584 | 589 |
585 // Create simple FILTER animation. | 590 // Create simple Filter animation. |
586 FilterOperations start_filters; | 591 FilterOperations start_filters; |
587 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); | 592 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); |
588 curve->AddKeyframe( | 593 curve->AddKeyframe( |
589 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); | 594 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); |
590 FilterOperations end_filters; | 595 FilterOperations end_filters; |
591 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); | 596 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); |
592 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), | 597 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), |
593 end_filters, nullptr)); | 598 end_filters, nullptr)); |
594 | 599 |
595 scoped_ptr<Animation> animation( | 600 scoped_ptr<Animation> animation( |
596 Animation::Create(curve.Pass(), 1, 0, Animation::FILTER)); | 601 Animation::Create(curve.Pass(), 1, 0, Animation::Filter)); |
597 animation->set_is_impl_only(true); | 602 animation->set_is_impl_only(true); |
598 controller_impl->AddAnimation(animation.Pass()); | 603 controller_impl->AddAnimation(animation.Pass()); |
599 | 604 |
600 // Run animation. | 605 // Run animation. |
601 controller_impl->Animate(kInitialTickTime); | 606 controller_impl->Animate(kInitialTickTime); |
602 controller_impl->UpdateState(true, events.get()); | 607 controller_impl->UpdateState(true, events.get()); |
603 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 608 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
604 EXPECT_EQ(start_filters, dummy_impl.filters()); | 609 EXPECT_EQ(start_filters, dummy_impl.filters()); |
605 EXPECT_EQ(1u, events->size()); | 610 EXPECT_EQ(1u, events->size()); |
606 const AnimationEvent* start_filter_event = | 611 const AnimationEvent* start_filter_event = |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 controller->set_value_provider(&dummy_provider); | 644 controller->set_value_provider(&dummy_provider); |
640 | 645 |
641 gfx::ScrollOffset initial_value(100.f, 300.f); | 646 gfx::ScrollOffset initial_value(100.f, 300.f); |
642 gfx::ScrollOffset target_value(300.f, 200.f); | 647 gfx::ScrollOffset target_value(300.f, 200.f); |
643 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 648 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
644 ScrollOffsetAnimationCurve::Create( | 649 ScrollOffsetAnimationCurve::Create( |
645 target_value, | 650 target_value, |
646 EaseInOutTimingFunction::Create().Pass())); | 651 EaseInOutTimingFunction::Create().Pass())); |
647 | 652 |
648 scoped_ptr<Animation> animation( | 653 scoped_ptr<Animation> animation( |
649 Animation::Create(curve.Pass(), 1, 0, Animation::SCROLL_OFFSET)); | 654 Animation::Create(curve.Pass(), 1, 0, Animation::ScrollOffset)); |
650 animation->set_needs_synchronized_start_time(true); | 655 animation->set_needs_synchronized_start_time(true); |
651 controller->AddAnimation(animation.Pass()); | 656 controller->AddAnimation(animation.Pass()); |
652 | 657 |
653 dummy_provider_impl.set_scroll_offset(initial_value); | 658 dummy_provider_impl.set_scroll_offset(initial_value); |
654 controller->PushAnimationUpdatesTo(controller_impl.get()); | 659 controller->PushAnimationUpdatesTo(controller_impl.get()); |
655 controller_impl->ActivateAnimations(); | 660 controller_impl->ActivateAnimations(); |
656 EXPECT_TRUE(controller_impl->GetAnimation(Animation::SCROLL_OFFSET)); | 661 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); |
657 TimeDelta duration = controller_impl->GetAnimation(Animation::SCROLL_OFFSET) | 662 TimeDelta duration = controller_impl->GetAnimation(Animation::ScrollOffset) |
658 ->curve() | 663 ->curve() |
659 ->Duration(); | 664 ->Duration(); |
660 EXPECT_EQ( | 665 EXPECT_EQ( |
661 duration, | 666 duration, |
662 controller->GetAnimation(Animation::SCROLL_OFFSET)->curve()->Duration()); | 667 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); |
663 | 668 |
664 controller->Animate(kInitialTickTime); | 669 controller->Animate(kInitialTickTime); |
665 controller->UpdateState(true, nullptr); | 670 controller->UpdateState(true, nullptr); |
666 EXPECT_TRUE(controller->HasActiveAnimation()); | 671 EXPECT_TRUE(controller->HasActiveAnimation()); |
667 EXPECT_EQ(initial_value, dummy.scroll_offset()); | 672 EXPECT_EQ(initial_value, dummy.scroll_offset()); |
668 | 673 |
669 controller_impl->Animate(kInitialTickTime); | 674 controller_impl->Animate(kInitialTickTime); |
670 controller_impl->UpdateState(true, events.get()); | 675 controller_impl->UpdateState(true, events.get()); |
671 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 676 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
672 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 677 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
718 controller->set_value_provider(&dummy_provider); | 723 controller->set_value_provider(&dummy_provider); |
719 | 724 |
720 gfx::ScrollOffset initial_value(500.f, 100.f); | 725 gfx::ScrollOffset initial_value(500.f, 100.f); |
721 gfx::ScrollOffset target_value(300.f, 200.f); | 726 gfx::ScrollOffset target_value(300.f, 200.f); |
722 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 727 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
723 ScrollOffsetAnimationCurve::Create( | 728 ScrollOffsetAnimationCurve::Create( |
724 target_value, | 729 target_value, |
725 EaseInOutTimingFunction::Create().Pass())); | 730 EaseInOutTimingFunction::Create().Pass())); |
726 | 731 |
727 scoped_ptr<Animation> animation( | 732 scoped_ptr<Animation> animation( |
728 Animation::Create(curve.Pass(), 1, 0, Animation::SCROLL_OFFSET)); | 733 Animation::Create(curve.Pass(), 1, 0, Animation::ScrollOffset)); |
729 animation->set_needs_synchronized_start_time(true); | 734 animation->set_needs_synchronized_start_time(true); |
730 controller->AddAnimation(animation.Pass()); | 735 controller->AddAnimation(animation.Pass()); |
731 | 736 |
732 dummy_provider.set_scroll_offset(initial_value); | 737 dummy_provider.set_scroll_offset(initial_value); |
733 controller->PushAnimationUpdatesTo(controller_impl.get()); | 738 controller->PushAnimationUpdatesTo(controller_impl.get()); |
734 controller_impl->ActivateAnimations(); | 739 controller_impl->ActivateAnimations(); |
735 EXPECT_TRUE(controller_impl->GetAnimation(Animation::SCROLL_OFFSET)); | 740 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); |
736 TimeDelta duration = controller_impl->GetAnimation(Animation::SCROLL_OFFSET) | 741 TimeDelta duration = controller_impl->GetAnimation(Animation::ScrollOffset) |
737 ->curve() | 742 ->curve() |
738 ->Duration(); | 743 ->Duration(); |
739 EXPECT_EQ( | 744 EXPECT_EQ( |
740 duration, | 745 duration, |
741 controller->GetAnimation(Animation::SCROLL_OFFSET)->curve()->Duration()); | 746 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); |
742 | 747 |
743 controller->Animate(kInitialTickTime); | 748 controller->Animate(kInitialTickTime); |
744 controller->UpdateState(true, nullptr); | 749 controller->UpdateState(true, nullptr); |
745 EXPECT_TRUE(controller->HasActiveAnimation()); | 750 EXPECT_TRUE(controller->HasActiveAnimation()); |
746 EXPECT_EQ(initial_value, dummy.scroll_offset()); | 751 EXPECT_EQ(initial_value, dummy.scroll_offset()); |
747 | 752 |
748 controller_impl->Animate(kInitialTickTime); | 753 controller_impl->Animate(kInitialTickTime); |
749 controller_impl->UpdateState(true, events.get()); | 754 controller_impl->UpdateState(true, events.get()); |
750 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 755 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
751 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 756 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 gfx::ScrollOffset initial_value(100.f, 300.f); | 796 gfx::ScrollOffset initial_value(100.f, 300.f); |
792 gfx::ScrollOffset target_value(300.f, 200.f); | 797 gfx::ScrollOffset target_value(300.f, 200.f); |
793 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 798 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
794 ScrollOffsetAnimationCurve::Create( | 799 ScrollOffsetAnimationCurve::Create( |
795 target_value, | 800 target_value, |
796 EaseInOutTimingFunction::Create().Pass())); | 801 EaseInOutTimingFunction::Create().Pass())); |
797 curve->SetInitialValue(initial_value); | 802 curve->SetInitialValue(initial_value); |
798 double duration_in_seconds = curve->Duration().InSecondsF(); | 803 double duration_in_seconds = curve->Duration().InSecondsF(); |
799 | 804 |
800 scoped_ptr<Animation> animation( | 805 scoped_ptr<Animation> animation( |
801 Animation::Create(curve.Pass(), 1, 0, Animation::SCROLL_OFFSET)); | 806 Animation::Create(curve.Pass(), 1, 0, Animation::ScrollOffset)); |
802 animation->set_is_impl_only(true); | 807 animation->set_is_impl_only(true); |
803 controller_impl->AddAnimation(animation.Pass()); | 808 controller_impl->AddAnimation(animation.Pass()); |
804 | 809 |
805 controller_impl->Animate(kInitialTickTime); | 810 controller_impl->Animate(kInitialTickTime); |
806 controller_impl->UpdateState(true, events.get()); | 811 controller_impl->UpdateState(true, events.get()); |
807 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 812 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
808 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 813 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
809 // Scroll offset animations should not generate property updates. | 814 // Scroll offset animations should not generate property updates. |
810 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 815 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
811 EXPECT_FALSE(event); | 816 EXPECT_FALSE(event); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 controller->set_value_provider(&dummy_provider); | 850 controller->set_value_provider(&dummy_provider); |
846 | 851 |
847 // First test the 1-argument version of RemoveAnimation. | 852 // First test the 1-argument version of RemoveAnimation. |
848 gfx::ScrollOffset target_value(300.f, 200.f); | 853 gfx::ScrollOffset target_value(300.f, 200.f); |
849 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 854 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
850 ScrollOffsetAnimationCurve::Create( | 855 ScrollOffsetAnimationCurve::Create( |
851 target_value, EaseInOutTimingFunction::Create().Pass())); | 856 target_value, EaseInOutTimingFunction::Create().Pass())); |
852 | 857 |
853 int animation_id = 1; | 858 int animation_id = 1; |
854 scoped_ptr<Animation> animation(Animation::Create( | 859 scoped_ptr<Animation> animation(Animation::Create( |
855 curve.Pass(), animation_id, 0, Animation::SCROLL_OFFSET)); | 860 curve.Pass(), animation_id, 0, Animation::ScrollOffset)); |
856 animation->set_needs_synchronized_start_time(true); | 861 animation->set_needs_synchronized_start_time(true); |
857 controller->AddAnimation(animation.Pass()); | 862 controller->AddAnimation(animation.Pass()); |
858 controller->PushAnimationUpdatesTo(controller_impl.get()); | 863 controller->PushAnimationUpdatesTo(controller_impl.get()); |
859 controller_impl->ActivateAnimations(); | 864 controller_impl->ActivateAnimations(); |
860 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); | 865 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); |
861 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); | 866 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); |
862 | 867 |
863 controller->RemoveAnimation(animation_id); | 868 controller->RemoveAnimation(animation_id); |
864 EXPECT_TRUE(controller->scroll_offset_animation_was_interrupted()); | 869 EXPECT_TRUE(controller->scroll_offset_animation_was_interrupted()); |
865 | 870 |
866 controller->PushAnimationUpdatesTo(controller_impl.get()); | 871 controller->PushAnimationUpdatesTo(controller_impl.get()); |
867 EXPECT_TRUE(controller_impl->scroll_offset_animation_was_interrupted()); | 872 EXPECT_TRUE(controller_impl->scroll_offset_animation_was_interrupted()); |
868 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); | 873 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); |
869 | 874 |
870 controller_impl->ActivateAnimations(); | 875 controller_impl->ActivateAnimations(); |
871 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); | 876 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); |
872 | 877 |
873 // Now, test the 2-argument version of RemoveAnimation. | 878 // Now, test the 2-argument version of RemoveAnimation. |
874 curve = ScrollOffsetAnimationCurve::Create( | 879 curve = ScrollOffsetAnimationCurve::Create( |
875 target_value, EaseInOutTimingFunction::Create().Pass()); | 880 target_value, EaseInOutTimingFunction::Create().Pass()); |
876 animation = Animation::Create(curve.Pass(), animation_id, 0, | 881 animation = |
877 Animation::SCROLL_OFFSET); | 882 Animation::Create(curve.Pass(), animation_id, 0, Animation::ScrollOffset); |
878 animation->set_needs_synchronized_start_time(true); | 883 animation->set_needs_synchronized_start_time(true); |
879 controller->AddAnimation(animation.Pass()); | 884 controller->AddAnimation(animation.Pass()); |
880 controller->PushAnimationUpdatesTo(controller_impl.get()); | 885 controller->PushAnimationUpdatesTo(controller_impl.get()); |
881 controller_impl->ActivateAnimations(); | 886 controller_impl->ActivateAnimations(); |
882 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); | 887 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); |
883 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); | 888 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); |
884 | 889 |
885 controller->RemoveAnimation(animation_id); | 890 controller->RemoveAnimation(animation_id); |
886 EXPECT_TRUE(controller->scroll_offset_animation_was_interrupted()); | 891 EXPECT_TRUE(controller->scroll_offset_animation_was_interrupted()); |
887 | 892 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 scoped_refptr<LayerAnimationController> controller_impl( | 968 scoped_refptr<LayerAnimationController> controller_impl( |
964 LayerAnimationController::Create(0)); | 969 LayerAnimationController::Create(0)); |
965 controller_impl->AddValueObserver(&dummy_impl); | 970 controller_impl->AddValueObserver(&dummy_impl); |
966 scoped_ptr<AnimationEventsVector> events( | 971 scoped_ptr<AnimationEventsVector> events( |
967 make_scoped_ptr(new AnimationEventsVector)); | 972 make_scoped_ptr(new AnimationEventsVector)); |
968 FakeAnimationDelegate delegate; | 973 FakeAnimationDelegate delegate; |
969 controller_impl->set_layer_animation_delegate(&delegate); | 974 controller_impl->set_layer_animation_delegate(&delegate); |
970 | 975 |
971 scoped_ptr<Animation> to_add(CreateAnimation( | 976 scoped_ptr<Animation> to_add(CreateAnimation( |
972 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 977 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
973 1, Animation::OPACITY)); | 978 1, |
| 979 Animation::Opacity)); |
974 to_add->set_is_impl_only(true); | 980 to_add->set_is_impl_only(true); |
975 controller_impl->AddAnimation(to_add.Pass()); | 981 controller_impl->AddAnimation(to_add.Pass()); |
976 | 982 |
977 EXPECT_FALSE(delegate.started()); | 983 EXPECT_FALSE(delegate.started()); |
978 EXPECT_FALSE(delegate.finished()); | 984 EXPECT_FALSE(delegate.finished()); |
979 | 985 |
980 controller_impl->Animate(kInitialTickTime); | 986 controller_impl->Animate(kInitialTickTime); |
981 controller_impl->UpdateState(true, events.get()); | 987 controller_impl->UpdateState(true, events.get()); |
982 | 988 |
983 EXPECT_TRUE(delegate.started()); | 989 EXPECT_TRUE(delegate.started()); |
(...skipping 14 matching lines...) Expand all Loading... |
998 AnimationsWaitingForStartTimeDoNotFinishIfTheyOutwaitTheirFinish) { | 1004 AnimationsWaitingForStartTimeDoNotFinishIfTheyOutwaitTheirFinish) { |
999 scoped_ptr<AnimationEventsVector> events( | 1005 scoped_ptr<AnimationEventsVector> events( |
1000 make_scoped_ptr(new AnimationEventsVector)); | 1006 make_scoped_ptr(new AnimationEventsVector)); |
1001 FakeLayerAnimationValueObserver dummy; | 1007 FakeLayerAnimationValueObserver dummy; |
1002 scoped_refptr<LayerAnimationController> controller( | 1008 scoped_refptr<LayerAnimationController> controller( |
1003 LayerAnimationController::Create(0)); | 1009 LayerAnimationController::Create(0)); |
1004 controller->AddValueObserver(&dummy); | 1010 controller->AddValueObserver(&dummy); |
1005 | 1011 |
1006 scoped_ptr<Animation> to_add(CreateAnimation( | 1012 scoped_ptr<Animation> to_add(CreateAnimation( |
1007 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1013 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1008 1, Animation::OPACITY)); | 1014 1, |
| 1015 Animation::Opacity)); |
1009 to_add->set_needs_synchronized_start_time(true); | 1016 to_add->set_needs_synchronized_start_time(true); |
1010 | 1017 |
1011 // We should pause at the first keyframe indefinitely waiting for that | 1018 // We should pause at the first keyframe indefinitely waiting for that |
1012 // animation to start. | 1019 // animation to start. |
1013 controller->AddAnimation(to_add.Pass()); | 1020 controller->AddAnimation(to_add.Pass()); |
1014 controller->Animate(kInitialTickTime); | 1021 controller->Animate(kInitialTickTime); |
1015 controller->UpdateState(true, events.get()); | 1022 controller->UpdateState(true, events.get()); |
1016 EXPECT_TRUE(controller->HasActiveAnimation()); | 1023 EXPECT_TRUE(controller->HasActiveAnimation()); |
1017 EXPECT_EQ(0.f, dummy.opacity()); | 1024 EXPECT_EQ(0.f, dummy.opacity()); |
1018 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1025 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1019 controller->UpdateState(true, events.get()); | 1026 controller->UpdateState(true, events.get()); |
1020 EXPECT_TRUE(controller->HasActiveAnimation()); | 1027 EXPECT_TRUE(controller->HasActiveAnimation()); |
1021 EXPECT_EQ(0.f, dummy.opacity()); | 1028 EXPECT_EQ(0.f, dummy.opacity()); |
1022 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1029 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
1023 controller->UpdateState(true, events.get()); | 1030 controller->UpdateState(true, events.get()); |
1024 EXPECT_TRUE(controller->HasActiveAnimation()); | 1031 EXPECT_TRUE(controller->HasActiveAnimation()); |
1025 EXPECT_EQ(0.f, dummy.opacity()); | 1032 EXPECT_EQ(0.f, dummy.opacity()); |
1026 | 1033 |
1027 // Send the synchronized start time. | 1034 // Send the synchronized start time. |
1028 controller->NotifyAnimationStarted( | 1035 controller->NotifyAnimationStarted( |
1029 AnimationEvent(AnimationEvent::STARTED, 0, 1, Animation::OPACITY, | 1036 AnimationEvent(AnimationEvent::Started, |
| 1037 0, |
| 1038 1, |
| 1039 Animation::Opacity, |
1030 kInitialTickTime + TimeDelta::FromMilliseconds(2000))); | 1040 kInitialTickTime + TimeDelta::FromMilliseconds(2000))); |
1031 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(5000)); | 1041 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(5000)); |
1032 controller->UpdateState(true, events.get()); | 1042 controller->UpdateState(true, events.get()); |
1033 EXPECT_EQ(1.f, dummy.opacity()); | 1043 EXPECT_EQ(1.f, dummy.opacity()); |
1034 EXPECT_FALSE(controller->HasActiveAnimation()); | 1044 EXPECT_FALSE(controller->HasActiveAnimation()); |
1035 } | 1045 } |
1036 | 1046 |
1037 // Tests that two queued animations affecting the same property run in sequence. | 1047 // Tests that two queued animations affecting the same property run in sequence. |
1038 TEST(LayerAnimationControllerTest, TrivialQueuing) { | 1048 TEST(LayerAnimationControllerTest, TrivialQueuing) { |
1039 scoped_ptr<AnimationEventsVector> events( | 1049 scoped_ptr<AnimationEventsVector> events( |
1040 make_scoped_ptr(new AnimationEventsVector)); | 1050 make_scoped_ptr(new AnimationEventsVector)); |
1041 FakeLayerAnimationValueObserver dummy; | 1051 FakeLayerAnimationValueObserver dummy; |
1042 scoped_refptr<LayerAnimationController> controller( | 1052 scoped_refptr<LayerAnimationController> controller( |
1043 LayerAnimationController::Create(0)); | 1053 LayerAnimationController::Create(0)); |
1044 controller->AddValueObserver(&dummy); | 1054 controller->AddValueObserver(&dummy); |
1045 | 1055 |
1046 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); | 1056 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); |
1047 | 1057 |
1048 controller->AddAnimation(CreateAnimation( | 1058 controller->AddAnimation(CreateAnimation( |
1049 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1059 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1050 1, Animation::OPACITY)); | 1060 1, |
| 1061 Animation::Opacity)); |
1051 controller->AddAnimation(CreateAnimation( | 1062 controller->AddAnimation(CreateAnimation( |
1052 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)) | 1063 scoped_ptr<AnimationCurve>( |
1053 .Pass(), | 1064 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), |
1054 2, Animation::OPACITY)); | 1065 2, |
| 1066 Animation::Opacity)); |
1055 | 1067 |
1056 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); | 1068 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); |
1057 | 1069 |
1058 controller->Animate(kInitialTickTime); | 1070 controller->Animate(kInitialTickTime); |
1059 | 1071 |
1060 // The second animation still needs to be started. | 1072 // The second animation still needs to be started. |
1061 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); | 1073 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); |
1062 | 1074 |
1063 controller->UpdateState(true, events.get()); | 1075 controller->UpdateState(true, events.get()); |
1064 EXPECT_TRUE(controller->HasActiveAnimation()); | 1076 EXPECT_TRUE(controller->HasActiveAnimation()); |
(...skipping 15 matching lines...) Expand all Loading... |
1080 // Tests interrupting a transition with another transition. | 1092 // Tests interrupting a transition with another transition. |
1081 TEST(LayerAnimationControllerTest, Interrupt) { | 1093 TEST(LayerAnimationControllerTest, Interrupt) { |
1082 scoped_ptr<AnimationEventsVector> events( | 1094 scoped_ptr<AnimationEventsVector> events( |
1083 make_scoped_ptr(new AnimationEventsVector)); | 1095 make_scoped_ptr(new AnimationEventsVector)); |
1084 FakeLayerAnimationValueObserver dummy; | 1096 FakeLayerAnimationValueObserver dummy; |
1085 scoped_refptr<LayerAnimationController> controller( | 1097 scoped_refptr<LayerAnimationController> controller( |
1086 LayerAnimationController::Create(0)); | 1098 LayerAnimationController::Create(0)); |
1087 controller->AddValueObserver(&dummy); | 1099 controller->AddValueObserver(&dummy); |
1088 controller->AddAnimation(CreateAnimation( | 1100 controller->AddAnimation(CreateAnimation( |
1089 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1101 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1090 1, Animation::OPACITY)); | 1102 1, |
| 1103 Animation::Opacity)); |
1091 controller->Animate(kInitialTickTime); | 1104 controller->Animate(kInitialTickTime); |
1092 controller->UpdateState(true, events.get()); | 1105 controller->UpdateState(true, events.get()); |
1093 EXPECT_TRUE(controller->HasActiveAnimation()); | 1106 EXPECT_TRUE(controller->HasActiveAnimation()); |
1094 EXPECT_EQ(0.f, dummy.opacity()); | 1107 EXPECT_EQ(0.f, dummy.opacity()); |
1095 | 1108 |
1096 scoped_ptr<Animation> to_add(CreateAnimation( | 1109 scoped_ptr<Animation> to_add(CreateAnimation( |
1097 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)) | 1110 scoped_ptr<AnimationCurve>( |
1098 .Pass(), | 1111 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), |
1099 2, Animation::OPACITY)); | 1112 2, |
1100 controller->AbortAnimations(Animation::OPACITY); | 1113 Animation::Opacity)); |
| 1114 controller->AbortAnimations(Animation::Opacity); |
1101 controller->AddAnimation(to_add.Pass()); | 1115 controller->AddAnimation(to_add.Pass()); |
1102 | 1116 |
1103 // Since the previous animation was aborted, the new animation should start | 1117 // Since the previous animation was aborted, the new animation should start |
1104 // right in this call to animate. | 1118 // right in this call to animate. |
1105 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1119 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
1106 controller->UpdateState(true, events.get()); | 1120 controller->UpdateState(true, events.get()); |
1107 EXPECT_TRUE(controller->HasActiveAnimation()); | 1121 EXPECT_TRUE(controller->HasActiveAnimation()); |
1108 EXPECT_EQ(1.f, dummy.opacity()); | 1122 EXPECT_EQ(1.f, dummy.opacity()); |
1109 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); | 1123 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); |
1110 controller->UpdateState(true, events.get()); | 1124 controller->UpdateState(true, events.get()); |
1111 EXPECT_EQ(0.5f, dummy.opacity()); | 1125 EXPECT_EQ(0.5f, dummy.opacity()); |
1112 EXPECT_FALSE(controller->HasActiveAnimation()); | 1126 EXPECT_FALSE(controller->HasActiveAnimation()); |
1113 } | 1127 } |
1114 | 1128 |
1115 // Tests scheduling two animations to run together when only one property is | 1129 // Tests scheduling two animations to run together when only one property is |
1116 // free. | 1130 // free. |
1117 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { | 1131 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { |
1118 scoped_ptr<AnimationEventsVector> events( | 1132 scoped_ptr<AnimationEventsVector> events( |
1119 make_scoped_ptr(new AnimationEventsVector)); | 1133 make_scoped_ptr(new AnimationEventsVector)); |
1120 FakeLayerAnimationValueObserver dummy; | 1134 FakeLayerAnimationValueObserver dummy; |
1121 scoped_refptr<LayerAnimationController> controller( | 1135 scoped_refptr<LayerAnimationController> controller( |
1122 LayerAnimationController::Create(0)); | 1136 LayerAnimationController::Create(0)); |
1123 controller->AddValueObserver(&dummy); | 1137 controller->AddValueObserver(&dummy); |
1124 | 1138 |
1125 controller->AddAnimation(CreateAnimation( | 1139 controller->AddAnimation(CreateAnimation( |
1126 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), 1, | 1140 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), |
1127 Animation::TRANSFORM)); | 1141 1, |
| 1142 Animation::Transform)); |
1128 controller->AddAnimation(CreateAnimation( | 1143 controller->AddAnimation(CreateAnimation( |
1129 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), 2, | 1144 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), |
1130 Animation::TRANSFORM)); | 1145 2, |
| 1146 Animation::Transform)); |
1131 controller->AddAnimation(CreateAnimation( | 1147 controller->AddAnimation(CreateAnimation( |
1132 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1148 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1133 2, Animation::OPACITY)); | 1149 2, |
| 1150 Animation::Opacity)); |
1134 | 1151 |
1135 controller->Animate(kInitialTickTime); | 1152 controller->Animate(kInitialTickTime); |
1136 controller->UpdateState(true, events.get()); | 1153 controller->UpdateState(true, events.get()); |
1137 EXPECT_EQ(0.f, dummy.opacity()); | 1154 EXPECT_EQ(0.f, dummy.opacity()); |
1138 EXPECT_TRUE(controller->HasActiveAnimation()); | 1155 EXPECT_TRUE(controller->HasActiveAnimation()); |
1139 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1156 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1140 controller->UpdateState(true, events.get()); | 1157 controller->UpdateState(true, events.get()); |
1141 // Should not have started the float transition yet. | 1158 // Should not have started the float transition yet. |
1142 EXPECT_TRUE(controller->HasActiveAnimation()); | 1159 EXPECT_TRUE(controller->HasActiveAnimation()); |
1143 EXPECT_EQ(0.f, dummy.opacity()); | 1160 EXPECT_EQ(0.f, dummy.opacity()); |
1144 // The float animation should have started at time 1 and should be done. | 1161 // The float animation should have started at time 1 and should be done. |
1145 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1162 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
1146 controller->UpdateState(true, events.get()); | 1163 controller->UpdateState(true, events.get()); |
1147 EXPECT_EQ(1.f, dummy.opacity()); | 1164 EXPECT_EQ(1.f, dummy.opacity()); |
1148 EXPECT_FALSE(controller->HasActiveAnimation()); | 1165 EXPECT_FALSE(controller->HasActiveAnimation()); |
1149 } | 1166 } |
1150 | 1167 |
1151 // Tests scheduling two animations to run together with different lengths and | 1168 // Tests scheduling two animations to run together with different lengths and |
1152 // another animation queued to start when the shorter animation finishes (should | 1169 // another animation queued to start when the shorter animation finishes (should |
1153 // wait for both to finish). | 1170 // wait for both to finish). |
1154 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { | 1171 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { |
1155 scoped_ptr<AnimationEventsVector> events( | 1172 scoped_ptr<AnimationEventsVector> events( |
1156 make_scoped_ptr(new AnimationEventsVector)); | 1173 make_scoped_ptr(new AnimationEventsVector)); |
1157 FakeLayerAnimationValueObserver dummy; | 1174 FakeLayerAnimationValueObserver dummy; |
1158 scoped_refptr<LayerAnimationController> controller( | 1175 scoped_refptr<LayerAnimationController> controller( |
1159 LayerAnimationController::Create(0)); | 1176 LayerAnimationController::Create(0)); |
1160 controller->AddValueObserver(&dummy); | 1177 controller->AddValueObserver(&dummy); |
1161 | 1178 |
1162 controller->AddAnimation(CreateAnimation( | 1179 controller->AddAnimation(CreateAnimation( |
1163 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2)).Pass(), 1, | 1180 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2)).Pass(), |
1164 Animation::TRANSFORM)); | 1181 1, |
| 1182 Animation::Transform)); |
1165 controller->AddAnimation(CreateAnimation( | 1183 controller->AddAnimation(CreateAnimation( |
1166 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1184 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1167 1, Animation::OPACITY)); | 1185 1, |
| 1186 Animation::Opacity)); |
1168 controller->AddAnimation(CreateAnimation( | 1187 controller->AddAnimation(CreateAnimation( |
1169 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)) | 1188 scoped_ptr<AnimationCurve>( |
1170 .Pass(), | 1189 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), |
1171 2, Animation::OPACITY)); | 1190 2, |
| 1191 Animation::Opacity)); |
1172 | 1192 |
1173 // Animations with id 1 should both start now. | 1193 // Animations with id 1 should both start now. |
1174 controller->Animate(kInitialTickTime); | 1194 controller->Animate(kInitialTickTime); |
1175 controller->UpdateState(true, events.get()); | 1195 controller->UpdateState(true, events.get()); |
1176 EXPECT_TRUE(controller->HasActiveAnimation()); | 1196 EXPECT_TRUE(controller->HasActiveAnimation()); |
1177 EXPECT_EQ(0.f, dummy.opacity()); | 1197 EXPECT_EQ(0.f, dummy.opacity()); |
1178 // The opacity animation should have finished at time 1, but the group | 1198 // The opacity animation should have finished at time 1, but the group |
1179 // of animations with id 1 don't finish until time 2 because of the length | 1199 // of animations with id 1 don't finish until time 2 because of the length |
1180 // of the transform animation. | 1200 // of the transform animation. |
1181 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1201 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
(...skipping 14 matching lines...) Expand all Loading... |
1196 TEST(LayerAnimationControllerTest, TrivialLooping) { | 1216 TEST(LayerAnimationControllerTest, TrivialLooping) { |
1197 scoped_ptr<AnimationEventsVector> events( | 1217 scoped_ptr<AnimationEventsVector> events( |
1198 make_scoped_ptr(new AnimationEventsVector)); | 1218 make_scoped_ptr(new AnimationEventsVector)); |
1199 FakeLayerAnimationValueObserver dummy; | 1219 FakeLayerAnimationValueObserver dummy; |
1200 scoped_refptr<LayerAnimationController> controller( | 1220 scoped_refptr<LayerAnimationController> controller( |
1201 LayerAnimationController::Create(0)); | 1221 LayerAnimationController::Create(0)); |
1202 controller->AddValueObserver(&dummy); | 1222 controller->AddValueObserver(&dummy); |
1203 | 1223 |
1204 scoped_ptr<Animation> to_add(CreateAnimation( | 1224 scoped_ptr<Animation> to_add(CreateAnimation( |
1205 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1225 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1206 1, Animation::OPACITY)); | 1226 1, |
| 1227 Animation::Opacity)); |
1207 to_add->set_iterations(3); | 1228 to_add->set_iterations(3); |
1208 controller->AddAnimation(to_add.Pass()); | 1229 controller->AddAnimation(to_add.Pass()); |
1209 | 1230 |
1210 controller->Animate(kInitialTickTime); | 1231 controller->Animate(kInitialTickTime); |
1211 controller->UpdateState(true, events.get()); | 1232 controller->UpdateState(true, events.get()); |
1212 EXPECT_TRUE(controller->HasActiveAnimation()); | 1233 EXPECT_TRUE(controller->HasActiveAnimation()); |
1213 EXPECT_EQ(0.f, dummy.opacity()); | 1234 EXPECT_EQ(0.f, dummy.opacity()); |
1214 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); | 1235 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); |
1215 controller->UpdateState(true, events.get()); | 1236 controller->UpdateState(true, events.get()); |
1216 EXPECT_TRUE(controller->HasActiveAnimation()); | 1237 EXPECT_TRUE(controller->HasActiveAnimation()); |
(...skipping 25 matching lines...) Expand all Loading... |
1242 TEST(LayerAnimationControllerTest, InfiniteLooping) { | 1263 TEST(LayerAnimationControllerTest, InfiniteLooping) { |
1243 scoped_ptr<AnimationEventsVector> events( | 1264 scoped_ptr<AnimationEventsVector> events( |
1244 make_scoped_ptr(new AnimationEventsVector)); | 1265 make_scoped_ptr(new AnimationEventsVector)); |
1245 FakeLayerAnimationValueObserver dummy; | 1266 FakeLayerAnimationValueObserver dummy; |
1246 scoped_refptr<LayerAnimationController> controller( | 1267 scoped_refptr<LayerAnimationController> controller( |
1247 LayerAnimationController::Create(0)); | 1268 LayerAnimationController::Create(0)); |
1248 controller->AddValueObserver(&dummy); | 1269 controller->AddValueObserver(&dummy); |
1249 | 1270 |
1250 scoped_ptr<Animation> to_add(CreateAnimation( | 1271 scoped_ptr<Animation> to_add(CreateAnimation( |
1251 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1272 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1252 1, Animation::OPACITY)); | 1273 1, Animation::Opacity)); |
1253 to_add->set_iterations(-1); | 1274 to_add->set_iterations(-1); |
1254 controller->AddAnimation(to_add.Pass()); | 1275 controller->AddAnimation(to_add.Pass()); |
1255 | 1276 |
1256 controller->Animate(kInitialTickTime); | 1277 controller->Animate(kInitialTickTime); |
1257 controller->UpdateState(true, events.get()); | 1278 controller->UpdateState(true, events.get()); |
1258 EXPECT_TRUE(controller->HasActiveAnimation()); | 1279 EXPECT_TRUE(controller->HasActiveAnimation()); |
1259 EXPECT_EQ(0.f, dummy.opacity()); | 1280 EXPECT_EQ(0.f, dummy.opacity()); |
1260 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); | 1281 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); |
1261 controller->UpdateState(true, events.get()); | 1282 controller->UpdateState(true, events.get()); |
1262 EXPECT_TRUE(controller->HasActiveAnimation()); | 1283 EXPECT_TRUE(controller->HasActiveAnimation()); |
1263 EXPECT_EQ(0.25f, dummy.opacity()); | 1284 EXPECT_EQ(0.25f, dummy.opacity()); |
1264 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); | 1285 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); |
1265 controller->UpdateState(true, events.get()); | 1286 controller->UpdateState(true, events.get()); |
1266 EXPECT_TRUE(controller->HasActiveAnimation()); | 1287 EXPECT_TRUE(controller->HasActiveAnimation()); |
1267 EXPECT_EQ(0.75f, dummy.opacity()); | 1288 EXPECT_EQ(0.75f, dummy.opacity()); |
1268 | 1289 |
1269 controller->Animate(kInitialTickTime + | 1290 controller->Animate(kInitialTickTime + |
1270 TimeDelta::FromMilliseconds(1073741824250)); | 1291 TimeDelta::FromMilliseconds(1073741824250)); |
1271 controller->UpdateState(true, events.get()); | 1292 controller->UpdateState(true, events.get()); |
1272 EXPECT_TRUE(controller->HasActiveAnimation()); | 1293 EXPECT_TRUE(controller->HasActiveAnimation()); |
1273 EXPECT_EQ(0.25f, dummy.opacity()); | 1294 EXPECT_EQ(0.25f, dummy.opacity()); |
1274 controller->Animate(kInitialTickTime + | 1295 controller->Animate(kInitialTickTime + |
1275 TimeDelta::FromMilliseconds(1073741824750)); | 1296 TimeDelta::FromMilliseconds(1073741824750)); |
1276 controller->UpdateState(true, events.get()); | 1297 controller->UpdateState(true, events.get()); |
1277 EXPECT_TRUE(controller->HasActiveAnimation()); | 1298 EXPECT_TRUE(controller->HasActiveAnimation()); |
1278 EXPECT_EQ(0.75f, dummy.opacity()); | 1299 EXPECT_EQ(0.75f, dummy.opacity()); |
1279 | 1300 |
1280 EXPECT_TRUE(controller->GetAnimation(Animation::OPACITY)); | 1301 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); |
1281 controller->GetAnimation(Animation::OPACITY) | 1302 controller->GetAnimation(Animation::Opacity) |
1282 ->SetRunState(Animation::ABORTED, | 1303 ->SetRunState(Animation::Aborted, |
1283 kInitialTickTime + TimeDelta::FromMilliseconds(750)); | 1304 kInitialTickTime + TimeDelta::FromMilliseconds(750)); |
1284 EXPECT_FALSE(controller->HasActiveAnimation()); | 1305 EXPECT_FALSE(controller->HasActiveAnimation()); |
1285 EXPECT_EQ(0.75f, dummy.opacity()); | 1306 EXPECT_EQ(0.75f, dummy.opacity()); |
1286 } | 1307 } |
1287 | 1308 |
1288 // Test that pausing and resuming work as expected. | 1309 // Test that pausing and resuming work as expected. |
1289 TEST(LayerAnimationControllerTest, PauseResume) { | 1310 TEST(LayerAnimationControllerTest, PauseResume) { |
1290 scoped_ptr<AnimationEventsVector> events( | 1311 scoped_ptr<AnimationEventsVector> events( |
1291 make_scoped_ptr(new AnimationEventsVector)); | 1312 make_scoped_ptr(new AnimationEventsVector)); |
1292 FakeLayerAnimationValueObserver dummy; | 1313 FakeLayerAnimationValueObserver dummy; |
1293 scoped_refptr<LayerAnimationController> controller( | 1314 scoped_refptr<LayerAnimationController> controller( |
1294 LayerAnimationController::Create(0)); | 1315 LayerAnimationController::Create(0)); |
1295 controller->AddValueObserver(&dummy); | 1316 controller->AddValueObserver(&dummy); |
1296 | 1317 |
1297 controller->AddAnimation(CreateAnimation( | 1318 controller->AddAnimation(CreateAnimation( |
1298 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1319 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1299 1, Animation::OPACITY)); | 1320 1, Animation::Opacity)); |
1300 | 1321 |
1301 controller->Animate(kInitialTickTime); | 1322 controller->Animate(kInitialTickTime); |
1302 controller->UpdateState(true, events.get()); | 1323 controller->UpdateState(true, events.get()); |
1303 EXPECT_TRUE(controller->HasActiveAnimation()); | 1324 EXPECT_TRUE(controller->HasActiveAnimation()); |
1304 EXPECT_EQ(0.f, dummy.opacity()); | 1325 EXPECT_EQ(0.f, dummy.opacity()); |
1305 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1326 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
1306 controller->UpdateState(true, events.get()); | 1327 controller->UpdateState(true, events.get()); |
1307 EXPECT_TRUE(controller->HasActiveAnimation()); | 1328 EXPECT_TRUE(controller->HasActiveAnimation()); |
1308 EXPECT_EQ(0.5f, dummy.opacity()); | 1329 EXPECT_EQ(0.5f, dummy.opacity()); |
1309 | 1330 |
1310 EXPECT_TRUE(controller->GetAnimation(Animation::OPACITY)); | 1331 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); |
1311 controller->GetAnimation(Animation::OPACITY) | 1332 controller->GetAnimation(Animation::Opacity) |
1312 ->SetRunState(Animation::PAUSED, | 1333 ->SetRunState(Animation::Paused, |
1313 kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1334 kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
1314 | 1335 |
1315 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); | 1336 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); |
1316 controller->UpdateState(true, events.get()); | 1337 controller->UpdateState(true, events.get()); |
1317 EXPECT_TRUE(controller->HasActiveAnimation()); | 1338 EXPECT_TRUE(controller->HasActiveAnimation()); |
1318 EXPECT_EQ(0.5f, dummy.opacity()); | 1339 EXPECT_EQ(0.5f, dummy.opacity()); |
1319 | 1340 |
1320 EXPECT_TRUE(controller->GetAnimation(Animation::OPACITY)); | 1341 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); |
1321 controller->GetAnimation(Animation::OPACITY) | 1342 controller->GetAnimation(Animation::Opacity) |
1322 ->SetRunState(Animation::RUNNING, | 1343 ->SetRunState(Animation::Running, |
1323 kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); | 1344 kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); |
1324 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024250)); | 1345 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024250)); |
1325 controller->UpdateState(true, events.get()); | 1346 controller->UpdateState(true, events.get()); |
1326 EXPECT_TRUE(controller->HasActiveAnimation()); | 1347 EXPECT_TRUE(controller->HasActiveAnimation()); |
1327 EXPECT_EQ(0.75f, dummy.opacity()); | 1348 EXPECT_EQ(0.75f, dummy.opacity()); |
1328 | 1349 |
1329 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024500)); | 1350 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024500)); |
1330 controller->UpdateState(true, events.get()); | 1351 controller->UpdateState(true, events.get()); |
1331 EXPECT_FALSE(controller->HasActiveAnimation()); | 1352 EXPECT_FALSE(controller->HasActiveAnimation()); |
1332 EXPECT_EQ(1.f, dummy.opacity()); | 1353 EXPECT_EQ(1.f, dummy.opacity()); |
1333 } | 1354 } |
1334 | 1355 |
1335 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { | 1356 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { |
1336 scoped_ptr<AnimationEventsVector> events( | 1357 scoped_ptr<AnimationEventsVector> events( |
1337 make_scoped_ptr(new AnimationEventsVector)); | 1358 make_scoped_ptr(new AnimationEventsVector)); |
1338 FakeLayerAnimationValueObserver dummy; | 1359 FakeLayerAnimationValueObserver dummy; |
1339 scoped_refptr<LayerAnimationController> controller( | 1360 scoped_refptr<LayerAnimationController> controller( |
1340 LayerAnimationController::Create(0)); | 1361 LayerAnimationController::Create(0)); |
1341 controller->AddValueObserver(&dummy); | 1362 controller->AddValueObserver(&dummy); |
1342 | 1363 |
1343 const int animation_id = 2; | 1364 const int animation_id = 2; |
1344 controller->AddAnimation(Animation::Create( | 1365 controller->AddAnimation(Animation::Create( |
1345 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), 1, 1, | 1366 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), 1, 1, |
1346 Animation::TRANSFORM)); | 1367 Animation::Transform)); |
1347 controller->AddAnimation(Animation::Create( | 1368 controller->AddAnimation(Animation::Create( |
1348 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), | 1369 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), |
1349 animation_id, 1, Animation::OPACITY)); | 1370 animation_id, 1, Animation::Opacity)); |
1350 controller->AddAnimation(Animation::Create( | 1371 controller->AddAnimation(Animation::Create( |
1351 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.75f)) | 1372 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.75f)) |
1352 .Pass(), | 1373 .Pass(), |
1353 3, 2, Animation::OPACITY)); | 1374 3, 2, Animation::Opacity)); |
1354 | 1375 |
1355 controller->Animate(kInitialTickTime); | 1376 controller->Animate(kInitialTickTime); |
1356 controller->UpdateState(true, events.get()); | 1377 controller->UpdateState(true, events.get()); |
1357 EXPECT_TRUE(controller->HasActiveAnimation()); | 1378 EXPECT_TRUE(controller->HasActiveAnimation()); |
1358 EXPECT_EQ(0.f, dummy.opacity()); | 1379 EXPECT_EQ(0.f, dummy.opacity()); |
1359 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1380 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1360 controller->UpdateState(true, events.get()); | 1381 controller->UpdateState(true, events.get()); |
1361 EXPECT_TRUE(controller->HasActiveAnimation()); | 1382 EXPECT_TRUE(controller->HasActiveAnimation()); |
1362 EXPECT_EQ(0.5f, dummy.opacity()); | 1383 EXPECT_EQ(0.5f, dummy.opacity()); |
1363 | 1384 |
1364 EXPECT_TRUE(controller->GetAnimationById(animation_id)); | 1385 EXPECT_TRUE(controller->GetAnimationById(animation_id)); |
1365 controller->GetAnimationById(animation_id) | 1386 controller->GetAnimationById(animation_id) |
1366 ->SetRunState(Animation::ABORTED, | 1387 ->SetRunState(Animation::Aborted, |
1367 kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1388 kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1368 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1389 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1369 controller->UpdateState(true, events.get()); | 1390 controller->UpdateState(true, events.get()); |
1370 EXPECT_TRUE(controller->HasActiveAnimation()); | 1391 EXPECT_TRUE(controller->HasActiveAnimation()); |
1371 EXPECT_EQ(1.f, dummy.opacity()); | 1392 EXPECT_EQ(1.f, dummy.opacity()); |
1372 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1393 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
1373 controller->UpdateState(true, events.get()); | 1394 controller->UpdateState(true, events.get()); |
1374 EXPECT_TRUE(!controller->HasActiveAnimation()); | 1395 EXPECT_TRUE(!controller->HasActiveAnimation()); |
1375 EXPECT_EQ(0.75f, dummy.opacity()); | 1396 EXPECT_EQ(0.75f, dummy.opacity()); |
1376 } | 1397 } |
1377 | 1398 |
1378 TEST(LayerAnimationControllerTest, PushUpdatesWhenSynchronizedStartTimeNeeded) { | 1399 TEST(LayerAnimationControllerTest, PushUpdatesWhenSynchronizedStartTimeNeeded) { |
1379 FakeLayerAnimationValueObserver dummy_impl; | 1400 FakeLayerAnimationValueObserver dummy_impl; |
1380 scoped_refptr<LayerAnimationController> controller_impl( | 1401 scoped_refptr<LayerAnimationController> controller_impl( |
1381 LayerAnimationController::Create(0)); | 1402 LayerAnimationController::Create(0)); |
1382 controller_impl->AddValueObserver(&dummy_impl); | 1403 controller_impl->AddValueObserver(&dummy_impl); |
1383 scoped_ptr<AnimationEventsVector> events( | 1404 scoped_ptr<AnimationEventsVector> events( |
1384 make_scoped_ptr(new AnimationEventsVector)); | 1405 make_scoped_ptr(new AnimationEventsVector)); |
1385 FakeLayerAnimationValueObserver dummy; | 1406 FakeLayerAnimationValueObserver dummy; |
1386 scoped_refptr<LayerAnimationController> controller( | 1407 scoped_refptr<LayerAnimationController> controller( |
1387 LayerAnimationController::Create(0)); | 1408 LayerAnimationController::Create(0)); |
1388 controller->AddValueObserver(&dummy); | 1409 controller->AddValueObserver(&dummy); |
1389 | 1410 |
1390 scoped_ptr<Animation> to_add(CreateAnimation( | 1411 scoped_ptr<Animation> to_add(CreateAnimation( |
1391 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), | 1412 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)).Pass(), |
1392 0, Animation::OPACITY)); | 1413 0, |
| 1414 Animation::Opacity)); |
1393 to_add->set_needs_synchronized_start_time(true); | 1415 to_add->set_needs_synchronized_start_time(true); |
1394 controller->AddAnimation(to_add.Pass()); | 1416 controller->AddAnimation(to_add.Pass()); |
1395 | 1417 |
1396 controller->Animate(kInitialTickTime); | 1418 controller->Animate(kInitialTickTime); |
1397 controller->UpdateState(true, events.get()); | 1419 controller->UpdateState(true, events.get()); |
1398 EXPECT_TRUE(controller->HasActiveAnimation()); | 1420 EXPECT_TRUE(controller->HasActiveAnimation()); |
1399 Animation* active_animation = controller->GetAnimation(Animation::OPACITY); | 1421 Animation* active_animation = controller->GetAnimation(Animation::Opacity); |
1400 EXPECT_TRUE(active_animation); | 1422 EXPECT_TRUE(active_animation); |
1401 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); | 1423 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); |
1402 | 1424 |
1403 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1425 controller->PushAnimationUpdatesTo(controller_impl.get()); |
1404 controller_impl->ActivateAnimations(); | 1426 controller_impl->ActivateAnimations(); |
1405 | 1427 |
1406 active_animation = controller_impl->GetAnimation(Animation::OPACITY); | 1428 active_animation = controller_impl->GetAnimation(Animation::Opacity); |
1407 EXPECT_TRUE(active_animation); | 1429 EXPECT_TRUE(active_animation); |
1408 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1430 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
1409 active_animation->run_state()); | 1431 active_animation->run_state()); |
1410 } | 1432 } |
1411 | 1433 |
1412 // Tests that skipping a call to UpdateState works as expected. | 1434 // Tests that skipping a call to UpdateState works as expected. |
1413 TEST(LayerAnimationControllerTest, SkipUpdateState) { | 1435 TEST(LayerAnimationControllerTest, SkipUpdateState) { |
1414 scoped_ptr<AnimationEventsVector> events( | 1436 scoped_ptr<AnimationEventsVector> events( |
1415 make_scoped_ptr(new AnimationEventsVector)); | 1437 make_scoped_ptr(new AnimationEventsVector)); |
1416 FakeLayerAnimationValueObserver dummy; | 1438 FakeLayerAnimationValueObserver dummy; |
1417 scoped_refptr<LayerAnimationController> controller( | 1439 scoped_refptr<LayerAnimationController> controller( |
1418 LayerAnimationController::Create(0)); | 1440 LayerAnimationController::Create(0)); |
1419 controller->AddValueObserver(&dummy); | 1441 controller->AddValueObserver(&dummy); |
1420 | 1442 |
1421 controller->AddAnimation(CreateAnimation( | 1443 controller->AddAnimation(CreateAnimation( |
1422 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), 1, | 1444 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), |
1423 Animation::TRANSFORM)); | 1445 1, |
| 1446 Animation::Transform)); |
1424 | 1447 |
1425 controller->Animate(kInitialTickTime); | 1448 controller->Animate(kInitialTickTime); |
1426 controller->UpdateState(true, events.get()); | 1449 controller->UpdateState(true, events.get()); |
1427 | 1450 |
1428 controller->AddAnimation(CreateAnimation( | 1451 controller->AddAnimation(CreateAnimation( |
1429 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1452 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1430 2, Animation::OPACITY)); | 1453 2, |
| 1454 Animation::Opacity)); |
1431 | 1455 |
1432 // Animate but don't UpdateState. | 1456 // Animate but don't UpdateState. |
1433 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1457 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1434 | 1458 |
1435 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1459 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
1436 events.reset(new AnimationEventsVector); | 1460 events.reset(new AnimationEventsVector); |
1437 controller->UpdateState(true, events.get()); | 1461 controller->UpdateState(true, events.get()); |
1438 | 1462 |
1439 // Should have one STARTED event and one FINISHED event. | 1463 // Should have one Started event and one Finished event. |
1440 EXPECT_EQ(2u, events->size()); | 1464 EXPECT_EQ(2u, events->size()); |
1441 EXPECT_NE((*events)[0].type, (*events)[1].type); | 1465 EXPECT_NE((*events)[0].type, (*events)[1].type); |
1442 | 1466 |
1443 // The float transition should still be at its starting point. | 1467 // The float transition should still be at its starting point. |
1444 EXPECT_TRUE(controller->HasActiveAnimation()); | 1468 EXPECT_TRUE(controller->HasActiveAnimation()); |
1445 EXPECT_EQ(0.f, dummy.opacity()); | 1469 EXPECT_EQ(0.f, dummy.opacity()); |
1446 | 1470 |
1447 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); | 1471 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
1448 controller->UpdateState(true, events.get()); | 1472 controller->UpdateState(true, events.get()); |
1449 | 1473 |
1450 // The float tranisition should now be done. | 1474 // The float tranisition should now be done. |
1451 EXPECT_EQ(1.f, dummy.opacity()); | 1475 EXPECT_EQ(1.f, dummy.opacity()); |
1452 EXPECT_FALSE(controller->HasActiveAnimation()); | 1476 EXPECT_FALSE(controller->HasActiveAnimation()); |
1453 } | 1477 } |
1454 | 1478 |
1455 // Tests that an animation controller with only a pending observer gets ticked | 1479 // Tests that an animation controller with only a pending observer gets ticked |
1456 // but doesn't progress animations past the STARTING state. | 1480 // but doesn't progress animations past the Starting state. |
1457 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { | 1481 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { |
1458 scoped_ptr<AnimationEventsVector> events( | 1482 scoped_ptr<AnimationEventsVector> events( |
1459 make_scoped_ptr(new AnimationEventsVector)); | 1483 make_scoped_ptr(new AnimationEventsVector)); |
1460 FakeLayerAnimationValueObserver dummy; | 1484 FakeLayerAnimationValueObserver dummy; |
1461 FakeInactiveLayerAnimationValueObserver pending_dummy; | 1485 FakeInactiveLayerAnimationValueObserver pending_dummy; |
1462 scoped_refptr<LayerAnimationController> controller( | 1486 scoped_refptr<LayerAnimationController> controller( |
1463 LayerAnimationController::Create(0)); | 1487 LayerAnimationController::Create(0)); |
1464 | 1488 |
1465 const int id = 1; | 1489 const int id = 1; |
1466 controller->AddAnimation(CreateAnimation( | 1490 controller->AddAnimation(CreateAnimation(scoped_ptr<AnimationCurve>( |
1467 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.5f, 1.f)) | 1491 new FakeFloatTransition(1.0, 0.5f, 1.f)).Pass(), |
1468 .Pass(), | 1492 id, |
1469 id, Animation::OPACITY)); | 1493 Animation::Opacity)); |
1470 | 1494 |
1471 // Without an observer, the animation shouldn't progress to the STARTING | 1495 // Without an observer, the animation shouldn't progress to the Starting |
1472 // state. | 1496 // state. |
1473 controller->Animate(kInitialTickTime); | 1497 controller->Animate(kInitialTickTime); |
1474 controller->UpdateState(true, events.get()); | 1498 controller->UpdateState(true, events.get()); |
1475 EXPECT_EQ(0u, events->size()); | 1499 EXPECT_EQ(0u, events->size()); |
1476 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1500 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
1477 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1501 controller->GetAnimation(Animation::Opacity)->run_state()); |
1478 | 1502 |
1479 controller->AddValueObserver(&pending_dummy); | 1503 controller->AddValueObserver(&pending_dummy); |
1480 | 1504 |
1481 // With only a pending observer, the animation should progress to the | 1505 // With only a pending observer, the animation should progress to the |
1482 // STARTING state and get ticked at its starting point, but should not | 1506 // Starting state and get ticked at its starting point, but should not |
1483 // progress to RUNNING. | 1507 // progress to Running. |
1484 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1508 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1485 controller->UpdateState(true, events.get()); | 1509 controller->UpdateState(true, events.get()); |
1486 EXPECT_EQ(0u, events->size()); | 1510 EXPECT_EQ(0u, events->size()); |
1487 EXPECT_EQ(Animation::STARTING, | 1511 EXPECT_EQ(Animation::Starting, |
1488 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1512 controller->GetAnimation(Animation::Opacity)->run_state()); |
1489 EXPECT_EQ(0.5f, pending_dummy.opacity()); | 1513 EXPECT_EQ(0.5f, pending_dummy.opacity()); |
1490 | 1514 |
1491 // Even when already in the STARTING state, the animation should stay | 1515 // Even when already in the Starting state, the animation should stay |
1492 // there, and shouldn't be ticked past its starting point. | 1516 // there, and shouldn't be ticked past its starting point. |
1493 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1517 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
1494 controller->UpdateState(true, events.get()); | 1518 controller->UpdateState(true, events.get()); |
1495 EXPECT_EQ(0u, events->size()); | 1519 EXPECT_EQ(0u, events->size()); |
1496 EXPECT_EQ(Animation::STARTING, | 1520 EXPECT_EQ(Animation::Starting, |
1497 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1521 controller->GetAnimation(Animation::Opacity)->run_state()); |
1498 EXPECT_EQ(0.5f, pending_dummy.opacity()); | 1522 EXPECT_EQ(0.5f, pending_dummy.opacity()); |
1499 | 1523 |
1500 controller->AddValueObserver(&dummy); | 1524 controller->AddValueObserver(&dummy); |
1501 | 1525 |
1502 // Now that an active observer has been added, the animation should still | 1526 // Now that an active observer has been added, the animation should still |
1503 // initially tick at its starting point, but should now progress to RUNNING. | 1527 // initially tick at its starting point, but should now progress to Running. |
1504 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); | 1528 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
1505 controller->UpdateState(true, events.get()); | 1529 controller->UpdateState(true, events.get()); |
1506 EXPECT_EQ(1u, events->size()); | 1530 EXPECT_EQ(1u, events->size()); |
1507 EXPECT_EQ(Animation::RUNNING, | 1531 EXPECT_EQ(Animation::Running, |
1508 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1532 controller->GetAnimation(Animation::Opacity)->run_state()); |
1509 EXPECT_EQ(0.5f, pending_dummy.opacity()); | 1533 EXPECT_EQ(0.5f, pending_dummy.opacity()); |
1510 EXPECT_EQ(0.5f, dummy.opacity()); | 1534 EXPECT_EQ(0.5f, dummy.opacity()); |
1511 | 1535 |
1512 // The animation should now tick past its starting point. | 1536 // The animation should now tick past its starting point. |
1513 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3500)); | 1537 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3500)); |
1514 EXPECT_NE(0.5f, pending_dummy.opacity()); | 1538 EXPECT_NE(0.5f, pending_dummy.opacity()); |
1515 EXPECT_NE(0.5f, dummy.opacity()); | 1539 EXPECT_NE(0.5f, dummy.opacity()); |
1516 } | 1540 } |
1517 | 1541 |
1518 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { | 1542 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { |
1519 scoped_refptr<LayerAnimationController> controller_impl( | 1543 scoped_refptr<LayerAnimationController> controller_impl( |
1520 LayerAnimationController::Create(0)); | 1544 LayerAnimationController::Create(0)); |
1521 | 1545 |
1522 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1546 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1523 KeyframedTransformAnimationCurve::Create()); | 1547 KeyframedTransformAnimationCurve::Create()); |
1524 | 1548 |
1525 TransformOperations operations1; | 1549 TransformOperations operations1; |
1526 curve1->AddKeyframe( | 1550 curve1->AddKeyframe( |
1527 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 1551 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
1528 operations1.AppendTranslate(10.0, 15.0, 0.0); | 1552 operations1.AppendTranslate(10.0, 15.0, 0.0); |
1529 curve1->AddKeyframe(TransformKeyframe::Create( | 1553 curve1->AddKeyframe(TransformKeyframe::Create( |
1530 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 1554 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
1531 | 1555 |
1532 scoped_ptr<Animation> animation( | 1556 scoped_ptr<Animation> animation( |
1533 Animation::Create(curve1.Pass(), 1, 1, Animation::TRANSFORM)); | 1557 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); |
1534 controller_impl->AddAnimation(animation.Pass()); | 1558 controller_impl->AddAnimation(animation.Pass()); |
1535 | 1559 |
1536 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 1560 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
1537 KeyframedTransformAnimationCurve::Create()); | 1561 KeyframedTransformAnimationCurve::Create()); |
1538 | 1562 |
1539 TransformOperations operations2; | 1563 TransformOperations operations2; |
1540 curve2->AddKeyframe( | 1564 curve2->AddKeyframe( |
1541 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 1565 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
1542 operations2.AppendScale(2.0, 3.0, 4.0); | 1566 operations2.AppendScale(2.0, 3.0, 4.0); |
1543 curve2->AddKeyframe(TransformKeyframe::Create( | 1567 curve2->AddKeyframe(TransformKeyframe::Create( |
1544 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 1568 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
1545 | 1569 |
1546 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::TRANSFORM); | 1570 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::Transform); |
1547 controller_impl->AddAnimation(animation.Pass()); | 1571 controller_impl->AddAnimation(animation.Pass()); |
1548 | 1572 |
1549 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); | 1573 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); |
1550 gfx::BoxF bounds; | 1574 gfx::BoxF bounds; |
1551 | 1575 |
1552 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1576 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); |
1553 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), | 1577 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), |
1554 bounds.ToString()); | 1578 bounds.ToString()); |
1555 | 1579 |
1556 controller_impl->GetAnimationById(1) | 1580 controller_impl->GetAnimationById(1) |
1557 ->SetRunState(Animation::FINISHED, TicksFromSecondsF(0.0)); | 1581 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1558 | 1582 |
1559 // Only the unfinished animation should affect the animated bounds. | 1583 // Only the unfinished animation should affect the animated bounds. |
1560 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1584 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); |
1561 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 7.f, 16.f, 20.f).ToString(), | 1585 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 7.f, 16.f, 20.f).ToString(), |
1562 bounds.ToString()); | 1586 bounds.ToString()); |
1563 | 1587 |
1564 controller_impl->GetAnimationById(2) | 1588 controller_impl->GetAnimationById(2) |
1565 ->SetRunState(Animation::FINISHED, TicksFromSecondsF(0.0)); | 1589 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1566 | 1590 |
1567 // There are no longer any running animations. | 1591 // There are no longer any running animations. |
1568 EXPECT_FALSE(controller_impl->HasTransformAnimationThatInflatesBounds()); | 1592 EXPECT_FALSE(controller_impl->HasTransformAnimationThatInflatesBounds()); |
1569 | 1593 |
1570 // Add an animation whose bounds we don't yet support computing. | 1594 // Add an animation whose bounds we don't yet support computing. |
1571 scoped_ptr<KeyframedTransformAnimationCurve> curve3( | 1595 scoped_ptr<KeyframedTransformAnimationCurve> curve3( |
1572 KeyframedTransformAnimationCurve::Create()); | 1596 KeyframedTransformAnimationCurve::Create()); |
1573 TransformOperations operations3; | 1597 TransformOperations operations3; |
1574 gfx::Transform transform3; | 1598 gfx::Transform transform3; |
1575 transform3.Scale3d(1.0, 2.0, 3.0); | 1599 transform3.Scale3d(1.0, 2.0, 3.0); |
1576 curve3->AddKeyframe( | 1600 curve3->AddKeyframe( |
1577 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 1601 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
1578 operations3.AppendMatrix(transform3); | 1602 operations3.AppendMatrix(transform3); |
1579 curve3->AddKeyframe(TransformKeyframe::Create( | 1603 curve3->AddKeyframe(TransformKeyframe::Create( |
1580 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); | 1604 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); |
1581 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::TRANSFORM); | 1605 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::Transform); |
1582 controller_impl->AddAnimation(animation.Pass()); | 1606 controller_impl->AddAnimation(animation.Pass()); |
1583 EXPECT_FALSE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1607 EXPECT_FALSE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); |
1584 } | 1608 } |
1585 | 1609 |
1586 // Tests that AbortAnimations aborts all animations targeting the specified | 1610 // Tests that AbortAnimations aborts all animations targeting the specified |
1587 // property. | 1611 // property. |
1588 TEST(LayerAnimationControllerTest, AbortAnimations) { | 1612 TEST(LayerAnimationControllerTest, AbortAnimations) { |
1589 FakeLayerAnimationValueObserver dummy; | 1613 FakeLayerAnimationValueObserver dummy; |
1590 scoped_refptr<LayerAnimationController> controller( | 1614 scoped_refptr<LayerAnimationController> controller( |
1591 LayerAnimationController::Create(0)); | 1615 LayerAnimationController::Create(0)); |
1592 controller->AddValueObserver(&dummy); | 1616 controller->AddValueObserver(&dummy); |
1593 | 1617 |
1594 // Start with several animations, and allow some of them to reach the finished | 1618 // Start with several animations, and allow some of them to reach the finished |
1595 // state. | 1619 // state. |
1596 controller->AddAnimation(Animation::Create( | 1620 controller->AddAnimation(Animation::Create( |
1597 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)).Pass(), 1, 1, | 1621 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)).Pass(), 1, 1, |
1598 Animation::TRANSFORM)); | 1622 Animation::Transform)); |
1599 controller->AddAnimation(Animation::Create( | 1623 controller->AddAnimation(Animation::Create( |
1600 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1624 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1601 2, 2, Animation::OPACITY)); | 1625 2, 2, Animation::Opacity)); |
1602 controller->AddAnimation(Animation::Create( | 1626 controller->AddAnimation(Animation::Create( |
1603 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)).Pass(), 3, 3, | 1627 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)).Pass(), 3, 3, |
1604 Animation::TRANSFORM)); | 1628 Animation::Transform)); |
1605 controller->AddAnimation(Animation::Create( | 1629 controller->AddAnimation(Animation::Create( |
1606 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), 4, 4, | 1630 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), 4, 4, |
1607 Animation::TRANSFORM)); | 1631 Animation::Transform)); |
1608 controller->AddAnimation(Animation::Create( | 1632 controller->AddAnimation(Animation::Create( |
1609 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1633 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1610 5, 5, Animation::OPACITY)); | 1634 5, 5, Animation::Opacity)); |
1611 | 1635 |
1612 controller->Animate(kInitialTickTime); | 1636 controller->Animate(kInitialTickTime); |
1613 controller->UpdateState(true, nullptr); | 1637 controller->UpdateState(true, nullptr); |
1614 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1638 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1615 controller->UpdateState(true, nullptr); | 1639 controller->UpdateState(true, nullptr); |
1616 | 1640 |
1617 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(1)->run_state()); | 1641 EXPECT_EQ(Animation::Finished, controller->GetAnimationById(1)->run_state()); |
1618 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(2)->run_state()); | 1642 EXPECT_EQ(Animation::Finished, controller->GetAnimationById(2)->run_state()); |
1619 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(3)->run_state()); | 1643 EXPECT_EQ(Animation::Running, controller->GetAnimationById(3)->run_state()); |
1620 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1644 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
1621 controller->GetAnimationById(4)->run_state()); | 1645 controller->GetAnimationById(4)->run_state()); |
1622 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(5)->run_state()); | 1646 EXPECT_EQ(Animation::Running, controller->GetAnimationById(5)->run_state()); |
1623 | 1647 |
1624 controller->AbortAnimations(Animation::TRANSFORM); | 1648 controller->AbortAnimations(Animation::Transform); |
1625 | 1649 |
1626 // Only un-finished TRANSFORM animations should have been aborted. | 1650 // Only un-finished Transform animations should have been aborted. |
1627 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(1)->run_state()); | 1651 EXPECT_EQ(Animation::Finished, controller->GetAnimationById(1)->run_state()); |
1628 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(2)->run_state()); | 1652 EXPECT_EQ(Animation::Finished, controller->GetAnimationById(2)->run_state()); |
1629 EXPECT_EQ(Animation::ABORTED, controller->GetAnimationById(3)->run_state()); | 1653 EXPECT_EQ(Animation::Aborted, controller->GetAnimationById(3)->run_state()); |
1630 EXPECT_EQ(Animation::ABORTED, controller->GetAnimationById(4)->run_state()); | 1654 EXPECT_EQ(Animation::Aborted, controller->GetAnimationById(4)->run_state()); |
1631 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(5)->run_state()); | 1655 EXPECT_EQ(Animation::Running, controller->GetAnimationById(5)->run_state()); |
1632 } | 1656 } |
1633 | 1657 |
1634 // An animation aborted on the main thread should get deleted on both threads. | 1658 // An animation aborted on the main thread should get deleted on both threads. |
1635 TEST(LayerAnimationControllerTest, MainThreadAbortedAnimationGetsDeleted) { | 1659 TEST(LayerAnimationControllerTest, MainThreadAbortedAnimationGetsDeleted) { |
1636 FakeLayerAnimationValueObserver dummy_impl; | 1660 FakeLayerAnimationValueObserver dummy_impl; |
1637 scoped_refptr<LayerAnimationController> controller_impl( | 1661 scoped_refptr<LayerAnimationController> controller_impl( |
1638 LayerAnimationController::Create(0)); | 1662 LayerAnimationController::Create(0)); |
1639 controller_impl->AddValueObserver(&dummy_impl); | 1663 controller_impl->AddValueObserver(&dummy_impl); |
1640 FakeLayerAnimationValueObserver dummy; | 1664 FakeLayerAnimationValueObserver dummy; |
1641 scoped_refptr<LayerAnimationController> controller( | 1665 scoped_refptr<LayerAnimationController> controller( |
1642 LayerAnimationController::Create(0)); | 1666 LayerAnimationController::Create(0)); |
1643 controller->AddValueObserver(&dummy); | 1667 controller->AddValueObserver(&dummy); |
1644 | 1668 |
1645 int animation_id = | 1669 int animation_id = |
1646 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); | 1670 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); |
1647 | 1671 |
1648 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1672 controller->PushAnimationUpdatesTo(controller_impl.get()); |
1649 controller_impl->ActivateAnimations(); | 1673 controller_impl->ActivateAnimations(); |
1650 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 1674 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
1651 | 1675 |
1652 controller->AbortAnimations(Animation::OPACITY); | 1676 controller->AbortAnimations(Animation::Opacity); |
1653 EXPECT_EQ(Animation::ABORTED, | 1677 EXPECT_EQ(Animation::Aborted, |
1654 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1678 controller->GetAnimation(Animation::Opacity)->run_state()); |
1655 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 1679 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
1656 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 1680 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
1657 | 1681 |
1658 controller->Animate(kInitialTickTime); | 1682 controller->Animate(kInitialTickTime); |
1659 controller->UpdateState(true, nullptr); | 1683 controller->UpdateState(true, nullptr); |
1660 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 1684 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
1661 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 1685 EXPECT_EQ(Animation::WaitingForDeletion, |
1662 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1686 controller->GetAnimation(Animation::Opacity)->run_state()); |
1663 | 1687 |
1664 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1688 controller->PushAnimationUpdatesTo(controller_impl.get()); |
1665 controller_impl->ActivateAnimations(); | 1689 controller_impl->ActivateAnimations(); |
1666 EXPECT_FALSE(controller->GetAnimationById(animation_id)); | 1690 EXPECT_FALSE(controller->GetAnimationById(animation_id)); |
1667 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); | 1691 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); |
1668 } | 1692 } |
1669 | 1693 |
1670 // An animation aborted on the impl thread should get deleted on both threads. | 1694 // An animation aborted on the impl thread should get deleted on both threads. |
1671 TEST(LayerAnimationControllerTest, ImplThreadAbortedAnimationGetsDeleted) { | 1695 TEST(LayerAnimationControllerTest, ImplThreadAbortedAnimationGetsDeleted) { |
1672 FakeLayerAnimationValueObserver dummy_impl; | 1696 FakeLayerAnimationValueObserver dummy_impl; |
1673 scoped_refptr<LayerAnimationController> controller_impl( | 1697 scoped_refptr<LayerAnimationController> controller_impl( |
1674 LayerAnimationController::Create(0)); | 1698 LayerAnimationController::Create(0)); |
1675 controller_impl->AddValueObserver(&dummy_impl); | 1699 controller_impl->AddValueObserver(&dummy_impl); |
1676 FakeLayerAnimationValueObserver dummy; | 1700 FakeLayerAnimationValueObserver dummy; |
1677 scoped_refptr<LayerAnimationController> controller( | 1701 scoped_refptr<LayerAnimationController> controller( |
1678 LayerAnimationController::Create(0)); | 1702 LayerAnimationController::Create(0)); |
1679 controller->AddValueObserver(&dummy); | 1703 controller->AddValueObserver(&dummy); |
1680 | 1704 |
1681 int animation_id = | 1705 int animation_id = |
1682 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); | 1706 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); |
1683 | 1707 |
1684 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1708 controller->PushAnimationUpdatesTo(controller_impl.get()); |
1685 controller_impl->ActivateAnimations(); | 1709 controller_impl->ActivateAnimations(); |
1686 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 1710 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
1687 | 1711 |
1688 controller_impl->AbortAnimations(Animation::OPACITY); | 1712 controller_impl->AbortAnimations(Animation::Opacity); |
1689 EXPECT_EQ(Animation::ABORTED, | 1713 EXPECT_EQ(Animation::Aborted, |
1690 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); | 1714 controller_impl->GetAnimation(Animation::Opacity)->run_state()); |
1691 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 1715 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
1692 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 1716 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
1693 | 1717 |
1694 AnimationEventsVector events; | 1718 AnimationEventsVector events; |
1695 controller_impl->Animate(kInitialTickTime); | 1719 controller_impl->Animate(kInitialTickTime); |
1696 controller_impl->UpdateState(true, &events); | 1720 controller_impl->UpdateState(true, &events); |
1697 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); | 1721 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); |
1698 EXPECT_EQ(1u, events.size()); | 1722 EXPECT_EQ(1u, events.size()); |
1699 EXPECT_EQ(AnimationEvent::ABORTED, events[0].type); | 1723 EXPECT_EQ(AnimationEvent::Aborted, events[0].type); |
1700 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 1724 EXPECT_EQ(Animation::WaitingForDeletion, |
1701 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); | 1725 controller_impl->GetAnimation(Animation::Opacity)->run_state()); |
1702 | 1726 |
1703 controller->NotifyAnimationAborted(events[0]); | 1727 controller->NotifyAnimationAborted(events[0]); |
1704 EXPECT_EQ(Animation::ABORTED, | 1728 EXPECT_EQ(Animation::Aborted, |
1705 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1729 controller->GetAnimation(Animation::Opacity)->run_state()); |
1706 | 1730 |
1707 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1731 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
1708 controller->UpdateState(true, nullptr); | 1732 controller->UpdateState(true, nullptr); |
1709 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 1733 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
1710 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 1734 EXPECT_EQ(Animation::WaitingForDeletion, |
1711 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1735 controller->GetAnimation(Animation::Opacity)->run_state()); |
1712 | 1736 |
1713 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1737 controller->PushAnimationUpdatesTo(controller_impl.get()); |
1714 controller_impl->ActivateAnimations(); | 1738 controller_impl->ActivateAnimations(); |
1715 EXPECT_FALSE(controller->GetAnimationById(animation_id)); | 1739 EXPECT_FALSE(controller->GetAnimationById(animation_id)); |
1716 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); | 1740 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); |
1717 } | 1741 } |
1718 | 1742 |
1719 // Ensure that we only generate FINISHED events for animations in a group | 1743 // Ensure that we only generate Finished events for animations in a group |
1720 // once all animations in that group are finished. | 1744 // once all animations in that group are finished. |
1721 TEST(LayerAnimationControllerTest, FinishedEventsForGroup) { | 1745 TEST(LayerAnimationControllerTest, FinishedEventsForGroup) { |
1722 scoped_ptr<AnimationEventsVector> events( | 1746 scoped_ptr<AnimationEventsVector> events( |
1723 make_scoped_ptr(new AnimationEventsVector)); | 1747 make_scoped_ptr(new AnimationEventsVector)); |
1724 FakeLayerAnimationValueObserver dummy_impl; | 1748 FakeLayerAnimationValueObserver dummy_impl; |
1725 scoped_refptr<LayerAnimationController> controller_impl( | 1749 scoped_refptr<LayerAnimationController> controller_impl( |
1726 LayerAnimationController::Create(0)); | 1750 LayerAnimationController::Create(0)); |
1727 controller_impl->AddValueObserver(&dummy_impl); | 1751 controller_impl->AddValueObserver(&dummy_impl); |
1728 | 1752 |
1729 const int group_id = 1; | 1753 const int group_id = 1; |
1730 | 1754 |
1731 // Add two animations with the same group id but different durations. | 1755 // Add two animations with the same group id but different durations. |
1732 controller_impl->AddAnimation(Animation::Create( | 1756 controller_impl->AddAnimation(Animation::Create( |
1733 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), 1, | 1757 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), 1, |
1734 group_id, Animation::TRANSFORM)); | 1758 group_id, Animation::Transform)); |
1735 controller_impl->AddAnimation(Animation::Create( | 1759 controller_impl->AddAnimation(Animation::Create( |
1736 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1760 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1737 2, group_id, Animation::OPACITY)); | 1761 2, group_id, Animation::Opacity)); |
1738 | 1762 |
1739 controller_impl->Animate(kInitialTickTime); | 1763 controller_impl->Animate(kInitialTickTime); |
1740 controller_impl->UpdateState(true, events.get()); | 1764 controller_impl->UpdateState(true, events.get()); |
1741 | 1765 |
1742 // Both animations should have started. | 1766 // Both animations should have started. |
1743 EXPECT_EQ(2u, events->size()); | 1767 EXPECT_EQ(2u, events->size()); |
1744 EXPECT_EQ(AnimationEvent::STARTED, (*events)[0].type); | 1768 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
1745 EXPECT_EQ(AnimationEvent::STARTED, (*events)[1].type); | 1769 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); |
1746 | 1770 |
1747 events.reset(new AnimationEventsVector); | 1771 events.reset(new AnimationEventsVector); |
1748 controller_impl->Animate(kInitialTickTime + | 1772 controller_impl->Animate(kInitialTickTime + |
1749 TimeDelta::FromMilliseconds(1000)); | 1773 TimeDelta::FromMilliseconds(1000)); |
1750 controller_impl->UpdateState(true, events.get()); | 1774 controller_impl->UpdateState(true, events.get()); |
1751 | 1775 |
1752 // The opacity animation should be finished, but should not have generated | 1776 // The opacity animation should be finished, but should not have generated |
1753 // a FINISHED event yet. | 1777 // a Finished event yet. |
1754 EXPECT_EQ(0u, events->size()); | 1778 EXPECT_EQ(0u, events->size()); |
1755 EXPECT_EQ(Animation::FINISHED, | 1779 EXPECT_EQ(Animation::Finished, |
1756 controller_impl->GetAnimationById(2)->run_state()); | 1780 controller_impl->GetAnimationById(2)->run_state()); |
1757 EXPECT_EQ(Animation::RUNNING, | 1781 EXPECT_EQ(Animation::Running, |
1758 controller_impl->GetAnimationById(1)->run_state()); | 1782 controller_impl->GetAnimationById(1)->run_state()); |
1759 | 1783 |
1760 controller_impl->Animate(kInitialTickTime + | 1784 controller_impl->Animate(kInitialTickTime + |
1761 TimeDelta::FromMilliseconds(2000)); | 1785 TimeDelta::FromMilliseconds(2000)); |
1762 controller_impl->UpdateState(true, events.get()); | 1786 controller_impl->UpdateState(true, events.get()); |
1763 | 1787 |
1764 // Both animations should have generated FINISHED events. | 1788 // Both animations should have generated Finished events. |
1765 EXPECT_EQ(2u, events->size()); | 1789 EXPECT_EQ(2u, events->size()); |
1766 EXPECT_EQ(AnimationEvent::FINISHED, (*events)[0].type); | 1790 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
1767 EXPECT_EQ(AnimationEvent::FINISHED, (*events)[1].type); | 1791 EXPECT_EQ(AnimationEvent::Finished, (*events)[1].type); |
1768 } | 1792 } |
1769 | 1793 |
1770 // Ensure that when a group has a mix of aborted and finished animations, | 1794 // Ensure that when a group has a mix of aborted and finished animations, |
1771 // we generate a FINISHED event for the finished animation and an ABORTED | 1795 // we generate a Finished event for the finished animation and an Aborted |
1772 // event for the aborted animation. | 1796 // event for the aborted animation. |
1773 TEST(LayerAnimationControllerTest, FinishedAndAbortedEventsForGroup) { | 1797 TEST(LayerAnimationControllerTest, FinishedAndAbortedEventsForGroup) { |
1774 scoped_ptr<AnimationEventsVector> events( | 1798 scoped_ptr<AnimationEventsVector> events( |
1775 make_scoped_ptr(new AnimationEventsVector)); | 1799 make_scoped_ptr(new AnimationEventsVector)); |
1776 FakeLayerAnimationValueObserver dummy_impl; | 1800 FakeLayerAnimationValueObserver dummy_impl; |
1777 scoped_refptr<LayerAnimationController> controller_impl( | 1801 scoped_refptr<LayerAnimationController> controller_impl( |
1778 LayerAnimationController::Create(0)); | 1802 LayerAnimationController::Create(0)); |
1779 controller_impl->AddValueObserver(&dummy_impl); | 1803 controller_impl->AddValueObserver(&dummy_impl); |
1780 | 1804 |
1781 // Add two animations with the same group id. | 1805 // Add two animations with the same group id. |
1782 controller_impl->AddAnimation(CreateAnimation( | 1806 controller_impl->AddAnimation(CreateAnimation( |
1783 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)).Pass(), 1, | 1807 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)).Pass(), |
1784 Animation::TRANSFORM)); | 1808 1, |
| 1809 Animation::Transform)); |
1785 controller_impl->AddAnimation(CreateAnimation( | 1810 controller_impl->AddAnimation(CreateAnimation( |
1786 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1811 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1787 1, Animation::OPACITY)); | 1812 1, |
| 1813 Animation::Opacity)); |
1788 | 1814 |
1789 controller_impl->Animate(kInitialTickTime); | 1815 controller_impl->Animate(kInitialTickTime); |
1790 controller_impl->UpdateState(true, events.get()); | 1816 controller_impl->UpdateState(true, events.get()); |
1791 | 1817 |
1792 // Both animations should have started. | 1818 // Both animations should have started. |
1793 EXPECT_EQ(2u, events->size()); | 1819 EXPECT_EQ(2u, events->size()); |
1794 EXPECT_EQ(AnimationEvent::STARTED, (*events)[0].type); | 1820 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
1795 EXPECT_EQ(AnimationEvent::STARTED, (*events)[1].type); | 1821 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); |
1796 | 1822 |
1797 controller_impl->AbortAnimations(Animation::OPACITY); | 1823 controller_impl->AbortAnimations(Animation::Opacity); |
1798 | 1824 |
1799 events.reset(new AnimationEventsVector); | 1825 events.reset(new AnimationEventsVector); |
1800 controller_impl->Animate(kInitialTickTime + | 1826 controller_impl->Animate(kInitialTickTime + |
1801 TimeDelta::FromMilliseconds(1000)); | 1827 TimeDelta::FromMilliseconds(1000)); |
1802 controller_impl->UpdateState(true, events.get()); | 1828 controller_impl->UpdateState(true, events.get()); |
1803 | 1829 |
1804 // We should have exactly 2 events: a FINISHED event for the tranform | 1830 // We should have exactly 2 events: a Finished event for the tranform |
1805 // animation, and an ABORTED event for the opacity animation. | 1831 // animation, and an Aborted event for the opacity animation. |
1806 EXPECT_EQ(2u, events->size()); | 1832 EXPECT_EQ(2u, events->size()); |
1807 EXPECT_EQ(AnimationEvent::FINISHED, (*events)[0].type); | 1833 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
1808 EXPECT_EQ(Animation::TRANSFORM, (*events)[0].target_property); | 1834 EXPECT_EQ(Animation::Transform, (*events)[0].target_property); |
1809 EXPECT_EQ(AnimationEvent::ABORTED, (*events)[1].type); | 1835 EXPECT_EQ(AnimationEvent::Aborted, (*events)[1].type); |
1810 EXPECT_EQ(Animation::OPACITY, (*events)[1].target_property); | 1836 EXPECT_EQ(Animation::Opacity, (*events)[1].target_property); |
1811 } | 1837 } |
1812 | 1838 |
1813 TEST(LayerAnimationControllerTest, HasAnimationThatAffectsScale) { | 1839 TEST(LayerAnimationControllerTest, HasAnimationThatAffectsScale) { |
1814 scoped_refptr<LayerAnimationController> controller_impl( | 1840 scoped_refptr<LayerAnimationController> controller_impl( |
1815 LayerAnimationController::Create(0)); | 1841 LayerAnimationController::Create(0)); |
1816 | 1842 |
1817 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); | 1843 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); |
1818 | 1844 |
1819 controller_impl->AddAnimation(CreateAnimation( | 1845 controller_impl->AddAnimation(CreateAnimation( |
1820 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1846 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1821 1, Animation::OPACITY)); | 1847 1, |
| 1848 Animation::Opacity)); |
1822 | 1849 |
1823 // Opacity animations don't affect scale. | 1850 // Opacity animations don't affect scale. |
1824 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); | 1851 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); |
1825 | 1852 |
1826 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1853 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1827 KeyframedTransformAnimationCurve::Create()); | 1854 KeyframedTransformAnimationCurve::Create()); |
1828 | 1855 |
1829 TransformOperations operations1; | 1856 TransformOperations operations1; |
1830 curve1->AddKeyframe( | 1857 curve1->AddKeyframe( |
1831 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 1858 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
1832 operations1.AppendTranslate(10.0, 15.0, 0.0); | 1859 operations1.AppendTranslate(10.0, 15.0, 0.0); |
1833 curve1->AddKeyframe(TransformKeyframe::Create( | 1860 curve1->AddKeyframe(TransformKeyframe::Create( |
1834 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 1861 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
1835 | 1862 |
1836 scoped_ptr<Animation> animation( | 1863 scoped_ptr<Animation> animation( |
1837 Animation::Create(curve1.Pass(), 2, 2, Animation::TRANSFORM)); | 1864 Animation::Create(curve1.Pass(), 2, 2, Animation::Transform)); |
1838 controller_impl->AddAnimation(animation.Pass()); | 1865 controller_impl->AddAnimation(animation.Pass()); |
1839 | 1866 |
1840 // Translations don't affect scale. | 1867 // Translations don't affect scale. |
1841 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); | 1868 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); |
1842 | 1869 |
1843 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 1870 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
1844 KeyframedTransformAnimationCurve::Create()); | 1871 KeyframedTransformAnimationCurve::Create()); |
1845 | 1872 |
1846 TransformOperations operations2; | 1873 TransformOperations operations2; |
1847 curve2->AddKeyframe( | 1874 curve2->AddKeyframe( |
1848 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 1875 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
1849 operations2.AppendScale(2.0, 3.0, 4.0); | 1876 operations2.AppendScale(2.0, 3.0, 4.0); |
1850 curve2->AddKeyframe(TransformKeyframe::Create( | 1877 curve2->AddKeyframe(TransformKeyframe::Create( |
1851 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 1878 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
1852 | 1879 |
1853 animation = Animation::Create(curve2.Pass(), 3, 3, Animation::TRANSFORM); | 1880 animation = Animation::Create(curve2.Pass(), 3, 3, Animation::Transform); |
1854 controller_impl->AddAnimation(animation.Pass()); | 1881 controller_impl->AddAnimation(animation.Pass()); |
1855 | 1882 |
1856 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); | 1883 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); |
1857 | 1884 |
1858 controller_impl->GetAnimationById(3) | 1885 controller_impl->GetAnimationById(3) |
1859 ->SetRunState(Animation::FINISHED, TicksFromSecondsF(0.0)); | 1886 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1860 | 1887 |
1861 // Only unfinished animations should be considered by | 1888 // Only unfinished animations should be considered by |
1862 // HasAnimationThatAffectsScale. | 1889 // HasAnimationThatAffectsScale. |
1863 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); | 1890 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); |
1864 } | 1891 } |
1865 | 1892 |
1866 TEST(LayerAnimationControllerTest, HasOnlyTranslationTransforms) { | 1893 TEST(LayerAnimationControllerTest, HasOnlyTranslationTransforms) { |
1867 scoped_refptr<LayerAnimationController> controller_impl( | 1894 scoped_refptr<LayerAnimationController> controller_impl( |
1868 LayerAnimationController::Create(0)); | 1895 LayerAnimationController::Create(0)); |
1869 | 1896 |
1870 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); | 1897 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); |
1871 | 1898 |
1872 controller_impl->AddAnimation(CreateAnimation( | 1899 controller_impl->AddAnimation(CreateAnimation( |
1873 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1900 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1874 1, Animation::OPACITY)); | 1901 1, |
| 1902 Animation::Opacity)); |
1875 | 1903 |
1876 // Opacity animations aren't non-translation transforms. | 1904 // Opacity animations aren't non-translation transforms. |
1877 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); | 1905 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); |
1878 | 1906 |
1879 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1907 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1880 KeyframedTransformAnimationCurve::Create()); | 1908 KeyframedTransformAnimationCurve::Create()); |
1881 | 1909 |
1882 TransformOperations operations1; | 1910 TransformOperations operations1; |
1883 curve1->AddKeyframe( | 1911 curve1->AddKeyframe( |
1884 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 1912 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
1885 operations1.AppendTranslate(10.0, 15.0, 0.0); | 1913 operations1.AppendTranslate(10.0, 15.0, 0.0); |
1886 curve1->AddKeyframe(TransformKeyframe::Create( | 1914 curve1->AddKeyframe(TransformKeyframe::Create( |
1887 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 1915 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
1888 | 1916 |
1889 scoped_ptr<Animation> animation( | 1917 scoped_ptr<Animation> animation( |
1890 Animation::Create(curve1.Pass(), 2, 2, Animation::TRANSFORM)); | 1918 Animation::Create(curve1.Pass(), 2, 2, Animation::Transform)); |
1891 controller_impl->AddAnimation(animation.Pass()); | 1919 controller_impl->AddAnimation(animation.Pass()); |
1892 | 1920 |
1893 // The only transform animation we've added is a translation. | 1921 // The only transform animation we've added is a translation. |
1894 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); | 1922 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); |
1895 | 1923 |
1896 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 1924 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
1897 KeyframedTransformAnimationCurve::Create()); | 1925 KeyframedTransformAnimationCurve::Create()); |
1898 | 1926 |
1899 TransformOperations operations2; | 1927 TransformOperations operations2; |
1900 curve2->AddKeyframe( | 1928 curve2->AddKeyframe( |
1901 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 1929 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
1902 operations2.AppendScale(2.0, 3.0, 4.0); | 1930 operations2.AppendScale(2.0, 3.0, 4.0); |
1903 curve2->AddKeyframe(TransformKeyframe::Create( | 1931 curve2->AddKeyframe(TransformKeyframe::Create( |
1904 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 1932 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
1905 | 1933 |
1906 animation = Animation::Create(curve2.Pass(), 3, 3, Animation::TRANSFORM); | 1934 animation = Animation::Create(curve2.Pass(), 3, 3, Animation::Transform); |
1907 controller_impl->AddAnimation(animation.Pass()); | 1935 controller_impl->AddAnimation(animation.Pass()); |
1908 | 1936 |
1909 // A scale animation is not a translation. | 1937 // A scale animation is not a translation. |
1910 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); | 1938 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); |
1911 | 1939 |
1912 controller_impl->GetAnimationById(3) | 1940 controller_impl->GetAnimationById(3) |
1913 ->SetRunState(Animation::FINISHED, TicksFromSecondsF(0.0)); | 1941 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1914 | 1942 |
1915 // Only unfinished animations should be considered by | 1943 // Only unfinished animations should be considered by |
1916 // HasOnlyTranslationTransforms. | 1944 // HasOnlyTranslationTransforms. |
1917 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); | 1945 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); |
1918 } | 1946 } |
1919 | 1947 |
1920 TEST(LayerAnimationControllerTest, MaximumTargetScale) { | 1948 TEST(LayerAnimationControllerTest, MaximumTargetScale) { |
1921 scoped_refptr<LayerAnimationController> controller_impl( | 1949 scoped_refptr<LayerAnimationController> controller_impl( |
1922 LayerAnimationController::Create(0)); | 1950 LayerAnimationController::Create(0)); |
1923 | 1951 |
1924 float max_scale = 0.f; | 1952 float max_scale = 0.f; |
1925 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 1953 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
1926 EXPECT_EQ(0.f, max_scale); | 1954 EXPECT_EQ(0.f, max_scale); |
1927 | 1955 |
1928 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1956 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1929 KeyframedTransformAnimationCurve::Create()); | 1957 KeyframedTransformAnimationCurve::Create()); |
1930 | 1958 |
1931 TransformOperations operations1; | 1959 TransformOperations operations1; |
1932 curve1->AddKeyframe( | 1960 curve1->AddKeyframe( |
1933 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 1961 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
1934 operations1.AppendScale(2.0, 3.0, 4.0); | 1962 operations1.AppendScale(2.0, 3.0, 4.0); |
1935 curve1->AddKeyframe(TransformKeyframe::Create( | 1963 curve1->AddKeyframe(TransformKeyframe::Create( |
1936 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 1964 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
1937 | 1965 |
1938 scoped_ptr<Animation> animation( | 1966 scoped_ptr<Animation> animation( |
1939 Animation::Create(curve1.Pass(), 1, 1, Animation::TRANSFORM)); | 1967 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); |
1940 controller_impl->AddAnimation(animation.Pass()); | 1968 controller_impl->AddAnimation(animation.Pass()); |
1941 | 1969 |
1942 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 1970 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
1943 EXPECT_EQ(4.f, max_scale); | 1971 EXPECT_EQ(4.f, max_scale); |
1944 | 1972 |
1945 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 1973 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
1946 KeyframedTransformAnimationCurve::Create()); | 1974 KeyframedTransformAnimationCurve::Create()); |
1947 | 1975 |
1948 TransformOperations operations2; | 1976 TransformOperations operations2; |
1949 curve2->AddKeyframe( | 1977 curve2->AddKeyframe( |
1950 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 1978 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
1951 operations2.AppendScale(6.0, 5.0, 4.0); | 1979 operations2.AppendScale(6.0, 5.0, 4.0); |
1952 curve2->AddKeyframe(TransformKeyframe::Create( | 1980 curve2->AddKeyframe(TransformKeyframe::Create( |
1953 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 1981 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
1954 | 1982 |
1955 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::TRANSFORM); | 1983 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::Transform); |
1956 controller_impl->AddAnimation(animation.Pass()); | 1984 controller_impl->AddAnimation(animation.Pass()); |
1957 | 1985 |
1958 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 1986 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
1959 EXPECT_EQ(6.f, max_scale); | 1987 EXPECT_EQ(6.f, max_scale); |
1960 | 1988 |
1961 scoped_ptr<KeyframedTransformAnimationCurve> curve3( | 1989 scoped_ptr<KeyframedTransformAnimationCurve> curve3( |
1962 KeyframedTransformAnimationCurve::Create()); | 1990 KeyframedTransformAnimationCurve::Create()); |
1963 | 1991 |
1964 TransformOperations operations3; | 1992 TransformOperations operations3; |
1965 curve3->AddKeyframe( | 1993 curve3->AddKeyframe( |
1966 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 1994 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
1967 operations3.AppendPerspective(6.0); | 1995 operations3.AppendPerspective(6.0); |
1968 curve3->AddKeyframe(TransformKeyframe::Create( | 1996 curve3->AddKeyframe(TransformKeyframe::Create( |
1969 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); | 1997 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); |
1970 | 1998 |
1971 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::TRANSFORM); | 1999 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::Transform); |
1972 controller_impl->AddAnimation(animation.Pass()); | 2000 controller_impl->AddAnimation(animation.Pass()); |
1973 | 2001 |
1974 EXPECT_FALSE(controller_impl->MaximumTargetScale(&max_scale)); | 2002 EXPECT_FALSE(controller_impl->MaximumTargetScale(&max_scale)); |
1975 | 2003 |
1976 controller_impl->GetAnimationById(3) | 2004 controller_impl->GetAnimationById(3) |
1977 ->SetRunState(Animation::FINISHED, TicksFromSecondsF(0.0)); | 2005 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1978 controller_impl->GetAnimationById(2) | 2006 controller_impl->GetAnimationById(2) |
1979 ->SetRunState(Animation::FINISHED, TicksFromSecondsF(0.0)); | 2007 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1980 | 2008 |
1981 // Only unfinished animations should be considered by | 2009 // Only unfinished animations should be considered by |
1982 // MaximumTargetScale. | 2010 // MaximumTargetScale. |
1983 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 2011 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
1984 EXPECT_EQ(4.f, max_scale); | 2012 EXPECT_EQ(4.f, max_scale); |
1985 } | 2013 } |
1986 | 2014 |
1987 TEST(LayerAnimationControllerTest, MaximumTargetScaleWithDirection) { | 2015 TEST(LayerAnimationControllerTest, MaximumTargetScaleWithDirection) { |
1988 scoped_refptr<LayerAnimationController> controller_impl( | 2016 scoped_refptr<LayerAnimationController> controller_impl( |
1989 LayerAnimationController::Create(0)); | 2017 LayerAnimationController::Create(0)); |
1990 | 2018 |
1991 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 2019 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1992 KeyframedTransformAnimationCurve::Create()); | 2020 KeyframedTransformAnimationCurve::Create()); |
1993 TransformOperations operations1; | 2021 TransformOperations operations1; |
1994 operations1.AppendScale(1.0, 2.0, 3.0); | 2022 operations1.AppendScale(1.0, 2.0, 3.0); |
1995 curve1->AddKeyframe( | 2023 curve1->AddKeyframe( |
1996 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2024 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
1997 TransformOperations operations2; | 2025 TransformOperations operations2; |
1998 operations2.AppendScale(4.0, 5.0, 6.0); | 2026 operations2.AppendScale(4.0, 5.0, 6.0); |
1999 curve1->AddKeyframe(TransformKeyframe::Create( | 2027 curve1->AddKeyframe(TransformKeyframe::Create( |
2000 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2028 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
2001 | 2029 |
2002 scoped_ptr<Animation> animation_owned( | 2030 scoped_ptr<Animation> animation_owned( |
2003 Animation::Create(curve1.Pass(), 1, 1, Animation::TRANSFORM)); | 2031 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); |
2004 Animation* animation = animation_owned.get(); | 2032 Animation* animation = animation_owned.get(); |
2005 controller_impl->AddAnimation(animation_owned.Pass()); | 2033 controller_impl->AddAnimation(animation_owned.Pass()); |
2006 | 2034 |
2007 float max_scale = 0.f; | 2035 float max_scale = 0.f; |
2008 | 2036 |
2009 EXPECT_GT(animation->playback_rate(), 0.0); | 2037 EXPECT_GT(animation->playback_rate(), 0.0); |
2010 | 2038 |
2011 // NORMAL direction with positive playback rate. | 2039 // Normal direction with positive playback rate. |
2012 animation->set_direction(Animation::DIRECTION_NORMAL); | 2040 animation->set_direction(Animation::Normal); |
2013 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 2041 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
2014 EXPECT_EQ(6.f, max_scale); | 2042 EXPECT_EQ(6.f, max_scale); |
2015 | 2043 |
2016 // ALTERNATE direction with positive playback rate. | 2044 // Alternate direction with positive playback rate. |
2017 animation->set_direction(Animation::DIRECTION_ALTERNATE); | 2045 animation->set_direction(Animation::Alternate); |
2018 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 2046 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
2019 EXPECT_EQ(6.f, max_scale); | 2047 EXPECT_EQ(6.f, max_scale); |
2020 | 2048 |
2021 // REVERSE direction with positive playback rate. | 2049 // Reverse direction with positive playback rate. |
2022 animation->set_direction(Animation::DIRECTION_REVERSE); | 2050 animation->set_direction(Animation::Reverse); |
2023 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 2051 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
2024 EXPECT_EQ(3.f, max_scale); | 2052 EXPECT_EQ(3.f, max_scale); |
2025 | 2053 |
2026 // ALTERNATE reverse direction. | 2054 // Alternate reverse direction. |
2027 animation->set_direction(Animation::DIRECTION_REVERSE); | 2055 animation->set_direction(Animation::Reverse); |
2028 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 2056 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
2029 EXPECT_EQ(3.f, max_scale); | 2057 EXPECT_EQ(3.f, max_scale); |
2030 | 2058 |
2031 animation->set_playback_rate(-1.0); | 2059 animation->set_playback_rate(-1.0); |
2032 | 2060 |
2033 // NORMAL direction with negative playback rate. | 2061 // Normal direction with negative playback rate. |
2034 animation->set_direction(Animation::DIRECTION_NORMAL); | 2062 animation->set_direction(Animation::Normal); |
2035 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 2063 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
2036 EXPECT_EQ(3.f, max_scale); | 2064 EXPECT_EQ(3.f, max_scale); |
2037 | 2065 |
2038 // ALTERNATE direction with negative playback rate. | 2066 // Alternate direction with negative playback rate. |
2039 animation->set_direction(Animation::DIRECTION_ALTERNATE); | 2067 animation->set_direction(Animation::Alternate); |
2040 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 2068 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
2041 EXPECT_EQ(3.f, max_scale); | 2069 EXPECT_EQ(3.f, max_scale); |
2042 | 2070 |
2043 // REVERSE direction with negative playback rate. | 2071 // Reverse direction with negative playback rate. |
2044 animation->set_direction(Animation::DIRECTION_REVERSE); | 2072 animation->set_direction(Animation::Reverse); |
2045 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 2073 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
2046 EXPECT_EQ(6.f, max_scale); | 2074 EXPECT_EQ(6.f, max_scale); |
2047 | 2075 |
2048 // ALTERNATE reverse direction with negative playback rate. | 2076 // Alternate reverse direction with negative playback rate. |
2049 animation->set_direction(Animation::DIRECTION_REVERSE); | 2077 animation->set_direction(Animation::Reverse); |
2050 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); | 2078 EXPECT_TRUE(controller_impl->MaximumTargetScale(&max_scale)); |
2051 EXPECT_EQ(6.f, max_scale); | 2079 EXPECT_EQ(6.f, max_scale); |
2052 } | 2080 } |
2053 | 2081 |
2054 TEST(LayerAnimationControllerTest, NewlyPushedAnimationWaitsForActivation) { | 2082 TEST(LayerAnimationControllerTest, NewlyPushedAnimationWaitsForActivation) { |
2055 scoped_ptr<AnimationEventsVector> events( | 2083 scoped_ptr<AnimationEventsVector> events( |
2056 make_scoped_ptr(new AnimationEventsVector)); | 2084 make_scoped_ptr(new AnimationEventsVector)); |
2057 FakeLayerAnimationValueObserver dummy_impl; | 2085 FakeLayerAnimationValueObserver dummy_impl; |
2058 FakeInactiveLayerAnimationValueObserver pending_dummy_impl; | 2086 FakeInactiveLayerAnimationValueObserver pending_dummy_impl; |
2059 scoped_refptr<LayerAnimationController> controller_impl( | 2087 scoped_refptr<LayerAnimationController> controller_impl( |
2060 LayerAnimationController::Create(0)); | 2088 LayerAnimationController::Create(0)); |
2061 controller_impl->AddValueObserver(&dummy_impl); | 2089 controller_impl->AddValueObserver(&dummy_impl); |
2062 controller_impl->AddValueObserver(&pending_dummy_impl); | 2090 controller_impl->AddValueObserver(&pending_dummy_impl); |
2063 FakeLayerAnimationValueObserver dummy; | 2091 FakeLayerAnimationValueObserver dummy; |
2064 scoped_refptr<LayerAnimationController> controller( | 2092 scoped_refptr<LayerAnimationController> controller( |
2065 LayerAnimationController::Create(0)); | 2093 LayerAnimationController::Create(0)); |
2066 controller->AddValueObserver(&dummy); | 2094 controller->AddValueObserver(&dummy); |
2067 | 2095 |
2068 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); | 2096 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); |
2069 int animation_id = | 2097 int animation_id = |
2070 AddOpacityTransitionToController(controller.get(), 1, 0.5f, 1.f, false); | 2098 AddOpacityTransitionToController(controller.get(), 1, 0.5f, 1.f, false); |
2071 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); | 2099 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); |
2072 | 2100 |
2073 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing()); | 2101 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing()); |
2074 controller->PushAnimationUpdatesTo(controller_impl.get()); | 2102 controller->PushAnimationUpdatesTo(controller_impl.get()); |
2075 EXPECT_TRUE(controller_impl->needs_to_start_animations_for_testing()); | 2103 EXPECT_TRUE(controller_impl->needs_to_start_animations_for_testing()); |
2076 | 2104 |
2077 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 2105 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
2078 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 2106 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
2079 controller_impl->GetAnimationById(animation_id)->run_state()); | 2107 controller_impl->GetAnimationById(animation_id)->run_state()); |
2080 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) | 2108 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) |
2081 ->affects_pending_observers()); | 2109 ->affects_pending_observers()); |
2082 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id) | 2110 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id) |
2083 ->affects_active_observers()); | 2111 ->affects_active_observers()); |
2084 | 2112 |
2085 controller_impl->Animate(kInitialTickTime); | 2113 controller_impl->Animate(kInitialTickTime); |
2086 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing()); | 2114 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing()); |
2087 controller_impl->UpdateState(true, events.get()); | 2115 controller_impl->UpdateState(true, events.get()); |
2088 | 2116 |
2089 // Since the animation hasn't been activated, it should still be STARTING | 2117 // Since the animation hasn't been activated, it should still be Starting |
2090 // rather than RUNNING. | 2118 // rather than Running. |
2091 EXPECT_EQ(Animation::STARTING, | 2119 EXPECT_EQ(Animation::Starting, |
2092 controller_impl->GetAnimationById(animation_id)->run_state()); | 2120 controller_impl->GetAnimationById(animation_id)->run_state()); |
2093 | 2121 |
2094 // Since the animation hasn't been activated, only the pending observer | 2122 // Since the animation hasn't been activated, only the pending observer |
2095 // should have been ticked. | 2123 // should have been ticked. |
2096 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); | 2124 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); |
2097 EXPECT_EQ(0.f, dummy_impl.opacity()); | 2125 EXPECT_EQ(0.f, dummy_impl.opacity()); |
2098 | 2126 |
2099 controller_impl->ActivateAnimations(); | 2127 controller_impl->ActivateAnimations(); |
2100 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) | 2128 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) |
2101 ->affects_pending_observers()); | 2129 ->affects_pending_observers()); |
2102 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) | 2130 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) |
2103 ->affects_active_observers()); | 2131 ->affects_active_observers()); |
2104 | 2132 |
2105 controller_impl->Animate(kInitialTickTime + | 2133 controller_impl->Animate(kInitialTickTime + |
2106 TimeDelta::FromMilliseconds(1000)); | 2134 TimeDelta::FromMilliseconds(1000)); |
2107 controller_impl->UpdateState(true, events.get()); | 2135 controller_impl->UpdateState(true, events.get()); |
2108 | 2136 |
2109 // Since the animation has been activated, it should have reached the | 2137 // Since the animation has been activated, it should have reached the |
2110 // RUNNING state and the active observer should start to get ticked. | 2138 // Running state and the active observer should start to get ticked. |
2111 EXPECT_EQ(Animation::RUNNING, | 2139 EXPECT_EQ(Animation::Running, |
2112 controller_impl->GetAnimationById(animation_id)->run_state()); | 2140 controller_impl->GetAnimationById(animation_id)->run_state()); |
2113 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); | 2141 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); |
2114 EXPECT_EQ(0.5f, dummy_impl.opacity()); | 2142 EXPECT_EQ(0.5f, dummy_impl.opacity()); |
2115 } | 2143 } |
2116 | 2144 |
2117 TEST(LayerAnimationControllerTest, ActivationBetweenAnimateAndUpdateState) { | 2145 TEST(LayerAnimationControllerTest, ActivationBetweenAnimateAndUpdateState) { |
2118 scoped_ptr<AnimationEventsVector> events( | 2146 scoped_ptr<AnimationEventsVector> events( |
2119 make_scoped_ptr(new AnimationEventsVector)); | 2147 make_scoped_ptr(new AnimationEventsVector)); |
2120 FakeLayerAnimationValueObserver dummy_impl; | 2148 FakeLayerAnimationValueObserver dummy_impl; |
2121 FakeInactiveLayerAnimationValueObserver pending_dummy_impl; | 2149 FakeInactiveLayerAnimationValueObserver pending_dummy_impl; |
2122 scoped_refptr<LayerAnimationController> controller_impl( | 2150 scoped_refptr<LayerAnimationController> controller_impl( |
2123 LayerAnimationController::Create(0)); | 2151 LayerAnimationController::Create(0)); |
2124 controller_impl->AddValueObserver(&dummy_impl); | 2152 controller_impl->AddValueObserver(&dummy_impl); |
2125 controller_impl->AddValueObserver(&pending_dummy_impl); | 2153 controller_impl->AddValueObserver(&pending_dummy_impl); |
2126 FakeLayerAnimationValueObserver dummy; | 2154 FakeLayerAnimationValueObserver dummy; |
2127 scoped_refptr<LayerAnimationController> controller( | 2155 scoped_refptr<LayerAnimationController> controller( |
2128 LayerAnimationController::Create(0)); | 2156 LayerAnimationController::Create(0)); |
2129 controller->AddValueObserver(&dummy); | 2157 controller->AddValueObserver(&dummy); |
2130 | 2158 |
2131 int animation_id = | 2159 int animation_id = |
2132 AddOpacityTransitionToController(controller.get(), 1, 0.5f, 1.f, true); | 2160 AddOpacityTransitionToController(controller.get(), 1, 0.5f, 1.f, true); |
2133 | 2161 |
2134 controller->PushAnimationUpdatesTo(controller_impl.get()); | 2162 controller->PushAnimationUpdatesTo(controller_impl.get()); |
2135 | 2163 |
2136 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 2164 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
2137 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 2165 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
2138 controller_impl->GetAnimationById(animation_id)->run_state()); | 2166 controller_impl->GetAnimationById(animation_id)->run_state()); |
2139 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) | 2167 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) |
2140 ->affects_pending_observers()); | 2168 ->affects_pending_observers()); |
2141 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id) | 2169 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id) |
2142 ->affects_active_observers()); | 2170 ->affects_active_observers()); |
2143 | 2171 |
2144 controller_impl->Animate(kInitialTickTime); | 2172 controller_impl->Animate(kInitialTickTime); |
2145 | 2173 |
2146 // Since the animation hasn't been activated, only the pending observer | 2174 // Since the animation hasn't been activated, only the pending observer |
2147 // should have been ticked. | 2175 // should have been ticked. |
2148 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); | 2176 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); |
2149 EXPECT_EQ(0.f, dummy_impl.opacity()); | 2177 EXPECT_EQ(0.f, dummy_impl.opacity()); |
2150 | 2178 |
2151 controller_impl->ActivateAnimations(); | 2179 controller_impl->ActivateAnimations(); |
2152 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) | 2180 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) |
2153 ->affects_pending_observers()); | 2181 ->affects_pending_observers()); |
2154 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) | 2182 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) |
2155 ->affects_active_observers()); | 2183 ->affects_active_observers()); |
2156 | 2184 |
2157 controller_impl->UpdateState(true, events.get()); | 2185 controller_impl->UpdateState(true, events.get()); |
2158 | 2186 |
2159 // Since the animation has been activated, it should have reached the | 2187 // Since the animation has been activated, it should have reached the |
2160 // RUNNING state. | 2188 // Running state. |
2161 EXPECT_EQ(Animation::RUNNING, | 2189 EXPECT_EQ(Animation::Running, |
2162 controller_impl->GetAnimationById(animation_id)->run_state()); | 2190 controller_impl->GetAnimationById(animation_id)->run_state()); |
2163 | 2191 |
2164 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 2192 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
2165 | 2193 |
2166 // Both observers should have been ticked. | 2194 // Both observers should have been ticked. |
2167 EXPECT_EQ(0.75f, pending_dummy_impl.opacity()); | 2195 EXPECT_EQ(0.75f, pending_dummy_impl.opacity()); |
2168 EXPECT_EQ(0.75f, dummy_impl.opacity()); | 2196 EXPECT_EQ(0.75f, dummy_impl.opacity()); |
2169 } | 2197 } |
2170 | 2198 |
2171 TEST(LayerAnimationControllerTest, ClippedOpacityValues) { | 2199 TEST(LayerAnimationControllerTest, ClippedOpacityValues) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2214 LayerAnimationController::Create(0)); | 2242 LayerAnimationController::Create(0)); |
2215 controller->AddValueObserver(&dummy); | 2243 controller->AddValueObserver(&dummy); |
2216 | 2244 |
2217 int animation_id = | 2245 int animation_id = |
2218 AddOpacityTransitionToController(controller.get(), 1, 0.5f, 1.f, true); | 2246 AddOpacityTransitionToController(controller.get(), 1, 0.5f, 1.f, true); |
2219 | 2247 |
2220 controller->PushAnimationUpdatesTo(controller_impl.get()); | 2248 controller->PushAnimationUpdatesTo(controller_impl.get()); |
2221 controller_impl->ActivateAnimations(); | 2249 controller_impl->ActivateAnimations(); |
2222 controller_impl->Animate(kInitialTickTime); | 2250 controller_impl->Animate(kInitialTickTime); |
2223 controller_impl->UpdateState(true, events.get()); | 2251 controller_impl->UpdateState(true, events.get()); |
2224 EXPECT_EQ(Animation::RUNNING, | 2252 EXPECT_EQ(Animation::Running, |
2225 controller_impl->GetAnimationById(animation_id)->run_state()); | 2253 controller_impl->GetAnimationById(animation_id)->run_state()); |
2226 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); | 2254 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); |
2227 EXPECT_EQ(0.5f, dummy_impl.opacity()); | 2255 EXPECT_EQ(0.5f, dummy_impl.opacity()); |
2228 | 2256 |
2229 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) | 2257 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) |
2230 ->affects_pending_observers()); | 2258 ->affects_pending_observers()); |
2231 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) | 2259 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) |
2232 ->affects_active_observers()); | 2260 ->affects_active_observers()); |
2233 | 2261 |
2234 // Delete the animation on the main-thread controller. | 2262 // Delete the animation on the main-thread controller. |
2235 controller->RemoveAnimation( | 2263 controller->RemoveAnimation( |
2236 controller->GetAnimation(Animation::OPACITY)->id()); | 2264 controller->GetAnimation(Animation::Opacity)->id()); |
2237 controller->PushAnimationUpdatesTo(controller_impl.get()); | 2265 controller->PushAnimationUpdatesTo(controller_impl.get()); |
2238 | 2266 |
2239 // The animation should no longer affect pending observers. | 2267 // The animation should no longer affect pending observers. |
2240 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id) | 2268 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id) |
2241 ->affects_pending_observers()); | 2269 ->affects_pending_observers()); |
2242 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) | 2270 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) |
2243 ->affects_active_observers()); | 2271 ->affects_active_observers()); |
2244 | 2272 |
2245 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 2273 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
2246 controller_impl->UpdateState(true, events.get()); | 2274 controller_impl->UpdateState(true, events.get()); |
(...skipping 28 matching lines...) Expand all Loading... |
2275 AddOpacityTransitionToController(controller.get(), 1, 0.f, 1.f, true); | 2303 AddOpacityTransitionToController(controller.get(), 1, 0.f, 1.f, true); |
2276 | 2304 |
2277 controller->PushAnimationUpdatesTo(controller_impl.get()); | 2305 controller->PushAnimationUpdatesTo(controller_impl.get()); |
2278 controller_impl->ActivateAnimations(); | 2306 controller_impl->ActivateAnimations(); |
2279 controller_impl->Animate(kInitialTickTime); | 2307 controller_impl->Animate(kInitialTickTime); |
2280 controller_impl->UpdateState(true, events.get()); | 2308 controller_impl->UpdateState(true, events.get()); |
2281 | 2309 |
2282 // Remove the first animation from the main-thread controller, and add a | 2310 // Remove the first animation from the main-thread controller, and add a |
2283 // new animation affecting the same property. | 2311 // new animation affecting the same property. |
2284 controller->RemoveAnimation( | 2312 controller->RemoveAnimation( |
2285 controller->GetAnimation(Animation::OPACITY)->id()); | 2313 controller->GetAnimation(Animation::Opacity)->id()); |
2286 int second_animation_id = | 2314 int second_animation_id = |
2287 AddOpacityTransitionToController(controller.get(), 1, 1.f, 0.5f, true); | 2315 AddOpacityTransitionToController(controller.get(), 1, 1.f, 0.5f, true); |
2288 controller->PushAnimationUpdatesTo(controller_impl.get()); | 2316 controller->PushAnimationUpdatesTo(controller_impl.get()); |
2289 | 2317 |
2290 // The original animation should only affect active observers, and the new | 2318 // The original animation should only affect active observers, and the new |
2291 // animation should only affect pending observers. | 2319 // animation should only affect pending observers. |
2292 EXPECT_FALSE(controller_impl->GetAnimationById(first_animation_id) | 2320 EXPECT_FALSE(controller_impl->GetAnimationById(first_animation_id) |
2293 ->affects_pending_observers()); | 2321 ->affects_pending_observers()); |
2294 EXPECT_TRUE(controller_impl->GetAnimationById(first_animation_id) | 2322 EXPECT_TRUE(controller_impl->GetAnimationById(first_animation_id) |
2295 ->affects_active_observers()); | 2323 ->affects_active_observers()); |
2296 EXPECT_TRUE(controller_impl->GetAnimationById(second_animation_id) | 2324 EXPECT_TRUE(controller_impl->GetAnimationById(second_animation_id) |
2297 ->affects_pending_observers()); | 2325 ->affects_pending_observers()); |
2298 EXPECT_FALSE(controller_impl->GetAnimationById(second_animation_id) | 2326 EXPECT_FALSE(controller_impl->GetAnimationById(second_animation_id) |
2299 ->affects_active_observers()); | 2327 ->affects_active_observers()); |
2300 | 2328 |
2301 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 2329 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
2302 controller_impl->UpdateState(true, events.get()); | 2330 controller_impl->UpdateState(true, events.get()); |
2303 | 2331 |
2304 // The original animation should still be running, and the new animation | 2332 // The original animation should still be running, and the new animation |
2305 // should be starting. | 2333 // should be starting. |
2306 EXPECT_EQ(Animation::RUNNING, | 2334 EXPECT_EQ(Animation::Running, |
2307 controller_impl->GetAnimationById(first_animation_id)->run_state()); | 2335 controller_impl->GetAnimationById(first_animation_id)->run_state()); |
2308 EXPECT_EQ( | 2336 EXPECT_EQ( |
2309 Animation::STARTING, | 2337 Animation::Starting, |
2310 controller_impl->GetAnimationById(second_animation_id)->run_state()); | 2338 controller_impl->GetAnimationById(second_animation_id)->run_state()); |
2311 | 2339 |
2312 // The active observer should have been ticked by the original animation, | 2340 // The active observer should have been ticked by the original animation, |
2313 // and the pending observer should have been ticked by the new animation. | 2341 // and the pending observer should have been ticked by the new animation. |
2314 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); | 2342 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); |
2315 EXPECT_EQ(0.5f, dummy_impl.opacity()); | 2343 EXPECT_EQ(0.5f, dummy_impl.opacity()); |
2316 | 2344 |
2317 controller_impl->ActivateAnimations(); | 2345 controller_impl->ActivateAnimations(); |
2318 | 2346 |
2319 // The original animation should have been deleted, and the new animation | 2347 // The original animation should have been deleted, and the new animation |
2320 // should now affect both observers. | 2348 // should now affect both observers. |
2321 EXPECT_FALSE(controller_impl->GetAnimationById(first_animation_id)); | 2349 EXPECT_FALSE(controller_impl->GetAnimationById(first_animation_id)); |
2322 EXPECT_TRUE(controller_impl->GetAnimationById(second_animation_id) | 2350 EXPECT_TRUE(controller_impl->GetAnimationById(second_animation_id) |
2323 ->affects_pending_observers()); | 2351 ->affects_pending_observers()); |
2324 EXPECT_TRUE(controller_impl->GetAnimationById(second_animation_id) | 2352 EXPECT_TRUE(controller_impl->GetAnimationById(second_animation_id) |
2325 ->affects_active_observers()); | 2353 ->affects_active_observers()); |
2326 | 2354 |
2327 controller_impl->Animate(kInitialTickTime + | 2355 controller_impl->Animate(kInitialTickTime + |
2328 TimeDelta::FromMilliseconds(1000)); | 2356 TimeDelta::FromMilliseconds(1000)); |
2329 controller_impl->UpdateState(true, events.get()); | 2357 controller_impl->UpdateState(true, events.get()); |
2330 | 2358 |
2331 // The new animation should be running, and the active observer should have | 2359 // The new animation should be running, and the active observer should have |
2332 // been ticked at the new animation's starting point. | 2360 // been ticked at the new animation's starting point. |
2333 EXPECT_EQ( | 2361 EXPECT_EQ( |
2334 Animation::RUNNING, | 2362 Animation::Running, |
2335 controller_impl->GetAnimationById(second_animation_id)->run_state()); | 2363 controller_impl->GetAnimationById(second_animation_id)->run_state()); |
2336 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); | 2364 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); |
2337 EXPECT_EQ(1.f, dummy_impl.opacity()); | 2365 EXPECT_EQ(1.f, dummy_impl.opacity()); |
2338 } | 2366 } |
2339 | 2367 |
2340 TEST(LayerAnimationControllerTest, TestIsAnimatingProperty) { | 2368 TEST(LayerAnimationControllerTest, TestIsAnimatingProperty) { |
2341 FakeLayerAnimationValueObserver dummy; | 2369 FakeLayerAnimationValueObserver dummy; |
2342 scoped_refptr<LayerAnimationController> controller( | 2370 scoped_refptr<LayerAnimationController> controller( |
2343 LayerAnimationController::Create(0)); | 2371 LayerAnimationController::Create(0)); |
2344 controller->AddValueObserver(&dummy); | 2372 controller->AddValueObserver(&dummy); |
2345 | 2373 |
2346 scoped_ptr<Animation> animation(CreateAnimation( | 2374 scoped_ptr<Animation> animation(CreateAnimation( |
2347 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 2375 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
2348 1, Animation::OPACITY)); | 2376 1, |
| 2377 Animation::Opacity)); |
2349 controller->AddAnimation(animation.Pass()); | 2378 controller->AddAnimation(animation.Pass()); |
2350 controller->Animate(kInitialTickTime); | 2379 controller->Animate(kInitialTickTime); |
2351 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::OPACITY)); | 2380 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::Opacity)); |
2352 controller->UpdateState(true, nullptr); | 2381 controller->UpdateState(true, nullptr); |
2353 EXPECT_TRUE(controller->HasActiveAnimation()); | 2382 EXPECT_TRUE(controller->HasActiveAnimation()); |
2354 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::OPACITY)); | 2383 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::Opacity)); |
2355 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::FILTER)); | 2384 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::Filter)); |
2356 EXPECT_EQ(0.f, dummy.opacity()); | 2385 EXPECT_EQ(0.f, dummy.opacity()); |
2357 } | 2386 } |
2358 | 2387 |
2359 TEST(LayerAnimationControllerTest, TestIsAnimatingPropertyTimeOffsetFillMode) { | 2388 TEST(LayerAnimationControllerTest, TestIsAnimatingPropertyTimeOffsetFillMode) { |
2360 FakeLayerAnimationValueObserver dummy; | 2389 FakeLayerAnimationValueObserver dummy; |
2361 scoped_refptr<LayerAnimationController> controller( | 2390 scoped_refptr<LayerAnimationController> controller( |
2362 LayerAnimationController::Create(0)); | 2391 LayerAnimationController::Create(0)); |
2363 controller->AddValueObserver(&dummy); | 2392 controller->AddValueObserver(&dummy); |
2364 | 2393 |
2365 scoped_ptr<Animation> animation(CreateAnimation( | 2394 scoped_ptr<Animation> animation(CreateAnimation( |
2366 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 2395 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
2367 1, Animation::OPACITY)); | 2396 1, |
2368 animation->set_fill_mode(Animation::FILL_MODE_NONE); | 2397 Animation::Opacity)); |
| 2398 animation->set_fill_mode(Animation::FillModeNone); |
2369 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); | 2399 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); |
2370 controller->AddAnimation(animation.Pass()); | 2400 controller->AddAnimation(animation.Pass()); |
2371 | 2401 |
2372 controller->Animate(kInitialTickTime); | 2402 controller->Animate(kInitialTickTime); |
2373 controller->UpdateState(true, nullptr); | 2403 controller->UpdateState(true, nullptr); |
2374 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::OPACITY)); | 2404 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::Opacity)); |
2375 EXPECT_TRUE(controller->HasActiveAnimation()); | 2405 EXPECT_TRUE(controller->HasActiveAnimation()); |
2376 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::OPACITY)); | 2406 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::Opacity)); |
2377 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::FILTER)); | 2407 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::Filter)); |
2378 | 2408 |
2379 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 2409 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
2380 controller->UpdateState(true, nullptr); | 2410 controller->UpdateState(true, nullptr); |
2381 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::OPACITY)); | 2411 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::Opacity)); |
2382 } | 2412 } |
2383 | 2413 |
2384 } // namespace | 2414 } // namespace |
2385 } // namespace cc | 2415 } // namespace cc |
OLD | NEW |