OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013, Google Inc. All rights reserved. | 2 * Copyright (c) 2013, Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 EXPECT_REFV_NE(v[i].second, v[j].second) \ | 57 EXPECT_REFV_NE(v[i].second, v[j].second) \ |
58 << v[i].first \ | 58 << v[i].first \ |
59 << " (" << ::testing::PrintToString(*v[i].second.get()) << ")" \ | 59 << " (" << ::testing::PrintToString(*v[i].second.get()) << ")" \ |
60 << " == " \ | 60 << " == " \ |
61 << v[j].first \ | 61 << v[j].first \ |
62 << " (" << ::testing::PrintToString(*v[j].second.get()) << ")" \ | 62 << " (" << ::testing::PrintToString(*v[j].second.get()) << ")" \ |
63 << "\n"; \ | 63 << "\n"; \ |
64 } \ | 64 } \ |
65 } | 65 } |
66 | 66 |
67 | |
68 using namespace WebCore; | 67 using namespace WebCore; |
69 | 68 |
70 namespace { | 69 namespace { |
71 | 70 |
72 class TimingFunctionTest : public ::testing::Test { | 71 class TimingFunctionTest : public ::testing::Test { |
73 protected: | 72 protected: |
74 virtual void SetUp() | 73 virtual void SetUp() |
75 { | 74 { |
76 // Needed for ChainedTimingFunction support | 75 // Needed for ChainedTimingFunction support |
77 RuntimeEnabledFeatures::setWebAnimationsEnabled(true); | 76 RuntimeEnabledFeatures::setWebAnimationsEnabled(true); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 EXPECT_REFV_EQ(chainedMixed1, chainedMixed3); | 252 EXPECT_REFV_EQ(chainedMixed1, chainedMixed3); |
254 EXPECT_REFV_NE(chainedMixed1, chainedSingleCubic1); | 253 EXPECT_REFV_NE(chainedMixed1, chainedSingleCubic1); |
255 EXPECT_REFV_NE(chainedMixed1, chainedSingleLinear1); | 254 EXPECT_REFV_NE(chainedMixed1, chainedSingleLinear1); |
256 | 255 |
257 RefPtr<ChainedTimingFunction> chainedMixed4 = ChainedTimingFunction::create(
); | 256 RefPtr<ChainedTimingFunction> chainedMixed4 = ChainedTimingFunction::create(
); |
258 chainedMixed4->appendSegment(0.20, chainedSingleLinear1.get()); // Different
offset | 257 chainedMixed4->appendSegment(0.20, chainedSingleLinear1.get()); // Different
offset |
259 chainedMixed4->appendSegment(1.0, cubicTiming1.get()); | 258 chainedMixed4->appendSegment(1.0, cubicTiming1.get()); |
260 EXPECT_REFV_NE(chainedMixed1, chainedMixed4); | 259 EXPECT_REFV_NE(chainedMixed1, chainedMixed4); |
261 } | 260 } |
262 | 261 |
| 262 TEST_F(TimingFunctionTest, LinearReverse) |
| 263 { |
| 264 RefPtr<TimingFunction> linearTiming = LinearTimingFunction::create(); |
| 265 EXPECT_REFV_EQ(linearTiming, linearTiming->reverse()); |
| 266 } |
| 267 |
| 268 TEST_F(TimingFunctionTest, CubicReverse) |
| 269 { |
| 270 RefPtr<TimingFunction> cubicEaseInTiming = CubicBezierTimingFunction::preset
(CubicBezierTimingFunction::EaseIn); |
| 271 RefPtr<TimingFunction> cubicEaseOutTiming = CubicBezierTimingFunction::prese
t(CubicBezierTimingFunction::EaseOut); |
| 272 RefPtr<TimingFunction> cubicEaseInOutTiming = CubicBezierTimingFunction::pre
set(CubicBezierTimingFunction::EaseInOut); |
| 273 |
| 274 EXPECT_REFV_EQ(cubicEaseOutTiming, cubicEaseInTiming->reverse()); |
| 275 EXPECT_REFV_EQ(cubicEaseInTiming, cubicEaseOutTiming->reverse()); |
| 276 EXPECT_REFV_EQ(cubicEaseInOutTiming, cubicEaseInOutTiming->reverse()); |
| 277 |
| 278 RefPtr<TimingFunction> cubicCustomTiming = CubicBezierTimingFunction::create
(0.17, 0.67, 1, -1.73); |
| 279 RefPtr<TimingFunction> cubicCustomTimingReversed = CubicBezierTimingFunction
::create(0.17, 0.67, 1, -1.73); |
| 280 EXPECT_REFV_EQ(cubicCustomTimingReversed, cubicCustomTiming->reverse()); |
| 281 } |
| 282 |
| 283 TEST_F(TimingFunctionTest, StepReverse) |
| 284 { |
| 285 RefPtr<TimingFunction> stepTimingStart = StepsTimingFunction::preset(StepsTi
mingFunction::Start); |
| 286 RefPtr<TimingFunction> stepTimingEnd = StepsTimingFunction::preset(StepsTimi
ngFunction::End); |
| 287 |
| 288 EXPECT_REFV_EQ(stepTimingEnd, stepTimingStart->reverse()); |
| 289 EXPECT_REFV_EQ(stepTimingStart, stepTimingEnd->reverse()); |
| 290 |
| 291 RefPtr<TimingFunction> stepTimingCustom = StepsTimingFunction::create(5, fal
se); |
| 292 RefPtr<TimingFunction> stepTimingCustomReversed = StepsTimingFunction::creat
e(5, true); |
| 293 EXPECT_REFV_EQ(stepTimingCustomReversed, stepTimingCustom); |
| 294 } |
| 295 |
| 296 TEST_F(TimingFunctionTest, ChainedReverse) |
| 297 { |
| 298 RefPtr<TimingFunction> linearTiming = LinearTimingFunction::create(); |
| 299 RefPtr<ChainedTimingFunction> chainedLinearSingle = ChainedTimingFunction::c
reate(); |
| 300 chainedLinearSingle->appendSegment(1.0, linearTiming.get()); |
| 301 EXPECT_REFV_EQ(chainedLinearSingle, chainedLinearSingle->reverse()); |
| 302 |
| 303 RefPtr<TimingFunction> cubicEaseInTiming = CubicBezierTimingFunction::preset
(CubicBezierTimingFunction::EaseIn); |
| 304 RefPtr<TimingFunction> cubicEaseOutTiming = CubicBezierTimingFunction::prese
t(CubicBezierTimingFunction::EaseOut); |
| 305 |
| 306 RefPtr<ChainedTimingFunction> chainedMixed = ChainedTimingFunction::create()
; |
| 307 chainedMixed->appendSegment(0.75, chainedLinearSingle.get()); |
| 308 chainedMixed->appendSegment(1.0, cubicEaseInTiming.get()); |
| 309 |
| 310 RefPtr<ChainedTimingFunction> chainedMixedReversed = ChainedTimingFunction::
create(); |
| 311 chainedMixed->appendSegment(0.25, cubicEaseOutTiming.get()); |
| 312 chainedMixed->appendSegment(1.0, chainedLinearSingle.get()); |
| 313 |
| 314 EXPECT_REFV_EQ(chainedMixed, chainedMixedReversed); |
| 315 } |
| 316 |
263 } // namespace | 317 } // namespace |
OLD | NEW |