| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/animation/layer_animation_controller.h" | 5 #include "cc/animation/layer_animation_controller.h" |
| 6 | 6 |
| 7 #include "cc/animation/animation.h" | 7 #include "cc/animation/animation.h" |
| 8 #include "cc/animation/animation_curve.h" | 8 #include "cc/animation/animation_curve.h" |
| 9 #include "cc/animation/animation_delegate.h" | 9 #include "cc/animation/animation_delegate.h" |
| 10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 // Synchronize the start times. | 100 // Synchronize the start times. |
| 101 EXPECT_EQ(1u, events.size()); | 101 EXPECT_EQ(1u, events.size()); |
| 102 controller->NotifyAnimationStarted(events[0]); | 102 controller->NotifyAnimationStarted(events[0]); |
| 103 EXPECT_EQ(controller->GetAnimation(group_id, | 103 EXPECT_EQ(controller->GetAnimation(group_id, |
| 104 Animation::Opacity)->start_time(), | 104 Animation::Opacity)->start_time(), |
| 105 controller_impl->GetAnimation(group_id, | 105 controller_impl->GetAnimation(group_id, |
| 106 Animation::Opacity)->start_time()); | 106 Animation::Opacity)->start_time()); |
| 107 | 107 |
| 108 // Start the animation on the main thread. Should not affect the start time. | 108 // Start the animation on the main thread. Should not affect the start time. |
| 109 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 109 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 110 controller->UpdateState(true, NULL); | 110 controller->UpdateState(true, nullptr); |
| 111 EXPECT_EQ(controller->GetAnimation(group_id, | 111 EXPECT_EQ(controller->GetAnimation(group_id, |
| 112 Animation::Opacity)->start_time(), | 112 Animation::Opacity)->start_time(), |
| 113 controller_impl->GetAnimation(group_id, | 113 controller_impl->GetAnimation(group_id, |
| 114 Animation::Opacity)->start_time()); | 114 Animation::Opacity)->start_time()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) { | 117 TEST(LayerAnimationControllerTest, UseSpecifiedStartTimes) { |
| 118 FakeLayerAnimationValueObserver dummy_impl; | 118 FakeLayerAnimationValueObserver dummy_impl; |
| 119 scoped_refptr<LayerAnimationController> controller_impl( | 119 scoped_refptr<LayerAnimationController> controller_impl( |
| 120 LayerAnimationController::Create(0)); | 120 LayerAnimationController::Create(0)); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 149 EXPECT_EQ(start_time, | 149 EXPECT_EQ(start_time, |
| 150 controller->GetAnimation(group_id, | 150 controller->GetAnimation(group_id, |
| 151 Animation::Opacity)->start_time()); | 151 Animation::Opacity)->start_time()); |
| 152 EXPECT_EQ(controller->GetAnimation(group_id, | 152 EXPECT_EQ(controller->GetAnimation(group_id, |
| 153 Animation::Opacity)->start_time(), | 153 Animation::Opacity)->start_time(), |
| 154 controller_impl->GetAnimation(group_id, | 154 controller_impl->GetAnimation(group_id, |
| 155 Animation::Opacity)->start_time()); | 155 Animation::Opacity)->start_time()); |
| 156 | 156 |
| 157 // Start the animation on the main thread. Should not affect the start time. | 157 // Start the animation on the main thread. Should not affect the start time. |
| 158 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 158 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 159 controller->UpdateState(true, NULL); | 159 controller->UpdateState(true, nullptr); |
| 160 EXPECT_EQ(start_time, | 160 EXPECT_EQ(start_time, |
| 161 controller->GetAnimation(group_id, | 161 controller->GetAnimation(group_id, |
| 162 Animation::Opacity)->start_time()); | 162 Animation::Opacity)->start_time()); |
| 163 EXPECT_EQ(controller->GetAnimation(group_id, | 163 EXPECT_EQ(controller->GetAnimation(group_id, |
| 164 Animation::Opacity)->start_time(), | 164 Animation::Opacity)->start_time(), |
| 165 controller_impl->GetAnimation(group_id, | 165 controller_impl->GetAnimation(group_id, |
| 166 Animation::Opacity)->start_time()); | 166 Animation::Opacity)->start_time()); |
| 167 } | 167 } |
| 168 | 168 |
| 169 // Tests that controllers activate and deactivate as expected. | 169 // Tests that controllers activate and deactivate as expected. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 | 203 |
| 204 controller_impl->Animate(kInitialTickTime); | 204 controller_impl->Animate(kInitialTickTime); |
| 205 controller_impl->UpdateState(true, events.get()); | 205 controller_impl->UpdateState(true, events.get()); |
| 206 EXPECT_EQ(1u, events->size()); | 206 EXPECT_EQ(1u, events->size()); |
| 207 controller->NotifyAnimationStarted((*events)[0]); | 207 controller->NotifyAnimationStarted((*events)[0]); |
| 208 | 208 |
| 209 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 209 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
| 210 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); | 210 EXPECT_EQ(1u, registrar_impl->active_animation_controllers().size()); |
| 211 | 211 |
| 212 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 212 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 213 controller->UpdateState(true, NULL); | 213 controller->UpdateState(true, nullptr); |
| 214 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 214 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
| 215 | 215 |
| 216 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 216 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 217 controller->UpdateState(true, NULL); | 217 controller->UpdateState(true, nullptr); |
| 218 EXPECT_EQ(Animation::Finished, | 218 EXPECT_EQ(Animation::Finished, |
| 219 controller->GetAnimation(Animation::Opacity)->run_state()); | 219 controller->GetAnimation(Animation::Opacity)->run_state()); |
| 220 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); | 220 EXPECT_EQ(1u, registrar->active_animation_controllers().size()); |
| 221 | 221 |
| 222 events.reset(new AnimationEventsVector); | 222 events.reset(new AnimationEventsVector); |
| 223 controller_impl->Animate(kInitialTickTime + | 223 controller_impl->Animate(kInitialTickTime + |
| 224 TimeDelta::FromMilliseconds(1500)); | 224 TimeDelta::FromMilliseconds(1500)); |
| 225 controller_impl->UpdateState(true, events.get()); | 225 controller_impl->UpdateState(true, events.get()); |
| 226 | 226 |
| 227 EXPECT_EQ(Animation::WaitingForDeletion, | 227 EXPECT_EQ(Animation::WaitingForDeletion, |
| 228 controller_impl->GetAnimation(Animation::Opacity)->run_state()); | 228 controller_impl->GetAnimation(Animation::Opacity)->run_state()); |
| 229 // The impl thread controller should have de-activated. | 229 // The impl thread controller should have de-activated. |
| 230 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); | 230 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); |
| 231 | 231 |
| 232 EXPECT_EQ(1u, events->size()); | 232 EXPECT_EQ(1u, events->size()); |
| 233 controller->NotifyAnimationFinished((*events)[0]); | 233 controller->NotifyAnimationFinished((*events)[0]); |
| 234 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); | 234 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); |
| 235 controller->UpdateState(true, NULL); | 235 controller->UpdateState(true, nullptr); |
| 236 | 236 |
| 237 EXPECT_EQ(Animation::WaitingForDeletion, | 237 EXPECT_EQ(Animation::WaitingForDeletion, |
| 238 controller->GetAnimation(Animation::Opacity)->run_state()); | 238 controller->GetAnimation(Animation::Opacity)->run_state()); |
| 239 // The main thread controller should have de-activated. | 239 // The main thread controller should have de-activated. |
| 240 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); | 240 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); |
| 241 | 241 |
| 242 controller->PushAnimationUpdatesTo(controller_impl.get()); | 242 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 243 controller_impl->ActivateAnimations(); | 243 controller_impl->ActivateAnimations(); |
| 244 EXPECT_FALSE(controller->has_any_animation()); | 244 EXPECT_FALSE(controller->has_any_animation()); |
| 245 EXPECT_FALSE(controller_impl->has_any_animation()); | 245 EXPECT_FALSE(controller_impl->has_any_animation()); |
| 246 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); | 246 EXPECT_EQ(0u, registrar->active_animation_controllers().size()); |
| 247 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); | 247 EXPECT_EQ(0u, registrar_impl->active_animation_controllers().size()); |
| 248 | 248 |
| 249 controller->SetAnimationRegistrar(NULL); | 249 controller->SetAnimationRegistrar(nullptr); |
| 250 controller_impl->SetAnimationRegistrar(NULL); | 250 controller_impl->SetAnimationRegistrar(nullptr); |
| 251 } | 251 } |
| 252 | 252 |
| 253 TEST(LayerAnimationControllerTest, SyncPause) { | 253 TEST(LayerAnimationControllerTest, SyncPause) { |
| 254 FakeLayerAnimationValueObserver dummy_impl; | 254 FakeLayerAnimationValueObserver dummy_impl; |
| 255 scoped_refptr<LayerAnimationController> controller_impl( | 255 scoped_refptr<LayerAnimationController> controller_impl( |
| 256 LayerAnimationController::Create(0)); | 256 LayerAnimationController::Create(0)); |
| 257 controller_impl->AddValueObserver(&dummy_impl); | 257 controller_impl->AddValueObserver(&dummy_impl); |
| 258 FakeLayerAnimationValueObserver dummy; | 258 FakeLayerAnimationValueObserver dummy; |
| 259 scoped_refptr<LayerAnimationController> controller( | 259 scoped_refptr<LayerAnimationController> controller( |
| 260 LayerAnimationController::Create(0)); | 260 LayerAnimationController::Create(0)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 272 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 272 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 273 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 273 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
| 274 controller_impl->GetAnimation(group_id, | 274 controller_impl->GetAnimation(group_id, |
| 275 Animation::Opacity)->run_state()); | 275 Animation::Opacity)->run_state()); |
| 276 | 276 |
| 277 // Start the animations on each controller. | 277 // Start the animations on each controller. |
| 278 AnimationEventsVector events; | 278 AnimationEventsVector events; |
| 279 controller_impl->Animate(kInitialTickTime); | 279 controller_impl->Animate(kInitialTickTime); |
| 280 controller_impl->UpdateState(true, &events); | 280 controller_impl->UpdateState(true, &events); |
| 281 controller->Animate(kInitialTickTime); | 281 controller->Animate(kInitialTickTime); |
| 282 controller->UpdateState(true, NULL); | 282 controller->UpdateState(true, nullptr); |
| 283 EXPECT_EQ(Animation::Running, | 283 EXPECT_EQ(Animation::Running, |
| 284 controller_impl->GetAnimation(group_id, | 284 controller_impl->GetAnimation(group_id, |
| 285 Animation::Opacity)->run_state()); | 285 Animation::Opacity)->run_state()); |
| 286 EXPECT_EQ(Animation::Running, | 286 EXPECT_EQ(Animation::Running, |
| 287 controller->GetAnimation(group_id, | 287 controller->GetAnimation(group_id, |
| 288 Animation::Opacity)->run_state()); | 288 Animation::Opacity)->run_state()); |
| 289 | 289 |
| 290 // Pause the main-thread animation. | 290 // Pause the main-thread animation. |
| 291 controller->PauseAnimation( | 291 controller->PauseAnimation( |
| 292 animation_id, | 292 animation_id, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 make_scoped_ptr(new AnimationEventsVector)); | 357 make_scoped_ptr(new AnimationEventsVector)); |
| 358 scoped_refptr<LayerAnimationController> controller( | 358 scoped_refptr<LayerAnimationController> controller( |
| 359 LayerAnimationController::Create(0)); | 359 LayerAnimationController::Create(0)); |
| 360 scoped_refptr<LayerAnimationController> controller_impl( | 360 scoped_refptr<LayerAnimationController> controller_impl( |
| 361 LayerAnimationController::Create(0)); | 361 LayerAnimationController::Create(0)); |
| 362 controller->AddValueObserver(&dummy); | 362 controller->AddValueObserver(&dummy); |
| 363 controller_impl->AddValueObserver(&dummy_impl); | 363 controller_impl->AddValueObserver(&dummy_impl); |
| 364 | 364 |
| 365 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false); | 365 AddOpacityTransitionToController(controller.get(), 1.0, 0.0f, 1.0f, false); |
| 366 controller->Animate(kInitialTickTime); | 366 controller->Animate(kInitialTickTime); |
| 367 controller->UpdateState(true, NULL); | 367 controller->UpdateState(true, nullptr); |
| 368 controller->PushAnimationUpdatesTo(controller_impl.get()); | 368 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 369 controller_impl->ActivateAnimations(); | 369 controller_impl->ActivateAnimations(); |
| 370 | 370 |
| 371 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 371 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 372 controller_impl->UpdateState(true, events.get()); | 372 controller_impl->UpdateState(true, events.get()); |
| 373 | 373 |
| 374 // There should be a Started event for the animation. | 374 // There should be a Started event for the animation. |
| 375 EXPECT_EQ(1u, events->size()); | 375 EXPECT_EQ(1u, events->size()); |
| 376 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); | 376 EXPECT_EQ(AnimationEvent::Started, (*events)[0].type); |
| 377 controller->NotifyAnimationStarted((*events)[0]); | 377 controller->NotifyAnimationStarted((*events)[0]); |
| 378 | 378 |
| 379 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 379 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 380 controller->UpdateState(true, NULL); | 380 controller->UpdateState(true, nullptr); |
| 381 | 381 |
| 382 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 382 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
| 383 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 383 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
| 384 | 384 |
| 385 events.reset(new AnimationEventsVector); | 385 events.reset(new AnimationEventsVector); |
| 386 controller_impl->Animate(kInitialTickTime + | 386 controller_impl->Animate(kInitialTickTime + |
| 387 TimeDelta::FromMilliseconds(2000)); | 387 TimeDelta::FromMilliseconds(2000)); |
| 388 controller_impl->UpdateState(true, events.get()); | 388 controller_impl->UpdateState(true, events.get()); |
| 389 | 389 |
| 390 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); | 390 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); |
| 391 | 391 |
| 392 // There should be a Finished event for the animation. | 392 // There should be a Finished event for the animation. |
| 393 EXPECT_EQ(1u, events->size()); | 393 EXPECT_EQ(1u, events->size()); |
| 394 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); | 394 EXPECT_EQ(AnimationEvent::Finished, (*events)[0].type); |
| 395 | 395 |
| 396 // Neither controller should have deleted the animation yet. | 396 // Neither controller should have deleted the animation yet. |
| 397 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); | 397 EXPECT_TRUE(controller->GetAnimation(Animation::Opacity)); |
| 398 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity)); | 398 EXPECT_TRUE(controller_impl->GetAnimation(Animation::Opacity)); |
| 399 | 399 |
| 400 controller->NotifyAnimationFinished((*events)[0]); | 400 controller->NotifyAnimationFinished((*events)[0]); |
| 401 | 401 |
| 402 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); | 402 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
| 403 controller->UpdateState(true, NULL); | 403 controller->UpdateState(true, nullptr); |
| 404 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 404 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
| 405 | 405 |
| 406 controller->PushAnimationUpdatesTo(controller_impl.get()); | 406 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 407 | 407 |
| 408 // Both controllers should now have deleted the animation. The impl controller | 408 // Both controllers should now have deleted the animation. The impl controller |
| 409 // should have deleted the animation even though activation has not occurred, | 409 // should have deleted the animation even though activation has not occurred, |
| 410 // since the animation was already waiting for deletion when | 410 // since the animation was already waiting for deletion when |
| 411 // PushAnimationUpdatesTo was called. | 411 // PushAnimationUpdatesTo was called. |
| 412 EXPECT_FALSE(controller->has_any_animation()); | 412 EXPECT_FALSE(controller->has_any_animation()); |
| 413 EXPECT_FALSE(controller_impl->has_any_animation()); | 413 EXPECT_FALSE(controller_impl->has_any_animation()); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 controller_impl->GetAnimation(Animation::ScrollOffset) | 683 controller_impl->GetAnimation(Animation::ScrollOffset) |
| 684 ->curve() | 684 ->curve() |
| 685 ->Duration(); | 685 ->Duration(); |
| 686 TimeDelta duration = TimeDelta::FromMicroseconds( | 686 TimeDelta duration = TimeDelta::FromMicroseconds( |
| 687 duration_in_seconds * base::Time::kMicrosecondsPerSecond); | 687 duration_in_seconds * base::Time::kMicrosecondsPerSecond); |
| 688 EXPECT_EQ( | 688 EXPECT_EQ( |
| 689 duration_in_seconds, | 689 duration_in_seconds, |
| 690 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); | 690 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); |
| 691 | 691 |
| 692 controller->Animate(kInitialTickTime); | 692 controller->Animate(kInitialTickTime); |
| 693 controller->UpdateState(true, NULL); | 693 controller->UpdateState(true, nullptr); |
| 694 EXPECT_TRUE(controller->HasActiveAnimation()); | 694 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 695 EXPECT_EQ(initial_value, dummy.scroll_offset()); | 695 EXPECT_EQ(initial_value, dummy.scroll_offset()); |
| 696 | 696 |
| 697 controller_impl->Animate(kInitialTickTime); | 697 controller_impl->Animate(kInitialTickTime); |
| 698 controller_impl->UpdateState(true, events.get()); | 698 controller_impl->UpdateState(true, events.get()); |
| 699 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 699 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 700 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 700 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
| 701 // Scroll offset animations should not generate property updates. | 701 // Scroll offset animations should not generate property updates. |
| 702 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 702 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 703 EXPECT_FALSE(event); | 703 EXPECT_FALSE(event); |
| 704 | 704 |
| 705 controller->NotifyAnimationStarted((*events)[0]); | 705 controller->NotifyAnimationStarted((*events)[0]); |
| 706 controller->Animate(kInitialTickTime + duration / 2); | 706 controller->Animate(kInitialTickTime + duration / 2); |
| 707 controller->UpdateState(true, NULL); | 707 controller->UpdateState(true, nullptr); |
| 708 EXPECT_TRUE(controller->HasActiveAnimation()); | 708 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 709 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset()); | 709 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), dummy.scroll_offset()); |
| 710 | 710 |
| 711 controller_impl->Animate(kInitialTickTime + duration / 2); | 711 controller_impl->Animate(kInitialTickTime + duration / 2); |
| 712 controller_impl->UpdateState(true, events.get()); | 712 controller_impl->UpdateState(true, events.get()); |
| 713 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), | 713 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(200.f, 250.f), |
| 714 dummy_impl.scroll_offset()); | 714 dummy_impl.scroll_offset()); |
| 715 event = GetMostRecentPropertyUpdateEvent(events.get()); | 715 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 716 EXPECT_FALSE(event); | 716 EXPECT_FALSE(event); |
| 717 | 717 |
| 718 controller_impl->Animate(kInitialTickTime + duration); | 718 controller_impl->Animate(kInitialTickTime + duration); |
| 719 controller_impl->UpdateState(true, events.get()); | 719 controller_impl->UpdateState(true, events.get()); |
| 720 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); | 720 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); |
| 721 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 721 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| 722 event = GetMostRecentPropertyUpdateEvent(events.get()); | 722 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 723 EXPECT_FALSE(event); | 723 EXPECT_FALSE(event); |
| 724 | 724 |
| 725 controller->Animate(kInitialTickTime + duration); | 725 controller->Animate(kInitialTickTime + duration); |
| 726 controller->UpdateState(true, NULL); | 726 controller->UpdateState(true, nullptr); |
| 727 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); | 727 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); |
| 728 EXPECT_FALSE(controller->HasActiveAnimation()); | 728 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 729 } | 729 } |
| 730 | 730 |
| 731 // Ensure that when the impl controller doesn't have a value provider, | 731 // Ensure that when the impl controller doesn't have a value provider, |
| 732 // the main-thread controller's value provider is used to obtain the intial | 732 // the main-thread controller's value provider is used to obtain the intial |
| 733 // scroll offset. | 733 // scroll offset. |
| 734 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionNoImplProvider) { | 734 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionNoImplProvider) { |
| 735 FakeLayerAnimationValueObserver dummy_impl; | 735 FakeLayerAnimationValueObserver dummy_impl; |
| 736 scoped_refptr<LayerAnimationController> controller_impl( | 736 scoped_refptr<LayerAnimationController> controller_impl( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 763 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); | 763 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); |
| 764 double duration_in_seconds = | 764 double duration_in_seconds = |
| 765 controller_impl->GetAnimation(Animation::ScrollOffset) | 765 controller_impl->GetAnimation(Animation::ScrollOffset) |
| 766 ->curve() | 766 ->curve() |
| 767 ->Duration(); | 767 ->Duration(); |
| 768 EXPECT_EQ( | 768 EXPECT_EQ( |
| 769 duration_in_seconds, | 769 duration_in_seconds, |
| 770 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); | 770 controller->GetAnimation(Animation::ScrollOffset)->curve()->Duration()); |
| 771 | 771 |
| 772 controller->Animate(kInitialTickTime); | 772 controller->Animate(kInitialTickTime); |
| 773 controller->UpdateState(true, NULL); | 773 controller->UpdateState(true, nullptr); |
| 774 EXPECT_TRUE(controller->HasActiveAnimation()); | 774 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 775 EXPECT_EQ(initial_value, dummy.scroll_offset()); | 775 EXPECT_EQ(initial_value, dummy.scroll_offset()); |
| 776 | 776 |
| 777 controller_impl->Animate(kInitialTickTime); | 777 controller_impl->Animate(kInitialTickTime); |
| 778 controller_impl->UpdateState(true, events.get()); | 778 controller_impl->UpdateState(true, events.get()); |
| 779 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 779 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 780 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 780 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
| 781 // Scroll offset animations should not generate property updates. | 781 // Scroll offset animations should not generate property updates. |
| 782 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 782 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 783 EXPECT_FALSE(event); | 783 EXPECT_FALSE(event); |
| 784 | 784 |
| 785 TimeDelta duration = TimeDelta::FromMicroseconds( | 785 TimeDelta duration = TimeDelta::FromMicroseconds( |
| 786 duration_in_seconds * base::Time::kMicrosecondsPerSecond); | 786 duration_in_seconds * base::Time::kMicrosecondsPerSecond); |
| 787 | 787 |
| 788 controller->NotifyAnimationStarted((*events)[0]); | 788 controller->NotifyAnimationStarted((*events)[0]); |
| 789 controller->Animate(kInitialTickTime + duration / 2); | 789 controller->Animate(kInitialTickTime + duration / 2); |
| 790 controller->UpdateState(true, NULL); | 790 controller->UpdateState(true, nullptr); |
| 791 EXPECT_TRUE(controller->HasActiveAnimation()); | 791 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 792 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset()); | 792 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), dummy.scroll_offset()); |
| 793 | 793 |
| 794 controller_impl->Animate(kInitialTickTime + duration / 2); | 794 controller_impl->Animate(kInitialTickTime + duration / 2); |
| 795 controller_impl->UpdateState(true, events.get()); | 795 controller_impl->UpdateState(true, events.get()); |
| 796 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), | 796 EXPECT_VECTOR2DF_EQ(gfx::Vector2dF(400.f, 150.f), |
| 797 dummy_impl.scroll_offset()); | 797 dummy_impl.scroll_offset()); |
| 798 event = GetMostRecentPropertyUpdateEvent(events.get()); | 798 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 799 EXPECT_FALSE(event); | 799 EXPECT_FALSE(event); |
| 800 | 800 |
| 801 controller_impl->Animate(kInitialTickTime + duration); | 801 controller_impl->Animate(kInitialTickTime + duration); |
| 802 controller_impl->UpdateState(true, events.get()); | 802 controller_impl->UpdateState(true, events.get()); |
| 803 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); | 803 EXPECT_VECTOR2DF_EQ(target_value, dummy_impl.scroll_offset()); |
| 804 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 804 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
| 805 event = GetMostRecentPropertyUpdateEvent(events.get()); | 805 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 806 EXPECT_FALSE(event); | 806 EXPECT_FALSE(event); |
| 807 | 807 |
| 808 controller->Animate(kInitialTickTime + duration); | 808 controller->Animate(kInitialTickTime + duration); |
| 809 controller->UpdateState(true, NULL); | 809 controller->UpdateState(true, nullptr); |
| 810 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); | 810 EXPECT_VECTOR2DF_EQ(target_value, dummy.scroll_offset()); |
| 811 EXPECT_FALSE(controller->HasActiveAnimation()); | 811 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 812 } | 812 } |
| 813 | 813 |
| 814 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionOnImplOnly) { | 814 TEST(LayerAnimationControllerTest, ScrollOffsetTransitionOnImplOnly) { |
| 815 FakeLayerAnimationValueObserver dummy_impl; | 815 FakeLayerAnimationValueObserver dummy_impl; |
| 816 scoped_refptr<LayerAnimationController> controller_impl( | 816 scoped_refptr<LayerAnimationController> controller_impl( |
| 817 LayerAnimationController::Create(0)); | 817 LayerAnimationController::Create(0)); |
| 818 controller_impl->AddValueObserver(&dummy_impl); | 818 controller_impl->AddValueObserver(&dummy_impl); |
| 819 scoped_ptr<AnimationEventsVector> events( | 819 scoped_ptr<AnimationEventsVector> events( |
| (...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 controller->AddAnimation(CreateAnimation( | 1562 controller->AddAnimation(CreateAnimation( |
| 1563 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), | 1563 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), |
| 1564 4, | 1564 4, |
| 1565 Animation::Transform)); | 1565 Animation::Transform)); |
| 1566 controller->AddAnimation(CreateAnimation( | 1566 controller->AddAnimation(CreateAnimation( |
| 1567 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1567 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
| 1568 5, | 1568 5, |
| 1569 Animation::Opacity)); | 1569 Animation::Opacity)); |
| 1570 | 1570 |
| 1571 controller->Animate(kInitialTickTime); | 1571 controller->Animate(kInitialTickTime); |
| 1572 controller->UpdateState(true, NULL); | 1572 controller->UpdateState(true, nullptr); |
| 1573 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1573 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1574 controller->UpdateState(true, NULL); | 1574 controller->UpdateState(true, nullptr); |
| 1575 | 1575 |
| 1576 EXPECT_EQ(Animation::Finished, | 1576 EXPECT_EQ(Animation::Finished, |
| 1577 controller->GetAnimation(1, Animation::Transform)->run_state()); | 1577 controller->GetAnimation(1, Animation::Transform)->run_state()); |
| 1578 EXPECT_EQ(Animation::Finished, | 1578 EXPECT_EQ(Animation::Finished, |
| 1579 controller->GetAnimation(2, Animation::Opacity)->run_state()); | 1579 controller->GetAnimation(2, Animation::Opacity)->run_state()); |
| 1580 EXPECT_EQ(Animation::Running, | 1580 EXPECT_EQ(Animation::Running, |
| 1581 controller->GetAnimation(3, Animation::Transform)->run_state()); | 1581 controller->GetAnimation(3, Animation::Transform)->run_state()); |
| 1582 EXPECT_EQ(Animation::WaitingForTargetAvailability, | 1582 EXPECT_EQ(Animation::WaitingForTargetAvailability, |
| 1583 controller->GetAnimation(4, Animation::Transform)->run_state()); | 1583 controller->GetAnimation(4, Animation::Transform)->run_state()); |
| 1584 EXPECT_EQ(Animation::Running, | 1584 EXPECT_EQ(Animation::Running, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1617 controller_impl->ActivateAnimations(); | 1617 controller_impl->ActivateAnimations(); |
| 1618 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 1618 EXPECT_TRUE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 1619 | 1619 |
| 1620 controller->AbortAnimations(Animation::Opacity); | 1620 controller->AbortAnimations(Animation::Opacity); |
| 1621 EXPECT_EQ(Animation::Aborted, | 1621 EXPECT_EQ(Animation::Aborted, |
| 1622 controller->GetAnimation(Animation::Opacity)->run_state()); | 1622 controller->GetAnimation(Animation::Opacity)->run_state()); |
| 1623 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 1623 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
| 1624 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 1624 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
| 1625 | 1625 |
| 1626 controller->Animate(kInitialTickTime); | 1626 controller->Animate(kInitialTickTime); |
| 1627 controller->UpdateState(true, NULL); | 1627 controller->UpdateState(true, nullptr); |
| 1628 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 1628 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
| 1629 EXPECT_EQ(Animation::WaitingForDeletion, | 1629 EXPECT_EQ(Animation::WaitingForDeletion, |
| 1630 controller->GetAnimation(Animation::Opacity)->run_state()); | 1630 controller->GetAnimation(Animation::Opacity)->run_state()); |
| 1631 | 1631 |
| 1632 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1632 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1633 controller_impl->ActivateAnimations(); | 1633 controller_impl->ActivateAnimations(); |
| 1634 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity)); | 1634 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity)); |
| 1635 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 1635 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 1636 } | 1636 } |
| 1637 | 1637 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1666 EXPECT_EQ(1u, events.size()); | 1666 EXPECT_EQ(1u, events.size()); |
| 1667 EXPECT_EQ(AnimationEvent::Aborted, events[0].type); | 1667 EXPECT_EQ(AnimationEvent::Aborted, events[0].type); |
| 1668 EXPECT_EQ(Animation::WaitingForDeletion, | 1668 EXPECT_EQ(Animation::WaitingForDeletion, |
| 1669 controller_impl->GetAnimation(Animation::Opacity)->run_state()); | 1669 controller_impl->GetAnimation(Animation::Opacity)->run_state()); |
| 1670 | 1670 |
| 1671 controller->NotifyAnimationAborted(events[0]); | 1671 controller->NotifyAnimationAborted(events[0]); |
| 1672 EXPECT_EQ(Animation::Aborted, | 1672 EXPECT_EQ(Animation::Aborted, |
| 1673 controller->GetAnimation(Animation::Opacity)->run_state()); | 1673 controller->GetAnimation(Animation::Opacity)->run_state()); |
| 1674 | 1674 |
| 1675 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1675 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 1676 controller->UpdateState(true, NULL); | 1676 controller->UpdateState(true, nullptr); |
| 1677 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 1677 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
| 1678 EXPECT_EQ(Animation::WaitingForDeletion, | 1678 EXPECT_EQ(Animation::WaitingForDeletion, |
| 1679 controller->GetAnimation(Animation::Opacity)->run_state()); | 1679 controller->GetAnimation(Animation::Opacity)->run_state()); |
| 1680 | 1680 |
| 1681 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1681 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1682 controller_impl->ActivateAnimations(); | 1682 controller_impl->ActivateAnimations(); |
| 1683 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity)); | 1683 EXPECT_FALSE(controller->GetAnimation(group_id, Animation::Opacity)); |
| 1684 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); | 1684 EXPECT_FALSE(controller_impl->GetAnimation(group_id, Animation::Opacity)); |
| 1685 } | 1685 } |
| 1686 | 1686 |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2254 // been ticked at the new animation's starting point. | 2254 // been ticked at the new animation's starting point. |
| 2255 EXPECT_EQ(Animation::Running, | 2255 EXPECT_EQ(Animation::Running, |
| 2256 controller_impl->GetAnimation(second_animation_group_id, | 2256 controller_impl->GetAnimation(second_animation_group_id, |
| 2257 Animation::Opacity)->run_state()); | 2257 Animation::Opacity)->run_state()); |
| 2258 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); | 2258 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); |
| 2259 EXPECT_EQ(1.f, dummy_impl.opacity()); | 2259 EXPECT_EQ(1.f, dummy_impl.opacity()); |
| 2260 } | 2260 } |
| 2261 | 2261 |
| 2262 } // namespace | 2262 } // namespace |
| 2263 } // namespace cc | 2263 } // namespace cc |
| OLD | NEW |