OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/animation/layer_animation_controller.h" | 5 #include "cc/animation/layer_animation_controller.h" |
6 | 6 |
7 #include "cc/animation/animation.h" | 7 #include "cc/animation/animation.h" |
8 #include "cc/animation/animation_curve.h" | 8 #include "cc/animation/animation_curve.h" |
9 #include "cc/animation/animation_delegate.h" | 9 #include "cc/animation/animation_delegate.h" |
10 #include "cc/animation/animation_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
(...skipping 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 | 1426 |
1427 // Tests that skipping a call to UpdateState works as expected. | 1427 // Tests that skipping a call to UpdateState works as expected. |
1428 TEST(LayerAnimationControllerTest, SkipUpdateState) { | 1428 TEST(LayerAnimationControllerTest, SkipUpdateState) { |
1429 scoped_ptr<AnimationEventsVector> events( | 1429 scoped_ptr<AnimationEventsVector> events( |
1430 make_scoped_ptr(new AnimationEventsVector)); | 1430 make_scoped_ptr(new AnimationEventsVector)); |
1431 FakeLayerAnimationValueObserver dummy; | 1431 FakeLayerAnimationValueObserver dummy; |
1432 scoped_refptr<LayerAnimationController> controller( | 1432 scoped_refptr<LayerAnimationController> controller( |
1433 LayerAnimationController::Create(0)); | 1433 LayerAnimationController::Create(0)); |
1434 controller->AddValueObserver(&dummy); | 1434 controller->AddValueObserver(&dummy); |
1435 | 1435 |
1436 controller->AddAnimation(CreateAnimation( | 1436 scoped_ptr<Animation> first_animation(CreateAnimation( |
1437 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), 1, | 1437 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1)).Pass(), 1, |
1438 Animation::TRANSFORM)); | 1438 Animation::TRANSFORM)); |
| 1439 first_animation->set_is_controlling_instance_for_test(true); |
| 1440 controller->AddAnimation(first_animation.Pass()); |
1439 | 1441 |
1440 controller->Animate(kInitialTickTime); | 1442 controller->Animate(kInitialTickTime); |
1441 controller->UpdateState(true, events.get()); | 1443 controller->UpdateState(true, events.get()); |
1442 | 1444 |
1443 controller->AddAnimation(CreateAnimation( | 1445 scoped_ptr<Animation> second_animation(CreateAnimation( |
1444 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1446 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1445 2, Animation::OPACITY)); | 1447 2, Animation::OPACITY)); |
| 1448 second_animation->set_is_controlling_instance_for_test(true); |
| 1449 controller->AddAnimation(second_animation.Pass()); |
1446 | 1450 |
1447 // Animate but don't UpdateState. | 1451 // Animate but don't UpdateState. |
1448 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); | 1452 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(1000)); |
1449 | 1453 |
1450 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 1454 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
1451 events.reset(new AnimationEventsVector); | 1455 events.reset(new AnimationEventsVector); |
1452 controller->UpdateState(true, events.get()); | 1456 controller->UpdateState(true, events.get()); |
1453 | 1457 |
1454 // Should have one STARTED event and one FINISHED event. | 1458 // Should have one STARTED event and one FINISHED event. |
1455 EXPECT_EQ(2u, events->size()); | 1459 EXPECT_EQ(2u, events->size()); |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1737 scoped_ptr<AnimationEventsVector> events( | 1741 scoped_ptr<AnimationEventsVector> events( |
1738 make_scoped_ptr(new AnimationEventsVector)); | 1742 make_scoped_ptr(new AnimationEventsVector)); |
1739 FakeLayerAnimationValueObserver dummy_impl; | 1743 FakeLayerAnimationValueObserver dummy_impl; |
1740 scoped_refptr<LayerAnimationController> controller_impl( | 1744 scoped_refptr<LayerAnimationController> controller_impl( |
1741 LayerAnimationController::Create(0)); | 1745 LayerAnimationController::Create(0)); |
1742 controller_impl->AddValueObserver(&dummy_impl); | 1746 controller_impl->AddValueObserver(&dummy_impl); |
1743 | 1747 |
1744 const int group_id = 1; | 1748 const int group_id = 1; |
1745 | 1749 |
1746 // Add two animations with the same group id but different durations. | 1750 // Add two animations with the same group id but different durations. |
1747 controller_impl->AddAnimation(Animation::Create( | 1751 scoped_ptr<Animation> first_animation(Animation::Create( |
1748 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), 1, | 1752 scoped_ptr<AnimationCurve>(new FakeTransformTransition(2.0)).Pass(), 1, |
1749 group_id, Animation::TRANSFORM)); | 1753 group_id, Animation::TRANSFORM)); |
1750 controller_impl->AddAnimation(Animation::Create( | 1754 first_animation->set_is_controlling_instance_for_test(true); |
| 1755 controller_impl->AddAnimation(first_animation.Pass()); |
| 1756 |
| 1757 scoped_ptr<Animation> second_animation(Animation::Create( |
1751 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1758 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1752 2, group_id, Animation::OPACITY)); | 1759 2, group_id, Animation::OPACITY)); |
| 1760 second_animation->set_is_controlling_instance_for_test(true); |
| 1761 controller_impl->AddAnimation(second_animation.Pass()); |
1753 | 1762 |
1754 controller_impl->Animate(kInitialTickTime); | 1763 controller_impl->Animate(kInitialTickTime); |
1755 controller_impl->UpdateState(true, events.get()); | 1764 controller_impl->UpdateState(true, events.get()); |
1756 | 1765 |
1757 // Both animations should have started. | 1766 // Both animations should have started. |
1758 EXPECT_EQ(2u, events->size()); | 1767 EXPECT_EQ(2u, events->size()); |
1759 EXPECT_EQ(AnimationEvent::STARTED, (*events)[0].type); | 1768 EXPECT_EQ(AnimationEvent::STARTED, (*events)[0].type); |
1760 EXPECT_EQ(AnimationEvent::STARTED, (*events)[1].type); | 1769 EXPECT_EQ(AnimationEvent::STARTED, (*events)[1].type); |
1761 | 1770 |
1762 events.reset(new AnimationEventsVector); | 1771 events.reset(new AnimationEventsVector); |
(...skipping 24 matching lines...) Expand all Loading... |
1787 // event for the aborted animation. | 1796 // event for the aborted animation. |
1788 TEST(LayerAnimationControllerTest, FinishedAndAbortedEventsForGroup) { | 1797 TEST(LayerAnimationControllerTest, FinishedAndAbortedEventsForGroup) { |
1789 scoped_ptr<AnimationEventsVector> events( | 1798 scoped_ptr<AnimationEventsVector> events( |
1790 make_scoped_ptr(new AnimationEventsVector)); | 1799 make_scoped_ptr(new AnimationEventsVector)); |
1791 FakeLayerAnimationValueObserver dummy_impl; | 1800 FakeLayerAnimationValueObserver dummy_impl; |
1792 scoped_refptr<LayerAnimationController> controller_impl( | 1801 scoped_refptr<LayerAnimationController> controller_impl( |
1793 LayerAnimationController::Create(0)); | 1802 LayerAnimationController::Create(0)); |
1794 controller_impl->AddValueObserver(&dummy_impl); | 1803 controller_impl->AddValueObserver(&dummy_impl); |
1795 | 1804 |
1796 // Add two animations with the same group id. | 1805 // Add two animations with the same group id. |
1797 controller_impl->AddAnimation(CreateAnimation( | 1806 scoped_ptr<Animation> first_animation(CreateAnimation( |
1798 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)).Pass(), 1, | 1807 scoped_ptr<AnimationCurve>(new FakeTransformTransition(1.0)).Pass(), 1, |
1799 Animation::TRANSFORM)); | 1808 Animation::TRANSFORM)); |
1800 controller_impl->AddAnimation(CreateAnimation( | 1809 first_animation->set_is_controlling_instance_for_test(true); |
| 1810 controller_impl->AddAnimation(first_animation.Pass()); |
| 1811 |
| 1812 scoped_ptr<Animation> second_animation(CreateAnimation( |
1801 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), | 1813 scoped_ptr<AnimationCurve>(new FakeFloatTransition(1.0, 0.f, 1.f)).Pass(), |
1802 1, Animation::OPACITY)); | 1814 1, Animation::OPACITY)); |
| 1815 second_animation->set_is_controlling_instance_for_test(true); |
| 1816 controller_impl->AddAnimation(second_animation.Pass()); |
1803 | 1817 |
1804 controller_impl->Animate(kInitialTickTime); | 1818 controller_impl->Animate(kInitialTickTime); |
1805 controller_impl->UpdateState(true, events.get()); | 1819 controller_impl->UpdateState(true, events.get()); |
1806 | 1820 |
1807 // Both animations should have started. | 1821 // Both animations should have started. |
1808 EXPECT_EQ(2u, events->size()); | 1822 EXPECT_EQ(2u, events->size()); |
1809 EXPECT_EQ(AnimationEvent::STARTED, (*events)[0].type); | 1823 EXPECT_EQ(AnimationEvent::STARTED, (*events)[0].type); |
1810 EXPECT_EQ(AnimationEvent::STARTED, (*events)[1].type); | 1824 EXPECT_EQ(AnimationEvent::STARTED, (*events)[1].type); |
1811 | 1825 |
1812 controller_impl->AbortAnimations(Animation::OPACITY); | 1826 controller_impl->AbortAnimations(Animation::OPACITY); |
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2455 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::OPACITY)); | 2469 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::OPACITY)); |
2456 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::FILTER)); | 2470 EXPECT_FALSE(controller->IsAnimatingProperty(Animation::FILTER)); |
2457 | 2471 |
2458 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); | 2472 controller->Animate(kInitialTickTime + TimeDelta::FromMilliseconds(2000)); |
2459 controller->UpdateState(true, nullptr); | 2473 controller->UpdateState(true, nullptr); |
2460 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::OPACITY)); | 2474 EXPECT_TRUE(controller->IsAnimatingProperty(Animation::OPACITY)); |
2461 } | 2475 } |
2462 | 2476 |
2463 } // namespace | 2477 } // namespace |
2464 } // namespace cc | 2478 } // namespace cc |
OLD | NEW |