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>2013-08-15 22:03:14 +0000
committerajuma@chromium.org <ajuma@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-15 22:03:14 +0000
commitdb2586f0cdfde4c4dc873e3bcd1d856382d4d2fa (patch)
tree05e0953f2ca06ca716bf458ece2d0f16e89f691e /cc/animation/keyframed_animation_curve_unittest.cc
parent61f697f26142f5081aaee176ccd82a2af170eabf (diff)
downloadchromium_src-db2586f0cdfde4c4dc873e3bcd1d856382d4d2fa.zip
chromium_src-db2586f0cdfde4c4dc873e3bcd1d856382d4d2fa.tar.gz
chromium_src-db2586f0cdfde4c4dc873e3bcd1d856382d4d2fa.tar.bz2
Compute bounds of animated layers
This adds support for computing the bounds of a box when transformed by the animations currently running on layer. This CL handles Scale and Translate animations, leaving other TransformOperations for future CLs. BUG=252472 Review URL: https://chromiumcodereview.appspot.com/21604002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217845 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/animation/keyframed_animation_curve_unittest.cc')
-rw-r--r--cc/animation/keyframed_animation_curve_unittest.cc25
1 files changed, 25 insertions, 0 deletions
diff --git a/cc/animation/keyframed_animation_curve_unittest.cc b/cc/animation/keyframed_animation_curve_unittest.cc
index 32efc14..48f511c0 100644
--- a/cc/animation/keyframed_animation_curve_unittest.cc
+++ b/cc/animation/keyframed_animation_curve_unittest.cc
@@ -7,6 +7,7 @@
#include "cc/animation/transform_operations.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/box_f.h"
namespace cc {
namespace {
@@ -332,5 +333,29 @@ TEST(KeyframedAnimationCurveTest, CubicBezierTimingFunction) {
EXPECT_FLOAT_EQ(1.f, curve->GetValue(1.f));
}
+// Tests that animated bounds are computed as expected.
+TEST(KeyframedAnimationCurveTest, AnimatedBounds) {
+ 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);
+ curve->AddKeyframe(TransformKeyframe::Create(
+ 0.5, operations1, scoped_ptr<TimingFunction>()));
+ TransformOperations operations2;
+ operations2.AppendTranslate(4.0, 1.0, 2.0);
+ curve->AddKeyframe(TransformKeyframe::Create(
+ 1.0, operations2, EaseTimingFunction::Create()));
+
+ gfx::BoxF box(2.f, 3.f, 4.f, 1.f, 3.f, 2.f);
+ gfx::BoxF bounds;
+
+ EXPECT_TRUE(curve->AnimatedBoundsForBox(box, &bounds));
+ EXPECT_EQ(gfx::BoxF(2.f, 3.f, 3.f, 5.f, 6.f, 5.f).ToString(),
+ bounds.ToString());
+}
+
} // namespace
} // namespace cc