| 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 "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "cc/animation/animation.h" | 10 #include "cc/animation/animation.h" |
| (...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 controller_impl->set_value_observer(&dummy_impl); | 1230 controller_impl->set_value_observer(&dummy_impl); |
| 1231 controller_impl->set_needs_active_value_observations(true); | 1231 controller_impl->set_needs_active_value_observations(true); |
| 1232 | 1232 |
| 1233 FakeLayerAnimationValueObserver dummy; | 1233 FakeLayerAnimationValueObserver dummy; |
| 1234 scoped_refptr<LayerAnimationController> controller( | 1234 scoped_refptr<LayerAnimationController> controller( |
| 1235 LayerAnimationController::Create(0)); | 1235 LayerAnimationController::Create(0)); |
| 1236 controller->set_value_observer(&dummy); | 1236 controller->set_value_observer(&dummy); |
| 1237 controller->set_needs_active_value_observations(true); | 1237 controller->set_needs_active_value_observations(true); |
| 1238 | 1238 |
| 1239 FakeLayerAnimationEventObserver observer; | 1239 FakeLayerAnimationEventObserver observer; |
| 1240 controller->AddEventObserver(&observer); | 1240 controller->SetEventObserver(&observer); |
| 1241 | 1241 |
| 1242 int animation_id = | 1242 int animation_id = |
| 1243 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); | 1243 AddOpacityTransitionToController(controller.get(), 1, 0, 1, false); |
| 1244 | 1244 |
| 1245 const TimeTicks start_time = TicksFromSecondsF(123); | 1245 const TimeTicks start_time = TicksFromSecondsF(123); |
| 1246 controller->GetAnimation(TargetProperty::OPACITY)->set_start_time(start_time); | 1246 controller->GetAnimation(TargetProperty::OPACITY)->set_start_time(start_time); |
| 1247 | 1247 |
| 1248 controller->PushAnimationUpdatesTo(controller_impl.get()); | 1248 controller->PushAnimationUpdatesTo(controller_impl.get()); |
| 1249 controller_impl->ActivateAnimations(); | 1249 controller_impl->ActivateAnimations(); |
| 1250 | 1250 |
| 1251 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); | 1251 EXPECT_TRUE(controller_impl->GetAnimationById(animation_id)); |
| 1252 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, | 1252 EXPECT_EQ(Animation::WAITING_FOR_TARGET_AVAILABILITY, |
| 1253 controller_impl->GetAnimationById(animation_id)->run_state()); | 1253 controller_impl->GetAnimationById(animation_id)->run_state()); |
| 1254 | 1254 |
| 1255 AnimationEvents events; | 1255 AnimationEvents events; |
| 1256 controller_impl->Animate(kInitialTickTime); | 1256 controller_impl->Animate(kInitialTickTime); |
| 1257 controller_impl->UpdateState(true, &events); | 1257 controller_impl->UpdateState(true, &events); |
| 1258 | 1258 |
| 1259 // Synchronize the start times. | 1259 // Synchronize the start times. |
| 1260 EXPECT_EQ(1u, events.events_.size()); | 1260 EXPECT_EQ(1u, events.events_.size()); |
| 1261 controller->NotifyAnimationStarted(events.events_[0]); | 1261 controller->NotifyAnimationStarted(events.events_[0]); |
| 1262 | 1262 |
| 1263 // Validate start time on the event observer. | 1263 // Validate start time on the event observer. |
| 1264 EXPECT_EQ(start_time, observer.start_time()); | 1264 EXPECT_EQ(start_time, observer.start_time()); |
| 1265 |
| 1266 controller->SetEventObserver(nullptr); |
| 1265 } | 1267 } |
| 1266 | 1268 |
| 1267 // Tests animations that are waiting for a synchronized start time do not | 1269 // Tests animations that are waiting for a synchronized start time do not |
| 1268 // finish. | 1270 // finish. |
| 1269 TEST(LayerAnimationControllerTest, | 1271 TEST(LayerAnimationControllerTest, |
| 1270 AnimationsWaitingForStartTimeDoNotFinishIfTheyOutwaitTheirFinish) { | 1272 AnimationsWaitingForStartTimeDoNotFinishIfTheyOutwaitTheirFinish) { |
| 1271 std::unique_ptr<AnimationEvents> events( | 1273 std::unique_ptr<AnimationEvents> events( |
| 1272 base::WrapUnique(new AnimationEvents)); | 1274 base::WrapUnique(new AnimationEvents)); |
| 1273 FakeLayerAnimationValueObserver dummy; | 1275 FakeLayerAnimationValueObserver dummy; |
| 1274 scoped_refptr<LayerAnimationController> controller( | 1276 scoped_refptr<LayerAnimationController> controller( |
| (...skipping 1935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3210 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 3212 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); |
| 3211 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 3213 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 3212 TargetProperty::OPACITY, | 3214 TargetProperty::OPACITY, |
| 3213 LayerAnimationController::ObserverType::PENDING)); | 3215 LayerAnimationController::ObserverType::PENDING)); |
| 3214 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( | 3216 EXPECT_FALSE(controller->IsCurrentlyAnimatingProperty( |
| 3215 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); | 3217 TargetProperty::OPACITY, LayerAnimationController::ObserverType::ACTIVE)); |
| 3216 } | 3218 } |
| 3217 | 3219 |
| 3218 } // namespace | 3220 } // namespace |
| 3219 } // namespace cc | 3221 } // namespace cc |
| OLD | NEW |