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" |
11 #include "cc/animation/keyframed_animation_curve.h" | 11 #include "cc/animation/keyframed_animation_curve.h" |
12 #include "cc/animation/scroll_offset_animation_curve.h" | 12 #include "cc/animation/scroll_offset_animation_curve.h" |
13 #include "cc/animation/transform_operations.h" | 13 #include "cc/animation/transform_operations.h" |
14 #include "cc/test/animation_test_common.h" | 14 #include "cc/test/animation_test_common.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "ui/gfx/box_f.h" | 17 #include "ui/gfx/box_f.h" |
18 #include "ui/gfx/transform.h" | 18 #include "ui/gfx/transform.h" |
19 | 19 |
20 namespace cc { | 20 namespace cc { |
21 namespace { | 21 namespace { |
22 | 22 |
23 using base::TimeDelta; | |
24 using base::TimeTicks; | |
25 | |
26 static base::TimeTicks TicksFromSecondsF(double seconds) { | |
27 return base::TimeTicks::FromInternalValue(seconds * | |
28 base::Time::kMicrosecondsPerSecond); | |
29 } | |
30 | |
23 // A LayerAnimationController cannot be ticked at 0.0, since an animation | 31 // A LayerAnimationController cannot be ticked at 0.0, since an animation |
24 // with start time 0.0 is treated as an animation whose start time has | 32 // with start time 0.0 is treated as an animation whose start time has |
25 // not yet been set. | 33 // not yet been set. |
26 const double kInitialTickTime = 1.0; | 34 const TimeTicks kInitialTickTime = TicksFromSecondsF(1.0); |
27 | 35 |
28 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, | 36 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, |
29 int id, | 37 int id, |
30 Animation::TargetProperty property) { | 38 Animation::TargetProperty property) { |
31 return Animation::Create(curve.Pass(), 0, id, property); | 39 return Animation::Create(curve.Pass(), 0, id, property); |
32 } | 40 } |
33 | 41 |
34 TEST(LayerAnimationControllerTest, SyncNewAnimation) { | 42 TEST(LayerAnimationControllerTest, SyncNewAnimation) { |
35 FakeLayerAnimationValueObserver dummy_impl; | 43 FakeLayerAnimationValueObserver dummy_impl; |
36 scoped_refptr<LayerAnimationController> controller_impl( | 44 scoped_refptr<LayerAnimationController> controller_impl( |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
86 | 94 |
87 // Synchronize the start times. | 95 // Synchronize the start times. |
88 EXPECT_EQ(1u, events.size()); | 96 EXPECT_EQ(1u, events.size()); |
89 controller->NotifyAnimationStarted(events[0]); | 97 controller->NotifyAnimationStarted(events[0]); |
90 EXPECT_EQ(controller->GetAnimation(group_id, | 98 EXPECT_EQ(controller->GetAnimation(group_id, |
91 Animation::Opacity)->start_time(), | 99 Animation::Opacity)->start_time(), |
92 controller_impl->GetAnimation(group_id, | 100 controller_impl->GetAnimation(group_id, |
93 Animation::Opacity)->start_time()); | 101 Animation::Opacity)->start_time()); |
94 | 102 |
95 // Start the animation on the main thread. Should not affect the start time. | 103 // Start the animation on the main thread. Should not affect the start time. |
96 controller->Animate(kInitialTickTime + 0.5); | 104 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
97 controller->UpdateState(true, NULL); | 105 controller->UpdateState(true, NULL); |
98 EXPECT_EQ(controller->GetAnimation(group_id, | 106 EXPECT_EQ(controller->GetAnimation(group_id, |
99 Animation::Opacity)->start_time(), | 107 Animation::Opacity)->start_time(), |
100 controller_impl->GetAnimation(group_id, | 108 controller_impl->GetAnimation(group_id, |
101 Animation::Opacity)->start_time()); | 109 Animation::Opacity)->start_time()); |
102 } | 110 } |
103 | 111 |
104 TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) { | 112 TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) { |
105 FakeLayerAnimationValueObserver dummy_impl; | 113 FakeLayerAnimationValueObserver dummy_impl; |
106 scoped_refptr<LayerAnimationController> controller_impl( | 114 scoped_refptr<LayerAnimationController> controller_impl( |
107 LayerAnimationController::Create(0)); | 115 LayerAnimationController::Create(0)); |
108 controller_impl->AddValueObserver(&dummy_impl); | 116 controller_impl->AddValueObserver(&dummy_impl); |
109 FakeLayerAnimationValueObserver dummy; | 117 FakeLayerAnimationValueObserver dummy; |
110 scoped_refptr<LayerAnimationController> controller( | 118 scoped_refptr<LayerAnimationController> controller( |
111 LayerAnimationController::Create(0)); | 119 LayerAnimationController::Create(0)); |
112 controller->AddValueObserver(&dummy); | 120 controller->AddValueObserver(&dummy); |
113 | 121 |
114 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 122 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
115 int group_id = controller->GetAnimation(Animation::Opacity)->group(); | 123 int group_id = controller->GetAnimation(Animation::Opacity)->group(); |
116 | 124 |
117 const double start_time = 123; | 125 const TimeTicks start_time = TicksFromSecondsF(123); |
118 controller->GetAnimation(Animation::Opacity)->set_start_time(start_time); | 126 controller->GetAnimation(Animation::Opacity)->set_start_time(start_time); |
119 | 127 |
120 controller->PushAnimationUpdatesTo(controller_impl.get()); | 128 controller->PushAnimationUpdatesTo(controller_impl.get()); |
121 controller_impl->ActivateAnimations(); | 129 controller_impl->ActivateAnimations(); |
122 | 130 |
123 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 131 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
124 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 132 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
125 controller_impl->GetAnimation(group_id, | 133 controller_impl->GetAnimation(group_id, |
126 Animation::Opacity)->run_state()); | 134 Animation::Opacity)->run_state()); |
127 | 135 |
128 AnimationEventsVector events; | 136 AnimationEventsVector events; |
129 controller_impl->Animate(kInitialTickTime); | 137 controller_impl->Animate(kInitialTickTime); |
130 controller_impl->UpdateState(true, &events); | 138 controller_impl->UpdateState(true, &events); |
131 | 139 |
132 // Synchronize the start times. | 140 // Synchronize the start times. |
133 EXPECT_EQ(1u, events.size()); | 141 EXPECT_EQ(1u, events.size()); |
134 controller->NotifyAnimationStarted(events[0]); | 142 controller->NotifyAnimationStarted(events[0]); |
135 | 143 |
136 EXPECT_EQ(start_time, | 144 EXPECT_EQ(start_time, |
137 controller->GetAnimation(group_id, | 145 controller->GetAnimation(group_id, |
138 Animation::Opacity)->start_time()); | 146 Animation::Opacity)->start_time()); |
139 EXPECT_EQ(controller->GetAnimation(group_id, | 147 EXPECT_EQ(controller->GetAnimation(group_id, |
140 Animation::Opacity)->start_time(), | 148 Animation::Opacity)->start_time(), |
141 controller_impl->GetAnimation(group_id, | 149 controller_impl->GetAnimation(group_id, |
142 Animation::Opacity)->start_time()); | 150 Animation::Opacity)->start_time()); |
143 | 151 |
144 // Start the animation on the main thread. Should not affect the start time. | 152 // Start the animation on the main thread. Should not affect the start time. |
145 controller->Animate(kInitialTickTime + 0.5); | 153 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
146 controller->UpdateState(true, NULL); | 154 controller->UpdateState(true, NULL); |
147 EXPECT_EQ(start_time, | 155 EXPECT_EQ(start_time, |
148 controller->GetAnimation(group_id, | 156 controller->GetAnimation(group_id, |
149 Animation::Opacity)->start_time()); | 157 Animation::Opacity)->start_time()); |
150 EXPECT_EQ(controller->GetAnimation(group_id, | 158 EXPECT_EQ(controller->GetAnimation(group_id, |
151 Animation::Opacity)->start_time(), | 159 Animation::Opacity)->start_time(), |
152 controller_impl->GetAnimation(group_id, | 160 controller_impl->GetAnimation(group_id, |
153 Animation::Opacity)->start_time()); | 161 Animation::Opacity)->start_time()); |
154 } | 162 } |
155 | 163 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); | 197 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); |
190 | 198 |
191 controller_impl->Animate(kInitialTickTime); | 199 controller_impl->Animate(kInitialTickTime); |
192 controller_impl->UpdateState(true, events.get()); | 200 controller_impl->UpdateState(true, events.get()); |
193 EXPECT_EQ(1u, events->size()); | 201 EXPECT_EQ(1u, events->size()); |
194 controller->NotifyAnimationStarted((*events)[0]); | 202 controller->NotifyAnimationStarted((*events)[0]); |
195 | 203 |
196 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 204 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
197 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); | 205 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); |
198 | 206 |
199 controller->Animate(kInitialTickTime + 0.5); | 207 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
200 controller->UpdateState(true, NULL); | 208 controller->UpdateState(true, NULL); |
201 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 209 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
202 | 210 |
203 controller->Animate(kInitialTickTime + 1.0); | 211 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
204 controller->UpdateState(true, NULL); | 212 controller->UpdateState(true, NULL); |
205 EXPECT_EQ(Animation::Finished, | 213 EXPECT_EQ(Animation::Finished, |
206 controller->GetAnimation(Animation::Opacity)->run_state()); | 214 controller->GetAnimation(Animation::Opacity)->run_state()); |
207 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 215 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
208 | 216 |
209 events.reset(new AnimationEventsVector); | 217 events.reset(new AnimationEventsVector); |
210 controller_impl->Animate(kInitialTickTime + 1.5); | 218 controller_impl->Animate(kInitialTickTime + |
219 TimeDelta::FromMilliseconds(1500)); | |
211 controller_impl->UpdateState(true, events.get()); | 220 controller_impl->UpdateState(true, events.get()); |
212 | 221 |
213 EXPECT_EQ(Animation::WaitingForDeletion, | 222 EXPECT_EQ(Animation::WaitingForDeletion, |
214 controller_impl->GetAnimation(Animation::Opacity)->run_state()); | 223 controller_impl->GetAnimation(Animation::Opacity)->run_state()); |
215 // The impl thread controller should have de-activated. | 224 // The impl thread controller should have de-activated. |
216 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); | 225 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); |
217 | 226 |
218 EXPECT_EQ(1u, events->size()); | 227 EXPECT_EQ(1u, events->size()); |
219 controller->NotifyAnimationFinished((*events)[0]); | 228 controller->NotifyAnimationFinished((*events)[0]); |
220 controller->Animate(kInitialTickTime + 1.5); | 229 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); |
221 controller->UpdateState(true, NULL); | 230 controller->UpdateState(true, NULL); |
222 | 231 |
223 EXPECT_EQ(Animation::WaitingForDeletion, | 232 EXPECT_EQ(Animation::WaitingForDeletion, |
224 controller->GetAnimation(Animation::Opacity)->run_state()); | 233 controller->GetAnimation(Animation::Opacity)->run_state()); |
225 // The main thread controller should have de-activated. | 234 // The main thread controller should have de-activated. |
226 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); | 235 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); |
227 | 236 |
228 controller->PushAnimationUpdatesTo(controller_impl.get()); | 237 controller->PushAnimationUpdatesTo(controller_impl.get()); |
229 controller_impl->ActivateAnimations(); | 238 controller_impl->ActivateAnimations(); |
230 EXPECT_FALSE(controller->has_any_animation()); | 239 EXPECT_FALSE(controller->has_any_animation()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 controller->Animate(kInitialTickTime); | 276 controller->Animate(kInitialTickTime); |
268 controller->UpdateState(true, NULL); | 277 controller->UpdateState(true, NULL); |
269 EXPECT_EQ(Animation::Running, | 278 EXPECT_EQ(Animation::Running, |
270 controller_impl->GetAnimation(group_id, | 279 controller_impl->GetAnimation(group_id, |
271 Animation::Opacity)->run_state()); | 280 Animation::Opacity)->run_state()); |
272 EXPECT_EQ(Animation::Running, | 281 EXPECT_EQ(Animation::Running, |
273 controller->GetAnimation(group_id, | 282 controller->GetAnimation(group_id, |
274 Animation::Opacity)->run_state()); | 283 Animation::Opacity)->run_state()); |
275 | 284 |
276 // Pause the main-thread animation. | 285 // Pause the main-thread animation. |
277 controller->PauseAnimation(animation_id, kInitialTickTime + 1.0); | 286 controller->PauseAnimation( |
287 animation_id, | |
288 TimeDelta::FromMilliseconds(1000) + TimeDelta::FromMilliseconds(1000)); | |
278 EXPECT_EQ(Animation::Paused, | 289 EXPECT_EQ(Animation::Paused, |
279 controller->GetAnimation(group_id, | 290 controller->GetAnimation(group_id, |
280 Animation::Opacity)->run_state()); | 291 Animation::Opacity)->run_state()); |
281 | 292 |
282 // The pause run state change should make it to the impl thread controller. | 293 // The pause run state change should make it to the impl thread controller. |
283 controller->PushAnimationUpdatesTo(controller_impl.get()); | 294 controller->PushAnimationUpdatesTo(controller_impl.get()); |
284 controller_impl->ActivateAnimations(); | 295 controller_impl->ActivateAnimations(); |
285 EXPECT_EQ(Animation::Paused, | 296 EXPECT_EQ(Animation::Paused, |
286 controller_impl->GetAnimation(group_id, | 297 controller_impl->GetAnimation(group_id, |
287 Animation::Opacity)->run_state()); | 298 Animation::Opacity)->run_state()); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
345 LayerAnimationController::Create(0)); | 356 LayerAnimationController::Create(0)); |
346 controller->AddValueObserver(&dummy); | 357 controller->AddValueObserver(&dummy); |
347 controller_impl->AddValueObserver(&dummy_impl); | 358 controller_impl->AddValueObserver(&dummy_impl); |
348 | 359 |
349 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false); | 360 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false); |
350 controller->Animate(kInitialTickTime); | 361 controller->Animate(kInitialTickTime); |
351 controller->UpdateState(true, NULL); | 362 controller->UpdateState(true, NULL); |
352 controller->PushAnimationUpdatesTo(controller_impl.get()); | 363 controller->PushAnimationUpdatesTo(controller_impl.get()); |
353 controller_impl->ActivateAnimations(); | 364 controller_impl->ActivateAnimations(); |
354 | 365 |
355 controller_impl->Animate(kInitialTickTime + 0.5); | 366 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
356 controller_impl->UpdateState(true, events.get()); | 367 controller_impl->UpdateState(true, events.get()); |
357 | 368 |
358 // There should be a Started event for the animation. | 369 // There should be a Started event for the animation. |
359 EXPECT_EQ(1u, events->size()); | 370 EXPECT_EQ(1u, events->size()); |
360 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); | 371 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
361 controller->NotifyAnimationStarted((*events)[0]); | 372 controller->NotifyAnimationStarted((*events)[0]); |
362 | 373 |
363 controller->Animate(kInitialTickTime + 1.0); | 374 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
364 controller->UpdateState(true, NULL); | 375 controller->UpdateState(true, NULL); |
365 | 376 |
366 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 377 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
367 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 378 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
368 | 379 |
369 events.reset(new AnimationEventsVector); | 380 events.reset(new AnimationEventsVector); |
370 controller_impl->Animate(kInitialTickTime + 2.0); | 381 controller_impl->Animate(kInitialTickTime + |
382 TimeDelta::FromMilliseconds(2000)); | |
371 controller_impl->UpdateState(true, events.get()); | 383 controller_impl->UpdateState(true, events.get()); |
372 | 384 |
373 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); | 385 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); |
374 | 386 |
375 // There should be a Finished event for the animation. | 387 // There should be a Finished event for the animation. |
376 EXPECT_EQ(1u, events->size()); | 388 EXPECT_EQ(1u, events->size()); |
377 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); | 389 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
378 | 390 |
379 // Neither controller should have deleted the animation yet. | 391 // Neither controller should have deleted the animation yet. |
380 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); | 392 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); |
381 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity)); | 393 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity)); |
382 | 394 |
383 controller->NotifyAnimationFinished((*events)[0]); | 395 controller->NotifyAnimationFinished((*events)[0]); |
384 | 396 |
385 controller->Animate(kInitialTickTime + 3.0); | 397 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
386 controller->UpdateState(true, NULL); | 398 controller->UpdateState(true, NULL); |
387 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 399 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
388 | 400 |
389 controller->PushAnimationUpdatesTo(controller_impl.get()); | 401 controller->PushAnimationUpdatesTo(controller_impl.get()); |
390 | 402 |
391 // Both controllers should now have deleted the animation. The impl controller | 403 // Both controllers should now have deleted the animation. The impl controller |
392 // should have deleted the animation even though activation has not occurred, | 404 // should have deleted the animation even though activation has not occurred, |
393 // since the animation was already waiting for deletion when | 405 // since the animation was already waiting for deletion when |
394 // PushAnimationUpdatesTo was called. | 406 // PushAnimationUpdatesTo was called. |
395 EXPECT_FALSE(controller->has_any_animation()); | 407 EXPECT_FALSE(controller->has_any_animation()); |
(...skipping 26 matching lines...) Expand all Loading... | |
422 Animation::Opacity)); | 434 Animation::Opacity)); |
423 | 435 |
424 controller->AddAnimation(to_add.Pass()); | 436 controller->AddAnimation(to_add.Pass()); |
425 controller->Animate(kInitialTickTime); | 437 controller->Animate(kInitialTickTime); |
426 controller->UpdateState(true, events.get()); | 438 controller->UpdateState(true, events.get()); |
427 EXPECT_TRUE(controller->HasActiveAnimation()); | 439 EXPECT_TRUE(controller->HasActiveAnimation()); |
428 EXPECT_EQ(0.f, dummy.opacity()); | 440 EXPECT_EQ(0.f, dummy.opacity()); |
429 // A non-impl-only animation should not generate property updates. | 441 // A non-impl-only animation should not generate property updates. |
430 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 442 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
431 EXPECT_FALSE(event); | 443 EXPECT_FALSE(event); |
432 controller->Animate(kInitialTickTime + 1.0); | 444 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
433 controller->UpdateState(true, events.get()); | 445 controller->UpdateState(true, events.get()); |
434 EXPECT_EQ(1.f, dummy.opacity()); | 446 EXPECT_EQ(1.f, dummy.opacity()); |
435 EXPECT_FALSE(controller->HasActiveAnimation()); | 447 EXPECT_FALSE(controller->HasActiveAnimation()); |
436 event = GetMostRecentPropertyUpdateEvent(events.get()); | 448 event = GetMostRecentPropertyUpdateEvent(events.get()); |
437 EXPECT_FALSE(event); | 449 EXPECT_FALSE(event); |
438 } | 450 } |
439 | 451 |
440 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { | 452 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { |
441 scoped_ptr<AnimationEventsVector> events( | 453 scoped_ptr<AnimationEventsVector> events( |
442 make_scoped_ptr(new AnimationEventsVector)); | 454 make_scoped_ptr(new AnimationEventsVector)); |
(...skipping 11 matching lines...) Expand all Loading... | |
454 controller_impl->AddAnimation(to_add.Pass()); | 466 controller_impl->AddAnimation(to_add.Pass()); |
455 controller_impl->Animate(kInitialTickTime); | 467 controller_impl->Animate(kInitialTickTime); |
456 controller_impl->UpdateState(true, events.get()); | 468 controller_impl->UpdateState(true, events.get()); |
457 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 469 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
458 EXPECT_EQ(0.f, dummy_impl.opacity()); | 470 EXPECT_EQ(0.f, dummy_impl.opacity()); |
459 EXPECT_EQ(2u, events->size()); | 471 EXPECT_EQ(2u, events->size()); |
460 const AnimationEvent* start_opacity_event = | 472 const AnimationEvent* start_opacity_event = |
461 GetMostRecentPropertyUpdateEvent(events.get()); | 473 GetMostRecentPropertyUpdateEvent(events.get()); |
462 EXPECT_EQ(0.f, start_opacity_event->opacity); | 474 EXPECT_EQ(0.f, start_opacity_event->opacity); |
463 | 475 |
464 controller_impl->Animate(kInitialTickTime + 1.0); | 476 controller_impl->Animate(kInitialTickTime + |
477 TimeDelta::FromMilliseconds(1000)); | |
465 controller_impl->UpdateState(true, events.get()); | 478 controller_impl->UpdateState(true, events.get()); |
466 EXPECT_EQ(1.f, dummy_impl.opacity()); | 479 EXPECT_EQ(1.f, dummy_impl.opacity()); |
467 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 480 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
468 EXPECT_EQ(4u, events->size()); | 481 EXPECT_EQ(4u, events->size()); |
469 const AnimationEvent* end_opacity_event = | 482 const AnimationEvent* end_opacity_event = |
470 GetMostRecentPropertyUpdateEvent(events.get()); | 483 GetMostRecentPropertyUpdateEvent(events.get()); |
471 EXPECT_EQ(1.f, end_opacity_event->opacity); | 484 EXPECT_EQ(1.f, end_opacity_event->opacity); |
472 } | 485 } |
473 | 486 |
474 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { | 487 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
508 EXPECT_EQ(2u, events->size()); | 521 EXPECT_EQ(2u, events->size()); |
509 const AnimationEvent* start_transform_event = | 522 const AnimationEvent* start_transform_event = |
510 GetMostRecentPropertyUpdateEvent(events.get()); | 523 GetMostRecentPropertyUpdateEvent(events.get()); |
511 ASSERT_TRUE(start_transform_event); | 524 ASSERT_TRUE(start_transform_event); |
512 EXPECT_EQ(gfx::Transform(), start_transform_event->transform); | 525 EXPECT_EQ(gfx::Transform(), start_transform_event->transform); |
513 EXPECT_TRUE(start_transform_event->is_impl_only); | 526 EXPECT_TRUE(start_transform_event->is_impl_only); |
514 | 527 |
515 gfx::Transform expected_transform; | 528 gfx::Transform expected_transform; |
516 expected_transform.Translate(delta_x, delta_y); | 529 expected_transform.Translate(delta_x, delta_y); |
517 | 530 |
518 controller_impl->Animate(kInitialTickTime + 1.0); | 531 controller_impl->Animate(kInitialTickTime + |
532 TimeDelta::FromMilliseconds(1000)); | |
519 controller_impl->UpdateState(true, events.get()); | 533 controller_impl->UpdateState(true, events.get()); |
520 EXPECT_EQ(expected_transform, dummy_impl.transform()); | 534 EXPECT_EQ(expected_transform, dummy_impl.transform()); |
521 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 535 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
522 EXPECT_EQ(4u, events->size()); | 536 EXPECT_EQ(4u, events->size()); |
523 const AnimationEvent* end_transform_event = | 537 const AnimationEvent* end_transform_event = |
524 GetMostRecentPropertyUpdateEvent(events.get()); | 538 GetMostRecentPropertyUpdateEvent(events.get()); |
525 EXPECT_EQ(expected_transform, end_transform_event->transform); | 539 EXPECT_EQ(expected_transform, end_transform_event->transform); |
526 EXPECT_TRUE(end_transform_event->is_impl_only); | 540 EXPECT_TRUE(end_transform_event->is_impl_only); |
527 } | 541 } |
528 | 542 |
(...skipping 22 matching lines...) Expand all Loading... | |
551 controller->AddAnimation(animation.Pass()); | 565 controller->AddAnimation(animation.Pass()); |
552 | 566 |
553 controller->Animate(kInitialTickTime); | 567 controller->Animate(kInitialTickTime); |
554 controller->UpdateState(true, events.get()); | 568 controller->UpdateState(true, events.get()); |
555 EXPECT_TRUE(controller->HasActiveAnimation()); | 569 EXPECT_TRUE(controller->HasActiveAnimation()); |
556 EXPECT_EQ(start_filters, dummy.filters()); | 570 EXPECT_EQ(start_filters, dummy.filters()); |
557 // A non-impl-only animation should not generate property updates. | 571 // A non-impl-only animation should not generate property updates. |
558 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 572 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
559 EXPECT_FALSE(event); | 573 EXPECT_FALSE(event); |
560 | 574 |
561 controller->Animate(kInitialTickTime + 0.5); | 575 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
562 controller->UpdateState(true, events.get()); | 576 controller->UpdateState(true, events.get()); |
563 EXPECT_EQ(1u, dummy.filters().size()); | 577 EXPECT_EQ(1u, dummy.filters().size()); |
564 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f), | 578 EXPECT_EQ(FilterOperation::CreateBrightnessFilter(1.5f), |
565 dummy.filters().at(0)); | 579 dummy.filters().at(0)); |
566 event = GetMostRecentPropertyUpdateEvent(events.get()); | 580 event = GetMostRecentPropertyUpdateEvent(events.get()); |
567 EXPECT_FALSE(event); | 581 EXPECT_FALSE(event); |
568 | 582 |
569 controller->Animate(kInitialTickTime + 1.0); | 583 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
570 controller->UpdateState(true, events.get()); | 584 controller->UpdateState(true, events.get()); |
571 EXPECT_EQ(end_filters, dummy.filters()); | 585 EXPECT_EQ(end_filters, dummy.filters()); |
572 EXPECT_FALSE(controller->HasActiveAnimation()); | 586 EXPECT_FALSE(controller->HasActiveAnimation()); |
573 event = GetMostRecentPropertyUpdateEvent(events.get()); | 587 event = GetMostRecentPropertyUpdateEvent(events.get()); |
574 EXPECT_FALSE(event); | 588 EXPECT_FALSE(event); |
575 } | 589 } |
576 | 590 |
577 TEST(LayerAnimationControllerTest, FilterTransitionOnImplOnly) { | 591 TEST(LayerAnimationControllerTest, FilterTransitionOnImplOnly) { |
578 scoped_ptr<AnimationEventsVector> events( | 592 scoped_ptr<AnimationEventsVector> events( |
579 make_scoped_ptr(new AnimationEventsVector)); | 593 make_scoped_ptr(new AnimationEventsVector)); |
(...skipping 25 matching lines...) Expand all Loading... | |
605 controller_impl->UpdateState(true, events.get()); | 619 controller_impl->UpdateState(true, events.get()); |
606 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 620 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
607 EXPECT_EQ(start_filters, dummy_impl.filters()); | 621 EXPECT_EQ(start_filters, dummy_impl.filters()); |
608 EXPECT_EQ(2u, events->size()); | 622 EXPECT_EQ(2u, events->size()); |
609 const AnimationEvent* start_filter_event = | 623 const AnimationEvent* start_filter_event = |
610 GetMostRecentPropertyUpdateEvent(events.get()); | 624 GetMostRecentPropertyUpdateEvent(events.get()); |
611 EXPECT_TRUE(start_filter_event); | 625 EXPECT_TRUE(start_filter_event); |
612 EXPECT_EQ(start_filters, start_filter_event->filters); | 626 EXPECT_EQ(start_filters, start_filter_event->filters); |
613 EXPECT_TRUE(start_filter_event->is_impl_only); | 627 EXPECT_TRUE(start_filter_event->is_impl_only); |
614 | 628 |
615 controller_impl->Animate(kInitialTickTime + 1.0); | 629 controller_impl->Animate(kInitialTickTime + |
630 TimeDelta::FromMilliseconds(1000)); | |
616 controller_impl->UpdateState(true, events.get()); | 631 controller_impl->UpdateState(true, events.get()); |
617 EXPECT_EQ(end_filters, dummy_impl.filters()); | 632 EXPECT_EQ(end_filters, dummy_impl.filters()); |
618 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 633 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
619 EXPECT_EQ(4u, events->size()); | 634 EXPECT_EQ(4u, events->size()); |
620 const AnimationEvent* end_filter_event = | 635 const AnimationEvent* end_filter_event = |
621 GetMostRecentPropertyUpdateEvent(events.get()); | 636 GetMostRecentPropertyUpdateEvent(events.get()); |
622 EXPECT_TRUE(end_filter_event); | 637 EXPECT_TRUE(end_filter_event); |
623 EXPECT_EQ(end_filters, end_filter_event->filters); | 638 EXPECT_EQ(end_filters, end_filter_event->filters); |
624 EXPECT_TRUE(end_filter_event->is_impl_only); | 639 EXPECT_TRUE(end_filter_event->is_impl_only); |
625 } | 640 } |
(...skipping 23 matching lines...) Expand all Loading... | |
649 | 664 |
650 scoped_ptr<Animation> animation(Animation::Create( | 665 scoped_ptr<Animation> animation(Animation::Create( |
651 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); | 666 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); |
652 animation->set_needs_synchronized_start_time(true); | 667 animation->set_needs_synchronized_start_time(true); |
653 controller->AddAnimation(animation.Pass()); | 668 controller->AddAnimation(animation.Pass()); |
654 | 669 |
655 dummy_provider_impl.set_scroll_offset(initial_value); | 670 dummy_provider_impl.set_scroll_offset(initial_value); |
656 controller->PushAnimationUpdatesTo(controller_impl.get()); | 671 controller->PushAnimationUpdatesTo(controller_impl.get()); |
657 controller_impl->ActivateAnimations(); | 672 controller_impl->ActivateAnimations(); |
658 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); | 673 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); |
659 double duration = controller_impl->GetAnimation( | 674 double duration_in_seconds = |
660 Animation::ScrollOffset)->curve()->Duration(); | 675 controller_impl->GetAnimation(Animation::ScrollOffset) |
661 | 676 ->curve() |
677 ->Duration(); | |
678 TimeDelta duration = TimeDelta::FromMicroseconds( | |
679 duration_in_seconds * base::Time::kMicrosecondsPerSecond); | |
662 EXPECT_EQ( | 680 EXPECT_EQ( |
663 duration, | 681 duration_in_seconds, |
664 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); | 682 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); |
665 | |
ajuma
2014/05/07 17:04:42
Please keep this whitespace.
Sikugu_
2014/05/12 16:01:53
Done.
| |
666 controller->Animate(kInitialTickTime); | 683 controller->Animate(kInitialTickTime); |
667 controller->UpdateState(true, NULL); | 684 controller->UpdateState(true, NULL); |
668 EXPECT_TRUE(controller->HasActiveAnimation()); | 685 EXPECT_TRUE(controller->HasActiveAnimation()); |
669 EXPECT_EQ(initial_value, dummy.scroll_offset()); | 686 EXPECT_EQ(initial_value, dummy.scroll_offset()); |
670 | 687 |
671 controller_impl->Animate(kInitialTickTime); | 688 controller_impl->Animate(kInitialTickTime); |
672 controller_impl->UpdateState(true, events.get()); | 689 controller_impl->UpdateState(true, events.get()); |
673 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 690 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
674 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 691 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
675 // Scroll offset animations should not generate property updates. | 692 // Scroll offset animations should not generate property updates. |
676 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 693 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
677 EXPECT_FALSE(event); | 694 EXPECT_FALSE(event); |
678 | |
ajuma
2014/05/07 17:04:42
Here too.
Sikugu_
2014/05/12 16:01:53
Done.
| |
679 controller->NotifyAnimationStarted((*events)[0]); | 695 controller->NotifyAnimationStarted((*events)[0]); |
680 controller->Animate(kInitialTickTime + duration/2.0); | 696 controller->Animate(kInitialTickTime + duration / 2); |
681 controller->UpdateState(true, NULL); | 697 controller->UpdateState(true, NULL); |
682 EXPECT_TRUE(controller->HasActiveAnimation()); | 698 EXPECT_TRUE(controller->HasActiveAnimation()); |
683 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset()); | 699 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset()); |
684 | 700 |
685 controller_impl->Animate(kInitialTickTime + duration/2.0); | 701 controller_impl->Animate(kInitialTickTime + duration / 2); |
686 controller_impl->UpdateState(true, events.get()); | 702 controller_impl->UpdateState(true, events.get()); |
687 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), | 703 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), |
688 dummy_impl.scroll_offset()); | 704 dummy_impl.scroll_offset()); |
689 event = GetMostRecentPropertyUpdateEvent(events.get()); | 705 event = GetMostRecentPropertyUpdateEvent(events.get()); |
690 EXPECT_FALSE(event); | 706 EXPECT_FALSE(event); |
691 | 707 |
692 controller_impl->Animate(kInitialTickTime + duration); | 708 controller_impl->Animate(kInitialTickTime + duration); |
693 controller_impl->UpdateState(true, events.get()); | 709 controller_impl->UpdateState(true, events.get()); |
694 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); | 710 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); |
695 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 711 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
728 | 744 |
729 scoped_ptr<Animation> animation(Animation::Create( | 745 scoped_ptr<Animation> animation(Animation::Create( |
730 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); | 746 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); |
731 animation->set_needs_synchronized_start_time(true); | 747 animation->set_needs_synchronized_start_time(true); |
732 controller->AddAnimation(animation.Pass()); | 748 controller->AddAnimation(animation.Pass()); |
733 | 749 |
734 dummy_provider.set_scroll_offset(initial_value); | 750 dummy_provider.set_scroll_offset(initial_value); |
735 controller->PushAnimationUpdatesTo(controller_impl.get()); | 751 controller->PushAnimationUpdatesTo(controller_impl.get()); |
736 controller_impl->ActivateAnimations(); | 752 controller_impl->ActivateAnimations(); |
737 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); | 753 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); |
738 double duration = controller_impl->GetAnimation( | 754 double duration_in_seconds = |
739 Animation::ScrollOffset)->curve()->Duration(); | 755 controller_impl->GetAnimation(Animation::ScrollOffset) |
740 | 756 ->curve() |
757 ->Duration(); | |
741 EXPECT_EQ( | 758 EXPECT_EQ( |
742 duration, | 759 duration_in_seconds, |
743 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); | 760 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); |
744 | 761 |
745 controller->Animate(kInitialTickTime); | 762 controller->Animate(kInitialTickTime); |
746 controller->UpdateState(true, NULL); | 763 controller->UpdateState(true, NULL); |
747 EXPECT_TRUE(controller->HasActiveAnimation()); | 764 EXPECT_TRUE(controller->HasActiveAnimation()); |
748 EXPECT_EQ(initial_value, dummy.scroll_offset()); | 765 EXPECT_EQ(initial_value, dummy.scroll_offset()); |
749 | 766 |
750 controller_impl->Animate(kInitialTickTime); | 767 controller_impl->Animate(kInitialTickTime); |
751 controller_impl->UpdateState(true, events.get()); | 768 controller_impl->UpdateState(true, events.get()); |
752 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 769 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
753 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 770 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
754 // Scroll offset animations should not generate property updates. | 771 // Scroll offset animations should not generate property updates. |
755 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 772 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
756 EXPECT_FALSE(event); | 773 EXPECT_FALSE(event); |
757 | 774 |
775 TimeDelta duration = TimeDelta::FromMicroseconds( | |
776 duration_in_seconds * base::Time::kMicrosecondsPerSecond); | |
777 | |
758 controller->NotifyAnimationStarted((*events)[0]); | 778 controller->NotifyAnimationStarted((*events)[0]); |
759 controller->Animate(kInitialTickTime + duration/2.0); | 779 controller->Animate(kInitialTickTime + duration / 2); |
760 controller->UpdateState(true, NULL); | 780 controller->UpdateState(true, NULL); |
761 EXPECT_TRUE(controller->HasActiveAnimation()); | 781 EXPECT_TRUE(controller->HasActiveAnimation()); |
762 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset()); | 782 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset()); |
763 | 783 |
764 controller_impl->Animate(kInitialTickTime + duration/2.0); | 784 controller_impl->Animate(kInitialTickTime + duration / 2); |
765 controller_impl->UpdateState(true, events.get()); | 785 controller_impl->UpdateState(true, events.get()); |
766 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), | 786 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), |
767 dummy_impl.scroll_offset()); | 787 dummy_impl.scroll_offset()); |
768 event = GetMostRecentPropertyUpdateEvent(events.get()); | 788 event = GetMostRecentPropertyUpdateEvent(events.get()); |
769 EXPECT_FALSE(event); | 789 EXPECT_FALSE(event); |
770 | 790 |
771 controller_impl->Animate(kInitialTickTime + duration); | 791 controller_impl->Animate(kInitialTickTime + duration); |
772 controller_impl->UpdateState(true, events.get()); | 792 controller_impl->UpdateState(true, events.get()); |
773 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); | 793 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); |
774 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 794 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
(...skipping 14 matching lines...) Expand all Loading... | |
789 scoped_ptr<AnimationEventsVector> events( | 809 scoped_ptr<AnimationEventsVector> events( |
790 make_scoped_ptr(new AnimationEventsVector)); | 810 make_scoped_ptr(new AnimationEventsVector)); |
791 | 811 |
792 gfx::Vector2dF initial_value(100.f, 300.f); | 812 gfx::Vector2dF initial_value(100.f, 300.f); |
793 gfx::Vector2dF target_value(300.f, 200.f); | 813 gfx::Vector2dF target_value(300.f, 200.f); |
794 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 814 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
795 ScrollOffsetAnimationCurve::Create( | 815 ScrollOffsetAnimationCurve::Create( |
796 target_value, | 816 target_value, |
797 EaseInOutTimingFunction::Create().Pass())); | 817 EaseInOutTimingFunction::Create().Pass())); |
798 curve->SetInitialValue(initial_value); | 818 curve->SetInitialValue(initial_value); |
799 double duration = curve->Duration(); | 819 double duration_in_seconds = curve->Duration(); |
800 | 820 |
801 scoped_ptr<Animation> animation(Animation::Create( | 821 scoped_ptr<Animation> animation(Animation::Create( |
802 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); | 822 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset)); |
803 animation->set_is_impl_only(true); | 823 animation->set_is_impl_only(true); |
804 controller_impl->AddAnimation(animation.Pass()); | 824 controller_impl->AddAnimation(animation.Pass()); |
805 | 825 |
806 controller_impl->Animate(kInitialTickTime); | 826 controller_impl->Animate(kInitialTickTime); |
807 controller_impl->UpdateState(true, events.get()); | 827 controller_impl->UpdateState(true, events.get()); |
808 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 828 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
809 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 829 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
810 // Scroll offset animations should not generate property updates. | 830 // Scroll offset animations should not generate property updates. |
811 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 831 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
812 EXPECT_FALSE(event); | 832 EXPECT_FALSE(event); |
813 | 833 |
814 controller_impl->Animate(kInitialTickTime + duration/2.0); | 834 TimeDelta duration = TimeDelta::FromMicroseconds( |
835 duration_in_seconds * base::Time::kMicrosecondsPerSecond); | |
836 | |
837 controller_impl->Animate(kInitialTickTime + duration / 2); | |
815 controller_impl->UpdateState(true, events.get()); | 838 controller_impl->UpdateState(true, events.get()); |
816 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), | 839 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), |
817 dummy_impl.scroll_offset()); | 840 dummy_impl.scroll_offset()); |
818 event = GetMostRecentPropertyUpdateEvent(events.get()); | 841 event = GetMostRecentPropertyUpdateEvent(events.get()); |
819 EXPECT_FALSE(event); | 842 EXPECT_FALSE(event); |
820 | 843 |
821 controller_impl->Animate(kInitialTickTime + duration); | 844 controller_impl->Animate(kInitialTickTime + duration); |
822 controller_impl->UpdateState(true, events.get()); | 845 controller_impl->UpdateState(true, events.get()); |
823 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); | 846 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); |
824 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 847 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
825 event = GetMostRecentPropertyUpdateEvent(events.get()); | 848 event = GetMostRecentPropertyUpdateEvent(events.get()); |
826 EXPECT_FALSE(event); | 849 EXPECT_FALSE(event); |
827 } | 850 } |
828 | 851 |
829 class FakeAnimationDelegate : public AnimationDelegate { | 852 class FakeAnimationDelegate : public AnimationDelegate { |
830 public: | 853 public: |
831 FakeAnimationDelegate() | 854 FakeAnimationDelegate() |
832 : started_(false), | 855 : started_(false), |
833 finished_(false) {} | 856 finished_(false) {} |
834 | 857 |
835 virtual void NotifyAnimationStarted( | 858 virtual void NotifyAnimationStarted( |
836 base::TimeTicks monotonic_time, | 859 TimeTicks monotonic_time, |
837 Animation::TargetProperty target_property) OVERRIDE { | 860 Animation::TargetProperty target_property) OVERRIDE { |
838 started_ = true; | 861 started_ = true; |
839 } | 862 } |
840 | 863 |
841 virtual void NotifyAnimationFinished( | 864 virtual void NotifyAnimationFinished( |
842 base::TimeTicks monotonic_time, | 865 TimeTicks monotonic_time, |
843 Animation::TargetProperty target_property) OVERRIDE { | 866 Animation::TargetProperty target_property) OVERRIDE { |
844 finished_ = true; | 867 finished_ = true; |
845 } | 868 } |
846 | 869 |
847 bool started() { return started_; } | 870 bool started() { return started_; } |
848 | 871 |
849 bool finished() { return finished_; } | 872 bool finished() { return finished_; } |
850 | 873 |
851 private: | 874 private: |
852 bool started_; | 875 bool started_; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
887 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); | 910 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); |
888 EXPECT_TRUE((*events)[1].is_impl_only); | 911 EXPECT_TRUE((*events)[1].is_impl_only); |
889 | 912 |
890 // Passing on the start event to the main thread controller should cause the | 913 // Passing on the start event to the main thread controller should cause the |
891 // delegate to get notified. | 914 // delegate to get notified. |
892 EXPECT_FALSE(delegate.started()); | 915 EXPECT_FALSE(delegate.started()); |
893 controller->NotifyAnimationStarted((*events)[0]); | 916 controller->NotifyAnimationStarted((*events)[0]); |
894 EXPECT_TRUE(delegate.started()); | 917 EXPECT_TRUE(delegate.started()); |
895 | 918 |
896 events.reset(new AnimationEventsVector); | 919 events.reset(new AnimationEventsVector); |
897 controller_impl->Animate(kInitialTickTime + 1.0); | 920 controller_impl->Animate(kInitialTickTime + |
921 TimeDelta::FromMilliseconds(1000)); | |
898 controller_impl->UpdateState(true, events.get()); | 922 controller_impl->UpdateState(true, events.get()); |
899 | 923 |
900 // We should receive 2 events (a finished notification and a property update). | 924 // We should receive 2 events (a finished notification and a property update). |
901 EXPECT_EQ(2u, events->size()); | 925 EXPECT_EQ(2u, events->size()); |
902 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); | 926 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
903 EXPECT_TRUE((*events)[0].is_impl_only); | 927 EXPECT_TRUE((*events)[0].is_impl_only); |
904 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); | 928 EXPECT_EQ(AnimationEvent::PropertyUpdate, (*events)[1].type); |
905 EXPECT_TRUE((*events)[1].is_impl_only); | 929 EXPECT_TRUE((*events)[1].is_impl_only); |
906 | 930 |
907 // Passing on the finished event to the main thread controller should cause | 931 // Passing on the finished event to the main thread controller should cause |
(...skipping 20 matching lines...) Expand all Loading... | |
928 Animation::Opacity)); | 952 Animation::Opacity)); |
929 to_add->set_needs_synchronized_start_time(true); | 953 to_add->set_needs_synchronized_start_time(true); |
930 | 954 |
931 // We should pause at the first keyframe indefinitely waiting for that | 955 // We should pause at the first keyframe indefinitely waiting for that |
932 // animation to start. | 956 // animation to start. |
933 controller->AddAnimation(to_add.Pass()); | 957 controller->AddAnimation(to_add.Pass()); |
934 controller->Animate(kInitialTickTime); | 958 controller->Animate(kInitialTickTime); |
935 controller->UpdateState(true, events.get()); | 959 controller->UpdateState(true, events.get()); |
936 EXPECT_TRUE(controller->HasActiveAnimation()); | 960 EXPECT_TRUE(controller->HasActiveAnimation()); |
937 EXPECT_EQ(0.f, dummy.opacity()); | 961 EXPECT_EQ(0.f, dummy.opacity()); |
938 controller->Animate(kInitialTickTime + 1.0); | 962 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
939 controller->UpdateState(true, events.get()); | 963 controller->UpdateState(true, events.get()); |
940 EXPECT_TRUE(controller->HasActiveAnimation()); | 964 EXPECT_TRUE(controller->HasActiveAnimation()); |
941 EXPECT_EQ(0.f, dummy.opacity()); | 965 EXPECT_EQ(0.f, dummy.opacity()); |
942 controller->Animate(kInitialTickTime + 2.0); | 966 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
943 controller->UpdateState(true, events.get()); | 967 controller->UpdateState(true, events.get()); |
944 EXPECT_TRUE(controller->HasActiveAnimation()); | 968 EXPECT_TRUE(controller->HasActiveAnimation()); |
945 EXPECT_EQ(0.f, dummy.opacity()); | 969 EXPECT_EQ(0.f, dummy.opacity()); |
946 | 970 |
947 // Send the synchronized start time. | 971 // Send the synchronized start time. |
948 controller->NotifyAnimationStarted(AnimationEvent( | 972 controller->NotifyAnimationStarted( |
949 AnimationEvent::Started, 0, 1, Animation::Opacity, kInitialTickTime + 2)); | 973 AnimationEvent(AnimationEvent::Started, |
950 controller->Animate(kInitialTickTime + 5.0); | 974 0, |
975 1, | |
976 Animation::Opacity, | |
977 kInitialTickTime + TimeDelta::FromMilliseconds(2000))); | |
978 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(5000)); | |
951 controller->UpdateState(true, events.get()); | 979 controller->UpdateState(true, events.get()); |
952 EXPECT_EQ(1.f, dummy.opacity()); | 980 EXPECT_EQ(1.f, dummy.opacity()); |
953 EXPECT_FALSE(controller->HasActiveAnimation()); | 981 EXPECT_FALSE(controller->HasActiveAnimation()); |
954 } | 982 } |
955 | 983 |
956 // Tests that two queued animations affecting the same property run in sequence. | 984 // Tests that two queued animations affecting the same property run in sequence. |
957 TEST(LayerAnimationControllerTest, TrivialQueuing) { | 985 TEST(LayerAnimationControllerTest, TrivialQueuing) { |
958 scoped_ptr<AnimationEventsVector> events( | 986 scoped_ptr<AnimationEventsVector> events( |
959 make_scoped_ptr(new AnimationEventsVector)); | 987 make_scoped_ptr(new AnimationEventsVector)); |
960 FakeLayerAnimationValueObserver dummy; | 988 FakeLayerAnimationValueObserver dummy; |
961 scoped_refptr<LayerAnimationController> controller( | 989 scoped_refptr<LayerAnimationController> controller( |
962 LayerAnimationController::Create(0)); | 990 LayerAnimationController::Create(0)); |
963 controller->AddValueObserver(&dummy); | 991 controller->AddValueObserver(&dummy); |
964 | 992 |
965 controller->AddAnimation(CreateAnimation( | 993 controller->AddAnimation(CreateAnimation( |
966 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 994 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
967 1, | 995 1, |
968 Animation::Opacity)); | 996 Animation::Opacity)); |
969 controller->AddAnimation(CreateAnimation( | 997 controller->AddAnimation(CreateAnimation( |
970 scoped_ptr<AnimationCurve>( | 998 scoped_ptr<AnimationCurve>( |
971 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), | 999 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), |
972 2, | 1000 2, |
973 Animation::Opacity)); | 1001 Animation::Opacity)); |
974 | 1002 |
975 controller->Animate(kInitialTickTime); | 1003 controller->Animate(kInitialTickTime); |
976 controller->UpdateState(true, events.get()); | 1004 controller->UpdateState(true, events.get()); |
977 EXPECT_TRUE(controller->HasActiveAnimation()); | 1005 EXPECT_TRUE(controller->HasActiveAnimation()); |
978 EXPECT_EQ(0.f, dummy.opacity()); | 1006 EXPECT_EQ(0.f, dummy.opacity()); |
979 controller->Animate(kInitialTickTime + 1.0); | 1007 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
980 controller->UpdateState(true, events.get()); | 1008 controller->UpdateState(true, events.get()); |
981 EXPECT_TRUE(controller->HasActiveAnimation()); | 1009 EXPECT_TRUE(controller->HasActiveAnimation()); |
982 EXPECT_EQ(1.f, dummy.opacity()); | 1010 EXPECT_EQ(1.f, dummy.opacity()); |
983 controller->Animate(kInitialTickTime + 2.0); | 1011 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
984 controller->UpdateState(true, events.get()); | 1012 controller->UpdateState(true, events.get()); |
985 EXPECT_EQ(0.5f, dummy.opacity()); | 1013 EXPECT_EQ(0.5f, dummy.opacity()); |
986 EXPECT_FALSE(controller->HasActiveAnimation()); | 1014 EXPECT_FALSE(controller->HasActiveAnimation()); |
987 } | 1015 } |
988 | 1016 |
989 // Tests interrupting a transition with another transition. | 1017 // Tests interrupting a transition with another transition. |
990 TEST(LayerAnimationControllerTest, Interrupt) { | 1018 TEST(LayerAnimationControllerTest, Interrupt) { |
991 scoped_ptr<AnimationEventsVector> events( | 1019 scoped_ptr<AnimationEventsVector> events( |
992 make_scoped_ptr(new AnimationEventsVector)); | 1020 make_scoped_ptr(new AnimationEventsVector)); |
993 FakeLayerAnimationValueObserver dummy; | 1021 FakeLayerAnimationValueObserver dummy; |
(...skipping 12 matching lines...) Expand all Loading... | |
1006 scoped_ptr<Animation> to_add(CreateAnimation( | 1034 scoped_ptr<Animation> to_add(CreateAnimation( |
1007 scoped_ptr<AnimationCurve>( | 1035 scoped_ptr<AnimationCurve>( |
1008 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), | 1036 new FakeFloatTransition(1.0, 1.f, 0.5f)).Pass(), |
1009 2, | 1037 2, |
1010 Animation::Opacity)); | 1038 Animation::Opacity)); |
1011 controller->AbortAnimations(Animation::Opacity); | 1039 controller->AbortAnimations(Animation::Opacity); |
1012 controller->AddAnimation(to_add.Pass()); | 1040 controller->AddAnimation(to_add.Pass()); |
1013 | 1041 |
1014 // Since the previous animation was aborted, the new animation should start | 1042 // Since the previous animation was aborted, the new animation should start |
1015 // right in this call to animate. | 1043 // right in this call to animate. |
1016 controller->Animate(kInitialTickTime + 0.5); | 1044 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
1017 controller->UpdateState(true, events.get()); | 1045 controller->UpdateState(true, events.get()); |
1018 EXPECT_TRUE(controller->HasActiveAnimation()); | 1046 EXPECT_TRUE(controller->HasActiveAnimation()); |
1019 EXPECT_EQ(1.f, dummy.opacity()); | 1047 EXPECT_EQ(1.f, dummy.opacity()); |
1020 controller->Animate(kInitialTickTime + 1.5); | 1048 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); |
1021 controller->UpdateState(true, events.get()); | 1049 controller->UpdateState(true, events.get()); |
1022 EXPECT_EQ(0.5f, dummy.opacity()); | 1050 EXPECT_EQ(0.5f, dummy.opacity()); |
1023 EXPECT_FALSE(controller->HasActiveAnimation()); | 1051 EXPECT_FALSE(controller->HasActiveAnimation()); |
1024 } | 1052 } |
1025 | 1053 |
1026 // Tests scheduling two animations to run together when only one property is | 1054 // Tests scheduling two animations to run together when only one property is |
1027 // free. | 1055 // free. |
1028 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { | 1056 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { |
1029 scoped_ptr<AnimationEventsVector> events( | 1057 scoped_ptr<AnimationEventsVector> events( |
1030 make_scoped_ptr(new AnimationEventsVector)); | 1058 make_scoped_ptr(new AnimationEventsVector)); |
(...skipping 12 matching lines...) Expand all Loading... | |
1043 Animation::Transform)); | 1071 Animation::Transform)); |
1044 controller->AddAnimation(CreateAnimation( | 1072 controller->AddAnimation(CreateAnimation( |
1045 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1073 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1046 2, | 1074 2, |
1047 Animation::Opacity)); | 1075 Animation::Opacity)); |
1048 | 1076 |
1049 controller->Animate(kInitialTickTime); | 1077 controller->Animate(kInitialTickTime); |
1050 controller->UpdateState(true, events.get()); | 1078 controller->UpdateState(true, events.get()); |
1051 EXPECT_EQ(0.f, dummy.opacity()); | 1079 EXPECT_EQ(0.f, dummy.opacity()); |
1052 EXPECT_TRUE(controller->HasActiveAnimation()); | 1080 EXPECT_TRUE(controller->HasActiveAnimation()); |
1053 controller->Animate(kInitialTickTime + 1.0); | 1081 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1054 controller->UpdateState(true, events.get()); | 1082 controller->UpdateState(true, events.get()); |
1055 // Should not have started the float transition yet. | 1083 // Should not have started the float transition yet. |
1056 EXPECT_TRUE(controller->HasActiveAnimation()); | 1084 EXPECT_TRUE(controller->HasActiveAnimation()); |
1057 EXPECT_EQ(0.f, dummy.opacity()); | 1085 EXPECT_EQ(0.f, dummy.opacity()); |
1058 // The float animation should have started at time 1 and should be done. | 1086 // The float animation should have started at time 1 and should be done. |
1059 controller->Animate(kInitialTickTime + 2.0); | 1087 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
1060 controller->UpdateState(true, events.get()); | 1088 controller->UpdateState(true, events.get()); |
1061 EXPECT_EQ(1.f, dummy.opacity()); | 1089 EXPECT_EQ(1.f, dummy.opacity()); |
1062 EXPECT_FALSE(controller->HasActiveAnimation()); | 1090 EXPECT_FALSE(controller->HasActiveAnimation()); |
1063 } | 1091 } |
1064 | 1092 |
1065 // Tests scheduling two animations to run together with different lengths and | 1093 // Tests scheduling two animations to run together with different lengths and |
1066 // another animation queued to start when the shorter animation finishes (should | 1094 // another animation queued to start when the shorter animation finishes (should |
1067 // wait for both to finish). | 1095 // wait for both to finish). |
1068 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { | 1096 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { |
1069 scoped_ptr<AnimationEventsVector> events( | 1097 scoped_ptr<AnimationEventsVector> events( |
(...skipping 18 matching lines...) Expand all Loading... | |
1088 Animation::Opacity)); | 1116 Animation::Opacity)); |
1089 | 1117 |
1090 // Animations with id 1 should both start now. | 1118 // Animations with id 1 should both start now. |
1091 controller->Animate(kInitialTickTime); | 1119 controller->Animate(kInitialTickTime); |
1092 controller->UpdateState(true, events.get()); | 1120 controller->UpdateState(true, events.get()); |
1093 EXPECT_TRUE(controller->HasActiveAnimation()); | 1121 EXPECT_TRUE(controller->HasActiveAnimation()); |
1094 EXPECT_EQ(0.f, dummy.opacity()); | 1122 EXPECT_EQ(0.f, dummy.opacity()); |
1095 // The opacity animation should have finished at time 1, but the group | 1123 // The opacity animation should have finished at time 1, but the group |
1096 // of animations with id 1 don't finish until time 2 because of the length | 1124 // of animations with id 1 don't finish until time 2 because of the length |
1097 // of the transform animation. | 1125 // of the transform animation. |
1098 controller->Animate(kInitialTickTime + 2.0); | 1126 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
1099 controller->UpdateState(true, events.get()); | 1127 controller->UpdateState(true, events.get()); |
1100 // Should not have started the float transition yet. | 1128 // Should not have started the float transition yet. |
1101 EXPECT_TRUE(controller->HasActiveAnimation()); | 1129 EXPECT_TRUE(controller->HasActiveAnimation()); |
1102 EXPECT_EQ(1.f, dummy.opacity()); | 1130 EXPECT_EQ(1.f, dummy.opacity()); |
1103 | 1131 |
1104 // The second opacity animation should start at time 2 and should be done by | 1132 // The second opacity animation should start at time 2 and should be done by |
1105 // time 3. | 1133 // time 3. |
1106 controller->Animate(kInitialTickTime + 3.0); | 1134 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
1107 controller->UpdateState(true, events.get()); | 1135 controller->UpdateState(true, events.get()); |
1108 EXPECT_EQ(0.5f, dummy.opacity()); | 1136 EXPECT_EQ(0.5f, dummy.opacity()); |
1109 EXPECT_FALSE(controller->HasActiveAnimation()); | 1137 EXPECT_FALSE(controller->HasActiveAnimation()); |
1110 } | 1138 } |
1111 | 1139 |
1112 // Test that a looping animation loops and for the correct number of iterations. | 1140 // Test that a looping animation loops and for the correct number of iterations. |
1113 TEST(LayerAnimationControllerTest, TrivialLooping) { | 1141 TEST(LayerAnimationControllerTest, TrivialLooping) { |
1114 scoped_ptr<AnimationEventsVector> events( | 1142 scoped_ptr<AnimationEventsVector> events( |
1115 make_scoped_ptr(new AnimationEventsVector)); | 1143 make_scoped_ptr(new AnimationEventsVector)); |
1116 FakeLayerAnimationValueObserver dummy; | 1144 FakeLayerAnimationValueObserver dummy; |
1117 scoped_refptr<LayerAnimationController> controller( | 1145 scoped_refptr<LayerAnimationController> controller( |
1118 LayerAnimationController::Create(0)); | 1146 LayerAnimationController::Create(0)); |
1119 controller->AddValueObserver(&dummy); | 1147 controller->AddValueObserver(&dummy); |
1120 | 1148 |
1121 scoped_ptr<Animation> to_add(CreateAnimation( | 1149 scoped_ptr<Animation> to_add(CreateAnimation( |
1122 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1150 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1123 1, | 1151 1, |
1124 Animation::Opacity)); | 1152 Animation::Opacity)); |
1125 to_add->set_iterations(3); | 1153 to_add->set_iterations(3); |
1126 controller->AddAnimation(to_add.Pass()); | 1154 controller->AddAnimation(to_add.Pass()); |
1127 | 1155 |
1128 controller->Animate(kInitialTickTime); | 1156 controller->Animate(kInitialTickTime); |
1129 controller->UpdateState(true, events.get()); | 1157 controller->UpdateState(true, events.get()); |
1130 EXPECT_TRUE(controller->HasActiveAnimation()); | 1158 EXPECT_TRUE(controller->HasActiveAnimation()); |
1131 EXPECT_EQ(0.f, dummy.opacity()); | 1159 EXPECT_EQ(0.f, dummy.opacity()); |
1132 controller->Animate(kInitialTickTime + 1.25); | 1160 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); |
1133 controller->UpdateState(true, events.get()); | 1161 controller->UpdateState(true, events.get()); |
1134 EXPECT_TRUE(controller->HasActiveAnimation()); | 1162 EXPECT_TRUE(controller->HasActiveAnimation()); |
1135 EXPECT_EQ(0.25f, dummy.opacity()); | 1163 EXPECT_EQ(0.25f, dummy.opacity()); |
1136 controller->Animate(kInitialTickTime + 1.75); | 1164 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); |
1137 controller->UpdateState(true, events.get()); | 1165 controller->UpdateState(true, events.get()); |
1138 EXPECT_TRUE(controller->HasActiveAnimation()); | 1166 EXPECT_TRUE(controller->HasActiveAnimation()); |
1139 EXPECT_EQ(0.75f, dummy.opacity()); | 1167 EXPECT_EQ(0.75f, dummy.opacity()); |
1140 controller->Animate(kInitialTickTime + 2.25); | 1168 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2250)); |
1141 controller->UpdateState(true, events.get()); | 1169 controller->UpdateState(true, events.get()); |
1142 EXPECT_TRUE(controller->HasActiveAnimation()); | 1170 EXPECT_TRUE(controller->HasActiveAnimation()); |
1143 EXPECT_EQ(0.25f, dummy.opacity()); | 1171 EXPECT_EQ(0.25f, dummy.opacity()); |
1144 controller->Animate(kInitialTickTime + 2.75); | 1172 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2750)); |
1145 controller->UpdateState(true, events.get()); | 1173 controller->UpdateState(true, events.get()); |
1146 EXPECT_TRUE(controller->HasActiveAnimation()); | 1174 EXPECT_TRUE(controller->HasActiveAnimation()); |
1147 EXPECT_EQ(0.75f, dummy.opacity()); | 1175 EXPECT_EQ(0.75f, dummy.opacity()); |
1148 controller->Animate(kInitialTickTime + 3.0); | 1176 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
1149 controller->UpdateState(true, events.get()); | 1177 controller->UpdateState(true, events.get()); |
1150 EXPECT_FALSE(controller->HasActiveAnimation()); | 1178 EXPECT_FALSE(controller->HasActiveAnimation()); |
1151 EXPECT_EQ(1.f, dummy.opacity()); | 1179 EXPECT_EQ(1.f, dummy.opacity()); |
1152 | 1180 |
1153 // Just be extra sure. | 1181 // Just be extra sure. |
1154 controller->Animate(kInitialTickTime + 4.0); | 1182 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); |
1155 controller->UpdateState(true, events.get()); | 1183 controller->UpdateState(true, events.get()); |
1156 EXPECT_EQ(1.f, dummy.opacity()); | 1184 EXPECT_EQ(1.f, dummy.opacity()); |
1157 } | 1185 } |
1158 | 1186 |
1159 // Test that an infinitely looping animation does indeed go until aborted. | 1187 // Test that an infinitely looping animation does indeed go until aborted. |
1160 TEST(LayerAnimationControllerTest, InfiniteLooping) { | 1188 TEST(LayerAnimationControllerTest, InfiniteLooping) { |
1161 scoped_ptr<AnimationEventsVector> events( | 1189 scoped_ptr<AnimationEventsVector> events( |
1162 make_scoped_ptr(new AnimationEventsVector)); | 1190 make_scoped_ptr(new AnimationEventsVector)); |
1163 FakeLayerAnimationValueObserver dummy; | 1191 FakeLayerAnimationValueObserver dummy; |
1164 scoped_refptr<LayerAnimationController> controller( | 1192 scoped_refptr<LayerAnimationController> controller( |
1165 LayerAnimationController::Create(0)); | 1193 LayerAnimationController::Create(0)); |
1166 controller->AddValueObserver(&dummy); | 1194 controller->AddValueObserver(&dummy); |
1167 | 1195 |
1168 const int id = 1; | 1196 const int id = 1; |
1169 scoped_ptr<Animation> to_add(CreateAnimation( | 1197 scoped_ptr<Animation> to_add(CreateAnimation( |
1170 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1198 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1171 id, | 1199 id, |
1172 Animation::Opacity)); | 1200 Animation::Opacity)); |
1173 to_add->set_iterations(-1); | 1201 to_add->set_iterations(-1); |
1174 controller->AddAnimation(to_add.Pass()); | 1202 controller->AddAnimation(to_add.Pass()); |
1175 | 1203 |
1176 controller->Animate(kInitialTickTime); | 1204 controller->Animate(kInitialTickTime); |
1177 controller->UpdateState(true, events.get()); | 1205 controller->UpdateState(true, events.get()); |
1178 EXPECT_TRUE(controller->HasActiveAnimation()); | 1206 EXPECT_TRUE(controller->HasActiveAnimation()); |
1179 EXPECT_EQ(0.f, dummy.opacity()); | 1207 EXPECT_EQ(0.f, dummy.opacity()); |
1180 controller->Animate(kInitialTickTime + 1.25); | 1208 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); |
1181 controller->UpdateState(true, events.get()); | 1209 controller->UpdateState(true, events.get()); |
1182 EXPECT_TRUE(controller->HasActiveAnimation()); | 1210 EXPECT_TRUE(controller->HasActiveAnimation()); |
1183 EXPECT_EQ(0.25f, dummy.opacity()); | 1211 EXPECT_EQ(0.25f, dummy.opacity()); |
1184 controller->Animate(kInitialTickTime + 1.75); | 1212 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); |
1185 controller->UpdateState(true, events.get()); | 1213 controller->UpdateState(true, events.get()); |
1186 EXPECT_TRUE(controller->HasActiveAnimation()); | 1214 EXPECT_TRUE(controller->HasActiveAnimation()); |
1187 EXPECT_EQ(0.75f, dummy.opacity()); | 1215 EXPECT_EQ(0.75f, dummy.opacity()); |
1188 | 1216 |
1189 controller->Animate(kInitialTickTime + 1073741824.25); | 1217 controller->Animate(kInitialTickTime + |
1218 TimeDelta::FromMilliseconds(1073741824250)); | |
1190 controller->UpdateState(true, events.get()); | 1219 controller->UpdateState(true, events.get()); |
1191 EXPECT_TRUE(controller->HasActiveAnimation()); | 1220 EXPECT_TRUE(controller->HasActiveAnimation()); |
1192 EXPECT_EQ(0.25f, dummy.opacity()); | 1221 EXPECT_EQ(0.25f, dummy.opacity()); |
1193 controller->Animate(kInitialTickTime + 1073741824.75); | 1222 controller->Animate(kInitialTickTime + |
1223 TimeDelta::FromMilliseconds(1073741824750)); | |
1194 controller->UpdateState(true, events.get()); | 1224 controller->UpdateState(true, events.get()); |
1195 EXPECT_TRUE(controller->HasActiveAnimation()); | 1225 EXPECT_TRUE(controller->HasActiveAnimation()); |
1196 EXPECT_EQ(0.75f, dummy.opacity()); | 1226 EXPECT_EQ(0.75f, dummy.opacity()); |
1197 | 1227 |
1198 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); | 1228 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); |
1199 controller->GetAnimation(id, Animation::Opacity)->SetRunState( | 1229 controller->GetAnimation(id, Animation::Opacity)->SetRunState( |
1200 Animation::Aborted, kInitialTickTime + 0.75); | 1230 Animation::Aborted, kInitialTickTime + TimeDelta::FromMilliseconds(750)); |
1201 EXPECT_FALSE(controller->HasActiveAnimation()); | 1231 EXPECT_FALSE(controller->HasActiveAnimation()); |
1202 EXPECT_EQ(0.75f, dummy.opacity()); | 1232 EXPECT_EQ(0.75f, dummy.opacity()); |
1203 } | 1233 } |
1204 | 1234 |
1205 // Test that pausing and resuming work as expected. | 1235 // Test that pausing and resuming work as expected. |
1206 TEST(LayerAnimationControllerTest, PauseResume) { | 1236 TEST(LayerAnimationControllerTest, PauseResume) { |
1207 scoped_ptr<AnimationEventsVector> events( | 1237 scoped_ptr<AnimationEventsVector> events( |
1208 make_scoped_ptr(new AnimationEventsVector)); | 1238 make_scoped_ptr(new AnimationEventsVector)); |
1209 FakeLayerAnimationValueObserver dummy; | 1239 FakeLayerAnimationValueObserver dummy; |
1210 scoped_refptr<LayerAnimationController> controller( | 1240 scoped_refptr<LayerAnimationController> controller( |
1211 LayerAnimationController::Create(0)); | 1241 LayerAnimationController::Create(0)); |
1212 controller->AddValueObserver(&dummy); | 1242 controller->AddValueObserver(&dummy); |
1213 | 1243 |
1214 const int id = 1; | 1244 const int id = 1; |
1215 controller->AddAnimation(CreateAnimation( | 1245 controller->AddAnimation(CreateAnimation( |
1216 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1246 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1217 id, | 1247 id, |
1218 Animation::Opacity)); | 1248 Animation::Opacity)); |
1219 | 1249 |
1220 controller->Animate(kInitialTickTime); | 1250 controller->Animate(kInitialTickTime); |
1221 controller->UpdateState(true, events.get()); | 1251 controller->UpdateState(true, events.get()); |
1222 EXPECT_TRUE(controller->HasActiveAnimation()); | 1252 EXPECT_TRUE(controller->HasActiveAnimation()); |
1223 EXPECT_EQ(0.f, dummy.opacity()); | 1253 EXPECT_EQ(0.f, dummy.opacity()); |
1224 controller->Animate(kInitialTickTime + 0.5); | 1254 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
1225 controller->UpdateState(true, events.get()); | 1255 controller->UpdateState(true, events.get()); |
1226 EXPECT_TRUE(controller->HasActiveAnimation()); | 1256 EXPECT_TRUE(controller->HasActiveAnimation()); |
1227 EXPECT_EQ(0.5f, dummy.opacity()); | 1257 EXPECT_EQ(0.5f, dummy.opacity()); |
1228 | 1258 |
1229 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); | 1259 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); |
1230 controller->GetAnimation(id, Animation::Opacity)->SetRunState( | 1260 controller->GetAnimation(id, Animation::Opacity)->SetRunState( |
1231 Animation::Paused, kInitialTickTime + 0.5); | 1261 Animation::Paused, kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
1232 | 1262 |
1233 controller->Animate(kInitialTickTime + 1024.0); | 1263 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); |
1234 controller->UpdateState(true, events.get()); | 1264 controller->UpdateState(true, events.get()); |
1235 EXPECT_TRUE(controller->HasActiveAnimation()); | 1265 EXPECT_TRUE(controller->HasActiveAnimation()); |
1236 EXPECT_EQ(0.5f, dummy.opacity()); | 1266 EXPECT_EQ(0.5f, dummy.opacity()); |
1237 | 1267 |
1238 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); | 1268 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); |
1239 controller->GetAnimation(id, Animation::Opacity)->SetRunState( | 1269 controller->GetAnimation(id, Animation::Opacity) |
1240 Animation::Running, kInitialTickTime + 1024); | 1270 ->SetRunState(Animation::Running, |
1241 | 1271 kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); |
1242 controller->Animate(kInitialTickTime + 1024.25); | 1272 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024250)); |
1243 controller->UpdateState(true, events.get()); | 1273 controller->UpdateState(true, events.get()); |
1244 EXPECT_TRUE(controller->HasActiveAnimation()); | 1274 EXPECT_TRUE(controller->HasActiveAnimation()); |
1245 EXPECT_EQ(0.75f, dummy.opacity()); | 1275 EXPECT_EQ(0.75f, dummy.opacity()); |
1246 controller->Animate(kInitialTickTime + 1024.5); | 1276 |
1277 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024500)); | |
1247 controller->UpdateState(true, events.get()); | 1278 controller->UpdateState(true, events.get()); |
1248 EXPECT_FALSE(controller->HasActiveAnimation()); | 1279 EXPECT_FALSE(controller->HasActiveAnimation()); |
1249 EXPECT_EQ(1.f, dummy.opacity()); | 1280 EXPECT_EQ(1.f, dummy.opacity()); |
1250 } | 1281 } |
1251 | 1282 |
1252 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { | 1283 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { |
1253 scoped_ptr<AnimationEventsVector> events( | 1284 scoped_ptr<AnimationEventsVector> events( |
1254 make_scoped_ptr(new AnimationEventsVector)); | 1285 make_scoped_ptr(new AnimationEventsVector)); |
1255 FakeLayerAnimationValueObserver dummy; | 1286 FakeLayerAnimationValueObserver dummy; |
1256 scoped_refptr<LayerAnimationController> controller( | 1287 scoped_refptr<LayerAnimationController> controller( |
(...skipping 12 matching lines...) Expand all Loading... | |
1269 controller->AddAnimation(CreateAnimation( | 1300 controller->AddAnimation(CreateAnimation( |
1270 scoped_ptr<AnimationCurve>( | 1301 scoped_ptr<AnimationCurve>( |
1271 new FakeFloatTransition(1.0, 1.f, 0.75f)).Pass(), | 1302 new FakeFloatTransition(1.0, 1.f, 0.75f)).Pass(), |
1272 2, | 1303 2, |
1273 Animation::Opacity)); | 1304 Animation::Opacity)); |
1274 | 1305 |
1275 controller->Animate(kInitialTickTime); | 1306 controller->Animate(kInitialTickTime); |
1276 controller->UpdateState(true, events.get()); | 1307 controller->UpdateState(true, events.get()); |
1277 EXPECT_TRUE(controller->HasActiveAnimation()); | 1308 EXPECT_TRUE(controller->HasActiveAnimation()); |
1278 EXPECT_EQ(0.f, dummy.opacity()); | 1309 EXPECT_EQ(0.f, dummy.opacity()); |
1279 controller->Animate(kInitialTickTime + 1.0); | 1310 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1280 controller->UpdateState(true, events.get()); | 1311 controller->UpdateState(true, events.get()); |
1281 EXPECT_TRUE(controller->HasActiveAnimation()); | 1312 EXPECT_TRUE(controller->HasActiveAnimation()); |
1282 EXPECT_EQ(0.5f, dummy.opacity()); | 1313 EXPECT_EQ(0.5f, dummy.opacity()); |
1283 | 1314 |
1284 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); | 1315 EXPECT_TRUE(controller->GetAnimation(id, Animation::Opacity)); |
1285 controller->GetAnimation(id, Animation::Opacity)->SetRunState( | 1316 controller->GetAnimation(id, Animation::Opacity)->SetRunState( |
1286 Animation::Aborted, kInitialTickTime + 1.0); | 1317 Animation::Aborted, kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1287 controller->Animate(kInitialTickTime + 1.0); | 1318 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1288 controller->UpdateState(true, events.get()); | 1319 controller->UpdateState(true, events.get()); |
1289 EXPECT_TRUE(controller->HasActiveAnimation()); | 1320 EXPECT_TRUE(controller->HasActiveAnimation()); |
1290 EXPECT_EQ(1.f, dummy.opacity()); | 1321 EXPECT_EQ(1.f, dummy.opacity()); |
1291 controller->Animate(kInitialTickTime + 2.0); | 1322 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
1292 controller->UpdateState(true, events.get()); | 1323 controller->UpdateState(true, events.get()); |
1293 EXPECT_TRUE(!controller->HasActiveAnimation()); | 1324 EXPECT_TRUE(!controller->HasActiveAnimation()); |
1294 EXPECT_EQ(0.75f, dummy.opacity()); | 1325 EXPECT_EQ(0.75f, dummy.opacity()); |
1295 } | 1326 } |
1296 | 1327 |
1297 TEST(LayerAnimationControllerTest, PushUpdatesWhenSynchronizedStartTimeNeeded) { | 1328 TEST(LayerAnimationControllerTest, PushUpdatesWhenSynchronizedStartTimeNeeded) { |
1298 FakeLayerAnimationValueObserver dummy_impl; | 1329 FakeLayerAnimationValueObserver dummy_impl; |
1299 scoped_refptr<LayerAnimationController> controller_impl( | 1330 scoped_refptr<LayerAnimationController> controller_impl( |
1300 LayerAnimationController::Create(0)); | 1331 LayerAnimationController::Create(0)); |
1301 controller_impl->AddValueObserver(&dummy_impl); | 1332 controller_impl->AddValueObserver(&dummy_impl); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1345 | 1376 |
1346 controller->Animate(kInitialTickTime); | 1377 controller->Animate(kInitialTickTime); |
1347 controller->UpdateState(true, events.get()); | 1378 controller->UpdateState(true, events.get()); |
1348 | 1379 |
1349 controller->AddAnimation(CreateAnimation( | 1380 controller->AddAnimation(CreateAnimation( |
1350 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1381 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1351 2, | 1382 2, |
1352 Animation::Opacity)); | 1383 Animation::Opacity)); |
1353 | 1384 |
1354 // Animate but don't UpdateState. | 1385 // Animate but don't UpdateState. |
1355 controller->Animate(kInitialTickTime + 1.0); | 1386 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1356 | 1387 |
1357 controller->Animate(kInitialTickTime + 2.0); | 1388 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
1358 events.reset(new AnimationEventsVector); | 1389 events.reset(new AnimationEventsVector); |
1359 controller->UpdateState(true, events.get()); | 1390 controller->UpdateState(true, events.get()); |
1360 | 1391 |
1361 // Should have one Started event and one Finished event. | 1392 // Should have one Started event and one Finished event. |
1362 EXPECT_EQ(2u, events->size()); | 1393 EXPECT_EQ(2u, events->size()); |
1363 EXPECT_NE((*events)[0].type, (*events)[1].type); | 1394 EXPECT_NE((*events)[0].type, (*events)[1].type); |
1364 | 1395 |
1365 // The float transition should still be at its starting point. | 1396 // The float transition should still be at its starting point. |
1366 EXPECT_TRUE(controller->HasActiveAnimation()); | 1397 EXPECT_TRUE(controller->HasActiveAnimation()); |
1367 EXPECT_EQ(0.f, dummy.opacity()); | 1398 EXPECT_EQ(0.f, dummy.opacity()); |
1368 | 1399 |
1369 controller->Animate(kInitialTickTime + 3.0); | 1400 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
1370 controller->UpdateState(true, events.get()); | 1401 controller->UpdateState(true, events.get()); |
1371 | 1402 |
1372 // The float tranisition should now be done. | 1403 // The float tranisition should now be done. |
1373 EXPECT_EQ(1.f, dummy.opacity()); | 1404 EXPECT_EQ(1.f, dummy.opacity()); |
1374 EXPECT_FALSE(controller->HasActiveAnimation()); | 1405 EXPECT_FALSE(controller->HasActiveAnimation()); |
1375 } | 1406 } |
1376 | 1407 |
1377 // Tests that an animation controller with only a pending observer gets ticked | 1408 // Tests that an animation controller with only a pending observer gets ticked |
1378 // but doesn't progress animations past the Starting state. | 1409 // but doesn't progress animations past the Starting state. |
1379 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { | 1410 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { |
(...skipping 16 matching lines...) Expand all Loading... | |
1396 controller->UpdateState(true, events.get()); | 1427 controller->UpdateState(true, events.get()); |
1397 EXPECT_EQ(0u, events->size()); | 1428 EXPECT_EQ(0u, events->size()); |
1398 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 1429 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
1399 controller->GetAnimation(id, Animation::Opacity)->run_state()); | 1430 controller->GetAnimation(id, Animation::Opacity)->run_state()); |
1400 | 1431 |
1401 controller->AddValueObserver(&pending_dummy); | 1432 controller->AddValueObserver(&pending_dummy); |
1402 | 1433 |
1403 // With only a pending observer, the animation should progress to the | 1434 // With only a pending observer, the animation should progress to the |
1404 // Starting state and get ticked at its starting point, but should not | 1435 // Starting state and get ticked at its starting point, but should not |
1405 // progress to Running. | 1436 // progress to Running. |
1406 controller->Animate(kInitialTickTime + 1.0); | 1437 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1407 controller->UpdateState(true, events.get()); | 1438 controller->UpdateState(true, events.get()); |
1408 EXPECT_EQ(0u, events->size()); | 1439 EXPECT_EQ(0u, events->size()); |
1409 EXPECT_EQ(Animation::Starting, | 1440 EXPECT_EQ(Animation::Starting, |
1410 controller->GetAnimation(id, Animation::Opacity)->run_state()); | 1441 controller->GetAnimation(id, Animation::Opacity)->run_state()); |
1411 EXPECT_EQ(0.5f, pending_dummy.opacity()); | 1442 EXPECT_EQ(0.5f, pending_dummy.opacity()); |
1412 | 1443 |
1413 // Even when already in the Starting state, the animation should stay | 1444 // Even when already in the Starting state, the animation should stay |
1414 // there, and shouldn't be ticked past its starting point. | 1445 // there, and shouldn't be ticked past its starting point. |
1415 controller->Animate(kInitialTickTime + 2.0); | 1446 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
1416 controller->UpdateState(true, events.get()); | 1447 controller->UpdateState(true, events.get()); |
1417 EXPECT_EQ(0u, events->size()); | 1448 EXPECT_EQ(0u, events->size()); |
1418 EXPECT_EQ(Animation::Starting, | 1449 EXPECT_EQ(Animation::Starting, |
1419 controller->GetAnimation(id, Animation::Opacity)->run_state()); | 1450 controller->GetAnimation(id, Animation::Opacity)->run_state()); |
1420 EXPECT_EQ(0.5f, pending_dummy.opacity()); | 1451 EXPECT_EQ(0.5f, pending_dummy.opacity()); |
1421 | 1452 |
1422 controller->AddValueObserver(&dummy); | 1453 controller->AddValueObserver(&dummy); |
1423 | 1454 |
1424 // Now that an active observer has been added, the animation should still | 1455 // Now that an active observer has been added, the animation should still |
1425 // initially tick at its starting point, but should now progress to Running. | 1456 // initially tick at its starting point, but should now progress to Running. |
1426 controller->Animate(kInitialTickTime + 3.0); | 1457 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
1427 controller->UpdateState(true, events.get()); | 1458 controller->UpdateState(true, events.get()); |
1428 EXPECT_EQ(1u, events->size()); | 1459 EXPECT_EQ(1u, events->size()); |
1429 EXPECT_EQ(Animation::Running, | 1460 EXPECT_EQ(Animation::Running, |
1430 controller->GetAnimation(id, Animation::Opacity)->run_state()); | 1461 controller->GetAnimation(id, Animation::Opacity)->run_state()); |
1431 EXPECT_EQ(0.5f, pending_dummy.opacity()); | 1462 EXPECT_EQ(0.5f, pending_dummy.opacity()); |
1432 EXPECT_EQ(0.5f, dummy.opacity()); | 1463 EXPECT_EQ(0.5f, dummy.opacity()); |
1433 | 1464 |
1434 // The animation should now tick past its starting point. | 1465 // The animation should now tick past its starting point. |
1435 controller->Animate(kInitialTickTime + 3.5); | 1466 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3500)); |
1436 EXPECT_NE(0.5f, pending_dummy.opacity()); | 1467 EXPECT_NE(0.5f, pending_dummy.opacity()); |
1437 EXPECT_NE(0.5f, dummy.opacity()); | 1468 EXPECT_NE(0.5f, dummy.opacity()); |
1438 } | 1469 } |
1439 | 1470 |
1440 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { | 1471 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { |
1441 scoped_refptr<LayerAnimationController> controller_impl( | 1472 scoped_refptr<LayerAnimationController> controller_impl( |
1442 LayerAnimationController::Create(0)); | 1473 LayerAnimationController::Create(0)); |
1443 | 1474 |
1444 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1475 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
1445 KeyframedTransformAnimationCurve::Create()); | 1476 KeyframedTransformAnimationCurve::Create()); |
(...skipping 24 matching lines...) Expand all Loading... | |
1470 controller_impl->AddAnimation(animation.Pass()); | 1501 controller_impl->AddAnimation(animation.Pass()); |
1471 | 1502 |
1472 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); | 1503 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); |
1473 gfx::BoxF bounds; | 1504 gfx::BoxF bounds; |
1474 | 1505 |
1475 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1506 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); |
1476 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), | 1507 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), |
1477 bounds.ToString()); | 1508 bounds.ToString()); |
1478 | 1509 |
1479 controller_impl->GetAnimation(1, Animation::Transform) | 1510 controller_impl->GetAnimation(1, Animation::Transform) |
1480 ->SetRunState(Animation::Finished, 0.0); | 1511 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1481 | 1512 |
1482 // Only the unfinished animation should affect the animated bounds. | 1513 // Only the unfinished animation should affect the animated bounds. |
1483 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1514 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); |
1484 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 7.f, 16.f, 20.f).ToString(), | 1515 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 7.f, 16.f, 20.f).ToString(), |
1485 bounds.ToString()); | 1516 bounds.ToString()); |
1486 | 1517 |
1487 controller_impl->GetAnimation(2, Animation::Transform) | 1518 controller_impl->GetAnimation(2, Animation::Transform) |
1488 ->SetRunState(Animation::Finished, 0.0); | 1519 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1489 | 1520 |
1490 // There are no longer any running animations. | 1521 // There are no longer any running animations. |
1491 EXPECT_FALSE(controller_impl->HasTransformAnimationThatInflatesBounds()); | 1522 EXPECT_FALSE(controller_impl->HasTransformAnimationThatInflatesBounds()); |
1492 | 1523 |
1493 // Add an animation whose bounds we don't yet support computing. | 1524 // Add an animation whose bounds we don't yet support computing. |
1494 scoped_ptr<KeyframedTransformAnimationCurve> curve3( | 1525 scoped_ptr<KeyframedTransformAnimationCurve> curve3( |
1495 KeyframedTransformAnimationCurve::Create()); | 1526 KeyframedTransformAnimationCurve::Create()); |
1496 TransformOperations operations3; | 1527 TransformOperations operations3; |
1497 gfx::Transform transform3; | 1528 gfx::Transform transform3; |
1498 transform3.Scale3d(1.0, 2.0, 3.0); | 1529 transform3.Scale3d(1.0, 2.0, 3.0); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1533 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), | 1564 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), |
1534 4, | 1565 4, |
1535 Animation::Transform)); | 1566 Animation::Transform)); |
1536 controller->AddAnimation(CreateAnimation( | 1567 controller->AddAnimation(CreateAnimation( |
1537 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1568 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1538 5, | 1569 5, |
1539 Animation::Opacity)); | 1570 Animation::Opacity)); |
1540 | 1571 |
1541 controller->Animate(kInitialTickTime); | 1572 controller->Animate(kInitialTickTime); |
1542 controller->UpdateState(true, NULL); | 1573 controller->UpdateState(true, NULL); |
1543 controller->Animate(kInitialTickTime + 1.0); | 1574 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1544 controller->UpdateState(true, NULL); | 1575 controller->UpdateState(true, NULL); |
1545 | 1576 |
1546 EXPECT_EQ(Animation::Finished, | 1577 EXPECT_EQ(Animation::Finished, |
1547 controller->GetAnimation(1, Animation::Transform)->run_state()); | 1578 controller->GetAnimation(1, Animation::Transform)->run_state()); |
1548 EXPECT_EQ(Animation::Finished, | 1579 EXPECT_EQ(Animation::Finished, |
1549 controller->GetAnimation(2, Animation::Opacity)->run_state()); | 1580 controller->GetAnimation(2, Animation::Opacity)->run_state()); |
1550 EXPECT_EQ(Animation::Running, | 1581 EXPECT_EQ(Animation::Running, |
1551 controller->GetAnimation(3, Animation::Transform)->run_state()); | 1582 controller->GetAnimation(3, Animation::Transform)->run_state()); |
1552 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 1583 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
1553 controller->GetAnimation(4, Animation::Transform)->run_state()); | 1584 controller->GetAnimation(4, Animation::Transform)->run_state()); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1635 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); | 1666 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); |
1636 EXPECT_EQ(1u, events.size()); | 1667 EXPECT_EQ(1u, events.size()); |
1637 EXPECT_EQ(AnimationEvent::Aborted, events[0].type); | 1668 EXPECT_EQ(AnimationEvent::Aborted, events[0].type); |
1638 EXPECT_EQ(Animation::WaitingForDeletion, | 1669 EXPECT_EQ(Animation::WaitingForDeletion, |
1639 controller_impl->GetAnimation(Animation::Opacity)->run_state()); | 1670 controller_impl->GetAnimation(Animation::Opacity)->run_state()); |
1640 | 1671 |
1641 controller->NotifyAnimationAborted(events[0]); | 1672 controller->NotifyAnimationAborted(events[0]); |
1642 EXPECT_EQ(Animation::Aborted, | 1673 EXPECT_EQ(Animation::Aborted, |
1643 controller->GetAnimation(Animation::Opacity)->run_state()); | 1674 controller->GetAnimation(Animation::Opacity)->run_state()); |
1644 | 1675 |
1645 controller->Animate(kInitialTickTime + 0.5); | 1676 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
1646 controller->UpdateState(true, NULL); | 1677 controller->UpdateState(true, NULL); |
1647 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 1678 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
1648 EXPECT_EQ(Animation::WaitingForDeletion, | 1679 EXPECT_EQ(Animation::WaitingForDeletion, |
1649 controller->GetAnimation(Animation::Opacity)->run_state()); | 1680 controller->GetAnimation(Animation::Opacity)->run_state()); |
1650 | 1681 |
1651 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1682 controller->PushAnimationUpdatesTo(controller_impl.get()); |
1652 controller_impl->ActivateAnimations(); | 1683 controller_impl->ActivateAnimations(); |
1653 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity)); | 1684 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity)); |
1654 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 1685 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
1655 } | 1686 } |
(...skipping 20 matching lines...) Expand all Loading... | |
1676 | 1707 |
1677 controller_impl->Animate(kInitialTickTime); | 1708 controller_impl->Animate(kInitialTickTime); |
1678 controller_impl->UpdateState(true, events.get()); | 1709 controller_impl->UpdateState(true, events.get()); |
1679 | 1710 |
1680 // Both animations should have started. | 1711 // Both animations should have started. |
1681 EXPECT_EQ(2u, events->size()); | 1712 EXPECT_EQ(2u, events->size()); |
1682 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); | 1713 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
1683 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); | 1714 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); |
1684 | 1715 |
1685 events.reset(new AnimationEventsVector); | 1716 events.reset(new AnimationEventsVector); |
1686 controller_impl->Animate(kInitialTickTime + 1.0); | 1717 controller_impl->Animate(kInitialTickTime + |
1718 TimeDelta::FromMilliseconds(1000)); | |
1687 controller_impl->UpdateState(true, events.get()); | 1719 controller_impl->UpdateState(true, events.get()); |
1688 | 1720 |
1689 // The opacity animation should be finished, but should not have generated | 1721 // The opacity animation should be finished, but should not have generated |
1690 // a Finished event yet. | 1722 // a Finished event yet. |
1691 EXPECT_EQ(0u, events->size()); | 1723 EXPECT_EQ(0u, events->size()); |
1692 EXPECT_EQ(Animation::Finished, | 1724 EXPECT_EQ(Animation::Finished, |
1693 controller_impl->GetAnimation(1, Animation::Opacity)->run_state()); | 1725 controller_impl->GetAnimation(1, Animation::Opacity)->run_state()); |
1694 EXPECT_EQ(Animation::Running, | 1726 EXPECT_EQ(Animation::Running, |
1695 controller_impl->GetAnimation(1, | 1727 controller_impl->GetAnimation(1, |
1696 Animation::Transform)->run_state()); | 1728 Animation::Transform)->run_state()); |
1697 | 1729 |
1698 controller_impl->Animate(kInitialTickTime + 2.0); | 1730 controller_impl->Animate(kInitialTickTime + |
1731 TimeDelta::FromMilliseconds(2000)); | |
1699 controller_impl->UpdateState(true, events.get()); | 1732 controller_impl->UpdateState(true, events.get()); |
1700 | 1733 |
1701 // Both animations should have generated Finished events. | 1734 // Both animations should have generated Finished events. |
1702 EXPECT_EQ(2u, events->size()); | 1735 EXPECT_EQ(2u, events->size()); |
1703 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); | 1736 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
1704 EXPECT_EQ(AnimationEvent::Finished, (*events)[1].type); | 1737 EXPECT_EQ(AnimationEvent::Finished, (*events)[1].type); |
1705 } | 1738 } |
1706 | 1739 |
1707 // Ensure that when a group has a mix of aborted and finished animations, | 1740 // Ensure that when a group has a mix of aborted and finished animations, |
1708 // we generate a Finished event for the finished animation and an Aborted | 1741 // we generate a Finished event for the finished animation and an Aborted |
(...skipping 20 matching lines...) Expand all Loading... | |
1729 controller_impl->UpdateState(true, events.get()); | 1762 controller_impl->UpdateState(true, events.get()); |
1730 | 1763 |
1731 // Both animations should have started. | 1764 // Both animations should have started. |
1732 EXPECT_EQ(2u, events->size()); | 1765 EXPECT_EQ(2u, events->size()); |
1733 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); | 1766 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
1734 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); | 1767 EXPECT_EQ(AnimationEvent::Started, (*events)[1].type); |
1735 | 1768 |
1736 controller_impl->AbortAnimations(Animation::Opacity); | 1769 controller_impl->AbortAnimations(Animation::Opacity); |
1737 | 1770 |
1738 events.reset(new AnimationEventsVector); | 1771 events.reset(new AnimationEventsVector); |
1739 controller_impl->Animate(kInitialTickTime + 1.0); | 1772 controller_impl->Animate(kInitialTickTime + |
1773 TimeDelta::FromMilliseconds(1000)); | |
1740 controller_impl->UpdateState(true, events.get()); | 1774 controller_impl->UpdateState(true, events.get()); |
1741 | 1775 |
1742 // We should have exactly 2 events: a Finished event for the tranform | 1776 // We should have exactly 2 events: a Finished event for the tranform |
1743 // animation, and an Aborted event for the opacity animation. | 1777 // animation, and an Aborted event for the opacity animation. |
1744 EXPECT_EQ(2u, events->size()); | 1778 EXPECT_EQ(2u, events->size()); |
1745 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); | 1779 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
1746 EXPECT_EQ(Animation::Transform, (*events)[0].target_property); | 1780 EXPECT_EQ(Animation::Transform, (*events)[0].target_property); |
1747 EXPECT_EQ(AnimationEvent::Aborted, (*events)[1].type); | 1781 EXPECT_EQ(AnimationEvent::Aborted, (*events)[1].type); |
1748 EXPECT_EQ(Animation::Opacity, (*events)[1].target_property); | 1782 EXPECT_EQ(Animation::Opacity, (*events)[1].target_property); |
1749 } | 1783 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1789 curve2->AddKeyframe(TransformKeyframe::Create( | 1823 curve2->AddKeyframe(TransformKeyframe::Create( |
1790 1.0, operations2, scoped_ptr<TimingFunction>())); | 1824 1.0, operations2, scoped_ptr<TimingFunction>())); |
1791 | 1825 |
1792 animation = Animation::Create( | 1826 animation = Animation::Create( |
1793 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); | 1827 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); |
1794 controller_impl->AddAnimation(animation.Pass()); | 1828 controller_impl->AddAnimation(animation.Pass()); |
1795 | 1829 |
1796 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); | 1830 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); |
1797 | 1831 |
1798 controller_impl->GetAnimation(3, Animation::Transform) | 1832 controller_impl->GetAnimation(3, Animation::Transform) |
1799 ->SetRunState(Animation::Finished, 0.0); | 1833 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1800 | 1834 |
1801 // Only unfinished animations should be considered by | 1835 // Only unfinished animations should be considered by |
1802 // HasAnimationThatAffectsScale. | 1836 // HasAnimationThatAffectsScale. |
1803 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); | 1837 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); |
1804 } | 1838 } |
1805 | 1839 |
1806 TEST(LayerAnimationControllerTest, HasOnlyTranslationTransforms) { | 1840 TEST(LayerAnimationControllerTest, HasOnlyTranslationTransforms) { |
1807 scoped_refptr<LayerAnimationController> controller_impl( | 1841 scoped_refptr<LayerAnimationController> controller_impl( |
1808 LayerAnimationController::Create(0)); | 1842 LayerAnimationController::Create(0)); |
1809 | 1843 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1845 1.0, operations2, scoped_ptr<TimingFunction>())); | 1879 1.0, operations2, scoped_ptr<TimingFunction>())); |
1846 | 1880 |
1847 animation = Animation::Create( | 1881 animation = Animation::Create( |
1848 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); | 1882 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); |
1849 controller_impl->AddAnimation(animation.Pass()); | 1883 controller_impl->AddAnimation(animation.Pass()); |
1850 | 1884 |
1851 // A scale animation is not a translation. | 1885 // A scale animation is not a translation. |
1852 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); | 1886 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); |
1853 | 1887 |
1854 controller_impl->GetAnimation(3, Animation::Transform) | 1888 controller_impl->GetAnimation(3, Animation::Transform) |
1855 ->SetRunState(Animation::Finished, 0.0); | 1889 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1856 | 1890 |
1857 // Only unfinished animations should be considered by | 1891 // Only unfinished animations should be considered by |
1858 // HasOnlyTranslationTransforms. | 1892 // HasOnlyTranslationTransforms. |
1859 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); | 1893 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); |
1860 } | 1894 } |
1861 | 1895 |
1862 TEST(LayerAnimationControllerTest, MaximumScale) { | 1896 TEST(LayerAnimationControllerTest, MaximumScale) { |
1863 scoped_refptr<LayerAnimationController> controller_impl( | 1897 scoped_refptr<LayerAnimationController> controller_impl( |
1864 LayerAnimationController::Create(0)); | 1898 LayerAnimationController::Create(0)); |
1865 | 1899 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1911 curve3->AddKeyframe(TransformKeyframe::Create( | 1945 curve3->AddKeyframe(TransformKeyframe::Create( |
1912 1.0, operations3, scoped_ptr<TimingFunction>())); | 1946 1.0, operations3, scoped_ptr<TimingFunction>())); |
1913 | 1947 |
1914 animation = Animation::Create( | 1948 animation = Animation::Create( |
1915 curve3.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); | 1949 curve3.PassAs<AnimationCurve>(), 3, 3, Animation::Transform); |
1916 controller_impl->AddAnimation(animation.Pass()); | 1950 controller_impl->AddAnimation(animation.Pass()); |
1917 | 1951 |
1918 EXPECT_FALSE(controller_impl->MaximumScale(&max_scale)); | 1952 EXPECT_FALSE(controller_impl->MaximumScale(&max_scale)); |
1919 | 1953 |
1920 controller_impl->GetAnimation(3, Animation::Transform) | 1954 controller_impl->GetAnimation(3, Animation::Transform) |
1921 ->SetRunState(Animation::Finished, 0.0); | 1955 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1922 controller_impl->GetAnimation(2, Animation::Transform) | 1956 controller_impl->GetAnimation(2, Animation::Transform) |
1923 ->SetRunState(Animation::Finished, 0.0); | 1957 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); |
1924 | 1958 |
1925 // Only unfinished animations should be considered by | 1959 // Only unfinished animations should be considered by |
1926 // MaximumScale. | 1960 // MaximumScale. |
1927 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); | 1961 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); |
1928 EXPECT_EQ(4.f, max_scale); | 1962 EXPECT_EQ(4.f, max_scale); |
1929 } | 1963 } |
1930 | 1964 |
1931 TEST(LayerAnimationControllerTest, NewlyPushedAnimationWaitsForActivation) { | 1965 TEST(LayerAnimationControllerTest, NewlyPushedAnimationWaitsForActivation) { |
1932 scoped_ptr<AnimationEventsVector> events( | 1966 scoped_ptr<AnimationEventsVector> events( |
1933 make_scoped_ptr(new AnimationEventsVector)); | 1967 make_scoped_ptr(new AnimationEventsVector)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1969 // should have been ticked. | 2003 // should have been ticked. |
1970 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); | 2004 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); |
1971 EXPECT_EQ(0.f, dummy_impl.opacity()); | 2005 EXPECT_EQ(0.f, dummy_impl.opacity()); |
1972 | 2006 |
1973 controller_impl->ActivateAnimations(); | 2007 controller_impl->ActivateAnimations(); |
1974 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity) | 2008 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity) |
1975 ->affects_pending_observers()); | 2009 ->affects_pending_observers()); |
1976 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity) | 2010 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity) |
1977 ->affects_active_observers()); | 2011 ->affects_active_observers()); |
1978 | 2012 |
1979 controller_impl->Animate(kInitialTickTime + 1.0); | 2013 controller_impl->Animate(kInitialTickTime + |
2014 TimeDelta::FromMilliseconds(1000)); | |
1980 controller_impl->UpdateState(true, events.get()); | 2015 controller_impl->UpdateState(true, events.get()); |
1981 | 2016 |
1982 // Since the animation has been activated, it should have reached the | 2017 // Since the animation has been activated, it should have reached the |
1983 // Running state and the active observer should start to get ticked. | 2018 // Running state and the active observer should start to get ticked. |
1984 EXPECT_EQ( | 2019 EXPECT_EQ( |
1985 Animation::Running, | 2020 Animation::Running, |
1986 controller_impl->GetAnimation(group_id, Animation::Opacity)->run_state()); | 2021 controller_impl->GetAnimation(group_id, Animation::Opacity)->run_state()); |
1987 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); | 2022 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); |
1988 EXPECT_EQ(0.5f, dummy_impl.opacity()); | 2023 EXPECT_EQ(0.5f, dummy_impl.opacity()); |
1989 } | 2024 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2030 ->affects_active_observers()); | 2065 ->affects_active_observers()); |
2031 | 2066 |
2032 controller_impl->UpdateState(true, events.get()); | 2067 controller_impl->UpdateState(true, events.get()); |
2033 | 2068 |
2034 // Since the animation has been activated, it should have reached the | 2069 // Since the animation has been activated, it should have reached the |
2035 // Running state. | 2070 // Running state. |
2036 EXPECT_EQ( | 2071 EXPECT_EQ( |
2037 Animation::Running, | 2072 Animation::Running, |
2038 controller_impl->GetAnimation(group_id, Animation::Opacity)->run_state()); | 2073 controller_impl->GetAnimation(group_id, Animation::Opacity)->run_state()); |
2039 | 2074 |
2040 controller_impl->Animate(kInitialTickTime + 0.5); | 2075 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
2041 | 2076 |
2042 // Both observers should have been ticked. | 2077 // Both observers should have been ticked. |
2043 EXPECT_EQ(0.75f, pending_dummy_impl.opacity()); | 2078 EXPECT_EQ(0.75f, pending_dummy_impl.opacity()); |
2044 EXPECT_EQ(0.75f, dummy_impl.opacity()); | 2079 EXPECT_EQ(0.75f, dummy_impl.opacity()); |
2045 } | 2080 } |
2046 | 2081 |
2047 TEST(LayerAnimationControllerTest, PushedDeletedAnimationWaitsForActivation) { | 2082 TEST(LayerAnimationControllerTest, PushedDeletedAnimationWaitsForActivation) { |
2048 scoped_ptr<AnimationEventsVector> events( | 2083 scoped_ptr<AnimationEventsVector> events( |
2049 make_scoped_ptr(new AnimationEventsVector)); | 2084 make_scoped_ptr(new AnimationEventsVector)); |
2050 FakeLayerAnimationValueObserver dummy_impl; | 2085 FakeLayerAnimationValueObserver dummy_impl; |
(...skipping 29 matching lines...) Expand all Loading... | |
2080 controller->RemoveAnimation( | 2115 controller->RemoveAnimation( |
2081 controller->GetAnimation(Animation::Opacity)->id()); | 2116 controller->GetAnimation(Animation::Opacity)->id()); |
2082 controller->PushAnimationUpdatesTo(controller_impl.get()); | 2117 controller->PushAnimationUpdatesTo(controller_impl.get()); |
2083 | 2118 |
2084 // The animation should no longer affect pending observers. | 2119 // The animation should no longer affect pending observers. |
2085 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity) | 2120 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity) |
2086 ->affects_pending_observers()); | 2121 ->affects_pending_observers()); |
2087 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity) | 2122 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity) |
2088 ->affects_active_observers()); | 2123 ->affects_active_observers()); |
2089 | 2124 |
2090 controller_impl->Animate(kInitialTickTime + 0.5); | 2125 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
2091 controller_impl->UpdateState(true, events.get()); | 2126 controller_impl->UpdateState(true, events.get()); |
2092 | 2127 |
2093 // Only the active observer should have been ticked. | 2128 // Only the active observer should have been ticked. |
2094 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); | 2129 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); |
2095 EXPECT_EQ(0.75f, dummy_impl.opacity()); | 2130 EXPECT_EQ(0.75f, dummy_impl.opacity()); |
2096 | 2131 |
2097 controller_impl->ActivateAnimations(); | 2132 controller_impl->ActivateAnimations(); |
2098 | 2133 |
2099 // Activation should cause the animation to be deleted. | 2134 // Activation should cause the animation to be deleted. |
2100 EXPECT_FALSE(controller_impl->has_any_animation()); | 2135 EXPECT_FALSE(controller_impl->has_any_animation()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2142 EXPECT_TRUE(controller_impl->GetAnimation(first_animation_group_id, | 2177 EXPECT_TRUE(controller_impl->GetAnimation(first_animation_group_id, |
2143 Animation::Opacity) | 2178 Animation::Opacity) |
2144 ->affects_active_observers()); | 2179 ->affects_active_observers()); |
2145 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id, | 2180 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id, |
2146 Animation::Opacity) | 2181 Animation::Opacity) |
2147 ->affects_pending_observers()); | 2182 ->affects_pending_observers()); |
2148 EXPECT_FALSE(controller_impl->GetAnimation(second_animation_group_id, | 2183 EXPECT_FALSE(controller_impl->GetAnimation(second_animation_group_id, |
2149 Animation::Opacity) | 2184 Animation::Opacity) |
2150 ->affects_active_observers()); | 2185 ->affects_active_observers()); |
2151 | 2186 |
2152 controller_impl->Animate(kInitialTickTime + 0.5); | 2187 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
2153 controller_impl->UpdateState(true, events.get()); | 2188 controller_impl->UpdateState(true, events.get()); |
2154 | 2189 |
2155 // The original animation should still be running, and the new animation | 2190 // The original animation should still be running, and the new animation |
2156 // should be starting. | 2191 // should be starting. |
2157 EXPECT_EQ(Animation::Running, | 2192 EXPECT_EQ(Animation::Running, |
2158 controller_impl->GetAnimation(first_animation_group_id, | 2193 controller_impl->GetAnimation(first_animation_group_id, |
2159 Animation::Opacity)->run_state()); | 2194 Animation::Opacity)->run_state()); |
2160 EXPECT_EQ(Animation::Starting, | 2195 EXPECT_EQ(Animation::Starting, |
2161 controller_impl->GetAnimation(second_animation_group_id, | 2196 controller_impl->GetAnimation(second_animation_group_id, |
2162 Animation::Opacity)->run_state()); | 2197 Animation::Opacity)->run_state()); |
2163 | 2198 |
2164 // The active observer should have been ticked by the original animation, | 2199 // The active observer should have been ticked by the original animation, |
2165 // and the pending observer should have been ticked by the new animation. | 2200 // and the pending observer should have been ticked by the new animation. |
2166 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); | 2201 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); |
2167 EXPECT_EQ(0.5f, dummy_impl.opacity()); | 2202 EXPECT_EQ(0.5f, dummy_impl.opacity()); |
2168 | 2203 |
2169 controller_impl->ActivateAnimations(); | 2204 controller_impl->ActivateAnimations(); |
2170 | 2205 |
2171 // The original animation should have been deleted, and the new animation | 2206 // The original animation should have been deleted, and the new animation |
2172 // should now affect both observers. | 2207 // should now affect both observers. |
2173 EXPECT_FALSE(controller_impl->GetAnimation(first_animation_group_id, | 2208 EXPECT_FALSE(controller_impl->GetAnimation(first_animation_group_id, |
2174 Animation::Opacity)); | 2209 Animation::Opacity)); |
2175 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id, | 2210 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id, |
2176 Animation::Opacity) | 2211 Animation::Opacity) |
2177 ->affects_pending_observers()); | 2212 ->affects_pending_observers()); |
2178 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id, | 2213 EXPECT_TRUE(controller_impl->GetAnimation(second_animation_group_id, |
2179 Animation::Opacity) | 2214 Animation::Opacity) |
2180 ->affects_active_observers()); | 2215 ->affects_active_observers()); |
2181 | 2216 |
2182 controller_impl->Animate(kInitialTickTime + 1.0); | 2217 controller_impl->Animate(kInitialTickTime + |
2218 TimeDelta::FromMilliseconds(1000)); | |
2183 controller_impl->UpdateState(true, events.get()); | 2219 controller_impl->UpdateState(true, events.get()); |
2184 | 2220 |
2185 // The new animation should be running, and the active observer should have | 2221 // The new animation should be running, and the active observer should have |
2186 // been ticked at the new animation's starting point. | 2222 // been ticked at the new animation's starting point. |
2187 EXPECT_EQ(Animation::Running, | 2223 EXPECT_EQ(Animation::Running, |
2188 controller_impl->GetAnimation(second_animation_group_id, | 2224 controller_impl->GetAnimation(second_animation_group_id, |
2189 Animation::Opacity)->run_state()); | 2225 Animation::Opacity)->run_state()); |
2190 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); | 2226 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); |
2191 EXPECT_EQ(1.f, dummy_impl.opacity()); | 2227 EXPECT_EQ(1.f, dummy_impl.opacity()); |
2192 } | 2228 } |
2193 | 2229 |
2194 } // namespace | 2230 } // namespace |
2195 } // namespace cc | 2231 } // namespace cc |
OLD | NEW |