summaryrefslogtreecommitdiffstats
path: root/cc/animation/keyframed_animation_curve_unittest.cc
diff options
context:
space:
mode:
authorajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-03 23:56:02 +0000
committerajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-03 23:56:02 +0000
commit6248bcc8d0717d4af4836299f54f51d0939042a8 (patch)
treef15c96ee198d1a424a46847227fd2a1ae7e0ca78 /cc/animation/keyframed_animation_curve_unittest.cc
parent22646b0458de4b49e9f84d051d5fb24316ad0271 (diff)
downloadchromium_src-6248bcc8d0717d4af4836299f54f51d0939042a8.zip
chromium_src-6248bcc8d0717d4af4836299f54f51d0939042a8.tar.gz
chromium_src-6248bcc8d0717d4af4836299f54f51d0939042a8.tar.bz2
cc: Compute the maximum scale of animations
This adds MaximumScale and HasOnlyTranslationTransforms methods to LayerAnimationController. BUG=224913 Review URL: https://codereview.chromium.org/214003004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261583 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/animation/keyframed_animation_curve_unittest.cc')
-rw-r--r--cc/animation/keyframed_animation_curve_unittest.cc63
1 files changed, 63 insertions, 0 deletions
diff --git a/cc/animation/keyframed_animation_curve_unittest.cc b/cc/animation/keyframed_animation_curve_unittest.cc
index 1fb14966..eceba6f 100644
--- a/cc/animation/keyframed_animation_curve_unittest.cc
+++ b/cc/animation/keyframed_animation_curve_unittest.cc
@@ -482,5 +482,68 @@ TEST(KeyframedAnimationCurveTest, AffectsScale) {
EXPECT_TRUE(curve->AffectsScale());
}
+// Tests that animations that are translations are correctly identified.
+TEST(KeyframedAnimationCurveTest, IsTranslation) {
+ scoped_ptr<KeyframedTransformAnimationCurve> curve(
+ KeyframedTransformAnimationCurve::Create());
+
+ TransformOperations operations1;
+ curve->AddKeyframe(TransformKeyframe::Create(
+ 0.0, operations1, scoped_ptr<TimingFunction>()));
+ operations1.AppendTranslate(2.0, 3.0, -1.0);
+ TransformOperations operations2;
+ operations2.AppendTranslate(4.0, 1.0, 2.0);
+ curve->AddKeyframe(TransformKeyframe::Create(
+ 1.0, operations2, scoped_ptr<TimingFunction>()));
+
+ EXPECT_TRUE(curve->IsTranslation());
+
+ TransformOperations operations3;
+ operations3.AppendScale(2.f, 2.f, 2.f);
+ curve->AddKeyframe(TransformKeyframe::Create(
+ 2.0, operations3, scoped_ptr<TimingFunction>()));
+
+ EXPECT_FALSE(curve->IsTranslation());
+
+ TransformOperations operations4;
+ operations3.AppendTranslate(2.f, 2.f, 2.f);
+ curve->AddKeyframe(TransformKeyframe::Create(
+ 3.0, operations4, scoped_ptr<TimingFunction>()));
+
+ EXPECT_FALSE(curve->IsTranslation());
+}
+
+// Tests that maximum scale is computed as expected.
+TEST(KeyframedAnimationCurveTest, MaximumScale) {
+ scoped_ptr<KeyframedTransformAnimationCurve> curve(
+ KeyframedTransformAnimationCurve::Create());
+
+ TransformOperations operations1;
+ curve->AddKeyframe(TransformKeyframe::Create(
+ 0.0, operations1, scoped_ptr<TimingFunction>()));
+ operations1.AppendScale(2.f, -3.f, 1.f);
+ curve->AddKeyframe(TransformKeyframe::Create(
+ 1.0, operations1, EaseTimingFunction::Create()));
+
+ float maximum_scale = 0.f;
+ EXPECT_TRUE(curve->MaximumScale(&maximum_scale));
+ EXPECT_EQ(3.f, maximum_scale);
+
+ TransformOperations operations2;
+ operations2.AppendScale(6.f, 3.f, 2.f);
+ curve->AddKeyframe(TransformKeyframe::Create(
+ 2.0, operations2, EaseTimingFunction::Create()));
+
+ EXPECT_TRUE(curve->MaximumScale(&maximum_scale));
+ EXPECT_EQ(6.f, maximum_scale);
+
+ TransformOperations operations3;
+ operations3.AppendRotate(1.f, 0.f, 0.f, 90.f);
+ curve->AddKeyframe(TransformKeyframe::Create(
+ 3.0, operations3, EaseTimingFunction::Create()));
+
+ EXPECT_FALSE(curve->MaximumScale(&maximum_scale));
+}
+
} // namespace
} // namespace cc