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

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

Issue 1076313006: Animation start scale should be considered for the raster scale (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 5 years, 8 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/keyframed_animation_curve.h" 5 #include "cc/animation/keyframed_animation_curve.h"
6 6
7 #include "cc/animation/transform_operations.h" 7 #include "cc/animation/transform_operations.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/gfx/animation/tween.h" 10 #include "ui/gfx/animation/tween.h"
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 TransformKeyframe::Create(base::TimeDelta::FromSecondsD(1.f), operations5, 670 TransformKeyframe::Create(base::TimeDelta::FromSecondsD(1.f), operations5,
671 EaseTimingFunction::Create())); 671 EaseTimingFunction::Create()));
672 672
673 EXPECT_TRUE(curve2->MaximumTargetScale(true, &maximum_scale)); 673 EXPECT_TRUE(curve2->MaximumTargetScale(true, &maximum_scale));
674 EXPECT_EQ(0.8f, maximum_scale); 674 EXPECT_EQ(0.8f, maximum_scale);
675 675
676 EXPECT_TRUE(curve2->MaximumTargetScale(false, &maximum_scale)); 676 EXPECT_TRUE(curve2->MaximumTargetScale(false, &maximum_scale));
677 EXPECT_EQ(0.6f, maximum_scale); 677 EXPECT_EQ(0.6f, maximum_scale);
678 } 678 }
679 679
680 // Tests that starting animation scale is computed as expected.
681 TEST(KeyframedAnimationCurveTest, AnimationStartScale) {
682 scoped_ptr<KeyframedTransformAnimationCurve> curve(
683 KeyframedTransformAnimationCurve::Create());
684
685 TransformOperations operations1;
686 curve->AddKeyframe(
687 TransformKeyframe::Create(base::TimeDelta(), operations1, nullptr));
688 operations1.AppendScale(2.f, -3.f, 1.f);
689 curve->AddKeyframe(
690 TransformKeyframe::Create(base::TimeDelta::FromSecondsD(1.f), operations1,
691 EaseTimingFunction::Create()));
692
693 float start_scale = 0.f;
694
695 // Forward direction
696 EXPECT_TRUE(curve->AnimationStartScale(true, &start_scale));
697 EXPECT_EQ(1.f, start_scale);
698
699 // Backward direction
700 EXPECT_TRUE(curve->AnimationStartScale(false, &start_scale));
701 EXPECT_EQ(3.f, start_scale);
702
703 TransformOperations operations2;
704 operations2.AppendScale(6.f, 3.f, 2.f);
705 curve->AddKeyframe(
706 TransformKeyframe::Create(base::TimeDelta::FromSecondsD(2.f), operations2,
707 EaseTimingFunction::Create()));
708
709 // Backward direction
710 EXPECT_TRUE(curve->AnimationStartScale(true, &start_scale));
711 EXPECT_EQ(1.f, start_scale);
712
713 // Backward direction
714 EXPECT_TRUE(curve->AnimationStartScale(false, &start_scale));
715 EXPECT_EQ(6.f, start_scale);
716
717 TransformOperations operations3;
718 operations3.AppendRotate(1.f, 0.f, 0.f, 90.f);
719 curve->AddKeyframe(
720 TransformKeyframe::Create(base::TimeDelta::FromSecondsD(3.f), operations3,
721 EaseTimingFunction::Create()));
722
723 EXPECT_FALSE(curve->AnimationStartScale(false, &start_scale));
724 EXPECT_EQ(0.f, start_scale);
725 }
726
680 // Tests that an animation with a curve timing function works as expected. 727 // Tests that an animation with a curve timing function works as expected.
681 TEST(KeyframedAnimationCurveTest, CurveTiming) { 728 TEST(KeyframedAnimationCurveTest, CurveTiming) {
682 scoped_ptr<KeyframedFloatAnimationCurve> curve( 729 scoped_ptr<KeyframedFloatAnimationCurve> curve(
683 KeyframedFloatAnimationCurve::Create()); 730 KeyframedFloatAnimationCurve::Create());
684 curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), 0.f, nullptr)); 731 curve->AddKeyframe(FloatKeyframe::Create(base::TimeDelta(), 0.f, nullptr));
685 curve->AddKeyframe( 732 curve->AddKeyframe(
686 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.f), 1.f, nullptr)); 733 FloatKeyframe::Create(base::TimeDelta::FromSecondsD(1.f), 1.f, nullptr));
687 curve->SetTimingFunction( 734 curve->SetTimingFunction(
688 CubicBezierTimingFunction::Create(0.75f, 0.f, 0.25f, 1.f).Pass()); 735 CubicBezierTimingFunction::Create(0.75f, 0.f, 0.25f, 1.f).Pass());
689 EXPECT_FLOAT_EQ(0.f, curve->GetValue(base::TimeDelta::FromSecondsD(-1.f))); 736 EXPECT_FLOAT_EQ(0.f, curve->GetValue(base::TimeDelta::FromSecondsD(-1.f)));
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 curve->SetTimingFunction( 881 curve->SetTimingFunction(
835 CubicBezierTimingFunction::Create(0.5f, -0.5f, 0.5f, 1.5f).Pass()); 882 CubicBezierTimingFunction::Create(0.5f, -0.5f, 0.5f, 1.5f).Pass());
836 EXPECT_LE(curve->GetValue(base::TimeDelta::FromSecondsD(1.f)), 883 EXPECT_LE(curve->GetValue(base::TimeDelta::FromSecondsD(1.f)),
837 0.f); // c(.25) < 0 884 0.f); // c(.25) < 0
838 EXPECT_GE(curve->GetValue(base::TimeDelta::FromSecondsD(3.f)), 885 EXPECT_GE(curve->GetValue(base::TimeDelta::FromSecondsD(3.f)),
839 9.f); // c(.75) > 1 886 9.f); // c(.75) > 1
840 } 887 }
841 888
842 } // namespace 889 } // namespace
843 } // namespace cc 890 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698