summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/tests/WebTransformAnimationCurveTest.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-08-24 08:29:43 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-08-24 08:29:43 +0200
commit2e2ba8ff45915f40ed3e014101269c175f2a89a0 (patch)
tree3b94a9a9fa83efa384b8dac611cf8c6495532a62 /Source/WebKit/chromium/tests/WebTransformAnimationCurveTest.cpp
parentf53e6f8e798362ed712d4a51633b0d0b03dbc213 (diff)
downloadqtwebkit-2e2ba8ff45915f40ed3e014101269c175f2a89a0.tar.gz
Imported WebKit commit bf0b0213bbf3886c96610020602012ca7d11b084 (http://svn.webkit.org/repository/webkit/trunk@126545)
New snapshot with clang and python build fixes
Diffstat (limited to 'Source/WebKit/chromium/tests/WebTransformAnimationCurveTest.cpp')
-rw-r--r--Source/WebKit/chromium/tests/WebTransformAnimationCurveTest.cpp176
1 files changed, 88 insertions, 88 deletions
diff --git a/Source/WebKit/chromium/tests/WebTransformAnimationCurveTest.cpp b/Source/WebKit/chromium/tests/WebTransformAnimationCurveTest.cpp
index 2f4de73cb..96acb3cc1 100644
--- a/Source/WebKit/chromium/tests/WebTransformAnimationCurveTest.cpp
+++ b/Source/WebKit/chromium/tests/WebTransformAnimationCurveTest.cpp
@@ -41,62 +41,62 @@ namespace {
// Tests that a transform animation with one keyframe works as expected.
TEST(WebTransformAnimationCurveTest, OneTransformKeyframe)
{
- WebTransformAnimationCurve curve;
+ OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCurve::create());
WebKit::WebTransformOperations operations;
operations.appendTranslate(2, 0, 0);
- curve.add(WebTransformKeyframe(0, operations), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(0, operations), WebAnimationCurve::TimingFunctionTypeLinear);
- EXPECT_FLOAT_EQ(2, curve.getValue(-1).m41());
- EXPECT_FLOAT_EQ(2, curve.getValue(0).m41());
- EXPECT_FLOAT_EQ(2, curve.getValue(0.5).m41());
- EXPECT_FLOAT_EQ(2, curve.getValue(1).m41());
- EXPECT_FLOAT_EQ(2, curve.getValue(2).m41());
+ EXPECT_FLOAT_EQ(2, curve->getValue(-1).m41());
+ EXPECT_FLOAT_EQ(2, curve->getValue(0).m41());
+ EXPECT_FLOAT_EQ(2, curve->getValue(0.5).m41());
+ EXPECT_FLOAT_EQ(2, curve->getValue(1).m41());
+ EXPECT_FLOAT_EQ(2, curve->getValue(2).m41());
}
// Tests that a transform animation with two keyframes works as expected.
TEST(WebTransformAnimationCurveTest, TwoTransformKeyframe)
{
- WebTransformAnimationCurve curve;
+ OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCurve::create());
WebKit::WebTransformOperations operations1;
operations1.appendTranslate(2, 0, 0);
WebKit::WebTransformOperations operations2;
operations2.appendTranslate(4, 0, 0);
- curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
- curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
- EXPECT_FLOAT_EQ(2, curve.getValue(-1).m41());
- EXPECT_FLOAT_EQ(2, curve.getValue(0).m41());
- EXPECT_FLOAT_EQ(3, curve.getValue(0.5).m41());
- EXPECT_FLOAT_EQ(4, curve.getValue(1).m41());
- EXPECT_FLOAT_EQ(4, curve.getValue(2).m41());
+ curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+ EXPECT_FLOAT_EQ(2, curve->getValue(-1).m41());
+ EXPECT_FLOAT_EQ(2, curve->getValue(0).m41());
+ EXPECT_FLOAT_EQ(3, curve->getValue(0.5).m41());
+ EXPECT_FLOAT_EQ(4, curve->getValue(1).m41());
+ EXPECT_FLOAT_EQ(4, curve->getValue(2).m41());
}
// Tests that a transform animation with three keyframes works as expected.
TEST(WebTransformAnimationCurveTest, ThreeTransformKeyframe)
{
- WebTransformAnimationCurve curve;
+ OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCurve::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.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
- curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
- curve.add(WebTransformKeyframe(2, operations3), WebAnimationCurve::TimingFunctionTypeLinear);
- EXPECT_FLOAT_EQ(2, curve.getValue(-1).m41());
- EXPECT_FLOAT_EQ(2, curve.getValue(0).m41());
- EXPECT_FLOAT_EQ(3, curve.getValue(0.5).m41());
- EXPECT_FLOAT_EQ(4, curve.getValue(1).m41());
- EXPECT_FLOAT_EQ(6, curve.getValue(1.5).m41());
- EXPECT_FLOAT_EQ(8, curve.getValue(2).m41());
- EXPECT_FLOAT_EQ(8, curve.getValue(3).m41());
+ curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(2, operations3), WebAnimationCurve::TimingFunctionTypeLinear);
+ EXPECT_FLOAT_EQ(2, curve->getValue(-1).m41());
+ EXPECT_FLOAT_EQ(2, curve->getValue(0).m41());
+ EXPECT_FLOAT_EQ(3, curve->getValue(0.5).m41());
+ EXPECT_FLOAT_EQ(4, curve->getValue(1).m41());
+ EXPECT_FLOAT_EQ(6, curve->getValue(1.5).m41());
+ EXPECT_FLOAT_EQ(8, curve->getValue(2).m41());
+ EXPECT_FLOAT_EQ(8, curve->getValue(3).m41());
}
// Tests that a transform animation with multiple keys at a given time works sanely.
TEST(WebTransformAnimationCurveTest, RepeatedTransformKeyTimes)
{
// A step function.
- WebTransformAnimationCurve curve;
+ OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCurve::create());
WebKit::WebTransformOperations operations1;
operations1.appendTranslate(4, 0, 0);
WebKit::WebTransformOperations operations2;
@@ -105,159 +105,159 @@ TEST(WebTransformAnimationCurveTest, RepeatedTransformKeyTimes)
operations3.appendTranslate(6, 0, 0);
WebKit::WebTransformOperations operations4;
operations4.appendTranslate(6, 0, 0);
- curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
- curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
- curve.add(WebTransformKeyframe(1, operations3), WebAnimationCurve::TimingFunctionTypeLinear);
- curve.add(WebTransformKeyframe(2, operations4), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(1, operations3), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(2, operations4), WebAnimationCurve::TimingFunctionTypeLinear);
- EXPECT_FLOAT_EQ(4, curve.getValue(-1).m41());
- EXPECT_FLOAT_EQ(4, curve.getValue(0).m41());
- EXPECT_FLOAT_EQ(4, curve.getValue(0.5).m41());
+ EXPECT_FLOAT_EQ(4, curve->getValue(-1).m41());
+ EXPECT_FLOAT_EQ(4, curve->getValue(0).m41());
+ EXPECT_FLOAT_EQ(4, curve->getValue(0.5).m41());
// There is a discontinuity at 1. Any value between 4 and 6 is valid.
- WebTransformationMatrix value = curve.getValue(1);
+ WebTransformationMatrix value = curve->getValue(1);
EXPECT_TRUE(value.m41() >= 4 && value.m41() <= 6);
- EXPECT_FLOAT_EQ(6, curve.getValue(1.5).m41());
- EXPECT_FLOAT_EQ(6, curve.getValue(2).m41());
- EXPECT_FLOAT_EQ(6, curve.getValue(3).m41());
+ EXPECT_FLOAT_EQ(6, curve->getValue(1.5).m41());
+ EXPECT_FLOAT_EQ(6, curve->getValue(2).m41());
+ EXPECT_FLOAT_EQ(6, curve->getValue(3).m41());
}
// Tests that the keyframes may be added out of order.
TEST(WebTransformAnimationCurveTest, UnsortedKeyframes)
{
- WebTransformAnimationCurve curve;
+ OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCurve::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.add(WebTransformKeyframe(2, operations3), WebAnimationCurve::TimingFunctionTypeLinear);
- curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
- curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
-
- EXPECT_FLOAT_EQ(2, curve.getValue(-1).m41());
- EXPECT_FLOAT_EQ(2, curve.getValue(0).m41());
- EXPECT_FLOAT_EQ(3, curve.getValue(0.5).m41());
- EXPECT_FLOAT_EQ(4, curve.getValue(1).m41());
- EXPECT_FLOAT_EQ(6, curve.getValue(1.5).m41());
- EXPECT_FLOAT_EQ(8, curve.getValue(2).m41());
- EXPECT_FLOAT_EQ(8, curve.getValue(3).m41());
+ curve->add(WebTransformKeyframe(2, operations3), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+
+ EXPECT_FLOAT_EQ(2, curve->getValue(-1).m41());
+ EXPECT_FLOAT_EQ(2, curve->getValue(0).m41());
+ EXPECT_FLOAT_EQ(3, curve->getValue(0.5).m41());
+ EXPECT_FLOAT_EQ(4, curve->getValue(1).m41());
+ EXPECT_FLOAT_EQ(6, curve->getValue(1.5).m41());
+ EXPECT_FLOAT_EQ(8, curve->getValue(2).m41());
+ EXPECT_FLOAT_EQ(8, curve->getValue(3).m41());
}
// Tests that a cubic bezier timing function works as expected.
TEST(WebTransformAnimationCurveTest, CubicBezierTimingFunction)
{
- WebTransformAnimationCurve curve;
+ OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCurve::create());
WebKit::WebTransformOperations operations1;
operations1.appendTranslate(0, 0, 0);
WebKit::WebTransformOperations operations2;
operations2.appendTranslate(1, 0, 0);
- curve.add(WebTransformKeyframe(0, operations1), 0.25, 0, 0.75, 1);
- curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
- EXPECT_FLOAT_EQ(0, curve.getValue(0).m41());
- EXPECT_LT(0, curve.getValue(0.25).m41());
- EXPECT_GT(0.25, curve.getValue(0.25).m41());
- EXPECT_FLOAT_EQ(0.5, curve.getValue(0.5).m41());
- EXPECT_LT(0.75, curve.getValue(0.75).m41());
- EXPECT_GT(1, curve.getValue(0.75).m41());
- EXPECT_FLOAT_EQ(1, curve.getValue(1).m41());
+ curve->add(WebTransformKeyframe(0, operations1), 0.25, 0, 0.75, 1);
+ curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+ EXPECT_FLOAT_EQ(0, curve->getValue(0).m41());
+ EXPECT_LT(0, curve->getValue(0.25).m41());
+ EXPECT_GT(0.25, curve->getValue(0.25).m41());
+ EXPECT_FLOAT_EQ(0.5, curve->getValue(0.5).m41());
+ EXPECT_LT(0.75, curve->getValue(0.75).m41());
+ EXPECT_GT(1, curve->getValue(0.75).m41());
+ EXPECT_FLOAT_EQ(1, curve->getValue(1).m41());
}
// Tests that an ease timing function works as expected.
TEST(WebTransformAnimationCurveTest, EaseTimingFunction)
{
- WebTransformAnimationCurve curve;
+ OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCurve::create());
WebKit::WebTransformOperations operations1;
operations1.appendTranslate(0, 0, 0);
WebKit::WebTransformOperations operations2;
operations2.appendTranslate(1, 0, 0);
- curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEase);
- curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEase);
+ curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseTimingFunction::create());
for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25;
- EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time).m41());
+ EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41());
}
}
// Tests using a linear timing function.
TEST(WebTransformAnimationCurveTest, LinearTimingFunction)
{
- WebTransformAnimationCurve curve;
+ OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCurve::create());
WebKit::WebTransformOperations operations1;
operations1.appendTranslate(0, 0, 0);
WebKit::WebTransformOperations operations2;
operations2.appendTranslate(1, 0, 0);
- curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
- curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25;
- EXPECT_FLOAT_EQ(time, curve.getValue(time).m41());
+ EXPECT_FLOAT_EQ(time, curve->getValue(time).m41());
}
}
// Tests that an ease in timing function works as expected.
TEST(WebTransformAnimationCurveTest, EaseInTimingFunction)
{
- WebTransformAnimationCurve curve;
+ OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCurve::create());
WebKit::WebTransformOperations operations1;
operations1.appendTranslate(0, 0, 0);
WebKit::WebTransformOperations operations2;
operations2.appendTranslate(1, 0, 0);
- curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseIn);
- curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseIn);
+ curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseInTimingFunction::create());
for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25;
- EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time).m41());
+ EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41());
}
}
// Tests that an ease in timing function works as expected.
TEST(WebTransformAnimationCurveTest, EaseOutTimingFunction)
{
- WebTransformAnimationCurve curve;
+ OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCurve::create());
WebKit::WebTransformOperations operations1;
operations1.appendTranslate(0, 0, 0);
WebKit::WebTransformOperations operations2;
operations2.appendTranslate(1, 0, 0);
- curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseOut);
- curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseOut);
+ curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseOutTimingFunction::create());
for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25;
- EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time).m41());
+ EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41());
}
}
// Tests that an ease in timing function works as expected.
TEST(WebTransformAnimationCurveTest, EaseInOutTimingFunction)
{
- WebTransformAnimationCurve curve;
+ OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCurve::create());
WebKit::WebTransformOperations operations1;
operations1.appendTranslate(0, 0, 0);
WebKit::WebTransformOperations operations2;
operations2.appendTranslate(1, 0, 0);
- curve.add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseInOut);
- curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFunctionTypeEaseInOut);
+ curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseInOutTimingFunction::create());
for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25;
- EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time).m41());
+ EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41());
}
}
// Tests that an ease in timing function works as expected.
TEST(WebTransformAnimationCurveTest, CustomBezierTimingFunction)
{
- WebTransformAnimationCurve curve;
+ OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCurve::create());
double x1 = 0.3;
double y1 = 0.2;
double x2 = 0.8;
@@ -266,31 +266,31 @@ TEST(WebTransformAnimationCurveTest, CustomBezierTimingFunction)
operations1.appendTranslate(0, 0, 0);
WebKit::WebTransformOperations operations2;
operations2.appendTranslate(1, 0, 0);
- curve.add(WebTransformKeyframe(0, operations1), x1, y1, x2, y2);
- curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(0, operations1), x1, y1, x2, y2);
+ curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCCubicBezierTimingFunction::create(x1, y1, x2, y2));
for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25;
- EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time).m41());
+ EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41());
}
}
// Tests that the default timing function is indeed ease.
TEST(WebTransformAnimationCurveTest, DefaultTimingFunction)
{
- WebTransformAnimationCurve curve;
+ OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCurve::create());
WebKit::WebTransformOperations operations1;
operations1.appendTranslate(0, 0, 0);
WebKit::WebTransformOperations operations2;
operations2.appendTranslate(1, 0, 0);
- curve.add(WebTransformKeyframe(0, operations1));
- curve.add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
+ curve->add(WebTransformKeyframe(0, operations1));
+ curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFunctionTypeLinear);
OwnPtr<WebCore::CCTimingFunction> timingFunction(WebCore::CCEaseTimingFunction::create());
for (int i = 0; i <= 4; ++i) {
const double time = i * 0.25;
- EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve.getValue(time).m41());
+ EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m41());
}
}