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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 { | 459 { |
460 m_timing.timingFunction = m_linearTimingFunction; | 460 m_timing.timingFunction = m_linearTimingFunction; |
461 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); | 461 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); |
462 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect5.get())); | 462 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect5.get())); |
463 } | 463 } |
464 | 464 |
465 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorTim
ingFunctionCubic) | 465 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorTim
ingFunctionCubic) |
466 { | 466 { |
467 m_timing.timingFunction = m_cubicEaseTimingFunction; | 467 m_timing.timingFunction = m_cubicEaseTimingFunction; |
468 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); | 468 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); |
469 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimat
ionEffect5.get())); | 469 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect5.get())); |
470 | 470 |
471 m_timing.timingFunction = m_cubicCustomTimingFunction; | 471 m_timing.timingFunction = m_cubicCustomTimingFunction; |
472 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); | 472 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); |
473 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimat
ionEffect5.get())); | 473 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect5.get())); |
474 } | 474 } |
475 | 475 |
476 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorTim
ingFunctionSteps) | 476 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorTim
ingFunctionSteps) |
477 { | 477 { |
478 m_timing.timingFunction = m_stepTimingFunction; | 478 m_timing.timingFunction = m_stepTimingFunction; |
479 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); | 479 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); |
480 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimat
ionEffect5.get())); | 480 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect5.get())); |
481 } | 481 } |
482 | 482 |
483 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorTim
ingFunctionChainedLinear) | 483 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorTim
ingFunctionChainedLinear) |
484 { | 484 { |
485 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); | 485 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); |
486 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect5.get())); | 486 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect5.get())); |
487 } | 487 } |
488 | 488 |
489 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorNon
LinearTimingFunctionOnFirstFrame) | 489 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorNon
LinearTimingFunctionOnFirstOrLastFrame) |
490 { | 490 { |
491 m_timing.timingFunction = m_cubicEaseTimingFunction; | |
492 | |
493 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); | |
494 | |
495 (*m_keyframeVector2)[0]->setEasing(m_cubicEaseTimingFunction.get()); | 491 (*m_keyframeVector2)[0]->setEasing(m_cubicEaseTimingFunction.get()); |
496 m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create(*m_k
eyframeVector2); | 492 m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create(*m_k
eyframeVector2); |
| 493 |
| 494 (*m_keyframeVector5)[3]->setEasing(m_cubicEaseTimingFunction.get()); |
| 495 m_keyframeAnimationEffect5 = AnimatableValueKeyframeEffectModel::create(*m_k
eyframeVector5); |
| 496 |
| 497 m_timing.timingFunction = m_cubicEaseTimingFunction; |
| 498 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); |
| 499 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect5.get())); |
| 500 |
| 501 m_timing.timingFunction = m_cubicCustomTimingFunction; |
497 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimat
ionEffect2.get())); | 502 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimat
ionEffect2.get())); |
| 503 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimat
ionEffect5.get())); |
498 } | 504 } |
499 | 505 |
500 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorTim
ingFunctionChainedCubicMatchingOffsets) | 506 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorTim
ingFunctionChainedCubicMatchingOffsets) |
501 { | 507 { |
502 (*m_keyframeVector2)[0]->setEasing(m_cubicEaseTimingFunction.get()); | 508 (*m_keyframeVector2)[0]->setEasing(m_cubicEaseTimingFunction.get()); |
503 m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create(*m_k
eyframeVector2); | 509 m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create(*m_k
eyframeVector2); |
504 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); | 510 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *m_keyframeAnimati
onEffect2.get())); |
505 | 511 |
506 (*m_keyframeVector2)[0]->setEasing(m_cubicCustomTimingFunction.get()); | 512 (*m_keyframeVector2)[0]->setEasing(m_cubicCustomTimingFunction.get()); |
507 m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create(*m_k
eyframeVector2); | 513 m_keyframeAnimationEffect2 = AnimatableValueKeyframeEffectModel::create(*m_k
eyframeVector2); |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 .After(usesMockCurve); | 1098 .After(usesMockCurve); |
1093 | 1099 |
1094 // Go! | 1100 // Go! |
1095 setCompositorForTesting(mockCompositor); | 1101 setCompositorForTesting(mockCompositor); |
1096 Vector<OwnPtr<WebCompositorAnimation> > result; | 1102 Vector<OwnPtr<WebCompositorAnimation> > result; |
1097 getAnimationOnCompositor(m_timing, *effect.get(), result); | 1103 getAnimationOnCompositor(m_timing, *effect.get(), result); |
1098 EXPECT_EQ(1U, result.size()); | 1104 EXPECT_EQ(1U, result.size()); |
1099 result[0].clear(); | 1105 result[0].clear(); |
1100 } | 1106 } |
1101 | 1107 |
| 1108 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationWithTiming
Function) |
| 1109 { |
| 1110 // Animation to convert |
| 1111 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
| 1112 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
| 1113 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
| 1114 |
| 1115 m_timing.timingFunction = m_cubicCustomTimingFunction; |
| 1116 |
| 1117 WebCompositorSupportMock mockCompositor; |
| 1118 |
| 1119 // Curve is created |
| 1120 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
| 1121 ExpectationSet usesMockCurve; |
| 1122 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
| 1123 .WillOnce(Return(mockCurvePtr)); |
| 1124 |
| 1125 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
| 1126 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)))
; |
| 1127 usesMockCurve += EXPECT_CALL(*mockCurvePtr, setCubicBezierTimingFunction(1,
2, 3, 4)); |
| 1128 |
| 1129 // Create animation |
| 1130 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); |
| 1131 ExpectationSet usesMockAnimation; |
| 1132 |
| 1133 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), WebCompositorAnimation::TargetPropertyOpacity, _, _)) |
| 1134 .WillOnce(Return(mockAnimationPtr)); |
| 1135 |
| 1136 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
| 1137 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
| 1138 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setDirection(blink::WebC
ompositorAnimation::DirectionNormal)); |
| 1139 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setPlaybackRate(1)); |
| 1140 |
| 1141 EXPECT_CALL(*mockAnimationPtr, delete_()) |
| 1142 .Times(1) |
| 1143 .After(usesMockAnimation); |
| 1144 EXPECT_CALL(*mockCurvePtr, delete_()) |
| 1145 .Times(1) |
| 1146 .After(usesMockCurve); |
| 1147 |
| 1148 // Go! |
| 1149 setCompositorForTesting(mockCompositor); |
| 1150 Vector<OwnPtr<WebCompositorAnimation> > result; |
| 1151 getAnimationOnCompositor(m_timing, *effect.get(), result); |
| 1152 EXPECT_EQ(1U, result.size()); |
| 1153 result[0].clear(); |
| 1154 } |
| 1155 |
1102 } // namespace blink | 1156 } // namespace blink |
OLD | NEW |