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

Unified Diff: cc/CCKeyframedAnimationCurveTest.cpp

Issue 11108020: [cc] Change cc_tests.gyp filenames to Chromium style (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/CCHeadsUpDisplayTest.cpp ('k') | cc/CCLayerAnimationControllerTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/CCKeyframedAnimationCurveTest.cpp
diff --git a/cc/CCKeyframedAnimationCurveTest.cpp b/cc/CCKeyframedAnimationCurveTest.cpp
deleted file mode 100644
index 9dca26aeabb402298e51d02535d98a250b9b0117..0000000000000000000000000000000000000000
--- a/cc/CCKeyframedAnimationCurveTest.cpp
+++ /dev/null
@@ -1,206 +0,0 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "config.h"
-
-#include "CCKeyframedAnimationCurve.h"
-
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include <public/WebTransformOperations.h>
-#include <public/WebTransformationMatrix.h>
-
-using namespace cc;
-using WebKit::WebTransformationMatrix;
-
-namespace {
-
-void expectTranslateX(double translateX, const WebTransformationMatrix& matrix)
-{
- EXPECT_FLOAT_EQ(translateX, matrix.m41());
-}
-
-// Tests that a float animation with one keyframe works as expected.
-TEST(CCKeyframedAnimationCurveTest, OneFloatKeyframe)
-{
- scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
- curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction>()));
- EXPECT_FLOAT_EQ(2, curve->getValue(-1));
- EXPECT_FLOAT_EQ(2, curve->getValue(0));
- EXPECT_FLOAT_EQ(2, curve->getValue(0.5));
- EXPECT_FLOAT_EQ(2, curve->getValue(1));
- EXPECT_FLOAT_EQ(2, curve->getValue(2));
-}
-
-// Tests that a float animation with two keyframes works as expected.
-TEST(CCKeyframedAnimationCurveTest, TwoFloatKeyframe)
-{
- scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
- curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction>()));
- EXPECT_FLOAT_EQ(2, curve->getValue(-1));
- EXPECT_FLOAT_EQ(2, curve->getValue(0));
- EXPECT_FLOAT_EQ(3, curve->getValue(0.5));
- EXPECT_FLOAT_EQ(4, curve->getValue(1));
- EXPECT_FLOAT_EQ(4, curve->getValue(2));
-}
-
-// Tests that a float animation with three keyframes works as expected.
-TEST(CCKeyframedAnimationCurveTest, ThreeFloatKeyframe)
-{
- scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
- curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCFloatKeyframe::create(2, 8, scoped_ptr<CCTimingFunction>()));
- EXPECT_FLOAT_EQ(2, curve->getValue(-1));
- EXPECT_FLOAT_EQ(2, curve->getValue(0));
- EXPECT_FLOAT_EQ(3, curve->getValue(0.5));
- EXPECT_FLOAT_EQ(4, curve->getValue(1));
- EXPECT_FLOAT_EQ(6, curve->getValue(1.5));
- EXPECT_FLOAT_EQ(8, curve->getValue(2));
- EXPECT_FLOAT_EQ(8, curve->getValue(3));
-}
-
-// Tests that a float animation with multiple keys at a given time works sanely.
-TEST(CCKeyframedAnimationCurveTest, RepeatedFloatKeyTimes)
-{
- scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
- curve->addKeyframe(CCFloatKeyframe::create(0, 4, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCFloatKeyframe::create(1, 6, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCFloatKeyframe::create(2, 6, scoped_ptr<CCTimingFunction>()));
-
- EXPECT_FLOAT_EQ(4, curve->getValue(-1));
- EXPECT_FLOAT_EQ(4, curve->getValue(0));
- EXPECT_FLOAT_EQ(4, curve->getValue(0.5));
-
- // There is a discontinuity at 1. Any value between 4 and 6 is valid.
- float value = curve->getValue(1);
- EXPECT_TRUE(value >= 4 && value <= 6);
-
- EXPECT_FLOAT_EQ(6, curve->getValue(1.5));
- EXPECT_FLOAT_EQ(6, curve->getValue(2));
- EXPECT_FLOAT_EQ(6, curve->getValue(3));
-}
-
-
-// Tests that a transform animation with one keyframe works as expected.
-TEST(CCKeyframedAnimationCurveTest, OneTransformKeyframe)
-{
- scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create());
- WebKit::WebTransformOperations operations;
- operations.appendTranslate(2, 0, 0);
- curve->addKeyframe(CCTransformKeyframe::create(0, operations, scoped_ptr<CCTimingFunction>()));
-
- expectTranslateX(2, curve->getValue(-1));
- expectTranslateX(2, curve->getValue(0));
- expectTranslateX(2, curve->getValue(0.5));
- expectTranslateX(2, curve->getValue(1));
- expectTranslateX(2, curve->getValue(2));
-}
-
-// Tests that a transform animation with two keyframes works as expected.
-TEST(CCKeyframedAnimationCurveTest, TwoTransformKeyframe)
-{
- scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create());
- WebKit::WebTransformOperations operations1;
- operations1.appendTranslate(2, 0, 0);
- WebKit::WebTransformOperations operations2;
- operations2.appendTranslate(4, 0, 0);
-
- curve->addKeyframe(CCTransformKeyframe::create(0, operations1, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr<CCTimingFunction>()));
- expectTranslateX(2, curve->getValue(-1));
- expectTranslateX(2, curve->getValue(0));
- expectTranslateX(3, curve->getValue(0.5));
- expectTranslateX(4, curve->getValue(1));
- expectTranslateX(4, curve->getValue(2));
-}
-
-// Tests that a transform animation with three keyframes works as expected.
-TEST(CCKeyframedAnimationCurveTest, ThreeTransformKeyframe)
-{
- scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create());
- WebKit::WebTransformOperations operations1;
- operations1.appendTranslate(2, 0, 0);
- WebKit::WebTransformOperations operations2;
- operations2.appendTranslate(4, 0, 0);
- WebKit::WebTransformOperations operations3;
- operations3.appendTranslate(8, 0, 0);
- curve->addKeyframe(CCTransformKeyframe::create(0, operations1, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCTransformKeyframe::create(2, operations3, scoped_ptr<CCTimingFunction>()));
- expectTranslateX(2, curve->getValue(-1));
- expectTranslateX(2, curve->getValue(0));
- expectTranslateX(3, curve->getValue(0.5));
- expectTranslateX(4, curve->getValue(1));
- expectTranslateX(6, curve->getValue(1.5));
- expectTranslateX(8, curve->getValue(2));
- expectTranslateX(8, curve->getValue(3));
-}
-
-// Tests that a transform animation with multiple keys at a given time works sanely.
-TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes)
-{
- scoped_ptr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create());
- // A step function.
- WebKit::WebTransformOperations operations1;
- operations1.appendTranslate(4, 0, 0);
- WebKit::WebTransformOperations operations2;
- operations2.appendTranslate(4, 0, 0);
- WebKit::WebTransformOperations operations3;
- operations3.appendTranslate(6, 0, 0);
- WebKit::WebTransformOperations operations4;
- operations4.appendTranslate(6, 0, 0);
- curve->addKeyframe(CCTransformKeyframe::create(0, operations1, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCTransformKeyframe::create(1, operations2, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCTransformKeyframe::create(1, operations3, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCTransformKeyframe::create(2, operations4, scoped_ptr<CCTimingFunction>()));
-
- expectTranslateX(4, curve->getValue(-1));
- expectTranslateX(4, curve->getValue(0));
- expectTranslateX(4, curve->getValue(0.5));
-
- // There is a discontinuity at 1. Any value between 4 and 6 is valid.
- WebTransformationMatrix value = curve->getValue(1);
- EXPECT_TRUE(value.m41() >= 4 && value.m41() <= 6);
-
- expectTranslateX(6, curve->getValue(1.5));
- expectTranslateX(6, curve->getValue(2));
- expectTranslateX(6, curve->getValue(3));
-}
-
-// Tests that the keyframes may be added out of order.
-TEST(CCKeyframedAnimationCurveTest, UnsortedKeyframes)
-{
- scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
- curve->addKeyframe(CCFloatKeyframe::create(2, 8, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCFloatKeyframe::create(0, 2, scoped_ptr<CCTimingFunction>()));
- curve->addKeyframe(CCFloatKeyframe::create(1, 4, scoped_ptr<CCTimingFunction>()));
- EXPECT_FLOAT_EQ(2, curve->getValue(-1));
- EXPECT_FLOAT_EQ(2, curve->getValue(0));
- EXPECT_FLOAT_EQ(3, curve->getValue(0.5));
- EXPECT_FLOAT_EQ(4, curve->getValue(1));
- EXPECT_FLOAT_EQ(6, curve->getValue(1.5));
- EXPECT_FLOAT_EQ(8, curve->getValue(2));
- EXPECT_FLOAT_EQ(8, curve->getValue(3));
-}
-
-// Tests that a cubic bezier timing function works as expected.
-TEST(CCKeyframedAnimationCurveTest, CubicBezierTimingFunction)
-{
- scoped_ptr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create());
- curve->addKeyframe(CCFloatKeyframe::create(0, 0, CCCubicBezierTimingFunction::create(0.25, 0, 0.75, 1).PassAs<CCTimingFunction>()));
- curve->addKeyframe(CCFloatKeyframe::create(1, 1, scoped_ptr<CCTimingFunction>()));
-
- EXPECT_FLOAT_EQ(0, curve->getValue(0));
- EXPECT_LT(0, curve->getValue(0.25));
- EXPECT_GT(0.25, curve->getValue(0.25));
- EXPECT_FLOAT_EQ(0.5, curve->getValue(0.5));
- EXPECT_LT(0.75, curve->getValue(0.75));
- EXPECT_GT(1, curve->getValue(0.75));
- EXPECT_FLOAT_EQ(1, curve->getValue(1));
-}
-
-} // namespace
« no previous file with comments | « cc/CCHeadsUpDisplayTest.cpp ('k') | cc/CCLayerAnimationControllerTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698