| OLD | NEW |
| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include <public/WebFloatAnimationCurve.h> | 7 #include "WebFloatAnimationCurveImpl.h" |
| 8 | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "CCTimingFunction.h" | 9 #include "cc/timing_function.h" |
| 10 | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include <gtest/gtest.h> | |
| 12 #include <wtf/OwnPtr.h> | |
| 13 #include <wtf/PassOwnPtr.h> | |
| 14 | 11 |
| 15 using namespace WebKit; | 12 using namespace WebKit; |
| 16 | 13 |
| 17 namespace { | 14 namespace { |
| 18 | 15 |
| 19 // Tests that a float animation with one keyframe works as expected. | 16 // Tests that a float animation with one keyframe works as expected. |
| 20 TEST(WebFloatAnimationCurveTest, OneFloatKeyframe) | 17 TEST(WebFloatAnimationCurveTest, OneFloatKeyframe) |
| 21 { | 18 { |
| 22 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 19 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
| 23 curve->add(WebFloatKeyframe(0, 2), WebAnimationCurve::TimingFunctionTypeLine
ar); | 20 curve->add(WebFloatKeyframe(0, 2), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 24 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); | 21 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); |
| 25 EXPECT_FLOAT_EQ(2, curve->getValue(0)); | 22 EXPECT_FLOAT_EQ(2, curve->getValue(0)); |
| 26 EXPECT_FLOAT_EQ(2, curve->getValue(0.5)); | 23 EXPECT_FLOAT_EQ(2, curve->getValue(0.5)); |
| 27 EXPECT_FLOAT_EQ(2, curve->getValue(1)); | 24 EXPECT_FLOAT_EQ(2, curve->getValue(1)); |
| 28 EXPECT_FLOAT_EQ(2, curve->getValue(2)); | 25 EXPECT_FLOAT_EQ(2, curve->getValue(2)); |
| 29 } | 26 } |
| 30 | 27 |
| 31 // Tests that a float animation with two keyframes works as expected. | 28 // Tests that a float animation with two keyframes works as expected. |
| 32 TEST(WebFloatAnimationCurveTest, TwoFloatKeyframe) | 29 TEST(WebFloatAnimationCurveTest, TwoFloatKeyframe) |
| 33 { | 30 { |
| 34 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 31 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
| 35 curve->add(WebFloatKeyframe(0, 2), WebAnimationCurve::TimingFunctionTypeLine
ar); | 32 curve->add(WebFloatKeyframe(0, 2), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 36 curve->add(WebFloatKeyframe(1, 4), WebAnimationCurve::TimingFunctionTypeLine
ar); | 33 curve->add(WebFloatKeyframe(1, 4), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 37 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); | 34 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); |
| 38 EXPECT_FLOAT_EQ(2, curve->getValue(0)); | 35 EXPECT_FLOAT_EQ(2, curve->getValue(0)); |
| 39 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); | 36 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); |
| 40 EXPECT_FLOAT_EQ(4, curve->getValue(1)); | 37 EXPECT_FLOAT_EQ(4, curve->getValue(1)); |
| 41 EXPECT_FLOAT_EQ(4, curve->getValue(2)); | 38 EXPECT_FLOAT_EQ(4, curve->getValue(2)); |
| 42 } | 39 } |
| 43 | 40 |
| 44 // Tests that a float animation with three keyframes works as expected. | 41 // Tests that a float animation with three keyframes works as expected. |
| 45 TEST(WebFloatAnimationCurveTest, ThreeFloatKeyframe) | 42 TEST(WebFloatAnimationCurveTest, ThreeFloatKeyframe) |
| 46 { | 43 { |
| 47 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 44 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
| 48 curve->add(WebFloatKeyframe(0, 2), WebAnimationCurve::TimingFunctionTypeLine
ar); | 45 curve->add(WebFloatKeyframe(0, 2), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 49 curve->add(WebFloatKeyframe(1, 4), WebAnimationCurve::TimingFunctionTypeLine
ar); | 46 curve->add(WebFloatKeyframe(1, 4), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 50 curve->add(WebFloatKeyframe(2, 8), WebAnimationCurve::TimingFunctionTypeLine
ar); | 47 curve->add(WebFloatKeyframe(2, 8), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 51 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); | 48 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); |
| 52 EXPECT_FLOAT_EQ(2, curve->getValue(0)); | 49 EXPECT_FLOAT_EQ(2, curve->getValue(0)); |
| 53 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); | 50 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); |
| 54 EXPECT_FLOAT_EQ(4, curve->getValue(1)); | 51 EXPECT_FLOAT_EQ(4, curve->getValue(1)); |
| 55 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); | 52 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); |
| 56 EXPECT_FLOAT_EQ(8, curve->getValue(2)); | 53 EXPECT_FLOAT_EQ(8, curve->getValue(2)); |
| 57 EXPECT_FLOAT_EQ(8, curve->getValue(3)); | 54 EXPECT_FLOAT_EQ(8, curve->getValue(3)); |
| 58 } | 55 } |
| 59 | 56 |
| 60 // Tests that a float animation with multiple keys at a given time works sanely. | 57 // Tests that a float animation with multiple keys at a given time works sanely. |
| 61 TEST(WebFloatAnimationCurveTest, RepeatedFloatKeyTimes) | 58 TEST(WebFloatAnimationCurveTest, RepeatedFloatKeyTimes) |
| 62 { | 59 { |
| 63 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 60 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
| 64 curve->add(WebFloatKeyframe(0, 4), WebAnimationCurve::TimingFunctionTypeLine
ar); | 61 curve->add(WebFloatKeyframe(0, 4), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 65 curve->add(WebFloatKeyframe(1, 4), WebAnimationCurve::TimingFunctionTypeLine
ar); | 62 curve->add(WebFloatKeyframe(1, 4), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 66 curve->add(WebFloatKeyframe(1, 6), WebAnimationCurve::TimingFunctionTypeLine
ar); | 63 curve->add(WebFloatKeyframe(1, 6), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 67 curve->add(WebFloatKeyframe(2, 6), WebAnimationCurve::TimingFunctionTypeLine
ar); | 64 curve->add(WebFloatKeyframe(2, 6), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 68 | 65 |
| 69 EXPECT_FLOAT_EQ(4, curve->getValue(-1)); | 66 EXPECT_FLOAT_EQ(4, curve->getValue(-1)); |
| 70 EXPECT_FLOAT_EQ(4, curve->getValue(0)); | 67 EXPECT_FLOAT_EQ(4, curve->getValue(0)); |
| 71 EXPECT_FLOAT_EQ(4, curve->getValue(0.5)); | 68 EXPECT_FLOAT_EQ(4, curve->getValue(0.5)); |
| 72 | 69 |
| 73 // There is a discontinuity at 1. Any value between 4 and 6 is valid. | 70 // There is a discontinuity at 1. Any value between 4 and 6 is valid. |
| 74 float value = curve->getValue(1); | 71 float value = curve->getValue(1); |
| 75 EXPECT_TRUE(value >= 4 && value <= 6); | 72 EXPECT_TRUE(value >= 4 && value <= 6); |
| 76 | 73 |
| 77 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); | 74 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); |
| 78 EXPECT_FLOAT_EQ(6, curve->getValue(2)); | 75 EXPECT_FLOAT_EQ(6, curve->getValue(2)); |
| 79 EXPECT_FLOAT_EQ(6, curve->getValue(3)); | 76 EXPECT_FLOAT_EQ(6, curve->getValue(3)); |
| 80 } | 77 } |
| 81 | 78 |
| 82 // Tests that the keyframes may be added out of order. | 79 // Tests that the keyframes may be added out of order. |
| 83 TEST(WebFloatAnimationCurveTest, UnsortedKeyframes) | 80 TEST(WebFloatAnimationCurveTest, UnsortedKeyframes) |
| 84 { | 81 { |
| 85 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 82 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
| 86 curve->add(WebFloatKeyframe(2, 8), WebAnimationCurve::TimingFunctionTypeLine
ar); | 83 curve->add(WebFloatKeyframe(2, 8), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 87 curve->add(WebFloatKeyframe(0, 2), WebAnimationCurve::TimingFunctionTypeLine
ar); | 84 curve->add(WebFloatKeyframe(0, 2), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 88 curve->add(WebFloatKeyframe(1, 4), WebAnimationCurve::TimingFunctionTypeLine
ar); | 85 curve->add(WebFloatKeyframe(1, 4), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 89 | 86 |
| 90 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); | 87 EXPECT_FLOAT_EQ(2, curve->getValue(-1)); |
| 91 EXPECT_FLOAT_EQ(2, curve->getValue(0)); | 88 EXPECT_FLOAT_EQ(2, curve->getValue(0)); |
| 92 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); | 89 EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); |
| 93 EXPECT_FLOAT_EQ(4, curve->getValue(1)); | 90 EXPECT_FLOAT_EQ(4, curve->getValue(1)); |
| 94 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); | 91 EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); |
| 95 EXPECT_FLOAT_EQ(8, curve->getValue(2)); | 92 EXPECT_FLOAT_EQ(8, curve->getValue(2)); |
| 96 EXPECT_FLOAT_EQ(8, curve->getValue(3)); | 93 EXPECT_FLOAT_EQ(8, curve->getValue(3)); |
| 97 } | 94 } |
| 98 | 95 |
| 99 // Tests that a cubic bezier timing function works as expected. | 96 // Tests that a cubic bezier timing function works as expected. |
| 100 TEST(WebFloatAnimationCurveTest, CubicBezierTimingFunction) | 97 TEST(WebFloatAnimationCurveTest, CubicBezierTimingFunction) |
| 101 { | 98 { |
| 102 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 99 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
| 103 curve->add(WebFloatKeyframe(0, 0), 0.25, 0, 0.75, 1); | 100 curve->add(WebFloatKeyframe(0, 0), 0.25, 0, 0.75, 1); |
| 104 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 101 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 105 | 102 |
| 106 EXPECT_FLOAT_EQ(0, curve->getValue(0)); | 103 EXPECT_FLOAT_EQ(0, curve->getValue(0)); |
| 107 EXPECT_LT(0, curve->getValue(0.25)); | 104 EXPECT_LT(0, curve->getValue(0.25)); |
| 108 EXPECT_GT(0.25, curve->getValue(0.25)); | 105 EXPECT_GT(0.25, curve->getValue(0.25)); |
| 109 EXPECT_FLOAT_EQ(0.5, curve->getValue(0.5)); | 106 EXPECT_FLOAT_EQ(0.5, curve->getValue(0.5)); |
| 110 EXPECT_LT(0.75, curve->getValue(0.75)); | 107 EXPECT_LT(0.75, curve->getValue(0.75)); |
| 111 EXPECT_GT(1, curve->getValue(0.75)); | 108 EXPECT_GT(1, curve->getValue(0.75)); |
| 112 EXPECT_FLOAT_EQ(1, curve->getValue(1)); | 109 EXPECT_FLOAT_EQ(1, curve->getValue(1)); |
| 113 } | 110 } |
| 114 | 111 |
| 115 // Tests that an ease timing function works as expected. | 112 // Tests that an ease timing function works as expected. |
| 116 TEST(WebFloatAnimationCurveTest, EaseTimingFunction) | 113 TEST(WebFloatAnimationCurveTest, EaseTimingFunction) |
| 117 { | 114 { |
| 118 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 115 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
| 119 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
); | 116 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
); |
| 120 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 117 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 121 | 118 |
| 122 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::cr
eate()); | 119 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::cr
eate()); |
| 123 for (int i = 0; i <= 4; ++i) { | 120 for (int i = 0; i <= 4; ++i) { |
| 124 const double time = i * 0.25; | 121 const double time = i * 0.25; |
| 125 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 122 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
| 126 } | 123 } |
| 127 } | 124 } |
| 128 | 125 |
| 129 // Tests using a linear timing function. | 126 // Tests using a linear timing function. |
| 130 TEST(WebFloatAnimationCurveTest, LinearTimingFunction) | 127 TEST(WebFloatAnimationCurveTest, LinearTimingFunction) |
| 131 { | 128 { |
| 132 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 129 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
| 133 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeLine
ar); | 130 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 134 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 131 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 135 | 132 |
| 136 for (int i = 0; i <= 4; ++i) { | 133 for (int i = 0; i <= 4; ++i) { |
| 137 const double time = i * 0.25; | 134 const double time = i * 0.25; |
| 138 EXPECT_FLOAT_EQ(time, curve->getValue(time)); | 135 EXPECT_FLOAT_EQ(time, curve->getValue(time)); |
| 139 } | 136 } |
| 140 } | 137 } |
| 141 | 138 |
| 142 // Tests that an ease in timing function works as expected. | 139 // Tests that an ease in timing function works as expected. |
| 143 TEST(WebFloatAnimationCurveTest, EaseInTimingFunction) | 140 TEST(WebFloatAnimationCurveTest, EaseInTimingFunction) |
| 144 { | 141 { |
| 145 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 142 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
| 146 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
In); | 143 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
In); |
| 147 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 144 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 148 | 145 |
| 149 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInTimingFunction::
create()); | 146 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInTimingFunction::
create()); |
| 150 for (int i = 0; i <= 4; ++i) { | 147 for (int i = 0; i <= 4; ++i) { |
| 151 const double time = i * 0.25; | 148 const double time = i * 0.25; |
| 152 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 149 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
| 153 } | 150 } |
| 154 } | 151 } |
| 155 | 152 |
| 156 // Tests that an ease in timing function works as expected. | 153 // Tests that an ease in timing function works as expected. |
| 157 TEST(WebFloatAnimationCurveTest, EaseOutTimingFunction) | 154 TEST(WebFloatAnimationCurveTest, EaseOutTimingFunction) |
| 158 { | 155 { |
| 159 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 156 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
| 160 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
Out); | 157 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
Out); |
| 161 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 158 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 162 | 159 |
| 163 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseOutTimingFunction:
:create()); | 160 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseOutTimingFunction:
:create()); |
| 164 for (int i = 0; i <= 4; ++i) { | 161 for (int i = 0; i <= 4; ++i) { |
| 165 const double time = i * 0.25; | 162 const double time = i * 0.25; |
| 166 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 163 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
| 167 } | 164 } |
| 168 } | 165 } |
| 169 | 166 |
| 170 // Tests that an ease in timing function works as expected. | 167 // Tests that an ease in timing function works as expected. |
| 171 TEST(WebFloatAnimationCurveTest, EaseInOutTimingFunction) | 168 TEST(WebFloatAnimationCurveTest, EaseInOutTimingFunction) |
| 172 { | 169 { |
| 173 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 170 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
| 174 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
InOut); | 171 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
InOut); |
| 175 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 172 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 176 | 173 |
| 177 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInOutTimingFunctio
n::create()); | 174 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInOutTimingFunctio
n::create()); |
| 178 for (int i = 0; i <= 4; ++i) { | 175 for (int i = 0; i <= 4; ++i) { |
| 179 const double time = i * 0.25; | 176 const double time = i * 0.25; |
| 180 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 177 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
| 181 } | 178 } |
| 182 } | 179 } |
| 183 | 180 |
| 184 // Tests that an ease in timing function works as expected. | 181 // Tests that an ease in timing function works as expected. |
| 185 TEST(WebFloatAnimationCurveTest, CustomBezierTimingFunction) | 182 TEST(WebFloatAnimationCurveTest, CustomBezierTimingFunction) |
| 186 { | 183 { |
| 187 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 184 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
| 188 double x1 = 0.3; | 185 double x1 = 0.3; |
| 189 double y1 = 0.2; | 186 double y1 = 0.2; |
| 190 double x2 = 0.8; | 187 double x2 = 0.8; |
| 191 double y2 = 0.7; | 188 double y2 = 0.7; |
| 192 curve->add(WebFloatKeyframe(0, 0), x1, y1, x2, y2); | 189 curve->add(WebFloatKeyframe(0, 0), x1, y1, x2, y2); |
| 193 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 190 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 194 | 191 |
| 195 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCCubicBezierTimingFunct
ion::create(x1, y1, x2, y2)); | 192 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCCubicBezierTimingFunct
ion::create(x1, y1, x2, y2)); |
| 196 for (int i = 0; i <= 4; ++i) { | 193 for (int i = 0; i <= 4; ++i) { |
| 197 const double time = i * 0.25; | 194 const double time = i * 0.25; |
| 198 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 195 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
| 199 } | 196 } |
| 200 } | 197 } |
| 201 | 198 |
| 202 // Tests that the default timing function is indeed ease. | 199 // Tests that the default timing function is indeed ease. |
| 203 TEST(WebFloatAnimationCurveTest, DefaultTimingFunction) | 200 TEST(WebFloatAnimationCurveTest, DefaultTimingFunction) |
| 204 { | 201 { |
| 205 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 202 scoped_ptr<WebFloatAnimationCurve> curve(new WebFloatAnimationCurveImpl); |
| 206 curve->add(WebFloatKeyframe(0, 0)); | 203 curve->add(WebFloatKeyframe(0, 0)); |
| 207 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 204 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 208 | 205 |
| 209 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::cr
eate()); | 206 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::cr
eate()); |
| 210 for (int i = 0; i <= 4; ++i) { | 207 for (int i = 0; i <= 4; ++i) { |
| 211 const double time = i * 0.25; | 208 const double time = i * 0.25; |
| 212 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 209 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
| 213 } | 210 } |
| 214 } | 211 } |
| 215 | 212 |
| 216 } // namespace | 213 } // namespace |
| OLD | NEW |