Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: cc/animation/layer_animation_controller_unittest.cc

Issue 608503005: Revert of cc: Remove use of PassAs() and constructor-casting with scoped_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 KeyframedTransformAnimationCurve::Create()); 509 KeyframedTransformAnimationCurve::Create());
510 510
511 // Create simple Transform animation. 511 // Create simple Transform animation.
512 TransformOperations operations; 512 TransformOperations operations;
513 curve->AddKeyframe( 513 curve->AddKeyframe(
514 TransformKeyframe::Create(0, operations, scoped_ptr<TimingFunction>())); 514 TransformKeyframe::Create(0, operations, scoped_ptr<TimingFunction>()));
515 operations.AppendTranslate(delta_x, delta_y, 0); 515 operations.AppendTranslate(delta_x, delta_y, 0);
516 curve->AddKeyframe( 516 curve->AddKeyframe(
517 TransformKeyframe::Create(1, operations, scoped_ptr<TimingFunction>())); 517 TransformKeyframe::Create(1, operations, scoped_ptr<TimingFunction>()));
518 518
519 scoped_ptr<Animation> animation( 519 scoped_ptr<Animation> animation(Animation::Create(
520 Animation::Create(curve.Pass(), 1, 0, Animation::Transform)); 520 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Transform));
521 animation->set_is_impl_only(true); 521 animation->set_is_impl_only(true);
522 controller_impl->AddAnimation(animation.Pass()); 522 controller_impl->AddAnimation(animation.Pass());
523 523
524 // Run animation. 524 // Run animation.
525 controller_impl->Animate(kInitialTickTime); 525 controller_impl->Animate(kInitialTickTime);
526 controller_impl->UpdateState(true, events.get()); 526 controller_impl->UpdateState(true, events.get());
527 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 527 EXPECT_TRUE(controller_impl->HasActiveAnimation());
528 EXPECT_EQ(gfx::Transform(), dummy_impl.transform()); 528 EXPECT_EQ(gfx::Transform(), dummy_impl.transform());
529 EXPECT_EQ(1u, events->size()); 529 EXPECT_EQ(1u, events->size());
530 const AnimationEvent* start_transform_event = 530 const AnimationEvent* start_transform_event =
(...skipping 30 matching lines...) Expand all
561 561
562 FilterOperations start_filters; 562 FilterOperations start_filters;
563 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); 563 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f));
564 curve->AddKeyframe( 564 curve->AddKeyframe(
565 FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>())); 565 FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>()));
566 FilterOperations end_filters; 566 FilterOperations end_filters;
567 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); 567 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f));
568 curve->AddKeyframe( 568 curve->AddKeyframe(
569 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); 569 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>()));
570 570
571 scoped_ptr<Animation> animation( 571 scoped_ptr<Animation> animation(Animation::Create(
572 Animation::Create(curve.Pass(), 1, 0, Animation::Filter)); 572 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Filter));
573 controller->AddAnimation(animation.Pass()); 573 controller->AddAnimation(animation.Pass());
574 574
575 controller->Animate(kInitialTickTime); 575 controller->Animate(kInitialTickTime);
576 controller->UpdateState(true, events.get()); 576 controller->UpdateState(true, events.get());
577 EXPECT_TRUE(controller->HasActiveAnimation()); 577 EXPECT_TRUE(controller->HasActiveAnimation());
578 EXPECT_EQ(start_filters, dummy.filters()); 578 EXPECT_EQ(start_filters, dummy.filters());
579 // A non-impl-only animation should not generate property updates. 579 // A non-impl-only animation should not generate property updates.
580 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 580 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
581 EXPECT_FALSE(event); 581 EXPECT_FALSE(event);
582 582
(...skipping 27 matching lines...) Expand all
610 // Create simple Filter animation. 610 // Create simple Filter animation.
611 FilterOperations start_filters; 611 FilterOperations start_filters;
612 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); 612 start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f));
613 curve->AddKeyframe( 613 curve->AddKeyframe(
614 FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>())); 614 FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>()));
615 FilterOperations end_filters; 615 FilterOperations end_filters;
616 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); 616 end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f));
617 curve->AddKeyframe( 617 curve->AddKeyframe(
618 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); 618 FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>()));
619 619
620 scoped_ptr<Animation> animation( 620 scoped_ptr<Animation> animation(Animation::Create(
621 Animation::Create(curve.Pass(), 1, 0, Animation::Filter)); 621 curve.PassAs<AnimationCurve>(), 1, 0, Animation::Filter));
622 animation->set_is_impl_only(true); 622 animation->set_is_impl_only(true);
623 controller_impl->AddAnimation(animation.Pass()); 623 controller_impl->AddAnimation(animation.Pass());
624 624
625 // Run animation. 625 // Run animation.
626 controller_impl->Animate(kInitialTickTime); 626 controller_impl->Animate(kInitialTickTime);
627 controller_impl->UpdateState(true, events.get()); 627 controller_impl->UpdateState(true, events.get());
628 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 628 EXPECT_TRUE(controller_impl->HasActiveAnimation());
629 EXPECT_EQ(start_filters, dummy_impl.filters()); 629 EXPECT_EQ(start_filters, dummy_impl.filters());
630 EXPECT_EQ(1u, events->size()); 630 EXPECT_EQ(1u, events->size());
631 const AnimationEvent* start_filter_event = 631 const AnimationEvent* start_filter_event =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 controller->AddValueObserver(&dummy); 663 controller->AddValueObserver(&dummy);
664 controller->set_value_provider(&dummy_provider); 664 controller->set_value_provider(&dummy_provider);
665 665
666 gfx::Vector2dF initial_value(100.f, 300.f); 666 gfx::Vector2dF initial_value(100.f, 300.f);
667 gfx::Vector2dF target_value(300.f, 200.f); 667 gfx::Vector2dF target_value(300.f, 200.f);
668 scoped_ptr<ScrollOffsetAnimationCurve> curve( 668 scoped_ptr<ScrollOffsetAnimationCurve> curve(
669 ScrollOffsetAnimationCurve::Create( 669 ScrollOffsetAnimationCurve::Create(
670 target_value, 670 target_value,
671 EaseInOutTimingFunction::Create().Pass())); 671 EaseInOutTimingFunction::Create().Pass()));
672 672
673 scoped_ptr<Animation> animation( 673 scoped_ptr<Animation> animation(Animation::Create(
674 Animation::Create(curve.Pass(), 1, 0, Animation::ScrollOffset)); 674 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset));
675 animation->set_needs_synchronized_start_time(true); 675 animation->set_needs_synchronized_start_time(true);
676 controller->AddAnimation(animation.Pass()); 676 controller->AddAnimation(animation.Pass());
677 677
678 dummy_provider_impl.set_scroll_offset(initial_value); 678 dummy_provider_impl.set_scroll_offset(initial_value);
679 controller->PushAnimationUpdatesTo(controller_impl.get()); 679 controller->PushAnimationUpdatesTo(controller_impl.get());
680 controller_impl->ActivateAnimations(); 680 controller_impl->ActivateAnimations();
681 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); 681 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset));
682 double duration_in_seconds = 682 double duration_in_seconds =
683 controller_impl->GetAnimation(Animation::ScrollOffset) 683 controller_impl->GetAnimation(Animation::ScrollOffset)
684 ->curve() 684 ->curve()
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 controller->AddValueObserver(&dummy); 745 controller->AddValueObserver(&dummy);
746 controller->set_value_provider(&dummy_provider); 746 controller->set_value_provider(&dummy_provider);
747 747
748 gfx::Vector2dF initial_value(500.f, 100.f); 748 gfx::Vector2dF initial_value(500.f, 100.f);
749 gfx::Vector2dF target_value(300.f, 200.f); 749 gfx::Vector2dF target_value(300.f, 200.f);
750 scoped_ptr<ScrollOffsetAnimationCurve> curve( 750 scoped_ptr<ScrollOffsetAnimationCurve> curve(
751 ScrollOffsetAnimationCurve::Create( 751 ScrollOffsetAnimationCurve::Create(
752 target_value, 752 target_value,
753 EaseInOutTimingFunction::Create().Pass())); 753 EaseInOutTimingFunction::Create().Pass()));
754 754
755 scoped_ptr<Animation> animation( 755 scoped_ptr<Animation> animation(Animation::Create(
756 Animation::Create(curve.Pass(), 1, 0, Animation::ScrollOffset)); 756 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset));
757 animation->set_needs_synchronized_start_time(true); 757 animation->set_needs_synchronized_start_time(true);
758 controller->AddAnimation(animation.Pass()); 758 controller->AddAnimation(animation.Pass());
759 759
760 dummy_provider.set_scroll_offset(initial_value); 760 dummy_provider.set_scroll_offset(initial_value);
761 controller->PushAnimationUpdatesTo(controller_impl.get()); 761 controller->PushAnimationUpdatesTo(controller_impl.get());
762 controller_impl->ActivateAnimations(); 762 controller_impl->ActivateAnimations();
763 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset)); 763 EXPECT_TRUE(controller_impl->GetAnimation(Animation::ScrollOffset));
764 double duration_in_seconds = 764 double duration_in_seconds =
765 controller_impl->GetAnimation(Animation::ScrollOffset) 765 controller_impl->GetAnimation(Animation::ScrollOffset)
766 ->curve() 766 ->curve()
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 821
822 gfx::Vector2dF initial_value(100.f, 300.f); 822 gfx::Vector2dF initial_value(100.f, 300.f);
823 gfx::Vector2dF target_value(300.f, 200.f); 823 gfx::Vector2dF target_value(300.f, 200.f);
824 scoped_ptr<ScrollOffsetAnimationCurve> curve( 824 scoped_ptr<ScrollOffsetAnimationCurve> curve(
825 ScrollOffsetAnimationCurve::Create( 825 ScrollOffsetAnimationCurve::Create(
826 target_value, 826 target_value,
827 EaseInOutTimingFunction::Create().Pass())); 827 EaseInOutTimingFunction::Create().Pass()));
828 curve->SetInitialValue(initial_value); 828 curve->SetInitialValue(initial_value);
829 double duration_in_seconds = curve->Duration(); 829 double duration_in_seconds = curve->Duration();
830 830
831 scoped_ptr<Animation> animation( 831 scoped_ptr<Animation> animation(Animation::Create(
832 Animation::Create(curve.Pass(), 1, 0, Animation::ScrollOffset)); 832 curve.PassAs<AnimationCurve>(), 1, 0, Animation::ScrollOffset));
833 animation->set_is_impl_only(true); 833 animation->set_is_impl_only(true);
834 controller_impl->AddAnimation(animation.Pass()); 834 controller_impl->AddAnimation(animation.Pass());
835 835
836 controller_impl->Animate(kInitialTickTime); 836 controller_impl->Animate(kInitialTickTime);
837 controller_impl->UpdateState(true, events.get()); 837 controller_impl->UpdateState(true, events.get());
838 EXPECT_TRUE(controller_impl->HasActiveAnimation()); 838 EXPECT_TRUE(controller_impl->HasActiveAnimation());
839 EXPECT_EQ(initial_value, dummy_impl.scroll_offset()); 839 EXPECT_EQ(initial_value, dummy_impl.scroll_offset());
840 // Scroll offset animations should not generate property updates. 840 // Scroll offset animations should not generate property updates.
841 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get()); 841 const AnimationEvent* event = GetMostRecentPropertyUpdateEvent(events.get());
842 EXPECT_FALSE(event); 842 EXPECT_FALSE(event);
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
1476 scoped_ptr<KeyframedTransformAnimationCurve> curve1( 1476 scoped_ptr<KeyframedTransformAnimationCurve> curve1(
1477 KeyframedTransformAnimationCurve::Create()); 1477 KeyframedTransformAnimationCurve::Create());
1478 1478
1479 TransformOperations operations1; 1479 TransformOperations operations1;
1480 curve1->AddKeyframe(TransformKeyframe::Create( 1480 curve1->AddKeyframe(TransformKeyframe::Create(
1481 0.0, operations1, scoped_ptr<TimingFunction>())); 1481 0.0, operations1, scoped_ptr<TimingFunction>()));
1482 operations1.AppendTranslate(10.0, 15.0, 0.0); 1482 operations1.AppendTranslate(10.0, 15.0, 0.0);
1483 curve1->AddKeyframe(TransformKeyframe::Create( 1483 curve1->AddKeyframe(TransformKeyframe::Create(
1484 1.0, operations1, scoped_ptr<TimingFunction>())); 1484 1.0, operations1, scoped_ptr<TimingFunction>()));
1485 1485
1486 scoped_ptr<Animation> animation( 1486 scoped_ptr<Animation> animation(Animation::Create(
1487 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); 1487 curve1.PassAs<AnimationCurve>(), 1, 1, Animation::Transform));
1488 controller_impl->AddAnimation(animation.Pass()); 1488 controller_impl->AddAnimation(animation.Pass());
1489 1489
1490 scoped_ptr<KeyframedTransformAnimationCurve> curve2( 1490 scoped_ptr<KeyframedTransformAnimationCurve> curve2(
1491 KeyframedTransformAnimationCurve::Create()); 1491 KeyframedTransformAnimationCurve::Create());
1492 1492
1493 TransformOperations operations2; 1493 TransformOperations operations2;
1494 curve2->AddKeyframe(TransformKeyframe::Create( 1494 curve2->AddKeyframe(TransformKeyframe::Create(
1495 0.0, operations2, scoped_ptr<TimingFunction>())); 1495 0.0, operations2, scoped_ptr<TimingFunction>()));
1496 operations2.AppendScale(2.0, 3.0, 4.0); 1496 operations2.AppendScale(2.0, 3.0, 4.0);
1497 curve2->AddKeyframe(TransformKeyframe::Create( 1497 curve2->AddKeyframe(TransformKeyframe::Create(
1498 1.0, operations2, scoped_ptr<TimingFunction>())); 1498 1.0, operations2, scoped_ptr<TimingFunction>()));
1499 1499
1500 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::Transform); 1500 animation = Animation::Create(
1501 curve2.PassAs<AnimationCurve>(), 2, 2, Animation::Transform);
1501 controller_impl->AddAnimation(animation.Pass()); 1502 controller_impl->AddAnimation(animation.Pass());
1502 1503
1503 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f); 1504 gfx::BoxF box(1.f, 2.f, -1.f, 3.f, 4.f, 5.f);
1504 gfx::BoxF bounds; 1505 gfx::BoxF bounds;
1505 1506
1506 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); 1507 EXPECT_TRUE(controller_impl->TransformAnimationBoundsForBox(box, &bounds));
1507 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), 1508 EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(),
1508 bounds.ToString()); 1509 bounds.ToString());
1509 1510
1510 controller_impl->GetAnimation(1, Animation::Transform) 1511 controller_impl->GetAnimation(1, Animation::Transform)
(...skipping 14 matching lines...) Expand all
1525 scoped_ptr<KeyframedTransformAnimationCurve> curve3( 1526 scoped_ptr<KeyframedTransformAnimationCurve> curve3(
1526 KeyframedTransformAnimationCurve::Create()); 1527 KeyframedTransformAnimationCurve::Create());
1527 TransformOperations operations3; 1528 TransformOperations operations3;
1528 gfx::Transform transform3; 1529 gfx::Transform transform3;
1529 transform3.Scale3d(1.0, 2.0, 3.0); 1530 transform3.Scale3d(1.0, 2.0, 3.0);
1530 curve3->AddKeyframe(TransformKeyframe::Create( 1531 curve3->AddKeyframe(TransformKeyframe::Create(
1531 0.0, operations3, scoped_ptr<TimingFunction>())); 1532 0.0, operations3, scoped_ptr<TimingFunction>()));
1532 operations3.AppendMatrix(transform3); 1533 operations3.AppendMatrix(transform3);
1533 curve3->AddKeyframe(TransformKeyframe::Create( 1534 curve3->AddKeyframe(TransformKeyframe::Create(
1534 1.0, operations3, scoped_ptr<TimingFunction>())); 1535 1.0, operations3, scoped_ptr<TimingFunction>()));
1535 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::Transform); 1536 animation = Animation::Create(
1537 curve3.PassAs<AnimationCurve>(), 3, 3, Animation::Transform);
1536 controller_impl->AddAnimation(animation.Pass()); 1538 controller_impl->AddAnimation(animation.Pass());
1537 EXPECT_FALSE(controller_impl->TransformAnimationBoundsForBox(box, &bounds)); 1539 EXPECT_FALSE(controller_impl->TransformAnimationBoundsForBox(box, &bounds));
1538 } 1540 }
1539 1541
1540 // Tests that AbortAnimations aborts all animations targeting the specified 1542 // Tests that AbortAnimations aborts all animations targeting the specified
1541 // property. 1543 // property.
1542 TEST(LayerAnimationControllerTest, AbortAnimations) { 1544 TEST(LayerAnimationControllerTest, AbortAnimations) {
1543 FakeLayerAnimationValueObserver dummy; 1545 FakeLayerAnimationValueObserver dummy;
1544 scoped_refptr<LayerAnimationController> controller( 1546 scoped_refptr<LayerAnimationController> controller(
1545 LayerAnimationController::Create(0)); 1547 LayerAnimationController::Create(0));
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 scoped_ptr<KeyframedTransformAnimationCurve> curve1( 1800 scoped_ptr<KeyframedTransformAnimationCurve> curve1(
1799 KeyframedTransformAnimationCurve::Create()); 1801 KeyframedTransformAnimationCurve::Create());
1800 1802
1801 TransformOperations operations1; 1803 TransformOperations operations1;
1802 curve1->AddKeyframe(TransformKeyframe::Create( 1804 curve1->AddKeyframe(TransformKeyframe::Create(
1803 0.0, operations1, scoped_ptr<TimingFunction>())); 1805 0.0, operations1, scoped_ptr<TimingFunction>()));
1804 operations1.AppendTranslate(10.0, 15.0, 0.0); 1806 operations1.AppendTranslate(10.0, 15.0, 0.0);
1805 curve1->AddKeyframe(TransformKeyframe::Create( 1807 curve1->AddKeyframe(TransformKeyframe::Create(
1806 1.0, operations1, scoped_ptr<TimingFunction>())); 1808 1.0, operations1, scoped_ptr<TimingFunction>()));
1807 1809
1808 scoped_ptr<Animation> animation( 1810 scoped_ptr<Animation> animation(Animation::Create(
1809 Animation::Create(curve1.Pass(), 2, 2, Animation::Transform)); 1811 curve1.PassAs<AnimationCurve>(), 2, 2, Animation::Transform));
1810 controller_impl->AddAnimation(animation.Pass()); 1812 controller_impl->AddAnimation(animation.Pass());
1811 1813
1812 // Translations don't affect scale. 1814 // Translations don't affect scale.
1813 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); 1815 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale());
1814 1816
1815 scoped_ptr<KeyframedTransformAnimationCurve> curve2( 1817 scoped_ptr<KeyframedTransformAnimationCurve> curve2(
1816 KeyframedTransformAnimationCurve::Create()); 1818 KeyframedTransformAnimationCurve::Create());
1817 1819
1818 TransformOperations operations2; 1820 TransformOperations operations2;
1819 curve2->AddKeyframe(TransformKeyframe::Create( 1821 curve2->AddKeyframe(TransformKeyframe::Create(
1820 0.0, operations2, scoped_ptr<TimingFunction>())); 1822 0.0, operations2, scoped_ptr<TimingFunction>()));
1821 operations2.AppendScale(2.0, 3.0, 4.0); 1823 operations2.AppendScale(2.0, 3.0, 4.0);
1822 curve2->AddKeyframe(TransformKeyframe::Create( 1824 curve2->AddKeyframe(TransformKeyframe::Create(
1823 1.0, operations2, scoped_ptr<TimingFunction>())); 1825 1.0, operations2, scoped_ptr<TimingFunction>()));
1824 1826
1825 animation = Animation::Create(curve2.Pass(), 3, 3, Animation::Transform); 1827 animation = Animation::Create(
1828 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform);
1826 controller_impl->AddAnimation(animation.Pass()); 1829 controller_impl->AddAnimation(animation.Pass());
1827 1830
1828 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale()); 1831 EXPECT_TRUE(controller_impl->HasAnimationThatAffectsScale());
1829 1832
1830 controller_impl->GetAnimation(3, Animation::Transform) 1833 controller_impl->GetAnimation(3, Animation::Transform)
1831 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); 1834 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0));
1832 1835
1833 // Only unfinished animations should be considered by 1836 // Only unfinished animations should be considered by
1834 // HasAnimationThatAffectsScale. 1837 // HasAnimationThatAffectsScale.
1835 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale()); 1838 EXPECT_FALSE(controller_impl->HasAnimationThatAffectsScale());
(...skipping 16 matching lines...) Expand all
1852 scoped_ptr<KeyframedTransformAnimationCurve> curve1( 1855 scoped_ptr<KeyframedTransformAnimationCurve> curve1(
1853 KeyframedTransformAnimationCurve::Create()); 1856 KeyframedTransformAnimationCurve::Create());
1854 1857
1855 TransformOperations operations1; 1858 TransformOperations operations1;
1856 curve1->AddKeyframe(TransformKeyframe::Create( 1859 curve1->AddKeyframe(TransformKeyframe::Create(
1857 0.0, operations1, scoped_ptr<TimingFunction>())); 1860 0.0, operations1, scoped_ptr<TimingFunction>()));
1858 operations1.AppendTranslate(10.0, 15.0, 0.0); 1861 operations1.AppendTranslate(10.0, 15.0, 0.0);
1859 curve1->AddKeyframe(TransformKeyframe::Create( 1862 curve1->AddKeyframe(TransformKeyframe::Create(
1860 1.0, operations1, scoped_ptr<TimingFunction>())); 1863 1.0, operations1, scoped_ptr<TimingFunction>()));
1861 1864
1862 scoped_ptr<Animation> animation( 1865 scoped_ptr<Animation> animation(Animation::Create(
1863 Animation::Create(curve1.Pass(), 2, 2, Animation::Transform)); 1866 curve1.PassAs<AnimationCurve>(), 2, 2, Animation::Transform));
1864 controller_impl->AddAnimation(animation.Pass()); 1867 controller_impl->AddAnimation(animation.Pass());
1865 1868
1866 // The only transform animation we've added is a translation. 1869 // The only transform animation we've added is a translation.
1867 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms()); 1870 EXPECT_TRUE(controller_impl->HasOnlyTranslationTransforms());
1868 1871
1869 scoped_ptr<KeyframedTransformAnimationCurve> curve2( 1872 scoped_ptr<KeyframedTransformAnimationCurve> curve2(
1870 KeyframedTransformAnimationCurve::Create()); 1873 KeyframedTransformAnimationCurve::Create());
1871 1874
1872 TransformOperations operations2; 1875 TransformOperations operations2;
1873 curve2->AddKeyframe(TransformKeyframe::Create( 1876 curve2->AddKeyframe(TransformKeyframe::Create(
1874 0.0, operations2, scoped_ptr<TimingFunction>())); 1877 0.0, operations2, scoped_ptr<TimingFunction>()));
1875 operations2.AppendScale(2.0, 3.0, 4.0); 1878 operations2.AppendScale(2.0, 3.0, 4.0);
1876 curve2->AddKeyframe(TransformKeyframe::Create( 1879 curve2->AddKeyframe(TransformKeyframe::Create(
1877 1.0, operations2, scoped_ptr<TimingFunction>())); 1880 1.0, operations2, scoped_ptr<TimingFunction>()));
1878 1881
1879 animation = Animation::Create(curve2.Pass(), 3, 3, Animation::Transform); 1882 animation = Animation::Create(
1883 curve2.PassAs<AnimationCurve>(), 3, 3, Animation::Transform);
1880 controller_impl->AddAnimation(animation.Pass()); 1884 controller_impl->AddAnimation(animation.Pass());
1881 1885
1882 // A scale animation is not a translation. 1886 // A scale animation is not a translation.
1883 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms()); 1887 EXPECT_FALSE(controller_impl->HasOnlyTranslationTransforms());
1884 1888
1885 controller_impl->GetAnimation(3, Animation::Transform) 1889 controller_impl->GetAnimation(3, Animation::Transform)
1886 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); 1890 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0));
1887 1891
1888 // Only unfinished animations should be considered by 1892 // Only unfinished animations should be considered by
1889 // HasOnlyTranslationTransforms. 1893 // HasOnlyTranslationTransforms.
(...skipping 11 matching lines...) Expand all
1901 scoped_ptr<KeyframedTransformAnimationCurve> curve1( 1905 scoped_ptr<KeyframedTransformAnimationCurve> curve1(
1902 KeyframedTransformAnimationCurve::Create()); 1906 KeyframedTransformAnimationCurve::Create());
1903 1907
1904 TransformOperations operations1; 1908 TransformOperations operations1;
1905 curve1->AddKeyframe(TransformKeyframe::Create( 1909 curve1->AddKeyframe(TransformKeyframe::Create(
1906 0.0, operations1, scoped_ptr<TimingFunction>())); 1910 0.0, operations1, scoped_ptr<TimingFunction>()));
1907 operations1.AppendScale(2.0, 3.0, 4.0); 1911 operations1.AppendScale(2.0, 3.0, 4.0);
1908 curve1->AddKeyframe(TransformKeyframe::Create( 1912 curve1->AddKeyframe(TransformKeyframe::Create(
1909 1.0, operations1, scoped_ptr<TimingFunction>())); 1913 1.0, operations1, scoped_ptr<TimingFunction>()));
1910 1914
1911 scoped_ptr<Animation> animation( 1915 scoped_ptr<Animation> animation(Animation::Create(
1912 Animation::Create(curve1.Pass(), 1, 1, Animation::Transform)); 1916 curve1.PassAs<AnimationCurve>(), 1, 1, Animation::Transform));
1913 controller_impl->AddAnimation(animation.Pass()); 1917 controller_impl->AddAnimation(animation.Pass());
1914 1918
1915 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); 1919 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale));
1916 EXPECT_EQ(4.f, max_scale); 1920 EXPECT_EQ(4.f, max_scale);
1917 1921
1918 scoped_ptr<KeyframedTransformAnimationCurve> curve2( 1922 scoped_ptr<KeyframedTransformAnimationCurve> curve2(
1919 KeyframedTransformAnimationCurve::Create()); 1923 KeyframedTransformAnimationCurve::Create());
1920 1924
1921 TransformOperations operations2; 1925 TransformOperations operations2;
1922 curve2->AddKeyframe(TransformKeyframe::Create( 1926 curve2->AddKeyframe(TransformKeyframe::Create(
1923 0.0, operations2, scoped_ptr<TimingFunction>())); 1927 0.0, operations2, scoped_ptr<TimingFunction>()));
1924 operations2.AppendScale(6.0, 5.0, 4.0); 1928 operations2.AppendScale(6.0, 5.0, 4.0);
1925 curve2->AddKeyframe(TransformKeyframe::Create( 1929 curve2->AddKeyframe(TransformKeyframe::Create(
1926 1.0, operations2, scoped_ptr<TimingFunction>())); 1930 1.0, operations2, scoped_ptr<TimingFunction>()));
1927 1931
1928 animation = Animation::Create(curve2.Pass(), 2, 2, Animation::Transform); 1932 animation = Animation::Create(
1933 curve2.PassAs<AnimationCurve>(), 2, 2, Animation::Transform);
1929 controller_impl->AddAnimation(animation.Pass()); 1934 controller_impl->AddAnimation(animation.Pass());
1930 1935
1931 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale)); 1936 EXPECT_TRUE(controller_impl->MaximumScale(&max_scale));
1932 EXPECT_EQ(6.f, max_scale); 1937 EXPECT_EQ(6.f, max_scale);
1933 1938
1934 scoped_ptr<KeyframedTransformAnimationCurve> curve3( 1939 scoped_ptr<KeyframedTransformAnimationCurve> curve3(
1935 KeyframedTransformAnimationCurve::Create()); 1940 KeyframedTransformAnimationCurve::Create());
1936 1941
1937 TransformOperations operations3; 1942 TransformOperations operations3;
1938 curve3->AddKeyframe(TransformKeyframe::Create( 1943 curve3->AddKeyframe(TransformKeyframe::Create(
1939 0.0, operations3, scoped_ptr<TimingFunction>())); 1944 0.0, operations3, scoped_ptr<TimingFunction>()));
1940 operations3.AppendPerspective(6.0); 1945 operations3.AppendPerspective(6.0);
1941 curve3->AddKeyframe(TransformKeyframe::Create( 1946 curve3->AddKeyframe(TransformKeyframe::Create(
1942 1.0, operations3, scoped_ptr<TimingFunction>())); 1947 1.0, operations3, scoped_ptr<TimingFunction>()));
1943 1948
1944 animation = Animation::Create(curve3.Pass(), 3, 3, Animation::Transform); 1949 animation = Animation::Create(
1950 curve3.PassAs<AnimationCurve>(), 3, 3, Animation::Transform);
1945 controller_impl->AddAnimation(animation.Pass()); 1951 controller_impl->AddAnimation(animation.Pass());
1946 1952
1947 EXPECT_FALSE(controller_impl->MaximumScale(&max_scale)); 1953 EXPECT_FALSE(controller_impl->MaximumScale(&max_scale));
1948 1954
1949 controller_impl->GetAnimation(3, Animation::Transform) 1955 controller_impl->GetAnimation(3, Animation::Transform)
1950 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); 1956 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0));
1951 controller_impl->GetAnimation(2, Animation::Transform) 1957 controller_impl->GetAnimation(2, Animation::Transform)
1952 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0)); 1958 ->SetRunState(Animation::Finished, TicksFromSecondsF(0.0));
1953 1959
1954 // Only unfinished animations should be considered by 1960 // Only unfinished animations should be considered by
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
2254 // been ticked at the new animation's starting point. 2260 // been ticked at the new animation's starting point.
2255 EXPECT_EQ(Animation::Running, 2261 EXPECT_EQ(Animation::Running,
2256 controller_impl->GetAnimation(second_animation_group_id, 2262 controller_impl->GetAnimation(second_animation_group_id,
2257 Animation::Opacity)->run_state()); 2263 Animation::Opacity)->run_state());
2258 EXPECT_EQ(1.f, pending_dummy_impl.opacity()); 2264 EXPECT_EQ(1.f, pending_dummy_impl.opacity());
2259 EXPECT_EQ(1.f, dummy_impl.opacity()); 2265 EXPECT_EQ(1.f, dummy_impl.opacity());
2260 } 2266 }
2261 2267
2262 } // namespace 2268 } // namespace
2263 } // namespace cc 2269 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/keyframed_animation_curve_unittest.cc ('k') | cc/animation/scroll_offset_animation_curve.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698