| 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 <public/WebFloatAnimationCurve.h> |
| 8 | 8 |
| 9 #include "CCTimingFunction.h" | 9 #include "CCTimingFunction.h" |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 EXPECT_FLOAT_EQ(1, curve->getValue(1)); | 112 EXPECT_FLOAT_EQ(1, curve->getValue(1)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Tests that an ease timing function works as expected. | 115 // Tests that an ease timing function works as expected. |
| 116 TEST(WebFloatAnimationCurveTest, EaseTimingFunction) | 116 TEST(WebFloatAnimationCurveTest, EaseTimingFunction) |
| 117 { | 117 { |
| 118 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 118 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); |
| 119 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
); | 119 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
); |
| 120 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 120 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 121 | 121 |
| 122 OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::create
()); | 122 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::cr
eate()); |
| 123 for (int i = 0; i <= 4; ++i) { | 123 for (int i = 0; i <= 4; ++i) { |
| 124 const double time = i * 0.25; | 124 const double time = i * 0.25; |
| 125 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 125 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 // Tests using a linear timing function. | 129 // Tests using a linear timing function. |
| 130 TEST(WebFloatAnimationCurveTest, LinearTimingFunction) | 130 TEST(WebFloatAnimationCurveTest, LinearTimingFunction) |
| 131 { | 131 { |
| 132 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 132 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); |
| 133 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeLine
ar); | 133 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 134 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 134 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 135 | 135 |
| 136 for (int i = 0; i <= 4; ++i) { | 136 for (int i = 0; i <= 4; ++i) { |
| 137 const double time = i * 0.25; | 137 const double time = i * 0.25; |
| 138 EXPECT_FLOAT_EQ(time, curve->getValue(time)); | 138 EXPECT_FLOAT_EQ(time, curve->getValue(time)); |
| 139 } | 139 } |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Tests that an ease in timing function works as expected. | 142 // Tests that an ease in timing function works as expected. |
| 143 TEST(WebFloatAnimationCurveTest, EaseInTimingFunction) | 143 TEST(WebFloatAnimationCurveTest, EaseInTimingFunction) |
| 144 { | 144 { |
| 145 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 145 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); |
| 146 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
In); | 146 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
In); |
| 147 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 147 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 148 | 148 |
| 149 OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseInTimingFunction::crea
te()); | 149 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInTimingFunction::
create()); |
| 150 for (int i = 0; i <= 4; ++i) { | 150 for (int i = 0; i <= 4; ++i) { |
| 151 const double time = i * 0.25; | 151 const double time = i * 0.25; |
| 152 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 152 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 | 155 |
| 156 // Tests that an ease in timing function works as expected. | 156 // Tests that an ease in timing function works as expected. |
| 157 TEST(WebFloatAnimationCurveTest, EaseOutTimingFunction) | 157 TEST(WebFloatAnimationCurveTest, EaseOutTimingFunction) |
| 158 { | 158 { |
| 159 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 159 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); |
| 160 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
Out); | 160 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
Out); |
| 161 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 161 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 162 | 162 |
| 163 OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseOutTimingFunction::cre
ate()); | 163 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseOutTimingFunction:
:create()); |
| 164 for (int i = 0; i <= 4; ++i) { | 164 for (int i = 0; i <= 4; ++i) { |
| 165 const double time = i * 0.25; | 165 const double time = i * 0.25; |
| 166 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 166 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 | 169 |
| 170 // Tests that an ease in timing function works as expected. | 170 // Tests that an ease in timing function works as expected. |
| 171 TEST(WebFloatAnimationCurveTest, EaseInOutTimingFunction) | 171 TEST(WebFloatAnimationCurveTest, EaseInOutTimingFunction) |
| 172 { | 172 { |
| 173 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 173 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); |
| 174 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
InOut); | 174 curve->add(WebFloatKeyframe(0, 0), WebAnimationCurve::TimingFunctionTypeEase
InOut); |
| 175 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 175 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 176 | 176 |
| 177 OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseInOutTimingFunction::c
reate()); | 177 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInOutTimingFunctio
n::create()); |
| 178 for (int i = 0; i <= 4; ++i) { | 178 for (int i = 0; i <= 4; ++i) { |
| 179 const double time = i * 0.25; | 179 const double time = i * 0.25; |
| 180 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 180 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
| 181 } | 181 } |
| 182 } | 182 } |
| 183 | 183 |
| 184 // Tests that an ease in timing function works as expected. | 184 // Tests that an ease in timing function works as expected. |
| 185 TEST(WebFloatAnimationCurveTest, CustomBezierTimingFunction) | 185 TEST(WebFloatAnimationCurveTest, CustomBezierTimingFunction) |
| 186 { | 186 { |
| 187 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 187 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); |
| 188 double x1 = 0.3; | 188 double x1 = 0.3; |
| 189 double y1 = 0.2; | 189 double y1 = 0.2; |
| 190 double x2 = 0.8; | 190 double x2 = 0.8; |
| 191 double y2 = 0.7; | 191 double y2 = 0.7; |
| 192 curve->add(WebFloatKeyframe(0, 0), x1, y1, x2, y2); | 192 curve->add(WebFloatKeyframe(0, 0), x1, y1, x2, y2); |
| 193 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 193 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 194 | 194 |
| 195 OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCCubicBezierTimingFunction:
:create(x1, y1, x2, y2)); | 195 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCCubicBezierTimingFunct
ion::create(x1, y1, x2, y2)); |
| 196 for (int i = 0; i <= 4; ++i) { | 196 for (int i = 0; i <= 4; ++i) { |
| 197 const double time = i * 0.25; | 197 const double time = i * 0.25; |
| 198 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 198 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 | 201 |
| 202 // Tests that the default timing function is indeed ease. | 202 // Tests that the default timing function is indeed ease. |
| 203 TEST(WebFloatAnimationCurveTest, DefaultTimingFunction) | 203 TEST(WebFloatAnimationCurveTest, DefaultTimingFunction) |
| 204 { | 204 { |
| 205 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); | 205 OwnPtr<WebFloatAnimationCurve> curve = adoptPtr(WebFloatAnimationCurve::crea
te()); |
| 206 curve->add(WebFloatKeyframe(0, 0)); | 206 curve->add(WebFloatKeyframe(0, 0)); |
| 207 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); | 207 curve->add(WebFloatKeyframe(1, 1), WebAnimationCurve::TimingFunctionTypeLine
ar); |
| 208 | 208 |
| 209 OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::create
()); | 209 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::cr
eate()); |
| 210 for (int i = 0; i <= 4; ++i) { | 210 for (int i = 0; i <= 4; ++i) { |
| 211 const double time = i * 0.25; | 211 const double time = i * 0.25; |
| 212 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); | 212 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time)); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 | 215 |
| 216 } // namespace | 216 } // namespace |
| OLD | NEW |