| 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/WebTransformAnimationCurve.h> | 7 #include <public/WebTransformAnimationCurve.h> |
| 8 | 8 |
| 9 #include "CCTimingFunction.h" | 9 #include "CCTimingFunction.h" |
| 10 | 10 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 TEST(WebTransformAnimationCurveTest, EaseTimingFunction) | 149 TEST(WebTransformAnimationCurveTest, EaseTimingFunction) |
| 150 { | 150 { |
| 151 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); | 151 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); |
| 152 WebKit::WebTransformOperations operations1; | 152 WebKit::WebTransformOperations operations1; |
| 153 operations1.appendTranslate(0, 0, 0); | 153 operations1.appendTranslate(0, 0, 0); |
| 154 WebKit::WebTransformOperations operations2; | 154 WebKit::WebTransformOperations operations2; |
| 155 operations2.appendTranslate(1, 0, 0); | 155 operations2.appendTranslate(1, 0, 0); |
| 156 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu
nctionTypeEase); | 156 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu
nctionTypeEase); |
| 157 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); | 157 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); |
| 158 | 158 |
| 159 OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::create
()); | 159 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::cr
eate()); |
| 160 for (int i = 0; i <= 4; ++i) { | 160 for (int i = 0; i <= 4; ++i) { |
| 161 const double time = i * 0.25; | 161 const double time = i * 0.25; |
| 162 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); | 162 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 | 165 |
| 166 // Tests using a linear timing function. | 166 // Tests using a linear timing function. |
| 167 TEST(WebTransformAnimationCurveTest, LinearTimingFunction) | 167 TEST(WebTransformAnimationCurveTest, LinearTimingFunction) |
| 168 { | 168 { |
| 169 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); | 169 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 184 TEST(WebTransformAnimationCurveTest, EaseInTimingFunction) | 184 TEST(WebTransformAnimationCurveTest, EaseInTimingFunction) |
| 185 { | 185 { |
| 186 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); | 186 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); |
| 187 WebKit::WebTransformOperations operations1; | 187 WebKit::WebTransformOperations operations1; |
| 188 operations1.appendTranslate(0, 0, 0); | 188 operations1.appendTranslate(0, 0, 0); |
| 189 WebKit::WebTransformOperations operations2; | 189 WebKit::WebTransformOperations operations2; |
| 190 operations2.appendTranslate(1, 0, 0); | 190 operations2.appendTranslate(1, 0, 0); |
| 191 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu
nctionTypeEaseIn); | 191 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu
nctionTypeEaseIn); |
| 192 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); | 192 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); |
| 193 | 193 |
| 194 OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseInTimingFunction::crea
te()); | 194 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInTimingFunction::
create()); |
| 195 for (int i = 0; i <= 4; ++i) { | 195 for (int i = 0; i <= 4; ++i) { |
| 196 const double time = i * 0.25; | 196 const double time = i * 0.25; |
| 197 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); | 197 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 | 200 |
| 201 // Tests that an ease in timing function works as expected. | 201 // Tests that an ease in timing function works as expected. |
| 202 TEST(WebTransformAnimationCurveTest, EaseOutTimingFunction) | 202 TEST(WebTransformAnimationCurveTest, EaseOutTimingFunction) |
| 203 { | 203 { |
| 204 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); | 204 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); |
| 205 WebKit::WebTransformOperations operations1; | 205 WebKit::WebTransformOperations operations1; |
| 206 operations1.appendTranslate(0, 0, 0); | 206 operations1.appendTranslate(0, 0, 0); |
| 207 WebKit::WebTransformOperations operations2; | 207 WebKit::WebTransformOperations operations2; |
| 208 operations2.appendTranslate(1, 0, 0); | 208 operations2.appendTranslate(1, 0, 0); |
| 209 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu
nctionTypeEaseOut); | 209 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu
nctionTypeEaseOut); |
| 210 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); | 210 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); |
| 211 | 211 |
| 212 OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseOutTimingFunction::cre
ate()); | 212 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseOutTimingFunction:
:create()); |
| 213 for (int i = 0; i <= 4; ++i) { | 213 for (int i = 0; i <= 4; ++i) { |
| 214 const double time = i * 0.25; | 214 const double time = i * 0.25; |
| 215 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); | 215 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 // Tests that an ease in timing function works as expected. | 219 // Tests that an ease in timing function works as expected. |
| 220 TEST(WebTransformAnimationCurveTest, EaseInOutTimingFunction) | 220 TEST(WebTransformAnimationCurveTest, EaseInOutTimingFunction) |
| 221 { | 221 { |
| 222 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); | 222 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); |
| 223 WebKit::WebTransformOperations operations1; | 223 WebKit::WebTransformOperations operations1; |
| 224 operations1.appendTranslate(0, 0, 0); | 224 operations1.appendTranslate(0, 0, 0); |
| 225 WebKit::WebTransformOperations operations2; | 225 WebKit::WebTransformOperations operations2; |
| 226 operations2.appendTranslate(1, 0, 0); | 226 operations2.appendTranslate(1, 0, 0); |
| 227 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu
nctionTypeEaseInOut); | 227 curve->add(WebTransformKeyframe(0, operations1), WebAnimationCurve::TimingFu
nctionTypeEaseInOut); |
| 228 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); | 228 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); |
| 229 | 229 |
| 230 OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseInOutTimingFunction::c
reate()); | 230 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseInOutTimingFunctio
n::create()); |
| 231 for (int i = 0; i <= 4; ++i) { | 231 for (int i = 0; i <= 4; ++i) { |
| 232 const double time = i * 0.25; | 232 const double time = i * 0.25; |
| 233 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); | 233 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 | 236 |
| 237 // Tests that an ease in timing function works as expected. | 237 // Tests that an ease in timing function works as expected. |
| 238 TEST(WebTransformAnimationCurveTest, CustomBezierTimingFunction) | 238 TEST(WebTransformAnimationCurveTest, CustomBezierTimingFunction) |
| 239 { | 239 { |
| 240 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); | 240 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); |
| 241 double x1 = 0.3; | 241 double x1 = 0.3; |
| 242 double y1 = 0.2; | 242 double y1 = 0.2; |
| 243 double x2 = 0.8; | 243 double x2 = 0.8; |
| 244 double y2 = 0.7; | 244 double y2 = 0.7; |
| 245 WebKit::WebTransformOperations operations1; | 245 WebKit::WebTransformOperations operations1; |
| 246 operations1.appendTranslate(0, 0, 0); | 246 operations1.appendTranslate(0, 0, 0); |
| 247 WebKit::WebTransformOperations operations2; | 247 WebKit::WebTransformOperations operations2; |
| 248 operations2.appendTranslate(1, 0, 0); | 248 operations2.appendTranslate(1, 0, 0); |
| 249 curve->add(WebTransformKeyframe(0, operations1), x1, y1, x2, y2); | 249 curve->add(WebTransformKeyframe(0, operations1), x1, y1, x2, y2); |
| 250 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); | 250 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); |
| 251 | 251 |
| 252 OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCCubicBezierTimingFunction:
:create(x1, y1, x2, y2)); | 252 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCCubicBezierTimingFunct
ion::create(x1, y1, x2, y2)); |
| 253 for (int i = 0; i <= 4; ++i) { | 253 for (int i = 0; i <= 4; ++i) { |
| 254 const double time = i * 0.25; | 254 const double time = i * 0.25; |
| 255 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); | 255 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); |
| 256 } | 256 } |
| 257 } | 257 } |
| 258 | 258 |
| 259 // Tests that the default timing function is indeed ease. | 259 // Tests that the default timing function is indeed ease. |
| 260 TEST(WebTransformAnimationCurveTest, DefaultTimingFunction) | 260 TEST(WebTransformAnimationCurveTest, DefaultTimingFunction) |
| 261 { | 261 { |
| 262 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); | 262 OwnPtr<WebTransformAnimationCurve> curve = adoptPtr(WebTransformAnimationCur
ve::create()); |
| 263 WebKit::WebTransformOperations operations1; | 263 WebKit::WebTransformOperations operations1; |
| 264 operations1.appendTranslate(0, 0, 0); | 264 operations1.appendTranslate(0, 0, 0); |
| 265 WebKit::WebTransformOperations operations2; | 265 WebKit::WebTransformOperations operations2; |
| 266 operations2.appendTranslate(1, 0, 0); | 266 operations2.appendTranslate(1, 0, 0); |
| 267 curve->add(WebTransformKeyframe(0, operations1)); | 267 curve->add(WebTransformKeyframe(0, operations1)); |
| 268 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); | 268 curve->add(WebTransformKeyframe(1, operations2), WebAnimationCurve::TimingFu
nctionTypeLinear); |
| 269 | 269 |
| 270 OwnPtr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::create
()); | 270 scoped_ptr<cc::CCTimingFunction> timingFunction(cc::CCEaseTimingFunction::cr
eate()); |
| 271 for (int i = 0; i <= 4; ++i) { | 271 for (int i = 0; i <= 4; ++i) { |
| 272 const double time = i * 0.25; | 272 const double time = i * 0.25; |
| 273 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); | 273 EXPECT_FLOAT_EQ(timingFunction->getValue(time), curve->getValue(time).m4
1()); |
| 274 } | 274 } |
| 275 } | 275 } |
| 276 | 276 |
| 277 } // namespace | 277 } // namespace |
| OLD | NEW |