OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/animation/layer_animation_controller.h" | 5 #include "cc/animation/layer_animation_controller.h" |
6 | 6 |
7 #include "cc/animation/animation.h" | 7 #include "cc/animation/animation.h" |
8 #include "cc/animation/animation_curve.h" | 8 #include "cc/animation/animation_curve.h" |
9 #include "cc/animation/keyframed_animation_curve.h" | 9 #include "cc/animation/keyframed_animation_curve.h" |
10 #include "cc/animation/transform_operations.h" | 10 #include "cc/animation/transform_operations.h" |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 228 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
229 1, | 229 1, |
230 Animation::Opacity)); | 230 Animation::Opacity)); |
231 to_add->set_is_impl_only(true); | 231 to_add->set_is_impl_only(true); |
232 | 232 |
233 controller_impl->AddAnimation(to_add.Pass()); | 233 controller_impl->AddAnimation(to_add.Pass()); |
234 controller_impl->Animate(0.0); | 234 controller_impl->Animate(0.0); |
235 controller_impl->UpdateState(events.get()); | 235 controller_impl->UpdateState(events.get()); |
236 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 236 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
237 EXPECT_EQ(0.f, dummy_impl.opacity()); | 237 EXPECT_EQ(0.f, dummy_impl.opacity()); |
238 EXPECT_EQ(2, events->size()); | 238 EXPECT_EQ(2u, events->size()); |
239 const AnimationEvent* start_opacity_event = | 239 const AnimationEvent* start_opacity_event = |
240 GetMostRecentPropertyUpdateEvent(events.get()); | 240 GetMostRecentPropertyUpdateEvent(events.get()); |
241 EXPECT_EQ(0, start_opacity_event->opacity); | 241 EXPECT_EQ(0.f, start_opacity_event->opacity); |
242 | 242 |
243 controller_impl->Animate(1.0); | 243 controller_impl->Animate(1.0); |
244 controller_impl->UpdateState(events.get()); | 244 controller_impl->UpdateState(events.get()); |
245 EXPECT_EQ(1.f, dummy_impl.opacity()); | 245 EXPECT_EQ(1.f, dummy_impl.opacity()); |
246 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 246 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
247 EXPECT_EQ(4, events->size()); | 247 EXPECT_EQ(4u, events->size()); |
248 const AnimationEvent* end_opacity_event = | 248 const AnimationEvent* end_opacity_event = |
249 GetMostRecentPropertyUpdateEvent(events.get()); | 249 GetMostRecentPropertyUpdateEvent(events.get()); |
250 EXPECT_EQ(1, end_opacity_event->opacity); | 250 EXPECT_EQ(1.f, end_opacity_event->opacity); |
251 } | 251 } |
252 | 252 |
253 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { | 253 TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { |
254 scoped_ptr<AnimationEventsVector> events( | 254 scoped_ptr<AnimationEventsVector> events( |
255 make_scoped_ptr(new AnimationEventsVector)); | 255 make_scoped_ptr(new AnimationEventsVector)); |
256 FakeLayerAnimationValueObserver dummy_impl; | 256 FakeLayerAnimationValueObserver dummy_impl; |
257 scoped_refptr<LayerAnimationController> controller_impl( | 257 scoped_refptr<LayerAnimationController> controller_impl( |
258 LayerAnimationController::Create(0)); | 258 LayerAnimationController::Create(0)); |
259 controller_impl->AddObserver(&dummy_impl); | 259 controller_impl->AddObserver(&dummy_impl); |
260 | 260 |
(...skipping 16 matching lines...) Expand all Loading... |
277 scoped_ptr<Animation> animation(Animation::Create( | 277 scoped_ptr<Animation> animation(Animation::Create( |
278 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Transform)); | 278 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Transform)); |
279 animation->set_is_impl_only(true); | 279 animation->set_is_impl_only(true); |
280 controller_impl->AddAnimation(animation.Pass()); | 280 controller_impl->AddAnimation(animation.Pass()); |
281 | 281 |
282 // Run animation. | 282 // Run animation. |
283 controller_impl->Animate(0.0); | 283 controller_impl->Animate(0.0); |
284 controller_impl->UpdateState(events.get()); | 284 controller_impl->UpdateState(events.get()); |
285 EXPECT_TRUE(controller_impl->HasActiveAnimation()); | 285 EXPECT_TRUE(controller_impl->HasActiveAnimation()); |
286 EXPECT_EQ(gfx::Transform(), dummy_impl.transform()); | 286 EXPECT_EQ(gfx::Transform(), dummy_impl.transform()); |
287 EXPECT_EQ(2, events->size()); | 287 EXPECT_EQ(2u, events->size()); |
288 const AnimationEvent* start_transform_event = | 288 const AnimationEvent* start_transform_event = |
289 GetMostRecentPropertyUpdateEvent(events.get()); | 289 GetMostRecentPropertyUpdateEvent(events.get()); |
290 ASSERT_TRUE(start_transform_event); | 290 ASSERT_TRUE(start_transform_event); |
291 EXPECT_EQ(gfx::Transform(), start_transform_event->transform); | 291 EXPECT_EQ(gfx::Transform(), start_transform_event->transform); |
292 | 292 |
293 gfx::Transform expected_transform; | 293 gfx::Transform expected_transform; |
294 expected_transform.Translate(delta_x, delta_y); | 294 expected_transform.Translate(delta_x, delta_y); |
295 | 295 |
296 controller_impl->Animate(1.0); | 296 controller_impl->Animate(1.0); |
297 controller_impl->UpdateState(events.get()); | 297 controller_impl->UpdateState(events.get()); |
298 EXPECT_EQ(expected_transform, dummy_impl.transform()); | 298 EXPECT_EQ(expected_transform, dummy_impl.transform()); |
299 EXPECT_FALSE(controller_impl->HasActiveAnimation()); | 299 EXPECT_FALSE(controller_impl->HasActiveAnimation()); |
300 EXPECT_EQ(4, events->size()); | 300 EXPECT_EQ(4u, events->size()); |
301 const AnimationEvent* end_transform_event = | 301 const AnimationEvent* end_transform_event = |
302 GetMostRecentPropertyUpdateEvent(events.get()); | 302 GetMostRecentPropertyUpdateEvent(events.get()); |
303 EXPECT_EQ(expected_transform, end_transform_event->transform); | 303 EXPECT_EQ(expected_transform, end_transform_event->transform); |
304 } | 304 } |
305 | 305 |
306 // Tests animations that are waiting for a synchronized start time do not | 306 // Tests animations that are waiting for a synchronized start time do not |
307 // finish. | 307 // finish. |
308 TEST(LayerAnimationControllerTest, | 308 TEST(LayerAnimationControllerTest, |
309 AnimationsWaitingForStartTimeDoNotFinishIfTheyWaitLongerToStartThanTheirDur
ation) { | 309 AnimationsWaitingForStartTimeDoNotFinishIfTheyWaitLongerToStartThanTheirDur
ation) { |
310 scoped_ptr<AnimationEventsVector> events( | 310 scoped_ptr<AnimationEventsVector> events( |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 Animation::Opacity)); | 875 Animation::Opacity)); |
876 | 876 |
877 // Animate but don't UpdateState. | 877 // Animate but don't UpdateState. |
878 controller->Animate(1.0); | 878 controller->Animate(1.0); |
879 | 879 |
880 controller->Animate(2.0); | 880 controller->Animate(2.0); |
881 events.reset(new AnimationEventsVector); | 881 events.reset(new AnimationEventsVector); |
882 controller->UpdateState(events.get()); | 882 controller->UpdateState(events.get()); |
883 | 883 |
884 // Should have one Started event and one Finished event. | 884 // Should have one Started event and one Finished event. |
885 EXPECT_EQ(2, events->size()); | 885 EXPECT_EQ(2u, events->size()); |
886 EXPECT_NE((*events)[0].type, (*events)[1].type); | 886 EXPECT_NE((*events)[0].type, (*events)[1].type); |
887 | 887 |
888 // The float transition should still be at its starting point. | 888 // The float transition should still be at its starting point. |
889 EXPECT_TRUE(controller->HasActiveAnimation()); | 889 EXPECT_TRUE(controller->HasActiveAnimation()); |
890 EXPECT_EQ(0.f, dummy.opacity()); | 890 EXPECT_EQ(0.f, dummy.opacity()); |
891 | 891 |
892 controller->Animate(3.0); | 892 controller->Animate(3.0); |
893 controller->UpdateState(events.get()); | 893 controller->UpdateState(events.get()); |
894 | 894 |
895 // The float tranisition should now be done. | 895 // The float tranisition should now be done. |
896 EXPECT_EQ(1.f, dummy.opacity()); | 896 EXPECT_EQ(1.f, dummy.opacity()); |
897 EXPECT_FALSE(controller->HasActiveAnimation()); | 897 EXPECT_FALSE(controller->HasActiveAnimation()); |
898 } | 898 } |
899 | 899 |
900 } // namespace | 900 } // namespace |
901 } // namespace cc | 901 } // namespace cc |
OLD | NEW |