| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "cc/animation/animation.h" | 9 #include "cc/animation/animation.h" |
| 10 #include "cc/animation/animation_curve.h" | 10 #include "cc/animation/animation_curve.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 base::Time::kMicrosecondsPerSecond); | 31 base::Time::kMicrosecondsPerSecond); |
| 32 } | 32 } |
| 33 | 33 |
| 34 // A LayerAnimationController cannot be ticked at 0.0, since an animation | 34 // A LayerAnimationController cannot be ticked at 0.0, since an animation |
| 35 // with start time 0.0 is treated as an animation whose start time has | 35 // with start time 0.0 is treated as an animation whose start time has |
| 36 // not yet been set. | 36 // not yet been set. |
| 37 const TimeTicks kInitialTickTime = TicksFromSecondsF(1.0); | 37 const TimeTicks kInitialTickTime = TicksFromSecondsF(1.0); |
| 38 | 38 |
| 39 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, | 39 scoped_ptr<Animation> CreateAnimation(scoped_ptr<AnimationCurve> curve, |
| 40 int group_id, | 40 int group_id, |
| 41 Animation::TargetProperty property) { | 41 AnimationTargetProperty::Enum property) { |
| 42 return Animation::Create(std::move(curve), 0, group_id, property); | 42 return Animation::Create(std::move(curve), 0, group_id, property); |
| 43 } | 43 } |
| 44 | 44 |
| 45 TEST(LayerAnimationControllerTest, SyncNewAnimation) { | 45 TEST(LayerAnimationControllerTest, SyncNewAnimation) { |
| 46 FakeLayerAnimationValueObserver dummy_impl; | 46 FakeLayerAnimationValueObserver dummy_impl; |
| 47 scoped_refptr<LayerAnimationController> controller_impl( | 47 scoped_refptr<LayerAnimationController> controller_impl( |
| 48 LayerAnimationController::Create(0)); | 48 LayerAnimationController::Create(0)); |
| 49 controller_impl->AddValueObserver(&dummy_impl); | 49 controller_impl->AddValueObserver(&dummy_impl); |
| 50 FakeLayerAnimationValueObserver dummy; | 50 FakeLayerAnimationValueObserver dummy; |
| 51 scoped_refptr<LayerAnimationController> controller( | 51 scoped_refptr<LayerAnimationController> controller( |
| 52 LayerAnimationController::Create(0)); | 52 LayerAnimationController::Create(0)); |
| 53 controller->AddValueObserver(&dummy); | 53 controller->AddValueObserver(&dummy); |
| 54 | 54 |
| 55 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY)); | 55 EXPECT_FALSE(controller_impl->GetAnimation(AnimationTargetProperty::OPACITY)); |
| 56 | 56 |
| 57 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); | 57 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); |
| 58 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing()); | 58 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing()); |
| 59 | 59 |
| 60 int animation_id = | 60 int animation_id = |
| 61 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 61 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
| 62 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); | 62 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); |
| 63 | 63 |
| 64 controller->PushAnimationUpdatesTo(controller_impl.get()); | 64 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 65 EXPECT_TRUE(controller_impl->needs_to_start_animations_for_testing()); | 65 EXPECT_TRUE(controller_impl->needs_to_start_animations_for_testing()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 78 LayerAnimationController::Create(0)); | 78 LayerAnimationController::Create(0)); |
| 79 controller_impl->AddValueObserver(&dummy_impl); | 79 controller_impl->AddValueObserver(&dummy_impl); |
| 80 controller_impl->set_value_provider(&dummy_provider_impl); | 80 controller_impl->set_value_provider(&dummy_provider_impl); |
| 81 FakeLayerAnimationValueObserver dummy; | 81 FakeLayerAnimationValueObserver dummy; |
| 82 FakeLayerAnimationValueProvider dummy_provider; | 82 FakeLayerAnimationValueProvider dummy_provider; |
| 83 scoped_refptr<LayerAnimationController> controller( | 83 scoped_refptr<LayerAnimationController> controller( |
| 84 LayerAnimationController::Create(0)); | 84 LayerAnimationController::Create(0)); |
| 85 controller->AddValueObserver(&dummy); | 85 controller->AddValueObserver(&dummy); |
| 86 controller->set_value_provider(&dummy_provider); | 86 controller->set_value_provider(&dummy_provider); |
| 87 | 87 |
| 88 EXPECT_FALSE(controller_impl->GetAnimation(Animation::SCROLL_OFFSET)); | 88 EXPECT_FALSE( |
| 89 controller_impl->GetAnimation(AnimationTargetProperty::SCROLL_OFFSET)); |
| 89 | 90 |
| 90 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); | 91 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); |
| 91 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing()); | 92 EXPECT_FALSE(controller_impl->needs_to_start_animations_for_testing()); |
| 92 | 93 |
| 93 gfx::ScrollOffset initial_value(100.f, 300.f); | 94 gfx::ScrollOffset initial_value(100.f, 300.f); |
| 94 gfx::ScrollOffset provider_initial_value(150.f, 300.f); | 95 gfx::ScrollOffset provider_initial_value(150.f, 300.f); |
| 95 gfx::ScrollOffset target_value(300.f, 200.f); | 96 gfx::ScrollOffset target_value(300.f, 200.f); |
| 96 | 97 |
| 97 dummy_provider_impl.set_scroll_offset(provider_initial_value); | 98 dummy_provider_impl.set_scroll_offset(provider_initial_value); |
| 98 | 99 |
| 99 // Animation with initial value set. | 100 // Animation with initial value set. |
| 100 scoped_ptr<ScrollOffsetAnimationCurve> curve_fixed( | 101 scoped_ptr<ScrollOffsetAnimationCurve> curve_fixed( |
| 101 ScrollOffsetAnimationCurve::Create(target_value, | 102 ScrollOffsetAnimationCurve::Create(target_value, |
| 102 EaseInOutTimingFunction::Create())); | 103 EaseInOutTimingFunction::Create())); |
| 103 curve_fixed->SetInitialValue(initial_value); | 104 curve_fixed->SetInitialValue(initial_value); |
| 104 scoped_ptr<Animation> animation_fixed( | 105 scoped_ptr<Animation> animation_fixed( |
| 105 Animation::Create(std::move(curve_fixed), 1 /* animation_id */, 0, | 106 Animation::Create(std::move(curve_fixed), 1 /* animation_id */, 0, |
| 106 Animation::SCROLL_OFFSET)); | 107 AnimationTargetProperty::SCROLL_OFFSET)); |
| 107 controller->AddAnimation(std::move(animation_fixed)); | 108 controller->AddAnimation(std::move(animation_fixed)); |
| 108 controller->PushAnimationUpdatesTo(controller_impl.get()); | 109 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 109 EXPECT_VECTOR2DF_EQ(initial_value, controller_impl->GetAnimationById(1) | 110 EXPECT_VECTOR2DF_EQ(initial_value, controller_impl->GetAnimationById(1) |
| 110 ->curve() | 111 ->curve() |
| 111 ->ToScrollOffsetAnimationCurve() | 112 ->ToScrollOffsetAnimationCurve() |
| 112 ->GetValue(base::TimeDelta())); | 113 ->GetValue(base::TimeDelta())); |
| 113 | 114 |
| 114 // Animation without initial value set. | 115 // Animation without initial value set. |
| 115 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 116 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
| 116 ScrollOffsetAnimationCurve::Create(target_value, | 117 ScrollOffsetAnimationCurve::Create(target_value, |
| 117 EaseInOutTimingFunction::Create())); | 118 EaseInOutTimingFunction::Create())); |
| 118 scoped_ptr<Animation> animation(Animation::Create( | 119 scoped_ptr<Animation> animation( |
| 119 std::move(curve), 2 /* animation id */, 0, Animation::SCROLL_OFFSET)); | 120 Animation::Create(std::move(curve), 2 /* animation id */, 0, |
| 121 AnimationTargetProperty::SCROLL_OFFSET)); |
| 120 controller->AddAnimation(std::move(animation)); | 122 controller->AddAnimation(std::move(animation)); |
| 121 controller->PushAnimationUpdatesTo(controller_impl.get()); | 123 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 122 EXPECT_VECTOR2DF_EQ(provider_initial_value, | 124 EXPECT_VECTOR2DF_EQ(provider_initial_value, |
| 123 controller_impl->GetAnimationById(2) | 125 controller_impl->GetAnimationById(2) |
| 124 ->curve() | 126 ->curve() |
| 125 ->ToScrollOffsetAnimationCurve() | 127 ->ToScrollOffsetAnimationCurve() |
| 126 ->GetValue(base::TimeDelta())); | 128 ->GetValue(base::TimeDelta())); |
| 127 } | 129 } |
| 128 | 130 |
| 129 // If an animation is started on the impl thread before it is ticked on the main | 131 // If an animation is started on the impl thread before it is ticked on the main |
| 130 // thread, we must be sure to respect the synchronized start time. | 132 // thread, we must be sure to respect the synchronized start time. |
| 131 TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) { | 133 TEST(LayerAnimationControllerTest, DoNotClobberStartTimes) { |
| 132 FakeLayerAnimationValueObserver dummy_impl; | 134 FakeLayerAnimationValueObserver dummy_impl; |
| 133 scoped_refptr<LayerAnimationController> controller_impl( | 135 scoped_refptr<LayerAnimationController> controller_impl( |
| 134 LayerAnimationController::Create(0)); | 136 LayerAnimationController::Create(0)); |
| 135 controller_impl->AddValueObserver(&dummy_impl); | 137 controller_impl->AddValueObserver(&dummy_impl); |
| 136 FakeLayerAnimationValueObserver dummy; | 138 FakeLayerAnimationValueObserver dummy; |
| 137 scoped_refptr<LayerAnimationController> controller( | 139 scoped_refptr<LayerAnimationController> controller( |
| 138 LayerAnimationController::Create(0)); | 140 LayerAnimationController::Create(0)); |
| 139 controller->AddValueObserver(&dummy); | 141 controller->AddValueObserver(&dummy); |
| 140 | 142 |
| 141 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY)); | 143 EXPECT_FALSE(controller_impl->GetAnimation(AnimationTargetProperty::OPACITY)); |
| 142 | 144 |
| 143 int animation_id = | 145 int animation_id = |
| 144 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 146 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
| 145 | 147 |
| 146 controller->PushAnimationUpdatesTo(controller_impl.get()); | 148 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 147 controller_impl->ActivateAnimations(); | 149 controller_impl->ActivateAnimations(); |
| 148 | 150 |
| 149 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 151 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
| 150 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 152 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 151 controller_impl->GetAnimationById(animation_id)->run_state()); | 153 controller_impl->GetAnimationById(animation_id)->run_state()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 174 controller_impl->AddValueObserver(&dummy_impl); | 176 controller_impl->AddValueObserver(&dummy_impl); |
| 175 FakeLayerAnimationValueObserver dummy; | 177 FakeLayerAnimationValueObserver dummy; |
| 176 scoped_refptr<LayerAnimationController> controller( | 178 scoped_refptr<LayerAnimationController> controller( |
| 177 LayerAnimationController::Create(0)); | 179 LayerAnimationController::Create(0)); |
| 178 controller->AddValueObserver(&dummy); | 180 controller->AddValueObserver(&dummy); |
| 179 | 181 |
| 180 int animation_id = | 182 int animation_id = |
| 181 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 183 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
| 182 | 184 |
| 183 const TimeTicks start_time = TicksFromSecondsF(123); | 185 const TimeTicks start_time = TicksFromSecondsF(123); |
| 184 controller->GetAnimation(Animation::OPACITY)->set_start_time(start_time); | 186 controller->GetAnimation(AnimationTargetProperty::OPACITY) |
| 187 ->set_start_time(start_time); |
| 185 | 188 |
| 186 controller->PushAnimationUpdatesTo(controller_impl.get()); | 189 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 187 controller_impl->ActivateAnimations(); | 190 controller_impl->ActivateAnimations(); |
| 188 | 191 |
| 189 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 192 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
| 190 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 193 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 191 controller_impl->GetAnimationById(animation_id)->run_state()); | 194 controller_impl->GetAnimationById(animation_id)->run_state()); |
| 192 | 195 |
| 193 AnimationEvents events; | 196 AnimationEvents events; |
| 194 controller_impl->Animate(kInitialTickTime); | 197 controller_impl->Animate(kInitialTickTime); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size()); | 259 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size()); |
| 257 EXPECT_EQ(1u, | 260 EXPECT_EQ(1u, |
| 258 registrar_impl->active_animation_controllers_for_testing().size()); | 261 registrar_impl->active_animation_controllers_for_testing().size()); |
| 259 | 262 |
| 260 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 263 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 261 controller->UpdateState(true, nullptr); | 264 controller->UpdateState(true, nullptr); |
| 262 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size()); | 265 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size()); |
| 263 | 266 |
| 264 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 267 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 265 controller->UpdateState(true, nullptr); | 268 controller->UpdateState(true, nullptr); |
| 266 EXPECT_EQ(Animation::FINISHED, | 269 EXPECT_EQ( |
| 267 controller->GetAnimation(Animation::OPACITY)->run_state()); | 270 Animation::FINISHED, |
| 271 controller->GetAnimation(AnimationTargetProperty::OPACITY)->run_state()); |
| 268 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size()); | 272 EXPECT_EQ(1u, registrar->active_animation_controllers_for_testing().size()); |
| 269 | 273 |
| 270 events.reset(new AnimationEvents); | 274 events.reset(new AnimationEvents); |
| 271 controller_impl->Animate(kInitialTickTime + | 275 controller_impl->Animate(kInitialTickTime + |
| 272 TimeDelta::FromMilliseconds(1500)); | 276 TimeDelta::FromMilliseconds(1500)); |
| 273 controller_impl->UpdateState(true, events.get()); | 277 controller_impl->UpdateState(true, events.get()); |
| 274 | 278 |
| 275 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 279 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
| 276 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); | 280 controller_impl->GetAnimation(AnimationTargetProperty::OPACITY) |
| 281 ->run_state()); |
| 277 // The impl thread controller should have de-activated. | 282 // The impl thread controller should have de-activated. |
| 278 EXPECT_EQ(0u, | 283 EXPECT_EQ(0u, |
| 279 registrar_impl->active_animation_controllers_for_testing().size()); | 284 registrar_impl->active_animation_controllers_for_testing().size()); |
| 280 | 285 |
| 281 EXPECT_EQ(1u, events->events_.size()); | 286 EXPECT_EQ(1u, events->events_.size()); |
| 282 controller->NotifyAnimationFinished(events->events_[0]); | 287 controller->NotifyAnimationFinished(events->events_[0]); |
| 283 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); | 288 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); |
| 284 controller->UpdateState(true, nullptr); | 289 controller->UpdateState(true, nullptr); |
| 285 | 290 |
| 286 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 291 EXPECT_EQ( |
| 287 controller->GetAnimation(Animation::OPACITY)->run_state()); | 292 Animation::WAITING_FOR_DELETION, |
| 293 controller->GetAnimation(AnimationTargetProperty::OPACITY)->run_state()); |
| 288 // The main thread controller should have de-activated. | 294 // The main thread controller should have de-activated. |
| 289 EXPECT_EQ(0u, registrar->active_animation_controllers_for_testing().size()); | 295 EXPECT_EQ(0u, registrar->active_animation_controllers_for_testing().size()); |
| 290 | 296 |
| 291 controller->PushAnimationUpdatesTo(controller_impl.get()); | 297 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 292 controller_impl->ActivateAnimations(); | 298 controller_impl->ActivateAnimations(); |
| 293 EXPECT_FALSE(controller->has_any_animation()); | 299 EXPECT_FALSE(controller->has_any_animation()); |
| 294 EXPECT_FALSE(controller_impl->has_any_animation()); | 300 EXPECT_FALSE(controller_impl->has_any_animation()); |
| 295 EXPECT_EQ(0u, registrar->active_animation_controllers_for_testing().size()); | 301 EXPECT_EQ(0u, registrar->active_animation_controllers_for_testing().size()); |
| 296 EXPECT_EQ(0u, | 302 EXPECT_EQ(0u, |
| 297 registrar_impl->active_animation_controllers_for_testing().size()); | 303 registrar_impl->active_animation_controllers_for_testing().size()); |
| 298 | 304 |
| 299 controller->SetAnimationRegistrar(nullptr); | 305 controller->SetAnimationRegistrar(nullptr); |
| 300 controller_impl->SetAnimationRegistrar(nullptr); | 306 controller_impl->SetAnimationRegistrar(nullptr); |
| 301 } | 307 } |
| 302 | 308 |
| 303 TEST(LayerAnimationControllerTest, SyncPause) { | 309 TEST(LayerAnimationControllerTest, SyncPause) { |
| 304 FakeLayerAnimationValueObserver dummy_impl; | 310 FakeLayerAnimationValueObserver dummy_impl; |
| 305 scoped_refptr<LayerAnimationController> controller_impl( | 311 scoped_refptr<LayerAnimationController> controller_impl( |
| 306 LayerAnimationController::Create(0)); | 312 LayerAnimationController::Create(0)); |
| 307 controller_impl->AddValueObserver(&dummy_impl); | 313 controller_impl->AddValueObserver(&dummy_impl); |
| 308 FakeLayerAnimationValueObserver dummy; | 314 FakeLayerAnimationValueObserver dummy; |
| 309 scoped_refptr<LayerAnimationController> controller( | 315 scoped_refptr<LayerAnimationController> controller( |
| 310 LayerAnimationController::Create(0)); | 316 LayerAnimationController::Create(0)); |
| 311 controller->AddValueObserver(&dummy); | 317 controller->AddValueObserver(&dummy); |
| 312 | 318 |
| 313 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY)); | 319 EXPECT_FALSE(controller_impl->GetAnimation(AnimationTargetProperty::OPACITY)); |
| 314 | 320 |
| 315 // Two steps, three ranges: [0-1) -> 0.2, [1-2) -> 0.3, [2-3] -> 0.4. | 321 // Two steps, three ranges: [0-1) -> 0.2, [1-2) -> 0.3, [2-3] -> 0.4. |
| 316 const double duration = 3.0; | 322 const double duration = 3.0; |
| 317 const int animation_id = | 323 const int animation_id = |
| 318 AddOpacityStepsToController(controller.get(), duration, 0.2f, 0.4f, 2); | 324 AddOpacityStepsToController(controller.get(), duration, 0.2f, 0.4f, 2); |
| 319 | 325 |
| 320 // Set start offset to be at the beginning of the second range. | 326 // Set start offset to be at the beginning of the second range. |
| 321 controller->GetAnimationById(animation_id) | 327 controller->GetAnimationById(animation_id) |
| 322 ->set_time_offset(TimeDelta::FromSecondsD(1.01)); | 328 ->set_time_offset(TimeDelta::FromSecondsD(1.01)); |
| 323 | 329 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 FakeLayerAnimationValueObserver dummy_impl; | 386 FakeLayerAnimationValueObserver dummy_impl; |
| 381 scoped_refptr<LayerAnimationController> controller_impl( | 387 scoped_refptr<LayerAnimationController> controller_impl( |
| 382 LayerAnimationController::Create(0)); | 388 LayerAnimationController::Create(0)); |
| 383 controller_impl->AddValueObserver(&dummy_impl); | 389 controller_impl->AddValueObserver(&dummy_impl); |
| 384 FakeLayerAnimationValueObserver dummy; | 390 FakeLayerAnimationValueObserver dummy; |
| 385 scoped_refptr<LayerAnimationController> controller( | 391 scoped_refptr<LayerAnimationController> controller( |
| 386 LayerAnimationController::Create(0)); | 392 LayerAnimationController::Create(0)); |
| 387 controller->AddValueObserver(&dummy); | 393 controller->AddValueObserver(&dummy); |
| 388 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 394 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 389 | 395 |
| 390 EXPECT_FALSE(controller_impl->GetAnimation(Animation::OPACITY)); | 396 EXPECT_FALSE(controller_impl->GetAnimation(AnimationTargetProperty::OPACITY)); |
| 391 | 397 |
| 392 int animation_id = | 398 int animation_id = |
| 393 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 399 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
| 394 | 400 |
| 395 controller->PushAnimationUpdatesTo(controller_impl.get()); | 401 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 396 controller_impl->ActivateAnimations(); | 402 controller_impl->ActivateAnimations(); |
| 397 | 403 |
| 398 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 404 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
| 399 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 405 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 400 controller_impl->GetAnimationById(animation_id)->run_state()); | 406 controller_impl->GetAnimationById(animation_id)->run_state()); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 TimeDelta::FromMilliseconds(2000)); | 470 TimeDelta::FromMilliseconds(2000)); |
| 465 controller_impl->UpdateState(true, events.get()); | 471 controller_impl->UpdateState(true, events.get()); |
| 466 | 472 |
| 467 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); | 473 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); |
| 468 | 474 |
| 469 // There should be a FINISHED event for the animation. | 475 // There should be a FINISHED event for the animation. |
| 470 EXPECT_EQ(1u, events->events_.size()); | 476 EXPECT_EQ(1u, events->events_.size()); |
| 471 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); | 477 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); |
| 472 | 478 |
| 473 // Neither controller should have deleted the animation yet. | 479 // Neither controller should have deleted the animation yet. |
| 474 EXPECT_TRUE(controller->GetAnimation(Animation::OPACITY)); | 480 EXPECT_TRUE(controller->GetAnimation(AnimationTargetProperty::OPACITY)); |
| 475 EXPECT_TRUE(controller_impl->GetAnimation(Animation::OPACITY)); | 481 EXPECT_TRUE(controller_impl->GetAnimation(AnimationTargetProperty::OPACITY)); |
| 476 | 482 |
| 477 controller->NotifyAnimationFinished(events->events_[0]); | 483 controller->NotifyAnimationFinished(events->events_[0]); |
| 478 | 484 |
| 479 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); | 485 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
| 480 controller->UpdateState(true, nullptr); | 486 controller->UpdateState(true, nullptr); |
| 481 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 487 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
| 482 | 488 |
| 483 controller->PushAnimationUpdatesTo(controller_impl.get()); | 489 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 484 | 490 |
| 485 // Both controllers should now have deleted the animation. The impl controller | 491 // Both controllers should now have deleted the animation. The impl controller |
| (...skipping 18 matching lines...) Expand all Loading... |
| 504 | 510 |
| 505 TEST(LayerAnimationControllerTest, TrivialTransition) { | 511 TEST(LayerAnimationControllerTest, TrivialTransition) { |
| 506 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 512 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 507 FakeLayerAnimationValueObserver dummy; | 513 FakeLayerAnimationValueObserver dummy; |
| 508 scoped_refptr<LayerAnimationController> controller( | 514 scoped_refptr<LayerAnimationController> controller( |
| 509 LayerAnimationController::Create(0)); | 515 LayerAnimationController::Create(0)); |
| 510 controller->AddValueObserver(&dummy); | 516 controller->AddValueObserver(&dummy); |
| 511 | 517 |
| 512 scoped_ptr<Animation> to_add(CreateAnimation( | 518 scoped_ptr<Animation> to_add(CreateAnimation( |
| 513 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 519 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 514 Animation::OPACITY)); | 520 AnimationTargetProperty::OPACITY)); |
| 515 | 521 |
| 516 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); | 522 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); |
| 517 controller->AddAnimation(std::move(to_add)); | 523 controller->AddAnimation(std::move(to_add)); |
| 518 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); | 524 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); |
| 519 controller->Animate(kInitialTickTime); | 525 controller->Animate(kInitialTickTime); |
| 520 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); | 526 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); |
| 521 controller->UpdateState(true, events.get()); | 527 controller->UpdateState(true, events.get()); |
| 522 EXPECT_TRUE(controller->HasActiveAnimation()); | 528 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 523 EXPECT_EQ(0.f, dummy.opacity()); | 529 EXPECT_EQ(0.f, dummy.opacity()); |
| 524 // A non-impl-only animation should not generate property updates. | 530 // A non-impl-only animation should not generate property updates. |
| 525 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 531 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 526 EXPECT_FALSE(event); | 532 EXPECT_FALSE(event); |
| 527 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 533 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 528 controller->UpdateState(true, events.get()); | 534 controller->UpdateState(true, events.get()); |
| 529 EXPECT_EQ(1.f, dummy.opacity()); | 535 EXPECT_EQ(1.f, dummy.opacity()); |
| 530 EXPECT_FALSE(controller->HasActiveAnimation()); | 536 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 531 event = GetMostRecentPropertyUpdateEvent(events.get()); | 537 event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 532 EXPECT_FALSE(event); | 538 EXPECT_FALSE(event); |
| 533 } | 539 } |
| 534 | 540 |
| 535 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { | 541 TEST(LayerAnimationControllerTest, TrivialTransitionOnImpl) { |
| 536 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 542 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 537 FakeLayerAnimationValueObserver dummy_impl; | 543 FakeLayerAnimationValueObserver dummy_impl; |
| 538 scoped_refptr<LayerAnimationController> controller_impl( | 544 scoped_refptr<LayerAnimationController> controller_impl( |
| 539 LayerAnimationController::Create(0)); | 545 LayerAnimationController::Create(0)); |
| 540 controller_impl->AddValueObserver(&dummy_impl); | 546 controller_impl->AddValueObserver(&dummy_impl); |
| 541 | 547 |
| 542 scoped_ptr<Animation> to_add(CreateAnimation( | 548 scoped_ptr<Animation> to_add(CreateAnimation( |
| 543 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 549 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 544 Animation::OPACITY)); | 550 AnimationTargetProperty::OPACITY)); |
| 545 to_add->set_is_impl_only(true); | 551 to_add->set_is_impl_only(true); |
| 546 | 552 |
| 547 controller_impl->AddAnimation(std::move(to_add)); | 553 controller_impl->AddAnimation(std::move(to_add)); |
| 548 controller_impl->Animate(kInitialTickTime); | 554 controller_impl->Animate(kInitialTickTime); |
| 549 controller_impl->UpdateState(true, events.get()); | 555 controller_impl->UpdateState(true, events.get()); |
| 550 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 556 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 551 EXPECT_EQ(0.f, dummy_impl.opacity()); | 557 EXPECT_EQ(0.f, dummy_impl.opacity()); |
| 552 EXPECT_EQ(1u, events->events_.size()); | 558 EXPECT_EQ(1u, events->events_.size()); |
| 553 const AnimationEvent* start_opacity_event = | 559 const AnimationEvent* start_opacity_event = |
| 554 GetMostRecentPropertyUpdateEvent(events.get()); | 560 GetMostRecentPropertyUpdateEvent(events.get()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 581 KeyframedTransformAnimationCurve::Create()); | 587 KeyframedTransformAnimationCurve::Create()); |
| 582 | 588 |
| 583 // Create simple TRANSFORM animation. | 589 // Create simple TRANSFORM animation. |
| 584 TransformOperations operations; | 590 TransformOperations operations; |
| 585 curve->AddKeyframe( | 591 curve->AddKeyframe( |
| 586 TransformKeyframe::Create(base::TimeDelta(), operations, nullptr)); | 592 TransformKeyframe::Create(base::TimeDelta(), operations, nullptr)); |
| 587 operations.AppendTranslate(delta_x, delta_y, 0); | 593 operations.AppendTranslate(delta_x, delta_y, 0); |
| 588 curve->AddKeyframe(TransformKeyframe::Create( | 594 curve->AddKeyframe(TransformKeyframe::Create( |
| 589 base::TimeDelta::FromSecondsD(1.0), operations, nullptr)); | 595 base::TimeDelta::FromSecondsD(1.0), operations, nullptr)); |
| 590 | 596 |
| 591 scoped_ptr<Animation> animation( | 597 scoped_ptr<Animation> animation(Animation::Create( |
| 592 Animation::Create(std::move(curve), 1, 0, Animation::TRANSFORM)); | 598 std::move(curve), 1, 0, AnimationTargetProperty::TRANSFORM)); |
| 593 animation->set_is_impl_only(true); | 599 animation->set_is_impl_only(true); |
| 594 controller_impl->AddAnimation(std::move(animation)); | 600 controller_impl->AddAnimation(std::move(animation)); |
| 595 | 601 |
| 596 // Run animation. | 602 // Run animation. |
| 597 controller_impl->Animate(kInitialTickTime); | 603 controller_impl->Animate(kInitialTickTime); |
| 598 controller_impl->UpdateState(true, events.get()); | 604 controller_impl->UpdateState(true, events.get()); |
| 599 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 605 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 600 EXPECT_EQ(gfx::Transform(), dummy_impl.transform()); | 606 EXPECT_EQ(gfx::Transform(), dummy_impl.transform()); |
| 601 EXPECT_EQ(1u, events->events_.size()); | 607 EXPECT_EQ(1u, events->events_.size()); |
| 602 const AnimationEvent* start_transform_event = | 608 const AnimationEvent* start_transform_event = |
| (...skipping 29 matching lines...) Expand all Loading... |
| 632 | 638 |
| 633 FilterOperations start_filters; | 639 FilterOperations start_filters; |
| 634 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); | 640 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); |
| 635 curve->AddKeyframe( | 641 curve->AddKeyframe( |
| 636 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); | 642 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); |
| 637 FilterOperations end_filters; | 643 FilterOperations end_filters; |
| 638 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); | 644 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); |
| 639 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), | 645 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), |
| 640 end_filters, nullptr)); | 646 end_filters, nullptr)); |
| 641 | 647 |
| 642 scoped_ptr<Animation> animation( | 648 scoped_ptr<Animation> animation(Animation::Create( |
| 643 Animation::Create(std::move(curve), 1, 0, Animation::FILTER)); | 649 std::move(curve), 1, 0, AnimationTargetProperty::FILTER)); |
| 644 controller->AddAnimation(std::move(animation)); | 650 controller->AddAnimation(std::move(animation)); |
| 645 | 651 |
| 646 controller->Animate(kInitialTickTime); | 652 controller->Animate(kInitialTickTime); |
| 647 controller->UpdateState(true, events.get()); | 653 controller->UpdateState(true, events.get()); |
| 648 EXPECT_TRUE(controller->HasActiveAnimation()); | 654 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 649 EXPECT_EQ(start_filters, dummy.filters()); | 655 EXPECT_EQ(start_filters, dummy.filters()); |
| 650 // A non-impl-only animation should not generate property updates. | 656 // A non-impl-only animation should not generate property updates. |
| 651 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 657 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 652 EXPECT_FALSE(event); | 658 EXPECT_FALSE(event); |
| 653 | 659 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 680 // Create simple FILTER animation. | 686 // Create simple FILTER animation. |
| 681 FilterOperations start_filters; | 687 FilterOperations start_filters; |
| 682 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); | 688 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); |
| 683 curve->AddKeyframe( | 689 curve->AddKeyframe( |
| 684 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); | 690 FilterKeyframe::Create(base::TimeDelta(), start_filters, nullptr)); |
| 685 FilterOperations end_filters; | 691 FilterOperations end_filters; |
| 686 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); | 692 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); |
| 687 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), | 693 curve->AddKeyframe(FilterKeyframe::Create(base::TimeDelta::FromSecondsD(1.0), |
| 688 end_filters, nullptr)); | 694 end_filters, nullptr)); |
| 689 | 695 |
| 690 scoped_ptr<Animation> animation( | 696 scoped_ptr<Animation> animation(Animation::Create( |
| 691 Animation::Create(std::move(curve), 1, 0, Animation::FILTER)); | 697 std::move(curve), 1, 0, AnimationTargetProperty::FILTER)); |
| 692 animation->set_is_impl_only(true); | 698 animation->set_is_impl_only(true); |
| 693 controller_impl->AddAnimation(std::move(animation)); | 699 controller_impl->AddAnimation(std::move(animation)); |
| 694 | 700 |
| 695 // Run animation. | 701 // Run animation. |
| 696 controller_impl->Animate(kInitialTickTime); | 702 controller_impl->Animate(kInitialTickTime); |
| 697 controller_impl->UpdateState(true, events.get()); | 703 controller_impl->UpdateState(true, events.get()); |
| 698 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 704 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 699 EXPECT_EQ(start_filters, dummy_impl.filters()); | 705 EXPECT_EQ(start_filters, dummy_impl.filters()); |
| 700 EXPECT_EQ(1u, events->events_.size()); | 706 EXPECT_EQ(1u, events->events_.size()); |
| 701 const AnimationEvent* start_filter_event = | 707 const AnimationEvent* start_filter_event = |
| (...skipping 29 matching lines...) Expand all Loading... |
| 731 LayerAnimationController::Create(0)); | 737 LayerAnimationController::Create(0)); |
| 732 controller->AddValueObserver(&dummy); | 738 controller->AddValueObserver(&dummy); |
| 733 controller->set_value_provider(&dummy_provider); | 739 controller->set_value_provider(&dummy_provider); |
| 734 | 740 |
| 735 gfx::ScrollOffset initial_value(100.f, 300.f); | 741 gfx::ScrollOffset initial_value(100.f, 300.f); |
| 736 gfx::ScrollOffset target_value(300.f, 200.f); | 742 gfx::ScrollOffset target_value(300.f, 200.f); |
| 737 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 743 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
| 738 ScrollOffsetAnimationCurve::Create(target_value, | 744 ScrollOffsetAnimationCurve::Create(target_value, |
| 739 EaseInOutTimingFunction::Create())); | 745 EaseInOutTimingFunction::Create())); |
| 740 | 746 |
| 741 scoped_ptr<Animation> animation( | 747 scoped_ptr<Animation> animation(Animation::Create( |
| 742 Animation::Create(std::move(curve), 1, 0, Animation::SCROLL_OFFSET)); | 748 std::move(curve), 1, 0, AnimationTargetProperty::SCROLL_OFFSET)); |
| 743 animation->set_needs_synchronized_start_time(true); | 749 animation->set_needs_synchronized_start_time(true); |
| 744 controller->AddAnimation(std::move(animation)); | 750 controller->AddAnimation(std::move(animation)); |
| 745 | 751 |
| 746 dummy_provider_impl.set_scroll_offset(initial_value); | 752 dummy_provider_impl.set_scroll_offset(initial_value); |
| 747 controller->PushAnimationUpdatesTo(controller_impl.get()); | 753 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 748 controller_impl->ActivateAnimations(); | 754 controller_impl->ActivateAnimations(); |
| 749 EXPECT_TRUE(controller_impl->GetAnimation(Animation::SCROLL_OFFSET)); | 755 EXPECT_TRUE( |
| 750 TimeDelta duration = controller_impl->GetAnimation(Animation::SCROLL_OFFSET) | 756 controller_impl->GetAnimation(AnimationTargetProperty::SCROLL_OFFSET)); |
| 751 ->curve() | 757 TimeDelta duration = |
| 752 ->Duration(); | 758 controller_impl->GetAnimation(AnimationTargetProperty::SCROLL_OFFSET) |
| 753 EXPECT_EQ( | 759 ->curve() |
| 754 duration, | 760 ->Duration(); |
| 755 controller->GetAnimation(Animation::SCROLL_OFFSET)->curve()->Duration()); | 761 EXPECT_EQ(duration, |
| 762 controller->GetAnimation(AnimationTargetProperty::SCROLL_OFFSET) |
| 763 ->curve() |
| 764 ->Duration()); |
| 756 | 765 |
| 757 controller->Animate(kInitialTickTime); | 766 controller->Animate(kInitialTickTime); |
| 758 controller->UpdateState(true, nullptr); | 767 controller->UpdateState(true, nullptr); |
| 759 EXPECT_TRUE(controller->HasActiveAnimation()); | 768 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 760 EXPECT_EQ(initial_value, dummy.scroll_offset()); | 769 EXPECT_EQ(initial_value, dummy.scroll_offset()); |
| 761 | 770 |
| 762 controller_impl->Animate(kInitialTickTime); | 771 controller_impl->Animate(kInitialTickTime); |
| 763 controller_impl->UpdateState(true, events.get()); | 772 controller_impl->UpdateState(true, events.get()); |
| 764 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 773 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 765 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 774 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 808 LayerAnimationController::Create(0)); | 817 LayerAnimationController::Create(0)); |
| 809 controller->AddValueObserver(&dummy); | 818 controller->AddValueObserver(&dummy); |
| 810 controller->set_value_provider(&dummy_provider); | 819 controller->set_value_provider(&dummy_provider); |
| 811 | 820 |
| 812 gfx::ScrollOffset initial_value(500.f, 100.f); | 821 gfx::ScrollOffset initial_value(500.f, 100.f); |
| 813 gfx::ScrollOffset target_value(300.f, 200.f); | 822 gfx::ScrollOffset target_value(300.f, 200.f); |
| 814 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 823 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
| 815 ScrollOffsetAnimationCurve::Create(target_value, | 824 ScrollOffsetAnimationCurve::Create(target_value, |
| 816 EaseInOutTimingFunction::Create())); | 825 EaseInOutTimingFunction::Create())); |
| 817 | 826 |
| 818 scoped_ptr<Animation> animation( | 827 scoped_ptr<Animation> animation(Animation::Create( |
| 819 Animation::Create(std::move(curve), 1, 0, Animation::SCROLL_OFFSET)); | 828 std::move(curve), 1, 0, AnimationTargetProperty::SCROLL_OFFSET)); |
| 820 animation->set_needs_synchronized_start_time(true); | 829 animation->set_needs_synchronized_start_time(true); |
| 821 controller->AddAnimation(std::move(animation)); | 830 controller->AddAnimation(std::move(animation)); |
| 822 | 831 |
| 823 dummy_provider.set_scroll_offset(initial_value); | 832 dummy_provider.set_scroll_offset(initial_value); |
| 824 controller->PushAnimationUpdatesTo(controller_impl.get()); | 833 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 825 controller_impl->ActivateAnimations(); | 834 controller_impl->ActivateAnimations(); |
| 826 EXPECT_TRUE(controller_impl->GetAnimation(Animation::SCROLL_OFFSET)); | 835 EXPECT_TRUE( |
| 827 TimeDelta duration = controller_impl->GetAnimation(Animation::SCROLL_OFFSET) | 836 controller_impl->GetAnimation(AnimationTargetProperty::SCROLL_OFFSET)); |
| 828 ->curve() | 837 TimeDelta duration = |
| 829 ->Duration(); | 838 controller_impl->GetAnimation(AnimationTargetProperty::SCROLL_OFFSET) |
| 830 EXPECT_EQ( | 839 ->curve() |
| 831 duration, | 840 ->Duration(); |
| 832 controller->GetAnimation(Animation::SCROLL_OFFSET)->curve()->Duration()); | 841 EXPECT_EQ(duration, |
| 842 controller->GetAnimation(AnimationTargetProperty::SCROLL_OFFSET) |
| 843 ->curve() |
| 844 ->Duration()); |
| 833 | 845 |
| 834 controller->Animate(kInitialTickTime); | 846 controller->Animate(kInitialTickTime); |
| 835 controller->UpdateState(true, nullptr); | 847 controller->UpdateState(true, nullptr); |
| 836 EXPECT_TRUE(controller->HasActiveAnimation()); | 848 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 837 EXPECT_EQ(initial_value, dummy.scroll_offset()); | 849 EXPECT_EQ(initial_value, dummy.scroll_offset()); |
| 838 | 850 |
| 839 controller_impl->Animate(kInitialTickTime); | 851 controller_impl->Animate(kInitialTickTime); |
| 840 controller_impl->UpdateState(true, events.get()); | 852 controller_impl->UpdateState(true, events.get()); |
| 841 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 853 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 842 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 854 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 890 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 879 | 891 |
| 880 gfx::ScrollOffset initial_value(100.f, 300.f); | 892 gfx::ScrollOffset initial_value(100.f, 300.f); |
| 881 gfx::ScrollOffset target_value(300.f, 200.f); | 893 gfx::ScrollOffset target_value(300.f, 200.f); |
| 882 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 894 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
| 883 ScrollOffsetAnimationCurve::Create(target_value, | 895 ScrollOffsetAnimationCurve::Create(target_value, |
| 884 EaseInOutTimingFunction::Create())); | 896 EaseInOutTimingFunction::Create())); |
| 885 curve->SetInitialValue(initial_value); | 897 curve->SetInitialValue(initial_value); |
| 886 double duration_in_seconds = curve->Duration().InSecondsF(); | 898 double duration_in_seconds = curve->Duration().InSecondsF(); |
| 887 | 899 |
| 888 scoped_ptr<Animation> animation( | 900 scoped_ptr<Animation> animation(Animation::Create( |
| 889 Animation::Create(std::move(curve), 1, 0, Animation::SCROLL_OFFSET)); | 901 std::move(curve), 1, 0, AnimationTargetProperty::SCROLL_OFFSET)); |
| 890 animation->set_is_impl_only(true); | 902 animation->set_is_impl_only(true); |
| 891 controller_impl->AddAnimation(std::move(animation)); | 903 controller_impl->AddAnimation(std::move(animation)); |
| 892 | 904 |
| 893 controller_impl->Animate(kInitialTickTime); | 905 controller_impl->Animate(kInitialTickTime); |
| 894 controller_impl->UpdateState(true, events.get()); | 906 controller_impl->UpdateState(true, events.get()); |
| 895 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 907 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
| 896 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); | 908 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); |
| 897 // Scroll offset animations should not generate property updates. | 909 // Scroll offset animations should not generate property updates. |
| 898 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); | 910 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); |
| 899 EXPECT_FALSE(event); | 911 EXPECT_FALSE(event); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 931 controller->AddValueObserver(&dummy); | 943 controller->AddValueObserver(&dummy); |
| 932 controller->set_value_provider(&dummy_provider); | 944 controller->set_value_provider(&dummy_provider); |
| 933 | 945 |
| 934 // First test the 1-argument version of RemoveAnimation. | 946 // First test the 1-argument version of RemoveAnimation. |
| 935 gfx::ScrollOffset target_value(300.f, 200.f); | 947 gfx::ScrollOffset target_value(300.f, 200.f); |
| 936 scoped_ptr<ScrollOffsetAnimationCurve> curve( | 948 scoped_ptr<ScrollOffsetAnimationCurve> curve( |
| 937 ScrollOffsetAnimationCurve::Create(target_value, | 949 ScrollOffsetAnimationCurve::Create(target_value, |
| 938 EaseInOutTimingFunction::Create())); | 950 EaseInOutTimingFunction::Create())); |
| 939 | 951 |
| 940 int animation_id = 1; | 952 int animation_id = 1; |
| 941 scoped_ptr<Animation> animation(Animation::Create( | 953 scoped_ptr<Animation> animation( |
| 942 std::move(curve), animation_id, 0, Animation::SCROLL_OFFSET)); | 954 Animation::Create(std::move(curve), animation_id, 0, |
| 955 AnimationTargetProperty::SCROLL_OFFSET)); |
| 943 animation->set_needs_synchronized_start_time(true); | 956 animation->set_needs_synchronized_start_time(true); |
| 944 controller->AddAnimation(std::move(animation)); | 957 controller->AddAnimation(std::move(animation)); |
| 945 controller->PushAnimationUpdatesTo(controller_impl.get()); | 958 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 946 controller_impl->ActivateAnimations(); | 959 controller_impl->ActivateAnimations(); |
| 947 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); | 960 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); |
| 948 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); | 961 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); |
| 949 | 962 |
| 950 controller->RemoveAnimation(animation_id); | 963 controller->RemoveAnimation(animation_id); |
| 951 EXPECT_TRUE(controller->scroll_offset_animation_was_interrupted()); | 964 EXPECT_TRUE(controller->scroll_offset_animation_was_interrupted()); |
| 952 | 965 |
| 953 controller->PushAnimationUpdatesTo(controller_impl.get()); | 966 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 954 EXPECT_TRUE(controller_impl->scroll_offset_animation_was_interrupted()); | 967 EXPECT_TRUE(controller_impl->scroll_offset_animation_was_interrupted()); |
| 955 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); | 968 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); |
| 956 | 969 |
| 957 controller_impl->ActivateAnimations(); | 970 controller_impl->ActivateAnimations(); |
| 958 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); | 971 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); |
| 959 | 972 |
| 960 // Now, test the 2-argument version of RemoveAnimation. | 973 // Now, test the 2-argument version of RemoveAnimation. |
| 961 curve = ScrollOffsetAnimationCurve::Create(target_value, | 974 curve = ScrollOffsetAnimationCurve::Create(target_value, |
| 962 EaseInOutTimingFunction::Create()); | 975 EaseInOutTimingFunction::Create()); |
| 963 animation = Animation::Create(std::move(curve), animation_id, 0, | 976 animation = Animation::Create(std::move(curve), animation_id, 0, |
| 964 Animation::SCROLL_OFFSET); | 977 AnimationTargetProperty::SCROLL_OFFSET); |
| 965 animation->set_needs_synchronized_start_time(true); | 978 animation->set_needs_synchronized_start_time(true); |
| 966 controller->AddAnimation(std::move(animation)); | 979 controller->AddAnimation(std::move(animation)); |
| 967 controller->PushAnimationUpdatesTo(controller_impl.get()); | 980 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 968 controller_impl->ActivateAnimations(); | 981 controller_impl->ActivateAnimations(); |
| 969 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); | 982 EXPECT_FALSE(controller->scroll_offset_animation_was_interrupted()); |
| 970 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); | 983 EXPECT_FALSE(controller_impl->scroll_offset_animation_was_interrupted()); |
| 971 | 984 |
| 972 controller->RemoveAnimation(animation_id); | 985 controller->RemoveAnimation(animation_id); |
| 973 EXPECT_TRUE(controller->scroll_offset_animation_was_interrupted()); | 986 EXPECT_TRUE(controller->scroll_offset_animation_was_interrupted()); |
| 974 | 987 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 | 1030 |
| 1018 class FakeAnimationDelegate : public AnimationDelegate { | 1031 class FakeAnimationDelegate : public AnimationDelegate { |
| 1019 public: | 1032 public: |
| 1020 FakeAnimationDelegate() | 1033 FakeAnimationDelegate() |
| 1021 : started_(false), | 1034 : started_(false), |
| 1022 finished_(false), | 1035 finished_(false), |
| 1023 aborted_(false), | 1036 aborted_(false), |
| 1024 start_time_(base::TimeTicks()) {} | 1037 start_time_(base::TimeTicks()) {} |
| 1025 | 1038 |
| 1026 void NotifyAnimationStarted(TimeTicks monotonic_time, | 1039 void NotifyAnimationStarted(TimeTicks monotonic_time, |
| 1027 Animation::TargetProperty target_property, | 1040 AnimationTargetProperty::Enum target_property, |
| 1028 int group) override { | 1041 int group) override { |
| 1029 started_ = true; | 1042 started_ = true; |
| 1030 start_time_ = monotonic_time; | 1043 start_time_ = monotonic_time; |
| 1031 } | 1044 } |
| 1032 | 1045 |
| 1033 void NotifyAnimationFinished(TimeTicks monotonic_time, | 1046 void NotifyAnimationFinished(TimeTicks monotonic_time, |
| 1034 Animation::TargetProperty target_property, | 1047 AnimationTargetProperty::Enum target_property, |
| 1035 int group) override { | 1048 int group) override { |
| 1036 finished_ = true; | 1049 finished_ = true; |
| 1037 } | 1050 } |
| 1038 | 1051 |
| 1039 void NotifyAnimationAborted(TimeTicks monotonic_time, | 1052 void NotifyAnimationAborted(TimeTicks monotonic_time, |
| 1040 Animation::TargetProperty target_property, | 1053 AnimationTargetProperty::Enum target_property, |
| 1041 int group) override { | 1054 int group) override { |
| 1042 aborted_ = true; | 1055 aborted_ = true; |
| 1043 } | 1056 } |
| 1044 | 1057 |
| 1045 bool started() { return started_; } | 1058 bool started() { return started_; } |
| 1046 | 1059 |
| 1047 bool finished() { return finished_; } | 1060 bool finished() { return finished_; } |
| 1048 | 1061 |
| 1049 bool aborted() { return aborted_; } | 1062 bool aborted() { return aborted_; } |
| 1050 | 1063 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1064 FakeLayerAnimationValueObserver dummy_impl; | 1077 FakeLayerAnimationValueObserver dummy_impl; |
| 1065 scoped_refptr<LayerAnimationController> controller_impl( | 1078 scoped_refptr<LayerAnimationController> controller_impl( |
| 1066 LayerAnimationController::Create(0)); | 1079 LayerAnimationController::Create(0)); |
| 1067 controller_impl->AddValueObserver(&dummy_impl); | 1080 controller_impl->AddValueObserver(&dummy_impl); |
| 1068 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1081 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1069 FakeAnimationDelegate delegate; | 1082 FakeAnimationDelegate delegate; |
| 1070 controller_impl->set_layer_animation_delegate(&delegate); | 1083 controller_impl->set_layer_animation_delegate(&delegate); |
| 1071 | 1084 |
| 1072 scoped_ptr<Animation> to_add(CreateAnimation( | 1085 scoped_ptr<Animation> to_add(CreateAnimation( |
| 1073 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 1086 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 1074 Animation::OPACITY)); | 1087 AnimationTargetProperty::OPACITY)); |
| 1075 to_add->set_is_impl_only(true); | 1088 to_add->set_is_impl_only(true); |
| 1076 controller_impl->AddAnimation(std::move(to_add)); | 1089 controller_impl->AddAnimation(std::move(to_add)); |
| 1077 | 1090 |
| 1078 EXPECT_FALSE(delegate.started()); | 1091 EXPECT_FALSE(delegate.started()); |
| 1079 EXPECT_FALSE(delegate.finished()); | 1092 EXPECT_FALSE(delegate.finished()); |
| 1080 | 1093 |
| 1081 controller_impl->Animate(kInitialTickTime); | 1094 controller_impl->Animate(kInitialTickTime); |
| 1082 controller_impl->UpdateState(true, events.get()); | 1095 controller_impl->UpdateState(true, events.get()); |
| 1083 | 1096 |
| 1084 EXPECT_TRUE(delegate.started()); | 1097 EXPECT_TRUE(delegate.started()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1104 scoped_refptr<LayerAnimationController> controller( | 1117 scoped_refptr<LayerAnimationController> controller( |
| 1105 LayerAnimationController::Create(0)); | 1118 LayerAnimationController::Create(0)); |
| 1106 controller->AddValueObserver(&dummy); | 1119 controller->AddValueObserver(&dummy); |
| 1107 FakeAnimationDelegate delegate; | 1120 FakeAnimationDelegate delegate; |
| 1108 controller->set_layer_animation_delegate(&delegate); | 1121 controller->set_layer_animation_delegate(&delegate); |
| 1109 | 1122 |
| 1110 int animation_id = | 1123 int animation_id = |
| 1111 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 1124 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
| 1112 | 1125 |
| 1113 const TimeTicks start_time = TicksFromSecondsF(123); | 1126 const TimeTicks start_time = TicksFromSecondsF(123); |
| 1114 controller->GetAnimation(Animation::OPACITY)->set_start_time(start_time); | 1127 controller->GetAnimation(AnimationTargetProperty::OPACITY) |
| 1128 ->set_start_time(start_time); |
| 1115 | 1129 |
| 1116 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1130 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1117 controller_impl->ActivateAnimations(); | 1131 controller_impl->ActivateAnimations(); |
| 1118 | 1132 |
| 1119 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 1133 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
| 1120 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1134 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 1121 controller_impl->GetAnimationById(animation_id)->run_state()); | 1135 controller_impl->GetAnimationById(animation_id)->run_state()); |
| 1122 | 1136 |
| 1123 AnimationEvents events; | 1137 AnimationEvents events; |
| 1124 controller_impl->Animate(kInitialTickTime); | 1138 controller_impl->Animate(kInitialTickTime); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1156 scoped_refptr<LayerAnimationController> controller( | 1170 scoped_refptr<LayerAnimationController> controller( |
| 1157 LayerAnimationController::Create(0)); | 1171 LayerAnimationController::Create(0)); |
| 1158 controller->AddValueObserver(&dummy); | 1172 controller->AddValueObserver(&dummy); |
| 1159 FakeLayerAnimationEventObserver observer; | 1173 FakeLayerAnimationEventObserver observer; |
| 1160 controller->AddEventObserver(&observer); | 1174 controller->AddEventObserver(&observer); |
| 1161 | 1175 |
| 1162 int animation_id = | 1176 int animation_id = |
| 1163 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 1177 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
| 1164 | 1178 |
| 1165 const TimeTicks start_time = TicksFromSecondsF(123); | 1179 const TimeTicks start_time = TicksFromSecondsF(123); |
| 1166 controller->GetAnimation(Animation::OPACITY)->set_start_time(start_time); | 1180 controller->GetAnimation(AnimationTargetProperty::OPACITY) |
| 1181 ->set_start_time(start_time); |
| 1167 | 1182 |
| 1168 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1183 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1169 controller_impl->ActivateAnimations(); | 1184 controller_impl->ActivateAnimations(); |
| 1170 | 1185 |
| 1171 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 1186 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
| 1172 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1187 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 1173 controller_impl->GetAnimationById(animation_id)->run_state()); | 1188 controller_impl->GetAnimationById(animation_id)->run_state()); |
| 1174 | 1189 |
| 1175 AnimationEvents events; | 1190 AnimationEvents events; |
| 1176 controller_impl->Animate(kInitialTickTime); | 1191 controller_impl->Animate(kInitialTickTime); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1189 TEST(LayerAnimationControllerTest, | 1204 TEST(LayerAnimationControllerTest, |
| 1190 AnimationsWaitingForStartTimeDoNotFinishIfTheyOutwaitTheirFinish) { | 1205 AnimationsWaitingForStartTimeDoNotFinishIfTheyOutwaitTheirFinish) { |
| 1191 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1206 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1192 FakeLayerAnimationValueObserver dummy; | 1207 FakeLayerAnimationValueObserver dummy; |
| 1193 scoped_refptr<LayerAnimationController> controller( | 1208 scoped_refptr<LayerAnimationController> controller( |
| 1194 LayerAnimationController::Create(0)); | 1209 LayerAnimationController::Create(0)); |
| 1195 controller->AddValueObserver(&dummy); | 1210 controller->AddValueObserver(&dummy); |
| 1196 | 1211 |
| 1197 scoped_ptr<Animation> to_add(CreateAnimation( | 1212 scoped_ptr<Animation> to_add(CreateAnimation( |
| 1198 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 1213 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 1199 Animation::OPACITY)); | 1214 AnimationTargetProperty::OPACITY)); |
| 1200 to_add->set_needs_synchronized_start_time(true); | 1215 to_add->set_needs_synchronized_start_time(true); |
| 1201 | 1216 |
| 1202 // We should pause at the first keyframe indefinitely waiting for that | 1217 // We should pause at the first keyframe indefinitely waiting for that |
| 1203 // animation to start. | 1218 // animation to start. |
| 1204 controller->AddAnimation(std::move(to_add)); | 1219 controller->AddAnimation(std::move(to_add)); |
| 1205 controller->Animate(kInitialTickTime); | 1220 controller->Animate(kInitialTickTime); |
| 1206 controller->UpdateState(true, events.get()); | 1221 controller->UpdateState(true, events.get()); |
| 1207 EXPECT_TRUE(controller->HasActiveAnimation()); | 1222 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1208 EXPECT_EQ(0.f, dummy.opacity()); | 1223 EXPECT_EQ(0.f, dummy.opacity()); |
| 1209 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1224 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1210 controller->UpdateState(true, events.get()); | 1225 controller->UpdateState(true, events.get()); |
| 1211 EXPECT_TRUE(controller->HasActiveAnimation()); | 1226 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1212 EXPECT_EQ(0.f, dummy.opacity()); | 1227 EXPECT_EQ(0.f, dummy.opacity()); |
| 1213 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1228 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 1214 controller->UpdateState(true, events.get()); | 1229 controller->UpdateState(true, events.get()); |
| 1215 EXPECT_TRUE(controller->HasActiveAnimation()); | 1230 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1216 EXPECT_EQ(0.f, dummy.opacity()); | 1231 EXPECT_EQ(0.f, dummy.opacity()); |
| 1217 | 1232 |
| 1218 // Send the synchronized start time. | 1233 // Send the synchronized start time. |
| 1219 controller->NotifyAnimationStarted( | 1234 controller->NotifyAnimationStarted(AnimationEvent( |
| 1220 AnimationEvent(AnimationEvent::STARTED, 0, 1, Animation::OPACITY, | 1235 AnimationEvent::STARTED, 0, 1, AnimationTargetProperty::OPACITY, |
| 1221 kInitialTickTime + TimeDelta::FromMilliseconds(2000))); | 1236 kInitialTickTime + TimeDelta::FromMilliseconds(2000))); |
| 1222 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(5000)); | 1237 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(5000)); |
| 1223 controller->UpdateState(true, events.get()); | 1238 controller->UpdateState(true, events.get()); |
| 1224 EXPECT_EQ(1.f, dummy.opacity()); | 1239 EXPECT_EQ(1.f, dummy.opacity()); |
| 1225 EXPECT_FALSE(controller->HasActiveAnimation()); | 1240 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 1226 } | 1241 } |
| 1227 | 1242 |
| 1228 // Tests that two queued animations affecting the same property run in sequence. | 1243 // Tests that two queued animations affecting the same property run in sequence. |
| 1229 TEST(LayerAnimationControllerTest, TrivialQueuing) { | 1244 TEST(LayerAnimationControllerTest, TrivialQueuing) { |
| 1230 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1245 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1231 FakeLayerAnimationValueObserver dummy; | 1246 FakeLayerAnimationValueObserver dummy; |
| 1232 scoped_refptr<LayerAnimationController> controller( | 1247 scoped_refptr<LayerAnimationController> controller( |
| 1233 LayerAnimationController::Create(0)); | 1248 LayerAnimationController::Create(0)); |
| 1234 controller->AddValueObserver(&dummy); | 1249 controller->AddValueObserver(&dummy); |
| 1235 | 1250 |
| 1236 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); | 1251 EXPECT_FALSE(controller->needs_to_start_animations_for_testing()); |
| 1237 | 1252 |
| 1238 controller->AddAnimation(CreateAnimation( | 1253 controller->AddAnimation(CreateAnimation( |
| 1239 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 1254 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 1240 Animation::OPACITY)); | 1255 AnimationTargetProperty::OPACITY)); |
| 1241 controller->AddAnimation(CreateAnimation( | 1256 controller->AddAnimation(CreateAnimation( |
| 1242 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 2, | 1257 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 2, |
| 1243 Animation::OPACITY)); | 1258 AnimationTargetProperty::OPACITY)); |
| 1244 | 1259 |
| 1245 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); | 1260 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); |
| 1246 | 1261 |
| 1247 controller->Animate(kInitialTickTime); | 1262 controller->Animate(kInitialTickTime); |
| 1248 | 1263 |
| 1249 // The second animation still needs to be started. | 1264 // The second animation still needs to be started. |
| 1250 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); | 1265 EXPECT_TRUE(controller->needs_to_start_animations_for_testing()); |
| 1251 | 1266 |
| 1252 controller->UpdateState(true, events.get()); | 1267 controller->UpdateState(true, events.get()); |
| 1253 EXPECT_TRUE(controller->HasActiveAnimation()); | 1268 EXPECT_TRUE(controller->HasActiveAnimation()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1268 | 1283 |
| 1269 // Tests interrupting a transition with another transition. | 1284 // Tests interrupting a transition with another transition. |
| 1270 TEST(LayerAnimationControllerTest, Interrupt) { | 1285 TEST(LayerAnimationControllerTest, Interrupt) { |
| 1271 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1286 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1272 FakeLayerAnimationValueObserver dummy; | 1287 FakeLayerAnimationValueObserver dummy; |
| 1273 scoped_refptr<LayerAnimationController> controller( | 1288 scoped_refptr<LayerAnimationController> controller( |
| 1274 LayerAnimationController::Create(0)); | 1289 LayerAnimationController::Create(0)); |
| 1275 controller->AddValueObserver(&dummy); | 1290 controller->AddValueObserver(&dummy); |
| 1276 controller->AddAnimation(CreateAnimation( | 1291 controller->AddAnimation(CreateAnimation( |
| 1277 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 1292 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 1278 Animation::OPACITY)); | 1293 AnimationTargetProperty::OPACITY)); |
| 1279 controller->Animate(kInitialTickTime); | 1294 controller->Animate(kInitialTickTime); |
| 1280 controller->UpdateState(true, events.get()); | 1295 controller->UpdateState(true, events.get()); |
| 1281 EXPECT_TRUE(controller->HasActiveAnimation()); | 1296 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1282 EXPECT_EQ(0.f, dummy.opacity()); | 1297 EXPECT_EQ(0.f, dummy.opacity()); |
| 1283 | 1298 |
| 1284 scoped_ptr<Animation> to_add(CreateAnimation( | 1299 scoped_ptr<Animation> to_add(CreateAnimation( |
| 1285 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 2, | 1300 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 2, |
| 1286 Animation::OPACITY)); | 1301 AnimationTargetProperty::OPACITY)); |
| 1287 controller->AbortAnimations(Animation::OPACITY); | 1302 controller->AbortAnimations(AnimationTargetProperty::OPACITY); |
| 1288 controller->AddAnimation(std::move(to_add)); | 1303 controller->AddAnimation(std::move(to_add)); |
| 1289 | 1304 |
| 1290 // Since the previous animation was aborted, the new animation should start | 1305 // Since the previous animation was aborted, the new animation should start |
| 1291 // right in this call to animate. | 1306 // right in this call to animate. |
| 1292 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1307 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 1293 controller->UpdateState(true, events.get()); | 1308 controller->UpdateState(true, events.get()); |
| 1294 EXPECT_TRUE(controller->HasActiveAnimation()); | 1309 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1295 EXPECT_EQ(1.f, dummy.opacity()); | 1310 EXPECT_EQ(1.f, dummy.opacity()); |
| 1296 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); | 1311 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1500)); |
| 1297 controller->UpdateState(true, events.get()); | 1312 controller->UpdateState(true, events.get()); |
| 1298 EXPECT_EQ(0.5f, dummy.opacity()); | 1313 EXPECT_EQ(0.5f, dummy.opacity()); |
| 1299 EXPECT_FALSE(controller->HasActiveAnimation()); | 1314 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 1300 } | 1315 } |
| 1301 | 1316 |
| 1302 // Tests scheduling two animations to run together when only one property is | 1317 // Tests scheduling two animations to run together when only one property is |
| 1303 // free. | 1318 // free. |
| 1304 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { | 1319 TEST(LayerAnimationControllerTest, ScheduleTogetherWhenAPropertyIsBlocked) { |
| 1305 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1320 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1306 FakeLayerAnimationValueObserver dummy; | 1321 FakeLayerAnimationValueObserver dummy; |
| 1307 scoped_refptr<LayerAnimationController> controller( | 1322 scoped_refptr<LayerAnimationController> controller( |
| 1308 LayerAnimationController::Create(0)); | 1323 LayerAnimationController::Create(0)); |
| 1309 controller->AddValueObserver(&dummy); | 1324 controller->AddValueObserver(&dummy); |
| 1310 | 1325 |
| 1311 controller->AddAnimation(CreateAnimation( | 1326 controller->AddAnimation(CreateAnimation( |
| 1312 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, | 1327 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, |
| 1313 Animation::TRANSFORM)); | 1328 AnimationTargetProperty::TRANSFORM)); |
| 1314 controller->AddAnimation(CreateAnimation( | 1329 controller->AddAnimation(CreateAnimation( |
| 1315 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 2, | 1330 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 2, |
| 1316 Animation::TRANSFORM)); | 1331 AnimationTargetProperty::TRANSFORM)); |
| 1317 controller->AddAnimation(CreateAnimation( | 1332 controller->AddAnimation(CreateAnimation( |
| 1318 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2, | 1333 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2, |
| 1319 Animation::OPACITY)); | 1334 AnimationTargetProperty::OPACITY)); |
| 1320 | 1335 |
| 1321 controller->Animate(kInitialTickTime); | 1336 controller->Animate(kInitialTickTime); |
| 1322 controller->UpdateState(true, events.get()); | 1337 controller->UpdateState(true, events.get()); |
| 1323 EXPECT_EQ(0.f, dummy.opacity()); | 1338 EXPECT_EQ(0.f, dummy.opacity()); |
| 1324 EXPECT_TRUE(controller->HasActiveAnimation()); | 1339 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1325 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1340 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1326 controller->UpdateState(true, events.get()); | 1341 controller->UpdateState(true, events.get()); |
| 1327 // Should not have started the float transition yet. | 1342 // Should not have started the float transition yet. |
| 1328 EXPECT_TRUE(controller->HasActiveAnimation()); | 1343 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1329 EXPECT_EQ(0.f, dummy.opacity()); | 1344 EXPECT_EQ(0.f, dummy.opacity()); |
| 1330 // The float animation should have started at time 1 and should be done. | 1345 // The float animation should have started at time 1 and should be done. |
| 1331 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1346 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 1332 controller->UpdateState(true, events.get()); | 1347 controller->UpdateState(true, events.get()); |
| 1333 EXPECT_EQ(1.f, dummy.opacity()); | 1348 EXPECT_EQ(1.f, dummy.opacity()); |
| 1334 EXPECT_FALSE(controller->HasActiveAnimation()); | 1349 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 1335 } | 1350 } |
| 1336 | 1351 |
| 1337 // Tests scheduling two animations to run together with different lengths and | 1352 // Tests scheduling two animations to run together with different lengths and |
| 1338 // another animation queued to start when the shorter animation finishes (should | 1353 // another animation queued to start when the shorter animation finishes (should |
| 1339 // wait for both to finish). | 1354 // wait for both to finish). |
| 1340 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { | 1355 TEST(LayerAnimationControllerTest, ScheduleTogetherWithAnAnimWaiting) { |
| 1341 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1356 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1342 FakeLayerAnimationValueObserver dummy; | 1357 FakeLayerAnimationValueObserver dummy; |
| 1343 scoped_refptr<LayerAnimationController> controller( | 1358 scoped_refptr<LayerAnimationController> controller( |
| 1344 LayerAnimationController::Create(0)); | 1359 LayerAnimationController::Create(0)); |
| 1345 controller->AddValueObserver(&dummy); | 1360 controller->AddValueObserver(&dummy); |
| 1346 | 1361 |
| 1347 controller->AddAnimation(CreateAnimation( | 1362 controller->AddAnimation(CreateAnimation( |
| 1348 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2)), 1, | 1363 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2)), 1, |
| 1349 Animation::TRANSFORM)); | 1364 AnimationTargetProperty::TRANSFORM)); |
| 1350 controller->AddAnimation(CreateAnimation( | 1365 controller->AddAnimation(CreateAnimation( |
| 1351 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 1366 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 1352 Animation::OPACITY)); | 1367 AnimationTargetProperty::OPACITY)); |
| 1353 controller->AddAnimation(CreateAnimation( | 1368 controller->AddAnimation(CreateAnimation( |
| 1354 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 2, | 1369 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.5f)), 2, |
| 1355 Animation::OPACITY)); | 1370 AnimationTargetProperty::OPACITY)); |
| 1356 | 1371 |
| 1357 // Animations with id 1 should both start now. | 1372 // Animations with id 1 should both start now. |
| 1358 controller->Animate(kInitialTickTime); | 1373 controller->Animate(kInitialTickTime); |
| 1359 controller->UpdateState(true, events.get()); | 1374 controller->UpdateState(true, events.get()); |
| 1360 EXPECT_TRUE(controller->HasActiveAnimation()); | 1375 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1361 EXPECT_EQ(0.f, dummy.opacity()); | 1376 EXPECT_EQ(0.f, dummy.opacity()); |
| 1362 // The opacity animation should have finished at time 1, but the group | 1377 // The opacity animation should have finished at time 1, but the group |
| 1363 // of animations with id 1 don't finish until time 2 because of the length | 1378 // of animations with id 1 don't finish until time 2 because of the length |
| 1364 // of the transform animation. | 1379 // of the transform animation. |
| 1365 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1380 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1379 // Test that a looping animation loops and for the correct number of iterations. | 1394 // Test that a looping animation loops and for the correct number of iterations. |
| 1380 TEST(LayerAnimationControllerTest, TrivialLooping) { | 1395 TEST(LayerAnimationControllerTest, TrivialLooping) { |
| 1381 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1396 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1382 FakeLayerAnimationValueObserver dummy; | 1397 FakeLayerAnimationValueObserver dummy; |
| 1383 scoped_refptr<LayerAnimationController> controller( | 1398 scoped_refptr<LayerAnimationController> controller( |
| 1384 LayerAnimationController::Create(0)); | 1399 LayerAnimationController::Create(0)); |
| 1385 controller->AddValueObserver(&dummy); | 1400 controller->AddValueObserver(&dummy); |
| 1386 | 1401 |
| 1387 scoped_ptr<Animation> to_add(CreateAnimation( | 1402 scoped_ptr<Animation> to_add(CreateAnimation( |
| 1388 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 1403 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 1389 Animation::OPACITY)); | 1404 AnimationTargetProperty::OPACITY)); |
| 1390 to_add->set_iterations(3); | 1405 to_add->set_iterations(3); |
| 1391 controller->AddAnimation(std::move(to_add)); | 1406 controller->AddAnimation(std::move(to_add)); |
| 1392 | 1407 |
| 1393 controller->Animate(kInitialTickTime); | 1408 controller->Animate(kInitialTickTime); |
| 1394 controller->UpdateState(true, events.get()); | 1409 controller->UpdateState(true, events.get()); |
| 1395 EXPECT_TRUE(controller->HasActiveAnimation()); | 1410 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1396 EXPECT_EQ(0.f, dummy.opacity()); | 1411 EXPECT_EQ(0.f, dummy.opacity()); |
| 1397 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); | 1412 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); |
| 1398 controller->UpdateState(true, events.get()); | 1413 controller->UpdateState(true, events.get()); |
| 1399 EXPECT_TRUE(controller->HasActiveAnimation()); | 1414 EXPECT_TRUE(controller->HasActiveAnimation()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1424 // Test that an infinitely looping animation does indeed go until aborted. | 1439 // Test that an infinitely looping animation does indeed go until aborted. |
| 1425 TEST(LayerAnimationControllerTest, InfiniteLooping) { | 1440 TEST(LayerAnimationControllerTest, InfiniteLooping) { |
| 1426 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1441 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1427 FakeLayerAnimationValueObserver dummy; | 1442 FakeLayerAnimationValueObserver dummy; |
| 1428 scoped_refptr<LayerAnimationController> controller( | 1443 scoped_refptr<LayerAnimationController> controller( |
| 1429 LayerAnimationController::Create(0)); | 1444 LayerAnimationController::Create(0)); |
| 1430 controller->AddValueObserver(&dummy); | 1445 controller->AddValueObserver(&dummy); |
| 1431 | 1446 |
| 1432 scoped_ptr<Animation> to_add(CreateAnimation( | 1447 scoped_ptr<Animation> to_add(CreateAnimation( |
| 1433 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 1448 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 1434 Animation::OPACITY)); | 1449 AnimationTargetProperty::OPACITY)); |
| 1435 to_add->set_iterations(-1); | 1450 to_add->set_iterations(-1); |
| 1436 controller->AddAnimation(std::move(to_add)); | 1451 controller->AddAnimation(std::move(to_add)); |
| 1437 | 1452 |
| 1438 controller->Animate(kInitialTickTime); | 1453 controller->Animate(kInitialTickTime); |
| 1439 controller->UpdateState(true, events.get()); | 1454 controller->UpdateState(true, events.get()); |
| 1440 EXPECT_TRUE(controller->HasActiveAnimation()); | 1455 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1441 EXPECT_EQ(0.f, dummy.opacity()); | 1456 EXPECT_EQ(0.f, dummy.opacity()); |
| 1442 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); | 1457 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1250)); |
| 1443 controller->UpdateState(true, events.get()); | 1458 controller->UpdateState(true, events.get()); |
| 1444 EXPECT_TRUE(controller->HasActiveAnimation()); | 1459 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1445 EXPECT_EQ(0.25f, dummy.opacity()); | 1460 EXPECT_EQ(0.25f, dummy.opacity()); |
| 1446 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); | 1461 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1750)); |
| 1447 controller->UpdateState(true, events.get()); | 1462 controller->UpdateState(true, events.get()); |
| 1448 EXPECT_TRUE(controller->HasActiveAnimation()); | 1463 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1449 EXPECT_EQ(0.75f, dummy.opacity()); | 1464 EXPECT_EQ(0.75f, dummy.opacity()); |
| 1450 | 1465 |
| 1451 controller->Animate(kInitialTickTime + | 1466 controller->Animate(kInitialTickTime + |
| 1452 TimeDelta::FromMilliseconds(1073741824250)); | 1467 TimeDelta::FromMilliseconds(1073741824250)); |
| 1453 controller->UpdateState(true, events.get()); | 1468 controller->UpdateState(true, events.get()); |
| 1454 EXPECT_TRUE(controller->HasActiveAnimation()); | 1469 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1455 EXPECT_EQ(0.25f, dummy.opacity()); | 1470 EXPECT_EQ(0.25f, dummy.opacity()); |
| 1456 controller->Animate(kInitialTickTime + | 1471 controller->Animate(kInitialTickTime + |
| 1457 TimeDelta::FromMilliseconds(1073741824750)); | 1472 TimeDelta::FromMilliseconds(1073741824750)); |
| 1458 controller->UpdateState(true, events.get()); | 1473 controller->UpdateState(true, events.get()); |
| 1459 EXPECT_TRUE(controller->HasActiveAnimation()); | 1474 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1460 EXPECT_EQ(0.75f, dummy.opacity()); | 1475 EXPECT_EQ(0.75f, dummy.opacity()); |
| 1461 | 1476 |
| 1462 EXPECT_TRUE(controller->GetAnimation(Animation::OPACITY)); | 1477 EXPECT_TRUE(controller->GetAnimation(AnimationTargetProperty::OPACITY)); |
| 1463 controller->GetAnimation(Animation::OPACITY) | 1478 controller->GetAnimation(AnimationTargetProperty::OPACITY) |
| 1464 ->SetRunState(Animation::ABORTED, | 1479 ->SetRunState(Animation::ABORTED, |
| 1465 kInitialTickTime + TimeDelta::FromMilliseconds(750)); | 1480 kInitialTickTime + TimeDelta::FromMilliseconds(750)); |
| 1466 EXPECT_FALSE(controller->HasActiveAnimation()); | 1481 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 1467 EXPECT_EQ(0.75f, dummy.opacity()); | 1482 EXPECT_EQ(0.75f, dummy.opacity()); |
| 1468 } | 1483 } |
| 1469 | 1484 |
| 1470 // Test that pausing and resuming work as expected. | 1485 // Test that pausing and resuming work as expected. |
| 1471 TEST(LayerAnimationControllerTest, PauseResume) { | 1486 TEST(LayerAnimationControllerTest, PauseResume) { |
| 1472 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1487 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1473 FakeLayerAnimationValueObserver dummy; | 1488 FakeLayerAnimationValueObserver dummy; |
| 1474 scoped_refptr<LayerAnimationController> controller( | 1489 scoped_refptr<LayerAnimationController> controller( |
| 1475 LayerAnimationController::Create(0)); | 1490 LayerAnimationController::Create(0)); |
| 1476 controller->AddValueObserver(&dummy); | 1491 controller->AddValueObserver(&dummy); |
| 1477 | 1492 |
| 1478 controller->AddAnimation(CreateAnimation( | 1493 controller->AddAnimation(CreateAnimation( |
| 1479 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 1494 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 1480 Animation::OPACITY)); | 1495 AnimationTargetProperty::OPACITY)); |
| 1481 | 1496 |
| 1482 controller->Animate(kInitialTickTime); | 1497 controller->Animate(kInitialTickTime); |
| 1483 controller->UpdateState(true, events.get()); | 1498 controller->UpdateState(true, events.get()); |
| 1484 EXPECT_TRUE(controller->HasActiveAnimation()); | 1499 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1485 EXPECT_EQ(0.f, dummy.opacity()); | 1500 EXPECT_EQ(0.f, dummy.opacity()); |
| 1486 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1501 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 1487 controller->UpdateState(true, events.get()); | 1502 controller->UpdateState(true, events.get()); |
| 1488 EXPECT_TRUE(controller->HasActiveAnimation()); | 1503 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1489 EXPECT_EQ(0.5f, dummy.opacity()); | 1504 EXPECT_EQ(0.5f, dummy.opacity()); |
| 1490 | 1505 |
| 1491 EXPECT_TRUE(controller->GetAnimation(Animation::OPACITY)); | 1506 EXPECT_TRUE(controller->GetAnimation(AnimationTargetProperty::OPACITY)); |
| 1492 controller->GetAnimation(Animation::OPACITY) | 1507 controller->GetAnimation(AnimationTargetProperty::OPACITY) |
| 1493 ->SetRunState(Animation::PAUSED, | 1508 ->SetRunState(Animation::PAUSED, |
| 1494 kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1509 kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 1495 | 1510 |
| 1496 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); | 1511 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); |
| 1497 controller->UpdateState(true, events.get()); | 1512 controller->UpdateState(true, events.get()); |
| 1498 EXPECT_TRUE(controller->HasActiveAnimation()); | 1513 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1499 EXPECT_EQ(0.5f, dummy.opacity()); | 1514 EXPECT_EQ(0.5f, dummy.opacity()); |
| 1500 | 1515 |
| 1501 EXPECT_TRUE(controller->GetAnimation(Animation::OPACITY)); | 1516 EXPECT_TRUE(controller->GetAnimation(AnimationTargetProperty::OPACITY)); |
| 1502 controller->GetAnimation(Animation::OPACITY) | 1517 controller->GetAnimation(AnimationTargetProperty::OPACITY) |
| 1503 ->SetRunState(Animation::RUNNING, | 1518 ->SetRunState(Animation::RUNNING, |
| 1504 kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); | 1519 kInitialTickTime + TimeDelta::FromMilliseconds(1024000)); |
| 1505 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024250)); | 1520 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024250)); |
| 1506 controller->UpdateState(true, events.get()); | 1521 controller->UpdateState(true, events.get()); |
| 1507 EXPECT_TRUE(controller->HasActiveAnimation()); | 1522 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1508 EXPECT_EQ(0.75f, dummy.opacity()); | 1523 EXPECT_EQ(0.75f, dummy.opacity()); |
| 1509 | 1524 |
| 1510 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024500)); | 1525 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1024500)); |
| 1511 controller->UpdateState(true, events.get()); | 1526 controller->UpdateState(true, events.get()); |
| 1512 EXPECT_FALSE(controller->HasActiveAnimation()); | 1527 EXPECT_FALSE(controller->HasActiveAnimation()); |
| 1513 EXPECT_EQ(1.f, dummy.opacity()); | 1528 EXPECT_EQ(1.f, dummy.opacity()); |
| 1514 } | 1529 } |
| 1515 | 1530 |
| 1516 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { | 1531 TEST(LayerAnimationControllerTest, AbortAGroupedAnimation) { |
| 1517 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1532 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1518 FakeLayerAnimationValueObserver dummy; | 1533 FakeLayerAnimationValueObserver dummy; |
| 1519 scoped_refptr<LayerAnimationController> controller( | 1534 scoped_refptr<LayerAnimationController> controller( |
| 1520 LayerAnimationController::Create(0)); | 1535 LayerAnimationController::Create(0)); |
| 1521 controller->AddValueObserver(&dummy); | 1536 controller->AddValueObserver(&dummy); |
| 1522 | 1537 |
| 1523 const int animation_id = 2; | 1538 const int animation_id = 2; |
| 1524 controller->AddAnimation(Animation::Create( | 1539 controller->AddAnimation(Animation::Create( |
| 1525 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, 1, | 1540 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, 1, |
| 1526 Animation::TRANSFORM)); | 1541 AnimationTargetProperty::TRANSFORM)); |
| 1527 controller->AddAnimation(Animation::Create( | 1542 controller->AddAnimation(Animation::Create( |
| 1528 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), | 1543 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), |
| 1529 animation_id, 1, Animation::OPACITY)); | 1544 animation_id, 1, AnimationTargetProperty::OPACITY)); |
| 1530 controller->AddAnimation(Animation::Create( | 1545 controller->AddAnimation(Animation::Create( |
| 1531 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.75f)), 3, | 1546 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 1.f, 0.75f)), 3, |
| 1532 2, Animation::OPACITY)); | 1547 2, AnimationTargetProperty::OPACITY)); |
| 1533 | 1548 |
| 1534 controller->Animate(kInitialTickTime); | 1549 controller->Animate(kInitialTickTime); |
| 1535 controller->UpdateState(true, events.get()); | 1550 controller->UpdateState(true, events.get()); |
| 1536 EXPECT_TRUE(controller->HasActiveAnimation()); | 1551 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1537 EXPECT_EQ(0.f, dummy.opacity()); | 1552 EXPECT_EQ(0.f, dummy.opacity()); |
| 1538 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1553 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1539 controller->UpdateState(true, events.get()); | 1554 controller->UpdateState(true, events.get()); |
| 1540 EXPECT_TRUE(controller->HasActiveAnimation()); | 1555 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1541 EXPECT_EQ(0.5f, dummy.opacity()); | 1556 EXPECT_EQ(0.5f, dummy.opacity()); |
| 1542 | 1557 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1560 LayerAnimationController::Create(0)); | 1575 LayerAnimationController::Create(0)); |
| 1561 controller_impl->AddValueObserver(&dummy_impl); | 1576 controller_impl->AddValueObserver(&dummy_impl); |
| 1562 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1577 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1563 FakeLayerAnimationValueObserver dummy; | 1578 FakeLayerAnimationValueObserver dummy; |
| 1564 scoped_refptr<LayerAnimationController> controller( | 1579 scoped_refptr<LayerAnimationController> controller( |
| 1565 LayerAnimationController::Create(0)); | 1580 LayerAnimationController::Create(0)); |
| 1566 controller->AddValueObserver(&dummy); | 1581 controller->AddValueObserver(&dummy); |
| 1567 | 1582 |
| 1568 scoped_ptr<Animation> to_add(CreateAnimation( | 1583 scoped_ptr<Animation> to_add(CreateAnimation( |
| 1569 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), 0, | 1584 scoped_ptr<AnimationCurve>(new FakeFloatTransition(2.0, 0.f, 1.f)), 0, |
| 1570 Animation::OPACITY)); | 1585 AnimationTargetProperty::OPACITY)); |
| 1571 to_add->set_needs_synchronized_start_time(true); | 1586 to_add->set_needs_synchronized_start_time(true); |
| 1572 controller->AddAnimation(std::move(to_add)); | 1587 controller->AddAnimation(std::move(to_add)); |
| 1573 | 1588 |
| 1574 controller->Animate(kInitialTickTime); | 1589 controller->Animate(kInitialTickTime); |
| 1575 controller->UpdateState(true, events.get()); | 1590 controller->UpdateState(true, events.get()); |
| 1576 EXPECT_TRUE(controller->HasActiveAnimation()); | 1591 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 1577 Animation* active_animation = controller->GetAnimation(Animation::OPACITY); | 1592 Animation* active_animation = |
| 1593 controller->GetAnimation(AnimationTargetProperty::OPACITY); |
| 1578 EXPECT_TRUE(active_animation); | 1594 EXPECT_TRUE(active_animation); |
| 1579 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); | 1595 EXPECT_TRUE(active_animation->needs_synchronized_start_time()); |
| 1580 | 1596 |
| 1581 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1597 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1582 controller_impl->ActivateAnimations(); | 1598 controller_impl->ActivateAnimations(); |
| 1583 | 1599 |
| 1584 active_animation = controller_impl->GetAnimation(Animation::OPACITY); | 1600 active_animation = |
| 1601 controller_impl->GetAnimation(AnimationTargetProperty::OPACITY); |
| 1585 EXPECT_TRUE(active_animation); | 1602 EXPECT_TRUE(active_animation); |
| 1586 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1603 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 1587 active_animation->run_state()); | 1604 active_animation->run_state()); |
| 1588 } | 1605 } |
| 1589 | 1606 |
| 1590 // Tests that skipping a call to UpdateState works as expected. | 1607 // Tests that skipping a call to UpdateState works as expected. |
| 1591 TEST(LayerAnimationControllerTest, SkipUpdateState) { | 1608 TEST(LayerAnimationControllerTest, SkipUpdateState) { |
| 1592 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1609 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1593 FakeLayerAnimationValueObserver dummy; | 1610 FakeLayerAnimationValueObserver dummy; |
| 1594 scoped_refptr<LayerAnimationController> controller( | 1611 scoped_refptr<LayerAnimationController> controller( |
| 1595 LayerAnimationController::Create(0)); | 1612 LayerAnimationController::Create(0)); |
| 1596 controller->AddValueObserver(&dummy); | 1613 controller->AddValueObserver(&dummy); |
| 1597 | 1614 |
| 1598 scoped_ptr<Animation> first_animation(CreateAnimation( | 1615 scoped_ptr<Animation> first_animation(CreateAnimation( |
| 1599 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, | 1616 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)), 1, |
| 1600 Animation::TRANSFORM)); | 1617 AnimationTargetProperty::TRANSFORM)); |
| 1601 first_animation->set_is_controlling_instance_for_test(true); | 1618 first_animation->set_is_controlling_instance_for_test(true); |
| 1602 controller->AddAnimation(std::move(first_animation)); | 1619 controller->AddAnimation(std::move(first_animation)); |
| 1603 | 1620 |
| 1604 controller->Animate(kInitialTickTime); | 1621 controller->Animate(kInitialTickTime); |
| 1605 controller->UpdateState(true, events.get()); | 1622 controller->UpdateState(true, events.get()); |
| 1606 | 1623 |
| 1607 scoped_ptr<Animation> second_animation(CreateAnimation( | 1624 scoped_ptr<Animation> second_animation(CreateAnimation( |
| 1608 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2, | 1625 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2, |
| 1609 Animation::OPACITY)); | 1626 AnimationTargetProperty::OPACITY)); |
| 1610 second_animation->set_is_controlling_instance_for_test(true); | 1627 second_animation->set_is_controlling_instance_for_test(true); |
| 1611 controller->AddAnimation(std::move(second_animation)); | 1628 controller->AddAnimation(std::move(second_animation)); |
| 1612 | 1629 |
| 1613 // Animate but don't UpdateState. | 1630 // Animate but don't UpdateState. |
| 1614 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1631 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1615 | 1632 |
| 1616 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1633 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 1617 events.reset(new AnimationEvents); | 1634 events.reset(new AnimationEvents); |
| 1618 controller->UpdateState(true, events.get()); | 1635 controller->UpdateState(true, events.get()); |
| 1619 | 1636 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1638 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { | 1655 TEST(LayerAnimationControllerTest, InactiveObserverGetsTicked) { |
| 1639 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1656 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1640 FakeLayerAnimationValueObserver dummy; | 1657 FakeLayerAnimationValueObserver dummy; |
| 1641 FakeInactiveLayerAnimationValueObserver pending_dummy; | 1658 FakeInactiveLayerAnimationValueObserver pending_dummy; |
| 1642 scoped_refptr<LayerAnimationController> controller( | 1659 scoped_refptr<LayerAnimationController> controller( |
| 1643 LayerAnimationController::Create(0)); | 1660 LayerAnimationController::Create(0)); |
| 1644 | 1661 |
| 1645 const int id = 1; | 1662 const int id = 1; |
| 1646 controller->AddAnimation(CreateAnimation( | 1663 controller->AddAnimation(CreateAnimation( |
| 1647 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.5f, 1.f)), id, | 1664 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.5f, 1.f)), id, |
| 1648 Animation::OPACITY)); | 1665 AnimationTargetProperty::OPACITY)); |
| 1649 | 1666 |
| 1650 // Without an observer, the animation shouldn't progress to the STARTING | 1667 // Without an observer, the animation shouldn't progress to the STARTING |
| 1651 // state. | 1668 // state. |
| 1652 controller->Animate(kInitialTickTime); | 1669 controller->Animate(kInitialTickTime); |
| 1653 controller->UpdateState(true, events.get()); | 1670 controller->UpdateState(true, events.get()); |
| 1654 EXPECT_EQ(0u, events->events_.size()); | 1671 EXPECT_EQ(0u, events->events_.size()); |
| 1655 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1672 EXPECT_EQ( |
| 1656 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1673 Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 1674 controller->GetAnimation(AnimationTargetProperty::OPACITY)->run_state()); |
| 1657 | 1675 |
| 1658 controller->AddValueObserver(&pending_dummy); | 1676 controller->AddValueObserver(&pending_dummy); |
| 1659 | 1677 |
| 1660 // With only a pending observer, the animation should progress to the | 1678 // With only a pending observer, the animation should progress to the |
| 1661 // STARTING state and get ticked at its starting point, but should not | 1679 // STARTING state and get ticked at its starting point, but should not |
| 1662 // progress to RUNNING. | 1680 // progress to RUNNING. |
| 1663 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1681 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1664 controller->UpdateState(true, events.get()); | 1682 controller->UpdateState(true, events.get()); |
| 1665 EXPECT_EQ(0u, events->events_.size()); | 1683 EXPECT_EQ(0u, events->events_.size()); |
| 1666 EXPECT_EQ(Animation::STARTING, | 1684 EXPECT_EQ( |
| 1667 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1685 Animation::STARTING, |
| 1686 controller->GetAnimation(AnimationTargetProperty::OPACITY)->run_state()); |
| 1668 EXPECT_EQ(0.5f, pending_dummy.opacity()); | 1687 EXPECT_EQ(0.5f, pending_dummy.opacity()); |
| 1669 | 1688 |
| 1670 // Even when already in the STARTING state, the animation should stay | 1689 // Even when already in the STARTING state, the animation should stay |
| 1671 // there, and shouldn't be ticked past its starting point. | 1690 // there, and shouldn't be ticked past its starting point. |
| 1672 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1691 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 1673 controller->UpdateState(true, events.get()); | 1692 controller->UpdateState(true, events.get()); |
| 1674 EXPECT_EQ(0u, events->events_.size()); | 1693 EXPECT_EQ(0u, events->events_.size()); |
| 1675 EXPECT_EQ(Animation::STARTING, | 1694 EXPECT_EQ( |
| 1676 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1695 Animation::STARTING, |
| 1696 controller->GetAnimation(AnimationTargetProperty::OPACITY)->run_state()); |
| 1677 EXPECT_EQ(0.5f, pending_dummy.opacity()); | 1697 EXPECT_EQ(0.5f, pending_dummy.opacity()); |
| 1678 | 1698 |
| 1679 controller->AddValueObserver(&dummy); | 1699 controller->AddValueObserver(&dummy); |
| 1680 | 1700 |
| 1681 // Now that an active observer has been added, the animation should still | 1701 // Now that an active observer has been added, the animation should still |
| 1682 // initially tick at its starting point, but should now progress to RUNNING. | 1702 // initially tick at its starting point, but should now progress to RUNNING. |
| 1683 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); | 1703 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3000)); |
| 1684 controller->UpdateState(true, events.get()); | 1704 controller->UpdateState(true, events.get()); |
| 1685 EXPECT_EQ(1u, events->events_.size()); | 1705 EXPECT_EQ(1u, events->events_.size()); |
| 1686 EXPECT_EQ(Animation::RUNNING, | 1706 EXPECT_EQ( |
| 1687 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1707 Animation::RUNNING, |
| 1708 controller->GetAnimation(AnimationTargetProperty::OPACITY)->run_state()); |
| 1688 EXPECT_EQ(0.5f, pending_dummy.opacity()); | 1709 EXPECT_EQ(0.5f, pending_dummy.opacity()); |
| 1689 EXPECT_EQ(0.5f, dummy.opacity()); | 1710 EXPECT_EQ(0.5f, dummy.opacity()); |
| 1690 | 1711 |
| 1691 // The animation should now tick past its starting point. | 1712 // The animation should now tick past its starting point. |
| 1692 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3500)); | 1713 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(3500)); |
| 1693 EXPECT_NE(0.5f, pending_dummy.opacity()); | 1714 EXPECT_NE(0.5f, pending_dummy.opacity()); |
| 1694 EXPECT_NE(0.5f, dummy.opacity()); | 1715 EXPECT_NE(0.5f, dummy.opacity()); |
| 1695 } | 1716 } |
| 1696 | 1717 |
| 1697 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { | 1718 TEST(LayerAnimationControllerTest, TransformAnimationBounds) { |
| 1698 scoped_refptr<LayerAnimationController> controller_impl( | 1719 scoped_refptr<LayerAnimationController> controller_impl( |
| 1699 LayerAnimationController::Create(0)); | 1720 LayerAnimationController::Create(0)); |
| 1700 | 1721 |
| 1701 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 1722 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
| 1702 KeyframedTransformAnimationCurve::Create()); | 1723 KeyframedTransformAnimationCurve::Create()); |
| 1703 | 1724 |
| 1704 TransformOperations operations1; | 1725 TransformOperations operations1; |
| 1705 curve1->AddKeyframe( | 1726 curve1->AddKeyframe( |
| 1706 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 1727 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 1707 operations1.AppendTranslate(10.0, 15.0, 0.0); | 1728 operations1.AppendTranslate(10.0, 15.0, 0.0); |
| 1708 curve1->AddKeyframe(TransformKeyframe::Create( | 1729 curve1->AddKeyframe(TransformKeyframe::Create( |
| 1709 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 1730 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
| 1710 | 1731 |
| 1711 scoped_ptr<Animation> animation( | 1732 scoped_ptr<Animation> animation(Animation::Create( |
| 1712 Animation::Create(std::move(curve1), 1, 1, Animation::TRANSFORM)); | 1733 std::move(curve1), 1, 1, AnimationTargetProperty::TRANSFORM)); |
| 1713 controller_impl->AddAnimation(std::move(animation)); | 1734 controller_impl->AddAnimation(std::move(animation)); |
| 1714 | 1735 |
| 1715 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 1736 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
| 1716 KeyframedTransformAnimationCurve::Create()); | 1737 KeyframedTransformAnimationCurve::Create()); |
| 1717 | 1738 |
| 1718 TransformOperations operations2; | 1739 TransformOperations operations2; |
| 1719 curve2->AddKeyframe( | 1740 curve2->AddKeyframe( |
| 1720 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 1741 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
| 1721 operations2.AppendScale(2.0, 3.0, 4.0); | 1742 operations2.AppendScale(2.0, 3.0, 4.0); |
| 1722 curve2->AddKeyframe(TransformKeyframe::Create( | 1743 curve2->AddKeyframe(TransformKeyframe::Create( |
| 1723 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 1744 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 1724 | 1745 |
| 1725 animation = Animation::Create(std::move(curve2), 2, 2, Animation::TRANSFORM); | 1746 animation = Animation::Create(std::move(curve2), 2, 2, |
| 1747 AnimationTargetProperty::TRANSFORM); |
| 1726 controller_impl->AddAnimation(std::move(animation)); | 1748 controller_impl->AddAnimation(std::move(animation)); |
| 1727 | 1749 |
| 1728 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); | 1750 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); |
| 1729 gfx::BoxF bounds; | 1751 gfx::BoxF bounds; |
| 1730 | 1752 |
| 1731 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1753 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); |
| 1732 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), | 1754 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), |
| 1733 bounds.ToString()); | 1755 bounds.ToString()); |
| 1734 | 1756 |
| 1735 controller_impl->GetAnimationById(1) | 1757 controller_impl->GetAnimationById(1) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1750 scoped_ptr<KeyframedTransformAnimationCurve> curve3( | 1772 scoped_ptr<KeyframedTransformAnimationCurve> curve3( |
| 1751 KeyframedTransformAnimationCurve::Create()); | 1773 KeyframedTransformAnimationCurve::Create()); |
| 1752 TransformOperations operations3; | 1774 TransformOperations operations3; |
| 1753 gfx::Transform transform3; | 1775 gfx::Transform transform3; |
| 1754 transform3.Scale3d(1.0, 2.0, 3.0); | 1776 transform3.Scale3d(1.0, 2.0, 3.0); |
| 1755 curve3->AddKeyframe( | 1777 curve3->AddKeyframe( |
| 1756 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 1778 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
| 1757 operations3.AppendMatrix(transform3); | 1779 operations3.AppendMatrix(transform3); |
| 1758 curve3->AddKeyframe(TransformKeyframe::Create( | 1780 curve3->AddKeyframe(TransformKeyframe::Create( |
| 1759 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); | 1781 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); |
| 1760 animation = Animation::Create(std::move(curve3), 3, 3, Animation::TRANSFORM); | 1782 animation = Animation::Create(std::move(curve3), 3, 3, |
| 1783 AnimationTargetProperty::TRANSFORM); |
| 1761 controller_impl->AddAnimation(std::move(animation)); | 1784 controller_impl->AddAnimation(std::move(animation)); |
| 1762 EXPECT_FALSE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); | 1785 EXPECT_FALSE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); |
| 1763 } | 1786 } |
| 1764 | 1787 |
| 1765 // Tests that AbortAnimations aborts all animations targeting the specified | 1788 // Tests that AbortAnimations aborts all animations targeting the specified |
| 1766 // property. | 1789 // property. |
| 1767 TEST(LayerAnimationControllerTest, AbortAnimations) { | 1790 TEST(LayerAnimationControllerTest, AbortAnimations) { |
| 1768 FakeLayerAnimationValueObserver dummy; | 1791 FakeLayerAnimationValueObserver dummy; |
| 1769 scoped_refptr<LayerAnimationController> controller( | 1792 scoped_refptr<LayerAnimationController> controller( |
| 1770 LayerAnimationController::Create(0)); | 1793 LayerAnimationController::Create(0)); |
| 1771 controller->AddValueObserver(&dummy); | 1794 controller->AddValueObserver(&dummy); |
| 1772 | 1795 |
| 1773 // Start with several animations, and allow some of them to reach the finished | 1796 // Start with several animations, and allow some of them to reach the finished |
| 1774 // state. | 1797 // state. |
| 1775 controller->AddAnimation(Animation::Create( | 1798 controller->AddAnimation(Animation::Create( |
| 1776 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1, 1, | 1799 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1, 1, |
| 1777 Animation::TRANSFORM)); | 1800 AnimationTargetProperty::TRANSFORM)); |
| 1778 controller->AddAnimation(Animation::Create( | 1801 controller->AddAnimation(Animation::Create( |
| 1779 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2, 2, | 1802 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2, 2, |
| 1780 Animation::OPACITY)); | 1803 AnimationTargetProperty::OPACITY)); |
| 1781 controller->AddAnimation(Animation::Create( | 1804 controller->AddAnimation(Animation::Create( |
| 1782 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 3, 3, | 1805 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 3, 3, |
| 1783 Animation::TRANSFORM)); | 1806 AnimationTargetProperty::TRANSFORM)); |
| 1784 controller->AddAnimation(Animation::Create( | 1807 controller->AddAnimation(Animation::Create( |
| 1785 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 4, 4, | 1808 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 4, 4, |
| 1786 Animation::TRANSFORM)); | 1809 AnimationTargetProperty::TRANSFORM)); |
| 1787 controller->AddAnimation(Animation::Create( | 1810 controller->AddAnimation(Animation::Create( |
| 1788 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 5, 5, | 1811 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 5, 5, |
| 1789 Animation::OPACITY)); | 1812 AnimationTargetProperty::OPACITY)); |
| 1790 | 1813 |
| 1791 controller->Animate(kInitialTickTime); | 1814 controller->Animate(kInitialTickTime); |
| 1792 controller->UpdateState(true, nullptr); | 1815 controller->UpdateState(true, nullptr); |
| 1793 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1816 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
| 1794 controller->UpdateState(true, nullptr); | 1817 controller->UpdateState(true, nullptr); |
| 1795 | 1818 |
| 1796 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(1)->run_state()); | 1819 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(1)->run_state()); |
| 1797 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(2)->run_state()); | 1820 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(2)->run_state()); |
| 1798 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(3)->run_state()); | 1821 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(3)->run_state()); |
| 1799 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1822 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 1800 controller->GetAnimationById(4)->run_state()); | 1823 controller->GetAnimationById(4)->run_state()); |
| 1801 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(5)->run_state()); | 1824 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(5)->run_state()); |
| 1802 | 1825 |
| 1803 controller->AbortAnimations(Animation::TRANSFORM); | 1826 controller->AbortAnimations(AnimationTargetProperty::TRANSFORM); |
| 1804 | 1827 |
| 1805 // Only un-finished TRANSFORM animations should have been aborted. | 1828 // Only un-finished TRANSFORM animations should have been aborted. |
| 1806 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(1)->run_state()); | 1829 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(1)->run_state()); |
| 1807 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(2)->run_state()); | 1830 EXPECT_EQ(Animation::FINISHED, controller->GetAnimationById(2)->run_state()); |
| 1808 EXPECT_EQ(Animation::ABORTED, controller->GetAnimationById(3)->run_state()); | 1831 EXPECT_EQ(Animation::ABORTED, controller->GetAnimationById(3)->run_state()); |
| 1809 EXPECT_EQ(Animation::ABORTED, controller->GetAnimationById(4)->run_state()); | 1832 EXPECT_EQ(Animation::ABORTED, controller->GetAnimationById(4)->run_state()); |
| 1810 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(5)->run_state()); | 1833 EXPECT_EQ(Animation::RUNNING, controller->GetAnimationById(5)->run_state()); |
| 1811 } | 1834 } |
| 1812 | 1835 |
| 1813 // An animation aborted on the main thread should get deleted on both threads. | 1836 // An animation aborted on the main thread should get deleted on both threads. |
| 1814 TEST(LayerAnimationControllerTest, MainThreadAbortedAnimationGetsDeleted) { | 1837 TEST(LayerAnimationControllerTest, MainThreadAbortedAnimationGetsDeleted) { |
| 1815 FakeLayerAnimationValueObserver dummy_impl; | 1838 FakeLayerAnimationValueObserver dummy_impl; |
| 1816 scoped_refptr<LayerAnimationController> controller_impl( | 1839 scoped_refptr<LayerAnimationController> controller_impl( |
| 1817 LayerAnimationController::Create(0)); | 1840 LayerAnimationController::Create(0)); |
| 1818 controller_impl->AddValueObserver(&dummy_impl); | 1841 controller_impl->AddValueObserver(&dummy_impl); |
| 1819 FakeLayerAnimationValueObserver dummy; | 1842 FakeLayerAnimationValueObserver dummy; |
| 1820 scoped_refptr<LayerAnimationController> controller( | 1843 scoped_refptr<LayerAnimationController> controller( |
| 1821 LayerAnimationController::Create(0)); | 1844 LayerAnimationController::Create(0)); |
| 1822 controller->AddValueObserver(&dummy); | 1845 controller->AddValueObserver(&dummy); |
| 1823 | 1846 |
| 1824 int animation_id = | 1847 int animation_id = |
| 1825 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); | 1848 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); |
| 1826 | 1849 |
| 1827 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1850 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1828 controller_impl->ActivateAnimations(); | 1851 controller_impl->ActivateAnimations(); |
| 1829 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 1852 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
| 1830 | 1853 |
| 1831 controller->AbortAnimations(Animation::OPACITY); | 1854 controller->AbortAnimations(AnimationTargetProperty::OPACITY); |
| 1832 EXPECT_EQ(Animation::ABORTED, | 1855 EXPECT_EQ( |
| 1833 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1856 Animation::ABORTED, |
| 1857 controller->GetAnimation(AnimationTargetProperty::OPACITY)->run_state()); |
| 1834 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 1858 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
| 1835 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 1859 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
| 1836 | 1860 |
| 1837 controller->Animate(kInitialTickTime); | 1861 controller->Animate(kInitialTickTime); |
| 1838 controller->UpdateState(true, nullptr); | 1862 controller->UpdateState(true, nullptr); |
| 1839 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 1863 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
| 1840 EXPECT_EQ(Animation::ABORTED, | 1864 EXPECT_EQ( |
| 1841 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1865 Animation::ABORTED, |
| 1866 controller->GetAnimation(AnimationTargetProperty::OPACITY)->run_state()); |
| 1842 | 1867 |
| 1843 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1868 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1844 EXPECT_FALSE(controller->GetAnimationById(animation_id)); | 1869 EXPECT_FALSE(controller->GetAnimationById(animation_id)); |
| 1845 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); | 1870 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); |
| 1846 } | 1871 } |
| 1847 | 1872 |
| 1848 // An animation aborted on the impl thread should get deleted on both threads. | 1873 // An animation aborted on the impl thread should get deleted on both threads. |
| 1849 TEST(LayerAnimationControllerTest, ImplThreadAbortedAnimationGetsDeleted) { | 1874 TEST(LayerAnimationControllerTest, ImplThreadAbortedAnimationGetsDeleted) { |
| 1850 FakeLayerAnimationValueObserver dummy_impl; | 1875 FakeLayerAnimationValueObserver dummy_impl; |
| 1851 scoped_refptr<LayerAnimationController> controller_impl( | 1876 scoped_refptr<LayerAnimationController> controller_impl( |
| 1852 LayerAnimationController::Create(0)); | 1877 LayerAnimationController::Create(0)); |
| 1853 controller_impl->AddValueObserver(&dummy_impl); | 1878 controller_impl->AddValueObserver(&dummy_impl); |
| 1854 FakeLayerAnimationValueObserver dummy; | 1879 FakeLayerAnimationValueObserver dummy; |
| 1855 scoped_refptr<LayerAnimationController> controller( | 1880 scoped_refptr<LayerAnimationController> controller( |
| 1856 LayerAnimationController::Create(0)); | 1881 LayerAnimationController::Create(0)); |
| 1857 controller->AddValueObserver(&dummy); | 1882 controller->AddValueObserver(&dummy); |
| 1858 FakeAnimationDelegate delegate; | 1883 FakeAnimationDelegate delegate; |
| 1859 controller->set_layer_animation_delegate(&delegate); | 1884 controller->set_layer_animation_delegate(&delegate); |
| 1860 | 1885 |
| 1861 int animation_id = | 1886 int animation_id = |
| 1862 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); | 1887 AddOpacityTransitionToController(controller.get(), 1.0, 0.f, 1.f, false); |
| 1863 | 1888 |
| 1864 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1889 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1865 controller_impl->ActivateAnimations(); | 1890 controller_impl->ActivateAnimations(); |
| 1866 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 1891 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
| 1867 | 1892 |
| 1868 controller_impl->AbortAnimations(Animation::OPACITY); | 1893 controller_impl->AbortAnimations(AnimationTargetProperty::OPACITY); |
| 1869 EXPECT_EQ(Animation::ABORTED, | 1894 EXPECT_EQ(Animation::ABORTED, |
| 1870 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); | 1895 controller_impl->GetAnimation(AnimationTargetProperty::OPACITY) |
| 1896 ->run_state()); |
| 1871 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); | 1897 EXPECT_FALSE(dummy.animation_waiting_for_deletion()); |
| 1872 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); | 1898 EXPECT_FALSE(dummy_impl.animation_waiting_for_deletion()); |
| 1873 | 1899 |
| 1874 AnimationEvents events; | 1900 AnimationEvents events; |
| 1875 controller_impl->Animate(kInitialTickTime); | 1901 controller_impl->Animate(kInitialTickTime); |
| 1876 controller_impl->UpdateState(true, &events); | 1902 controller_impl->UpdateState(true, &events); |
| 1877 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); | 1903 EXPECT_TRUE(dummy_impl.animation_waiting_for_deletion()); |
| 1878 EXPECT_EQ(1u, events.events_.size()); | 1904 EXPECT_EQ(1u, events.events_.size()); |
| 1879 EXPECT_EQ(AnimationEvent::ABORTED, events.events_[0].type); | 1905 EXPECT_EQ(AnimationEvent::ABORTED, events.events_[0].type); |
| 1880 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 1906 EXPECT_EQ(Animation::WAITING_FOR_DELETION, |
| 1881 controller_impl->GetAnimation(Animation::OPACITY)->run_state()); | 1907 controller_impl->GetAnimation(AnimationTargetProperty::OPACITY) |
| 1908 ->run_state()); |
| 1882 | 1909 |
| 1883 controller->NotifyAnimationAborted(events.events_[0]); | 1910 controller->NotifyAnimationAborted(events.events_[0]); |
| 1884 EXPECT_EQ(Animation::ABORTED, | 1911 EXPECT_EQ( |
| 1885 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1912 Animation::ABORTED, |
| 1913 controller->GetAnimation(AnimationTargetProperty::OPACITY)->run_state()); |
| 1886 EXPECT_TRUE(delegate.aborted()); | 1914 EXPECT_TRUE(delegate.aborted()); |
| 1887 | 1915 |
| 1888 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 1916 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 1889 controller->UpdateState(true, nullptr); | 1917 controller->UpdateState(true, nullptr); |
| 1890 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); | 1918 EXPECT_TRUE(dummy.animation_waiting_for_deletion()); |
| 1891 EXPECT_EQ(Animation::WAITING_FOR_DELETION, | 1919 EXPECT_EQ( |
| 1892 controller->GetAnimation(Animation::OPACITY)->run_state()); | 1920 Animation::WAITING_FOR_DELETION, |
| 1921 controller->GetAnimation(AnimationTargetProperty::OPACITY)->run_state()); |
| 1893 | 1922 |
| 1894 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1923 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1895 controller_impl->ActivateAnimations(); | 1924 controller_impl->ActivateAnimations(); |
| 1896 EXPECT_FALSE(controller->GetAnimationById(animation_id)); | 1925 EXPECT_FALSE(controller->GetAnimationById(animation_id)); |
| 1897 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); | 1926 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id)); |
| 1898 } | 1927 } |
| 1899 | 1928 |
| 1900 // Ensure that we only generate FINISHED events for animations in a group | 1929 // Ensure that we only generate FINISHED events for animations in a group |
| 1901 // once all animations in that group are finished. | 1930 // once all animations in that group are finished. |
| 1902 TEST(LayerAnimationControllerTest, FinishedEventsForGroup) { | 1931 TEST(LayerAnimationControllerTest, FinishedEventsForGroup) { |
| 1903 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1932 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1904 FakeLayerAnimationValueObserver dummy_impl; | 1933 FakeLayerAnimationValueObserver dummy_impl; |
| 1905 scoped_refptr<LayerAnimationController> controller_impl( | 1934 scoped_refptr<LayerAnimationController> controller_impl( |
| 1906 LayerAnimationController::Create(0)); | 1935 LayerAnimationController::Create(0)); |
| 1907 controller_impl->AddValueObserver(&dummy_impl); | 1936 controller_impl->AddValueObserver(&dummy_impl); |
| 1908 | 1937 |
| 1909 const int group_id = 1; | 1938 const int group_id = 1; |
| 1910 | 1939 |
| 1911 // Add two animations with the same group id but different durations. | 1940 // Add two animations with the same group id but different durations. |
| 1912 scoped_ptr<Animation> first_animation(Animation::Create( | 1941 scoped_ptr<Animation> first_animation(Animation::Create( |
| 1913 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 1, group_id, | 1942 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)), 1, group_id, |
| 1914 Animation::TRANSFORM)); | 1943 AnimationTargetProperty::TRANSFORM)); |
| 1915 first_animation->set_is_controlling_instance_for_test(true); | 1944 first_animation->set_is_controlling_instance_for_test(true); |
| 1916 controller_impl->AddAnimation(std::move(first_animation)); | 1945 controller_impl->AddAnimation(std::move(first_animation)); |
| 1917 | 1946 |
| 1918 scoped_ptr<Animation> second_animation(Animation::Create( | 1947 scoped_ptr<Animation> second_animation(Animation::Create( |
| 1919 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2, | 1948 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 2, |
| 1920 group_id, Animation::OPACITY)); | 1949 group_id, AnimationTargetProperty::OPACITY)); |
| 1921 second_animation->set_is_controlling_instance_for_test(true); | 1950 second_animation->set_is_controlling_instance_for_test(true); |
| 1922 controller_impl->AddAnimation(std::move(second_animation)); | 1951 controller_impl->AddAnimation(std::move(second_animation)); |
| 1923 | 1952 |
| 1924 controller_impl->Animate(kInitialTickTime); | 1953 controller_impl->Animate(kInitialTickTime); |
| 1925 controller_impl->UpdateState(true, events.get()); | 1954 controller_impl->UpdateState(true, events.get()); |
| 1926 | 1955 |
| 1927 // Both animations should have started. | 1956 // Both animations should have started. |
| 1928 EXPECT_EQ(2u, events->events_.size()); | 1957 EXPECT_EQ(2u, events->events_.size()); |
| 1929 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 1958 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
| 1930 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); | 1959 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1958 TEST(LayerAnimationControllerTest, FinishedAndAbortedEventsForGroup) { | 1987 TEST(LayerAnimationControllerTest, FinishedAndAbortedEventsForGroup) { |
| 1959 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); | 1988 scoped_ptr<AnimationEvents> events(make_scoped_ptr(new AnimationEvents)); |
| 1960 FakeLayerAnimationValueObserver dummy_impl; | 1989 FakeLayerAnimationValueObserver dummy_impl; |
| 1961 scoped_refptr<LayerAnimationController> controller_impl( | 1990 scoped_refptr<LayerAnimationController> controller_impl( |
| 1962 LayerAnimationController::Create(0)); | 1991 LayerAnimationController::Create(0)); |
| 1963 controller_impl->AddValueObserver(&dummy_impl); | 1992 controller_impl->AddValueObserver(&dummy_impl); |
| 1964 | 1993 |
| 1965 // Add two animations with the same group id. | 1994 // Add two animations with the same group id. |
| 1966 scoped_ptr<Animation> first_animation(CreateAnimation( | 1995 scoped_ptr<Animation> first_animation(CreateAnimation( |
| 1967 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1, | 1996 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)), 1, |
| 1968 Animation::TRANSFORM)); | 1997 AnimationTargetProperty::TRANSFORM)); |
| 1969 first_animation->set_is_controlling_instance_for_test(true); | 1998 first_animation->set_is_controlling_instance_for_test(true); |
| 1970 controller_impl->AddAnimation(std::move(first_animation)); | 1999 controller_impl->AddAnimation(std::move(first_animation)); |
| 1971 | 2000 |
| 1972 scoped_ptr<Animation> second_animation(CreateAnimation( | 2001 scoped_ptr<Animation> second_animation(CreateAnimation( |
| 1973 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 2002 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 1974 Animation::OPACITY)); | 2003 AnimationTargetProperty::OPACITY)); |
| 1975 second_animation->set_is_controlling_instance_for_test(true); | 2004 second_animation->set_is_controlling_instance_for_test(true); |
| 1976 controller_impl->AddAnimation(std::move(second_animation)); | 2005 controller_impl->AddAnimation(std::move(second_animation)); |
| 1977 | 2006 |
| 1978 controller_impl->Animate(kInitialTickTime); | 2007 controller_impl->Animate(kInitialTickTime); |
| 1979 controller_impl->UpdateState(true, events.get()); | 2008 controller_impl->UpdateState(true, events.get()); |
| 1980 | 2009 |
| 1981 // Both animations should have started. | 2010 // Both animations should have started. |
| 1982 EXPECT_EQ(2u, events->events_.size()); | 2011 EXPECT_EQ(2u, events->events_.size()); |
| 1983 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); | 2012 EXPECT_EQ(AnimationEvent::STARTED, events->events_[0].type); |
| 1984 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); | 2013 EXPECT_EQ(AnimationEvent::STARTED, events->events_[1].type); |
| 1985 | 2014 |
| 1986 controller_impl->AbortAnimations(Animation::OPACITY); | 2015 controller_impl->AbortAnimations(AnimationTargetProperty::OPACITY); |
| 1987 | 2016 |
| 1988 events.reset(new AnimationEvents); | 2017 events.reset(new AnimationEvents); |
| 1989 controller_impl->Animate(kInitialTickTime + | 2018 controller_impl->Animate(kInitialTickTime + |
| 1990 TimeDelta::FromMilliseconds(1000)); | 2019 TimeDelta::FromMilliseconds(1000)); |
| 1991 controller_impl->UpdateState(true, events.get()); | 2020 controller_impl->UpdateState(true, events.get()); |
| 1992 | 2021 |
| 1993 // We should have exactly 2 events: a FINISHED event for the tranform | 2022 // We should have exactly 2 events: a FINISHED event for the tranform |
| 1994 // animation, and an ABORTED event for the opacity animation. | 2023 // animation, and an ABORTED event for the opacity animation. |
| 1995 EXPECT_EQ(2u, events->events_.size()); | 2024 EXPECT_EQ(2u, events->events_.size()); |
| 1996 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); | 2025 EXPECT_EQ(AnimationEvent::FINISHED, events->events_[0].type); |
| 1997 EXPECT_EQ(Animation::TRANSFORM, events->events_[0].target_property); | 2026 EXPECT_EQ(AnimationTargetProperty::TRANSFORM, |
| 2027 events->events_[0].target_property); |
| 1998 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[1].type); | 2028 EXPECT_EQ(AnimationEvent::ABORTED, events->events_[1].type); |
| 1999 EXPECT_EQ(Animation::OPACITY, events->events_[1].target_property); | 2029 EXPECT_EQ(AnimationTargetProperty::OPACITY, |
| 2030 events->events_[1].target_property); |
| 2000 } | 2031 } |
| 2001 | 2032 |
| 2002 TEST(LayerAnimationControllerTest, HasAnimationThatAffectsScale) { | 2033 TEST(LayerAnimationControllerTest, HasAnimationThatAffectsScale) { |
| 2003 scoped_refptr<LayerAnimationController> controller_impl( | 2034 scoped_refptr<LayerAnimationController> controller_impl( |
| 2004 LayerAnimationController::Create(0)); | 2035 LayerAnimationController::Create(0)); |
| 2005 | 2036 |
| 2006 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); | 2037 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); |
| 2007 | 2038 |
| 2008 controller_impl->AddAnimation(CreateAnimation( | 2039 controller_impl->AddAnimation(CreateAnimation( |
| 2009 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 2040 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 2010 Animation::OPACITY)); | 2041 AnimationTargetProperty::OPACITY)); |
| 2011 | 2042 |
| 2012 // Opacity animations don't affect scale. | 2043 // Opacity animations don't affect scale. |
| 2013 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); | 2044 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); |
| 2014 | 2045 |
| 2015 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 2046 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
| 2016 KeyframedTransformAnimationCurve::Create()); | 2047 KeyframedTransformAnimationCurve::Create()); |
| 2017 | 2048 |
| 2018 TransformOperations operations1; | 2049 TransformOperations operations1; |
| 2019 curve1->AddKeyframe( | 2050 curve1->AddKeyframe( |
| 2020 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2051 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 2021 operations1.AppendTranslate(10.0, 15.0, 0.0); | 2052 operations1.AppendTranslate(10.0, 15.0, 0.0); |
| 2022 curve1->AddKeyframe(TransformKeyframe::Create( | 2053 curve1->AddKeyframe(TransformKeyframe::Create( |
| 2023 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 2054 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
| 2024 | 2055 |
| 2025 scoped_ptr<Animation> animation( | 2056 scoped_ptr<Animation> animation(Animation::Create( |
| 2026 Animation::Create(std::move(curve1), 2, 2, Animation::TRANSFORM)); | 2057 std::move(curve1), 2, 2, AnimationTargetProperty::TRANSFORM)); |
| 2027 controller_impl->AddAnimation(std::move(animation)); | 2058 controller_impl->AddAnimation(std::move(animation)); |
| 2028 | 2059 |
| 2029 // Translations don't affect scale. | 2060 // Translations don't affect scale. |
| 2030 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); | 2061 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); |
| 2031 | 2062 |
| 2032 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 2063 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
| 2033 KeyframedTransformAnimationCurve::Create()); | 2064 KeyframedTransformAnimationCurve::Create()); |
| 2034 | 2065 |
| 2035 TransformOperations operations2; | 2066 TransformOperations operations2; |
| 2036 curve2->AddKeyframe( | 2067 curve2->AddKeyframe( |
| 2037 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 2068 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
| 2038 operations2.AppendScale(2.0, 3.0, 4.0); | 2069 operations2.AppendScale(2.0, 3.0, 4.0); |
| 2039 curve2->AddKeyframe(TransformKeyframe::Create( | 2070 curve2->AddKeyframe(TransformKeyframe::Create( |
| 2040 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2071 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 2041 | 2072 |
| 2042 animation = Animation::Create(std::move(curve2), 3, 3, Animation::TRANSFORM); | 2073 animation = Animation::Create(std::move(curve2), 3, 3, |
| 2074 AnimationTargetProperty::TRANSFORM); |
| 2043 controller_impl->AddAnimation(std::move(animation)); | 2075 controller_impl->AddAnimation(std::move(animation)); |
| 2044 | 2076 |
| 2045 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); | 2077 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); |
| 2046 | 2078 |
| 2047 controller_impl->GetAnimationById(3) | 2079 controller_impl->GetAnimationById(3) |
| 2048 ->SetRunState(Animation::FINISHED, TicksFromSecondsF(0.0)); | 2080 ->SetRunState(Animation::FINISHED, TicksFromSecondsF(0.0)); |
| 2049 | 2081 |
| 2050 // Only unfinished animations should be considered by | 2082 // Only unfinished animations should be considered by |
| 2051 // HasAnimationThatAffectsScale. | 2083 // HasAnimationThatAffectsScale. |
| 2052 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); | 2084 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); |
| 2053 } | 2085 } |
| 2054 | 2086 |
| 2055 TEST(LayerAnimationControllerTest, HasOnlyTranslationTransforms) { | 2087 TEST(LayerAnimationControllerTest, HasOnlyTranslationTransforms) { |
| 2056 scoped_refptr<LayerAnimationController> controller_impl( | 2088 scoped_refptr<LayerAnimationController> controller_impl( |
| 2057 LayerAnimationController::Create(0)); | 2089 LayerAnimationController::Create(0)); |
| 2058 | 2090 |
| 2059 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( | 2091 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( |
| 2060 LayerAnimationController::ObserverType::ACTIVE)); | 2092 LayerAnimationController::ObserverType::ACTIVE)); |
| 2061 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( | 2093 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( |
| 2062 LayerAnimationController::ObserverType::PENDING)); | 2094 LayerAnimationController::ObserverType::PENDING)); |
| 2063 | 2095 |
| 2064 controller_impl->AddAnimation(CreateAnimation( | 2096 controller_impl->AddAnimation(CreateAnimation( |
| 2065 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 2097 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 2066 Animation::OPACITY)); | 2098 AnimationTargetProperty::OPACITY)); |
| 2067 | 2099 |
| 2068 // Opacity animations aren't non-translation transforms. | 2100 // Opacity animations aren't non-translation transforms. |
| 2069 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( | 2101 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( |
| 2070 LayerAnimationController::ObserverType::ACTIVE)); | 2102 LayerAnimationController::ObserverType::ACTIVE)); |
| 2071 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( | 2103 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( |
| 2072 LayerAnimationController::ObserverType::PENDING)); | 2104 LayerAnimationController::ObserverType::PENDING)); |
| 2073 | 2105 |
| 2074 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 2106 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
| 2075 KeyframedTransformAnimationCurve::Create()); | 2107 KeyframedTransformAnimationCurve::Create()); |
| 2076 | 2108 |
| 2077 TransformOperations operations1; | 2109 TransformOperations operations1; |
| 2078 curve1->AddKeyframe( | 2110 curve1->AddKeyframe( |
| 2079 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2111 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 2080 operations1.AppendTranslate(10.0, 15.0, 0.0); | 2112 operations1.AppendTranslate(10.0, 15.0, 0.0); |
| 2081 curve1->AddKeyframe(TransformKeyframe::Create( | 2113 curve1->AddKeyframe(TransformKeyframe::Create( |
| 2082 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 2114 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
| 2083 | 2115 |
| 2084 scoped_ptr<Animation> animation( | 2116 scoped_ptr<Animation> animation(Animation::Create( |
| 2085 Animation::Create(std::move(curve1), 2, 2, Animation::TRANSFORM)); | 2117 std::move(curve1), 2, 2, AnimationTargetProperty::TRANSFORM)); |
| 2086 controller_impl->AddAnimation(std::move(animation)); | 2118 controller_impl->AddAnimation(std::move(animation)); |
| 2087 | 2119 |
| 2088 // The only transform animation we've added is a translation. | 2120 // The only transform animation we've added is a translation. |
| 2089 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( | 2121 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( |
| 2090 LayerAnimationController::ObserverType::ACTIVE)); | 2122 LayerAnimationController::ObserverType::ACTIVE)); |
| 2091 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( | 2123 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( |
| 2092 LayerAnimationController::ObserverType::PENDING)); | 2124 LayerAnimationController::ObserverType::PENDING)); |
| 2093 | 2125 |
| 2094 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 2126 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
| 2095 KeyframedTransformAnimationCurve::Create()); | 2127 KeyframedTransformAnimationCurve::Create()); |
| 2096 | 2128 |
| 2097 TransformOperations operations2; | 2129 TransformOperations operations2; |
| 2098 curve2->AddKeyframe( | 2130 curve2->AddKeyframe( |
| 2099 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 2131 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
| 2100 operations2.AppendScale(2.0, 3.0, 4.0); | 2132 operations2.AppendScale(2.0, 3.0, 4.0); |
| 2101 curve2->AddKeyframe(TransformKeyframe::Create( | 2133 curve2->AddKeyframe(TransformKeyframe::Create( |
| 2102 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2134 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 2103 | 2135 |
| 2104 animation = Animation::Create(std::move(curve2), 3, 3, Animation::TRANSFORM); | 2136 animation = Animation::Create(std::move(curve2), 3, 3, |
| 2137 AnimationTargetProperty::TRANSFORM); |
| 2105 animation->set_affects_active_observers(false); | 2138 animation->set_affects_active_observers(false); |
| 2106 controller_impl->AddAnimation(std::move(animation)); | 2139 controller_impl->AddAnimation(std::move(animation)); |
| 2107 | 2140 |
| 2108 // A scale animation is not a translation. | 2141 // A scale animation is not a translation. |
| 2109 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms( | 2142 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms( |
| 2110 LayerAnimationController::ObserverType::PENDING)); | 2143 LayerAnimationController::ObserverType::PENDING)); |
| 2111 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( | 2144 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms( |
| 2112 LayerAnimationController::ObserverType::ACTIVE)); | 2145 LayerAnimationController::ObserverType::ACTIVE)); |
| 2113 | 2146 |
| 2114 controller_impl->ActivateAnimations(); | 2147 controller_impl->ActivateAnimations(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2140 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 2173 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
| 2141 KeyframedTransformAnimationCurve::Create()); | 2174 KeyframedTransformAnimationCurve::Create()); |
| 2142 | 2175 |
| 2143 TransformOperations operations1; | 2176 TransformOperations operations1; |
| 2144 operations1.AppendScale(2.0, 3.0, 4.0); | 2177 operations1.AppendScale(2.0, 3.0, 4.0); |
| 2145 curve1->AddKeyframe( | 2178 curve1->AddKeyframe( |
| 2146 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2179 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 2147 TransformOperations operations2; | 2180 TransformOperations operations2; |
| 2148 curve1->AddKeyframe(TransformKeyframe::Create( | 2181 curve1->AddKeyframe(TransformKeyframe::Create( |
| 2149 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2182 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 2150 scoped_ptr<Animation> animation( | 2183 scoped_ptr<Animation> animation(Animation::Create( |
| 2151 Animation::Create(std::move(curve1), 1, 1, Animation::TRANSFORM)); | 2184 std::move(curve1), 1, 1, AnimationTargetProperty::TRANSFORM)); |
| 2152 animation->set_affects_active_observers(false); | 2185 animation->set_affects_active_observers(false); |
| 2153 controller_impl->AddAnimation(std::move(animation)); | 2186 controller_impl->AddAnimation(std::move(animation)); |
| 2154 | 2187 |
| 2155 float start_scale = 0.f; | 2188 float start_scale = 0.f; |
| 2156 EXPECT_TRUE(controller_impl->AnimationStartScale( | 2189 EXPECT_TRUE(controller_impl->AnimationStartScale( |
| 2157 LayerAnimationController::ObserverType::PENDING, &start_scale)); | 2190 LayerAnimationController::ObserverType::PENDING, &start_scale)); |
| 2158 EXPECT_EQ(4.f, start_scale); | 2191 EXPECT_EQ(4.f, start_scale); |
| 2159 EXPECT_TRUE(controller_impl->AnimationStartScale( | 2192 EXPECT_TRUE(controller_impl->AnimationStartScale( |
| 2160 LayerAnimationController::ObserverType::ACTIVE, &start_scale)); | 2193 LayerAnimationController::ObserverType::ACTIVE, &start_scale)); |
| 2161 EXPECT_EQ(0.f, start_scale); | 2194 EXPECT_EQ(0.f, start_scale); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2172 KeyframedTransformAnimationCurve::Create()); | 2205 KeyframedTransformAnimationCurve::Create()); |
| 2173 | 2206 |
| 2174 TransformOperations operations3; | 2207 TransformOperations operations3; |
| 2175 curve2->AddKeyframe( | 2208 curve2->AddKeyframe( |
| 2176 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 2209 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
| 2177 operations3.AppendScale(6.0, 5.0, 4.0); | 2210 operations3.AppendScale(6.0, 5.0, 4.0); |
| 2178 curve2->AddKeyframe(TransformKeyframe::Create( | 2211 curve2->AddKeyframe(TransformKeyframe::Create( |
| 2179 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); | 2212 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); |
| 2180 | 2213 |
| 2181 controller_impl->RemoveAnimation(1); | 2214 controller_impl->RemoveAnimation(1); |
| 2182 animation = Animation::Create(std::move(curve2), 2, 2, Animation::TRANSFORM); | 2215 animation = Animation::Create(std::move(curve2), 2, 2, |
| 2216 AnimationTargetProperty::TRANSFORM); |
| 2183 | 2217 |
| 2184 // Reverse Direction | 2218 // Reverse Direction |
| 2185 animation->set_direction(Animation::DIRECTION_REVERSE); | 2219 animation->set_direction(Animation::DIRECTION_REVERSE); |
| 2186 animation->set_affects_active_observers(false); | 2220 animation->set_affects_active_observers(false); |
| 2187 controller_impl->AddAnimation(std::move(animation)); | 2221 controller_impl->AddAnimation(std::move(animation)); |
| 2188 | 2222 |
| 2189 scoped_ptr<KeyframedTransformAnimationCurve> curve3( | 2223 scoped_ptr<KeyframedTransformAnimationCurve> curve3( |
| 2190 KeyframedTransformAnimationCurve::Create()); | 2224 KeyframedTransformAnimationCurve::Create()); |
| 2191 | 2225 |
| 2192 TransformOperations operations4; | 2226 TransformOperations operations4; |
| 2193 operations4.AppendScale(5.0, 3.0, 1.0); | 2227 operations4.AppendScale(5.0, 3.0, 1.0); |
| 2194 curve3->AddKeyframe( | 2228 curve3->AddKeyframe( |
| 2195 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr)); | 2229 TransformKeyframe::Create(base::TimeDelta(), operations4, nullptr)); |
| 2196 TransformOperations operations5; | 2230 TransformOperations operations5; |
| 2197 curve3->AddKeyframe(TransformKeyframe::Create( | 2231 curve3->AddKeyframe(TransformKeyframe::Create( |
| 2198 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr)); | 2232 base::TimeDelta::FromSecondsD(1.0), operations5, nullptr)); |
| 2199 | 2233 |
| 2200 animation = Animation::Create(std::move(curve3), 3, 3, Animation::TRANSFORM); | 2234 animation = Animation::Create(std::move(curve3), 3, 3, |
| 2235 AnimationTargetProperty::TRANSFORM); |
| 2201 animation->set_affects_active_observers(false); | 2236 animation->set_affects_active_observers(false); |
| 2202 controller_impl->AddAnimation(std::move(animation)); | 2237 controller_impl->AddAnimation(std::move(animation)); |
| 2203 | 2238 |
| 2204 EXPECT_TRUE(controller_impl->AnimationStartScale( | 2239 EXPECT_TRUE(controller_impl->AnimationStartScale( |
| 2205 LayerAnimationController::ObserverType::PENDING, &start_scale)); | 2240 LayerAnimationController::ObserverType::PENDING, &start_scale)); |
| 2206 EXPECT_EQ(6.f, start_scale); | 2241 EXPECT_EQ(6.f, start_scale); |
| 2207 EXPECT_TRUE(controller_impl->AnimationStartScale( | 2242 EXPECT_TRUE(controller_impl->AnimationStartScale( |
| 2208 LayerAnimationController::ObserverType::ACTIVE, &start_scale)); | 2243 LayerAnimationController::ObserverType::ACTIVE, &start_scale)); |
| 2209 EXPECT_EQ(0.f, start_scale); | 2244 EXPECT_EQ(0.f, start_scale); |
| 2210 | 2245 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2244 scoped_ptr<KeyframedTransformAnimationCurve> curve1( | 2279 scoped_ptr<KeyframedTransformAnimationCurve> curve1( |
| 2245 KeyframedTransformAnimationCurve::Create()); | 2280 KeyframedTransformAnimationCurve::Create()); |
| 2246 | 2281 |
| 2247 TransformOperations operations1; | 2282 TransformOperations operations1; |
| 2248 curve1->AddKeyframe( | 2283 curve1->AddKeyframe( |
| 2249 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2284 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 2250 operations1.AppendScale(2.0, 3.0, 4.0); | 2285 operations1.AppendScale(2.0, 3.0, 4.0); |
| 2251 curve1->AddKeyframe(TransformKeyframe::Create( | 2286 curve1->AddKeyframe(TransformKeyframe::Create( |
| 2252 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); | 2287 base::TimeDelta::FromSecondsD(1.0), operations1, nullptr)); |
| 2253 | 2288 |
| 2254 scoped_ptr<Animation> animation( | 2289 scoped_ptr<Animation> animation(Animation::Create( |
| 2255 Animation::Create(std::move(curve1), 1, 1, Animation::TRANSFORM)); | 2290 std::move(curve1), 1, 1, AnimationTargetProperty::TRANSFORM)); |
| 2256 animation->set_affects_active_observers(false); | 2291 animation->set_affects_active_observers(false); |
| 2257 controller_impl->AddAnimation(std::move(animation)); | 2292 controller_impl->AddAnimation(std::move(animation)); |
| 2258 | 2293 |
| 2259 EXPECT_TRUE(controller_impl->MaximumTargetScale( | 2294 EXPECT_TRUE(controller_impl->MaximumTargetScale( |
| 2260 LayerAnimationController::ObserverType::PENDING, &max_scale)); | 2295 LayerAnimationController::ObserverType::PENDING, &max_scale)); |
| 2261 EXPECT_EQ(4.f, max_scale); | 2296 EXPECT_EQ(4.f, max_scale); |
| 2262 EXPECT_TRUE(controller_impl->MaximumTargetScale( | 2297 EXPECT_TRUE(controller_impl->MaximumTargetScale( |
| 2263 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); | 2298 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); |
| 2264 EXPECT_EQ(0.f, max_scale); | 2299 EXPECT_EQ(0.f, max_scale); |
| 2265 | 2300 |
| 2266 controller_impl->ActivateAnimations(); | 2301 controller_impl->ActivateAnimations(); |
| 2267 EXPECT_TRUE(controller_impl->MaximumTargetScale( | 2302 EXPECT_TRUE(controller_impl->MaximumTargetScale( |
| 2268 LayerAnimationController::ObserverType::PENDING, &max_scale)); | 2303 LayerAnimationController::ObserverType::PENDING, &max_scale)); |
| 2269 EXPECT_EQ(4.f, max_scale); | 2304 EXPECT_EQ(4.f, max_scale); |
| 2270 EXPECT_TRUE(controller_impl->MaximumTargetScale( | 2305 EXPECT_TRUE(controller_impl->MaximumTargetScale( |
| 2271 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); | 2306 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); |
| 2272 EXPECT_EQ(4.f, max_scale); | 2307 EXPECT_EQ(4.f, max_scale); |
| 2273 | 2308 |
| 2274 scoped_ptr<KeyframedTransformAnimationCurve> curve2( | 2309 scoped_ptr<KeyframedTransformAnimationCurve> curve2( |
| 2275 KeyframedTransformAnimationCurve::Create()); | 2310 KeyframedTransformAnimationCurve::Create()); |
| 2276 | 2311 |
| 2277 TransformOperations operations2; | 2312 TransformOperations operations2; |
| 2278 curve2->AddKeyframe( | 2313 curve2->AddKeyframe( |
| 2279 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); | 2314 TransformKeyframe::Create(base::TimeDelta(), operations2, nullptr)); |
| 2280 operations2.AppendScale(6.0, 5.0, 4.0); | 2315 operations2.AppendScale(6.0, 5.0, 4.0); |
| 2281 curve2->AddKeyframe(TransformKeyframe::Create( | 2316 curve2->AddKeyframe(TransformKeyframe::Create( |
| 2282 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2317 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 2283 | 2318 |
| 2284 animation = Animation::Create(std::move(curve2), 2, 2, Animation::TRANSFORM); | 2319 animation = Animation::Create(std::move(curve2), 2, 2, |
| 2320 AnimationTargetProperty::TRANSFORM); |
| 2285 animation->set_affects_active_observers(false); | 2321 animation->set_affects_active_observers(false); |
| 2286 controller_impl->AddAnimation(std::move(animation)); | 2322 controller_impl->AddAnimation(std::move(animation)); |
| 2287 | 2323 |
| 2288 EXPECT_TRUE(controller_impl->MaximumTargetScale( | 2324 EXPECT_TRUE(controller_impl->MaximumTargetScale( |
| 2289 LayerAnimationController::ObserverType::PENDING, &max_scale)); | 2325 LayerAnimationController::ObserverType::PENDING, &max_scale)); |
| 2290 EXPECT_EQ(6.f, max_scale); | 2326 EXPECT_EQ(6.f, max_scale); |
| 2291 EXPECT_TRUE(controller_impl->MaximumTargetScale( | 2327 EXPECT_TRUE(controller_impl->MaximumTargetScale( |
| 2292 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); | 2328 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); |
| 2293 EXPECT_EQ(4.f, max_scale); | 2329 EXPECT_EQ(4.f, max_scale); |
| 2294 | 2330 |
| 2295 controller_impl->ActivateAnimations(); | 2331 controller_impl->ActivateAnimations(); |
| 2296 EXPECT_TRUE(controller_impl->MaximumTargetScale( | 2332 EXPECT_TRUE(controller_impl->MaximumTargetScale( |
| 2297 LayerAnimationController::ObserverType::PENDING, &max_scale)); | 2333 LayerAnimationController::ObserverType::PENDING, &max_scale)); |
| 2298 EXPECT_EQ(6.f, max_scale); | 2334 EXPECT_EQ(6.f, max_scale); |
| 2299 EXPECT_TRUE(controller_impl->MaximumTargetScale( | 2335 EXPECT_TRUE(controller_impl->MaximumTargetScale( |
| 2300 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); | 2336 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); |
| 2301 EXPECT_EQ(6.f, max_scale); | 2337 EXPECT_EQ(6.f, max_scale); |
| 2302 | 2338 |
| 2303 scoped_ptr<KeyframedTransformAnimationCurve> curve3( | 2339 scoped_ptr<KeyframedTransformAnimationCurve> curve3( |
| 2304 KeyframedTransformAnimationCurve::Create()); | 2340 KeyframedTransformAnimationCurve::Create()); |
| 2305 | 2341 |
| 2306 TransformOperations operations3; | 2342 TransformOperations operations3; |
| 2307 curve3->AddKeyframe( | 2343 curve3->AddKeyframe( |
| 2308 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); | 2344 TransformKeyframe::Create(base::TimeDelta(), operations3, nullptr)); |
| 2309 operations3.AppendPerspective(6.0); | 2345 operations3.AppendPerspective(6.0); |
| 2310 curve3->AddKeyframe(TransformKeyframe::Create( | 2346 curve3->AddKeyframe(TransformKeyframe::Create( |
| 2311 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); | 2347 base::TimeDelta::FromSecondsD(1.0), operations3, nullptr)); |
| 2312 | 2348 |
| 2313 animation = Animation::Create(std::move(curve3), 3, 3, Animation::TRANSFORM); | 2349 animation = Animation::Create(std::move(curve3), 3, 3, |
| 2350 AnimationTargetProperty::TRANSFORM); |
| 2314 animation->set_affects_active_observers(false); | 2351 animation->set_affects_active_observers(false); |
| 2315 controller_impl->AddAnimation(std::move(animation)); | 2352 controller_impl->AddAnimation(std::move(animation)); |
| 2316 | 2353 |
| 2317 EXPECT_FALSE(controller_impl->MaximumTargetScale( | 2354 EXPECT_FALSE(controller_impl->MaximumTargetScale( |
| 2318 LayerAnimationController::ObserverType::PENDING, &max_scale)); | 2355 LayerAnimationController::ObserverType::PENDING, &max_scale)); |
| 2319 EXPECT_TRUE(controller_impl->MaximumTargetScale( | 2356 EXPECT_TRUE(controller_impl->MaximumTargetScale( |
| 2320 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); | 2357 LayerAnimationController::ObserverType::ACTIVE, &max_scale)); |
| 2321 EXPECT_EQ(6.f, max_scale); | 2358 EXPECT_EQ(6.f, max_scale); |
| 2322 | 2359 |
| 2323 controller_impl->ActivateAnimations(); | 2360 controller_impl->ActivateAnimations(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2349 KeyframedTransformAnimationCurve::Create()); | 2386 KeyframedTransformAnimationCurve::Create()); |
| 2350 TransformOperations operations1; | 2387 TransformOperations operations1; |
| 2351 operations1.AppendScale(1.0, 2.0, 3.0); | 2388 operations1.AppendScale(1.0, 2.0, 3.0); |
| 2352 curve1->AddKeyframe( | 2389 curve1->AddKeyframe( |
| 2353 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); | 2390 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr)); |
| 2354 TransformOperations operations2; | 2391 TransformOperations operations2; |
| 2355 operations2.AppendScale(4.0, 5.0, 6.0); | 2392 operations2.AppendScale(4.0, 5.0, 6.0); |
| 2356 curve1->AddKeyframe(TransformKeyframe::Create( | 2393 curve1->AddKeyframe(TransformKeyframe::Create( |
| 2357 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); | 2394 base::TimeDelta::FromSecondsD(1.0), operations2, nullptr)); |
| 2358 | 2395 |
| 2359 scoped_ptr<Animation> animation_owned( | 2396 scoped_ptr<Animation> animation_owned(Animation::Create( |
| 2360 Animation::Create(std::move(curve1), 1, 1, Animation::TRANSFORM)); | 2397 std::move(curve1), 1, 1, AnimationTargetProperty::TRANSFORM)); |
| 2361 Animation* animation = animation_owned.get(); | 2398 Animation* animation = animation_owned.get(); |
| 2362 controller_impl->AddAnimation(std::move(animation_owned)); | 2399 controller_impl->AddAnimation(std::move(animation_owned)); |
| 2363 | 2400 |
| 2364 float max_scale = 0.f; | 2401 float max_scale = 0.f; |
| 2365 | 2402 |
| 2366 EXPECT_GT(animation->playback_rate(), 0.0); | 2403 EXPECT_GT(animation->playback_rate(), 0.0); |
| 2367 | 2404 |
| 2368 // NORMAL direction with positive playback rate. | 2405 // NORMAL direction with positive playback rate. |
| 2369 animation->set_direction(Animation::DIRECTION_NORMAL); | 2406 animation->set_direction(Animation::DIRECTION_NORMAL); |
| 2370 EXPECT_TRUE(controller_impl->MaximumTargetScale( | 2407 EXPECT_TRUE(controller_impl->MaximumTargetScale( |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2654 EXPECT_TRUE(pending_dummy_impl.transform_is_animating()); | 2691 EXPECT_TRUE(pending_dummy_impl.transform_is_animating()); |
| 2655 EXPECT_TRUE(active_dummy_impl.transform_is_animating()); | 2692 EXPECT_TRUE(active_dummy_impl.transform_is_animating()); |
| 2656 | 2693 |
| 2657 controller_impl->Animate(kInitialTickTime + | 2694 controller_impl->Animate(kInitialTickTime + |
| 2658 TimeDelta::FromMilliseconds(3000)); | 2695 TimeDelta::FromMilliseconds(3000)); |
| 2659 controller_impl->UpdateState(true, &events); | 2696 controller_impl->UpdateState(true, &events); |
| 2660 | 2697 |
| 2661 controller->NotifyAnimationStarted(events.events_[0]); | 2698 controller->NotifyAnimationStarted(events.events_[0]); |
| 2662 events.events_.clear(); | 2699 events.events_.clear(); |
| 2663 | 2700 |
| 2664 controller_impl->AbortAnimations(Animation::TRANSFORM); | 2701 controller_impl->AbortAnimations(AnimationTargetProperty::TRANSFORM); |
| 2665 EXPECT_FALSE(pending_dummy_impl.transform_is_animating()); | 2702 EXPECT_FALSE(pending_dummy_impl.transform_is_animating()); |
| 2666 EXPECT_FALSE(active_dummy_impl.transform_is_animating()); | 2703 EXPECT_FALSE(active_dummy_impl.transform_is_animating()); |
| 2667 | 2704 |
| 2668 controller_impl->Animate(kInitialTickTime + | 2705 controller_impl->Animate(kInitialTickTime + |
| 2669 TimeDelta::FromMilliseconds(4000)); | 2706 TimeDelta::FromMilliseconds(4000)); |
| 2670 controller_impl->UpdateState(true, &events); | 2707 controller_impl->UpdateState(true, &events); |
| 2671 | 2708 |
| 2672 controller->NotifyAnimationAborted(events.events_[0]); | 2709 controller->NotifyAnimationAborted(events.events_[0]); |
| 2673 EXPECT_FALSE(dummy.transform_is_animating()); | 2710 EXPECT_FALSE(dummy.transform_is_animating()); |
| 2674 } | 2711 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2730 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); | 2767 EXPECT_EQ(0.5f, pending_dummy_impl.opacity()); |
| 2731 EXPECT_EQ(0.5f, dummy_impl.opacity()); | 2768 EXPECT_EQ(0.5f, dummy_impl.opacity()); |
| 2732 | 2769 |
| 2733 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) | 2770 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) |
| 2734 ->affects_pending_observers()); | 2771 ->affects_pending_observers()); |
| 2735 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) | 2772 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) |
| 2736 ->affects_active_observers()); | 2773 ->affects_active_observers()); |
| 2737 | 2774 |
| 2738 // Delete the animation on the main-thread controller. | 2775 // Delete the animation on the main-thread controller. |
| 2739 controller->RemoveAnimation( | 2776 controller->RemoveAnimation( |
| 2740 controller->GetAnimation(Animation::OPACITY)->id()); | 2777 controller->GetAnimation(AnimationTargetProperty::OPACITY)->id()); |
| 2741 controller->PushAnimationUpdatesTo(controller_impl.get()); | 2778 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 2742 | 2779 |
| 2743 // The animation should no longer affect pending observers. | 2780 // The animation should no longer affect pending observers. |
| 2744 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id) | 2781 EXPECT_FALSE(controller_impl->GetAnimationById(animation_id) |
| 2745 ->affects_pending_observers()); | 2782 ->affects_pending_observers()); |
| 2746 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) | 2783 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id) |
| 2747 ->affects_active_observers()); | 2784 ->affects_active_observers()); |
| 2748 | 2785 |
| 2749 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); | 2786 controller_impl->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(500)); |
| 2750 controller_impl->UpdateState(true, events.get()); | 2787 controller_impl->UpdateState(true, events.get()); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 2778 AddOpacityTransitionToController(controller.get(), 1, 0.f, 1.f, true); | 2815 AddOpacityTransitionToController(controller.get(), 1, 0.f, 1.f, true); |
| 2779 | 2816 |
| 2780 controller->PushAnimationUpdatesTo(controller_impl.get()); | 2817 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 2781 controller_impl->ActivateAnimations(); | 2818 controller_impl->ActivateAnimations(); |
| 2782 controller_impl->Animate(kInitialTickTime); | 2819 controller_impl->Animate(kInitialTickTime); |
| 2783 controller_impl->UpdateState(true, events.get()); | 2820 controller_impl->UpdateState(true, events.get()); |
| 2784 | 2821 |
| 2785 // Remove the first animation from the main-thread controller, and add a | 2822 // Remove the first animation from the main-thread controller, and add a |
| 2786 // new animation affecting the same property. | 2823 // new animation affecting the same property. |
| 2787 controller->RemoveAnimation( | 2824 controller->RemoveAnimation( |
| 2788 controller->GetAnimation(Animation::OPACITY)->id()); | 2825 controller->GetAnimation(AnimationTargetProperty::OPACITY)->id()); |
| 2789 int second_animation_id = | 2826 int second_animation_id = |
| 2790 AddOpacityTransitionToController(controller.get(), 1, 1.f, 0.5f, true); | 2827 AddOpacityTransitionToController(controller.get(), 1, 1.f, 0.5f, true); |
| 2791 controller->PushAnimationUpdatesTo(controller_impl.get()); | 2828 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 2792 | 2829 |
| 2793 // The original animation should only affect active observers, and the new | 2830 // The original animation should only affect active observers, and the new |
| 2794 // animation should only affect pending observers. | 2831 // animation should only affect pending observers. |
| 2795 EXPECT_FALSE(controller_impl->GetAnimationById(first_animation_id) | 2832 EXPECT_FALSE(controller_impl->GetAnimationById(first_animation_id) |
| 2796 ->affects_pending_observers()); | 2833 ->affects_pending_observers()); |
| 2797 EXPECT_TRUE(controller_impl->GetAnimationById(first_animation_id) | 2834 EXPECT_TRUE(controller_impl->GetAnimationById(first_animation_id) |
| 2798 ->affects_active_observers()); | 2835 ->affects_active_observers()); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2842 | 2879 |
| 2843 TEST(LayerAnimationControllerTest, TestIsCurrentlyAnimatingProperty) { | 2880 TEST(LayerAnimationControllerTest, TestIsCurrentlyAnimatingProperty) { |
| 2844 FakeLayerAnimationValueObserver dummy; | 2881 FakeLayerAnimationValueObserver dummy; |
| 2845 scoped_refptr<LayerAnimationController> controller( | 2882 scoped_refptr<LayerAnimationController> controller( |
| 2846 LayerAnimationController::Create(0)); | 2883 LayerAnimationController::Create(0)); |
| 2847 controller->AddValueObserver(&dummy); | 2884 controller->AddValueObserver(&dummy); |
| 2848 | 2885 |
| 2849 // Create an animation that initially affects only pending observers. | 2886 // Create an animation that initially affects only pending observers. |
| 2850 scoped_ptr<Animation> animation(CreateAnimation( | 2887 scoped_ptr<Animation> animation(CreateAnimation( |
| 2851 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 2888 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 2852 Animation::OPACITY)); | 2889 AnimationTargetProperty::OPACITY)); |
| 2853 animation->set_affects_active_observers(false); | 2890 animation->set_affects_active_observers(false); |
| 2854 | 2891 |
| 2855 controller->AddAnimation(std::move(animation)); | 2892 controller->AddAnimation(std::move(animation)); |
| 2856 controller->Animate(kInitialTickTime); | 2893 controller->Animate(kInitialTickTime); |
| 2857 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( | 2894 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( |
| 2858 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 2895 AnimationTargetProperty::OPACITY, |
| 2896 LayerAnimationController::ObserverType::PENDING)); |
| 2859 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 2897 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2860 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 2898 AnimationTargetProperty::OPACITY, |
| 2899 LayerAnimationController::ObserverType::ACTIVE)); |
| 2861 controller->UpdateState(true, nullptr); | 2900 controller->UpdateState(true, nullptr); |
| 2862 EXPECT_TRUE(controller->HasActiveAnimation()); | 2901 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 2863 | 2902 |
| 2864 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( | 2903 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( |
| 2865 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 2904 AnimationTargetProperty::OPACITY, |
| 2905 LayerAnimationController::ObserverType::PENDING)); |
| 2866 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 2906 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2867 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 2907 AnimationTargetProperty::OPACITY, |
| 2908 LayerAnimationController::ObserverType::ACTIVE)); |
| 2868 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 2909 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2869 Animation::FILTER, LayerAnimationController::ObserverType::PENDING)); | 2910 AnimationTargetProperty::FILTER, |
| 2911 LayerAnimationController::ObserverType::PENDING)); |
| 2870 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 2912 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2871 Animation::FILTER, LayerAnimationController::ObserverType::ACTIVE)); | 2913 AnimationTargetProperty::FILTER, |
| 2914 LayerAnimationController::ObserverType::ACTIVE)); |
| 2872 | 2915 |
| 2873 controller->ActivateAnimations(); | 2916 controller->ActivateAnimations(); |
| 2874 | 2917 |
| 2875 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( | 2918 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( |
| 2876 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 2919 AnimationTargetProperty::OPACITY, |
| 2920 LayerAnimationController::ObserverType::PENDING)); |
| 2877 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( | 2921 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( |
| 2878 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 2922 AnimationTargetProperty::OPACITY, |
| 2923 LayerAnimationController::ObserverType::ACTIVE)); |
| 2879 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 2924 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2880 Animation::FILTER, LayerAnimationController::ObserverType::PENDING)); | 2925 AnimationTargetProperty::FILTER, |
| 2926 LayerAnimationController::ObserverType::PENDING)); |
| 2881 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 2927 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2882 Animation::FILTER, LayerAnimationController::ObserverType::ACTIVE)); | 2928 AnimationTargetProperty::FILTER, |
| 2929 LayerAnimationController::ObserverType::ACTIVE)); |
| 2883 | 2930 |
| 2884 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(10)); | 2931 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(10)); |
| 2885 controller->UpdateState(true, nullptr); | 2932 controller->UpdateState(true, nullptr); |
| 2886 | 2933 |
| 2887 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( | 2934 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( |
| 2888 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 2935 AnimationTargetProperty::OPACITY, |
| 2936 LayerAnimationController::ObserverType::PENDING)); |
| 2889 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( | 2937 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( |
| 2890 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 2938 AnimationTargetProperty::OPACITY, |
| 2939 LayerAnimationController::ObserverType::ACTIVE)); |
| 2891 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 2940 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2892 Animation::FILTER, LayerAnimationController::ObserverType::PENDING)); | 2941 AnimationTargetProperty::FILTER, |
| 2942 LayerAnimationController::ObserverType::PENDING)); |
| 2893 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 2943 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2894 Animation::FILTER, LayerAnimationController::ObserverType::ACTIVE)); | 2944 AnimationTargetProperty::FILTER, |
| 2945 LayerAnimationController::ObserverType::ACTIVE)); |
| 2895 | 2946 |
| 2896 EXPECT_EQ(0.f, dummy.opacity()); | 2947 EXPECT_EQ(0.f, dummy.opacity()); |
| 2897 | 2948 |
| 2898 // Tick past the end of the animation. | 2949 // Tick past the end of the animation. |
| 2899 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1100)); | 2950 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1100)); |
| 2900 controller->UpdateState(true, nullptr); | 2951 controller->UpdateState(true, nullptr); |
| 2901 | 2952 |
| 2902 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 2953 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2903 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 2954 AnimationTargetProperty::OPACITY, |
| 2955 LayerAnimationController::ObserverType::PENDING)); |
| 2904 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 2956 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2905 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 2957 AnimationTargetProperty::OPACITY, |
| 2958 LayerAnimationController::ObserverType::ACTIVE)); |
| 2906 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 2959 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2907 Animation::FILTER, LayerAnimationController::ObserverType::PENDING)); | 2960 AnimationTargetProperty::FILTER, |
| 2961 LayerAnimationController::ObserverType::PENDING)); |
| 2908 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 2962 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2909 Animation::FILTER, LayerAnimationController::ObserverType::ACTIVE)); | 2963 AnimationTargetProperty::FILTER, |
| 2964 LayerAnimationController::ObserverType::ACTIVE)); |
| 2910 | 2965 |
| 2911 EXPECT_EQ(1.f, dummy.opacity()); | 2966 EXPECT_EQ(1.f, dummy.opacity()); |
| 2912 } | 2967 } |
| 2913 | 2968 |
| 2914 TEST(LayerAnimationControllerTest, TestIsAnimatingPropertyTimeOffsetFillMode) { | 2969 TEST(LayerAnimationControllerTest, TestIsAnimatingPropertyTimeOffsetFillMode) { |
| 2915 FakeLayerAnimationValueObserver dummy; | 2970 FakeLayerAnimationValueObserver dummy; |
| 2916 scoped_refptr<LayerAnimationController> controller( | 2971 scoped_refptr<LayerAnimationController> controller( |
| 2917 LayerAnimationController::Create(0)); | 2972 LayerAnimationController::Create(0)); |
| 2918 controller->AddValueObserver(&dummy); | 2973 controller->AddValueObserver(&dummy); |
| 2919 | 2974 |
| 2920 // Create an animation that initially affects only pending observers, and has | 2975 // Create an animation that initially affects only pending observers, and has |
| 2921 // a start delay of 2 seconds. | 2976 // a start delay of 2 seconds. |
| 2922 scoped_ptr<Animation> animation(CreateAnimation( | 2977 scoped_ptr<Animation> animation(CreateAnimation( |
| 2923 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, | 2978 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)), 1, |
| 2924 Animation::OPACITY)); | 2979 AnimationTargetProperty::OPACITY)); |
| 2925 animation->set_fill_mode(Animation::FILL_MODE_NONE); | 2980 animation->set_fill_mode(Animation::FILL_MODE_NONE); |
| 2926 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); | 2981 animation->set_time_offset(TimeDelta::FromMilliseconds(-2000)); |
| 2927 animation->set_affects_active_observers(false); | 2982 animation->set_affects_active_observers(false); |
| 2928 | 2983 |
| 2929 controller->AddAnimation(std::move(animation)); | 2984 controller->AddAnimation(std::move(animation)); |
| 2930 | 2985 |
| 2931 controller->Animate(kInitialTickTime); | 2986 controller->Animate(kInitialTickTime); |
| 2932 | 2987 |
| 2933 // Since the animation has a start delay, the observers it affects have a | 2988 // Since the animation has a start delay, the observers it affects have a |
| 2934 // potentially running transform animation but aren't currently animating | 2989 // potentially running transform animation but aren't currently animating |
| 2935 // transform. | 2990 // transform. |
| 2936 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( | 2991 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( |
| 2937 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 2992 AnimationTargetProperty::OPACITY, |
| 2993 LayerAnimationController::ObserverType::PENDING)); |
| 2938 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( | 2994 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( |
| 2939 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 2995 AnimationTargetProperty::OPACITY, |
| 2996 LayerAnimationController::ObserverType::ACTIVE)); |
| 2940 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 2997 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2941 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 2998 AnimationTargetProperty::OPACITY, |
| 2999 LayerAnimationController::ObserverType::PENDING)); |
| 2942 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 3000 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2943 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 3001 AnimationTargetProperty::OPACITY, |
| 3002 LayerAnimationController::ObserverType::ACTIVE)); |
| 2944 EXPECT_TRUE(controller->HasActiveAnimation()); | 3003 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 2945 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( | 3004 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( |
| 2946 Animation::FILTER, LayerAnimationController::ObserverType::PENDING)); | 3005 AnimationTargetProperty::FILTER, |
| 3006 LayerAnimationController::ObserverType::PENDING)); |
| 2947 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( | 3007 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( |
| 2948 Animation::FILTER, LayerAnimationController::ObserverType::ACTIVE)); | 3008 AnimationTargetProperty::FILTER, |
| 3009 LayerAnimationController::ObserverType::ACTIVE)); |
| 2949 | 3010 |
| 2950 controller->ActivateAnimations(); | 3011 controller->ActivateAnimations(); |
| 2951 | 3012 |
| 2952 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( | 3013 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( |
| 2953 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 3014 AnimationTargetProperty::OPACITY, |
| 3015 LayerAnimationController::ObserverType::PENDING)); |
| 2954 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( | 3016 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( |
| 2955 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 3017 AnimationTargetProperty::OPACITY, |
| 3018 LayerAnimationController::ObserverType::ACTIVE)); |
| 2956 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 3019 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2957 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 3020 AnimationTargetProperty::OPACITY, |
| 3021 LayerAnimationController::ObserverType::PENDING)); |
| 2958 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 3022 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2959 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 3023 AnimationTargetProperty::OPACITY, |
| 3024 LayerAnimationController::ObserverType::ACTIVE)); |
| 2960 EXPECT_TRUE(controller->HasActiveAnimation()); | 3025 EXPECT_TRUE(controller->HasActiveAnimation()); |
| 2961 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( | 3026 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( |
| 2962 Animation::FILTER, LayerAnimationController::ObserverType::PENDING)); | 3027 AnimationTargetProperty::FILTER, |
| 3028 LayerAnimationController::ObserverType::PENDING)); |
| 2963 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( | 3029 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( |
| 2964 Animation::FILTER, LayerAnimationController::ObserverType::ACTIVE)); | 3030 AnimationTargetProperty::FILTER, |
| 3031 LayerAnimationController::ObserverType::ACTIVE)); |
| 2965 | 3032 |
| 2966 controller->UpdateState(true, nullptr); | 3033 controller->UpdateState(true, nullptr); |
| 2967 | 3034 |
| 2968 // Tick past the start delay. | 3035 // Tick past the start delay. |
| 2969 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 3036 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
| 2970 controller->UpdateState(true, nullptr); | 3037 controller->UpdateState(true, nullptr); |
| 2971 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( | 3038 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( |
| 2972 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 3039 AnimationTargetProperty::OPACITY, |
| 3040 LayerAnimationController::ObserverType::PENDING)); |
| 2973 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( | 3041 EXPECT_TRUE(controller->IsPotentiallyAnimatingProperty( |
| 2974 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 3042 AnimationTargetProperty::OPACITY, |
| 3043 LayerAnimationController::ObserverType::ACTIVE)); |
| 2975 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( | 3044 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( |
| 2976 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 3045 AnimationTargetProperty::OPACITY, |
| 3046 LayerAnimationController::ObserverType::PENDING)); |
| 2977 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( | 3047 EXPECT_TRUE(controller->IsCurrentlyAnimatingProperty( |
| 2978 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 3048 AnimationTargetProperty::OPACITY, |
| 3049 LayerAnimationController::ObserverType::ACTIVE)); |
| 2979 | 3050 |
| 2980 // After the animaton finishes, the observers it affects have neither a | 3051 // After the animaton finishes, the observers it affects have neither a |
| 2981 // potentially running transform animation nor a currently running transform | 3052 // potentially running transform animation nor a currently running transform |
| 2982 // animation. | 3053 // animation. |
| 2983 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); | 3054 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(4000)); |
| 2984 controller->UpdateState(true, nullptr); | 3055 controller->UpdateState(true, nullptr); |
| 2985 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( | 3056 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( |
| 2986 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 3057 AnimationTargetProperty::OPACITY, |
| 3058 LayerAnimationController::ObserverType::PENDING)); |
| 2987 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( | 3059 EXPECT_FALSE(controller->IsPotentiallyAnimatingProperty( |
| 2988 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 3060 AnimationTargetProperty::OPACITY, |
| 3061 LayerAnimationController::ObserverType::ACTIVE)); |
| 2989 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 3062 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2990 Animation::OPACITY, LayerAnimationController::ObserverType::PENDING)); | 3063 AnimationTargetProperty::OPACITY, |
| 3064 LayerAnimationController::ObserverType::PENDING)); |
| 2991 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 3065 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 2992 Animation::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 3066 AnimationTargetProperty::OPACITY, |
| 3067 LayerAnimationController::ObserverType::ACTIVE)); |
| 2993 } | 3068 } |
| 2994 | 3069 |
| 2995 } // namespace | 3070 } // namespace |
| 2996 } // namespace cc | 3071 } // namespace cc |
| OLD | NEW |