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 25 matching lines...) Expand all Loading... |
36 #include "core/animation/CompositorAnimationsTestHelper.h" | 36 #include "core/animation/CompositorAnimationsTestHelper.h" |
37 #include "core/animation/animatable/AnimatableDouble.h" | 37 #include "core/animation/animatable/AnimatableDouble.h" |
38 #include "core/animation/animatable/AnimatableFilterOperations.h" | 38 #include "core/animation/animatable/AnimatableFilterOperations.h" |
39 #include "core/animation/animatable/AnimatableTransform.h" | 39 #include "core/animation/animatable/AnimatableTransform.h" |
40 #include "core/animation/animatable/AnimatableValueTestHelper.h" | 40 #include "core/animation/animatable/AnimatableValueTestHelper.h" |
41 #include "platform/geometry/FloatBox.h" | 41 #include "platform/geometry/FloatBox.h" |
42 #include "platform/geometry/IntSize.h" | 42 #include "platform/geometry/IntSize.h" |
43 #include "platform/graphics/filters/FilterOperations.h" | 43 #include "platform/graphics/filters/FilterOperations.h" |
44 #include "platform/transforms/TransformOperations.h" | 44 #include "platform/transforms/TransformOperations.h" |
45 #include "platform/transforms/TranslateTransformOperation.h" | 45 #include "platform/transforms/TranslateTransformOperation.h" |
46 #include "public/platform/WebAnimation.h" | 46 #include "public/platform/WebCompositorAnimation.h" |
47 #include "wtf/HashFunctions.h" | 47 #include "wtf/HashFunctions.h" |
48 #include "wtf/OwnPtr.h" | 48 #include "wtf/OwnPtr.h" |
49 #include "wtf/PassOwnPtr.h" | 49 #include "wtf/PassOwnPtr.h" |
50 #include "wtf/PassRefPtr.h" | 50 #include "wtf/PassRefPtr.h" |
51 #include "wtf/RefPtr.h" | 51 #include "wtf/RefPtr.h" |
52 | 52 |
53 #include <gmock/gmock.h> | 53 #include <gmock/gmock.h> |
54 #include <gtest/gtest.h> | 54 #include <gtest/gtest.h> |
55 | 55 |
56 namespace blink { | 56 namespace blink { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 public: | 100 public: |
101 | 101 |
102 bool convertTimingForCompositor(const Timing& t, CompositorAnimationsImpl::C
ompositorTiming& out) | 102 bool convertTimingForCompositor(const Timing& t, CompositorAnimationsImpl::C
ompositorTiming& out) |
103 { | 103 { |
104 return CompositorAnimationsImpl::convertTimingForCompositor(t, out); | 104 return CompositorAnimationsImpl::convertTimingForCompositor(t, out); |
105 } | 105 } |
106 bool isCandidateForAnimationOnCompositor(const Timing& timing, const Animati
onEffect& effect) | 106 bool isCandidateForAnimationOnCompositor(const Timing& timing, const Animati
onEffect& effect) |
107 { | 107 { |
108 return CompositorAnimations::instance()->isCandidateForAnimationOnCompos
itor(timing, effect); | 108 return CompositorAnimations::instance()->isCandidateForAnimationOnCompos
itor(timing, effect); |
109 } | 109 } |
110 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM
odel& effect, Vector<OwnPtr<blink::WebAnimation> >& animations) | 110 void getAnimationOnCompositor(Timing& timing, AnimatableValueKeyframeEffectM
odel& effect, Vector<OwnPtr<WebCompositorAnimation> >& animations) |
111 { | 111 { |
112 return CompositorAnimationsImpl::getAnimationOnCompositor(timing, std::n
umeric_limits<double>::quiet_NaN(), effect, animations); | 112 return CompositorAnimationsImpl::getAnimationOnCompositor(timing, std::n
umeric_limits<double>::quiet_NaN(), effect, animations); |
113 } | 113 } |
114 bool getAnimationBounds(FloatBox& boundingBox, const AnimationEffect& effect
, double minValue, double maxValue) | 114 bool getAnimationBounds(FloatBox& boundingBox, const AnimationEffect& effect
, double minValue, double maxValue) |
115 { | 115 { |
116 return CompositorAnimations::instance()->getAnimatedBoundingBox(bounding
Box, effect, minValue, maxValue); | 116 return CompositorAnimations::instance()->getAnimatedBoundingBox(bounding
Box, effect, minValue, maxValue); |
117 } | 117 } |
118 | 118 |
119 bool duplicateSingleKeyframeAndTestIsCandidateOnResult(AnimatableValueKeyfra
me* frame) | 119 bool duplicateSingleKeyframeAndTestIsCandidateOnResult(AnimatableValueKeyfra
me* frame) |
120 { | 120 { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeGoodMu
ltiple.get())); | 239 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeGoodMu
ltiple.get())); |
240 | 240 |
241 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeBadMultipleID = createDe
faultKeyframe(CSSPropertyColor, AnimationEffect::CompositeReplace); | 241 RefPtrWillBeRawPtr<AnimatableValueKeyframe> keyframeBadMultipleID = createDe
faultKeyframe(CSSPropertyColor, AnimationEffect::CompositeReplace); |
242 keyframeBadMultipleID->setPropertyValue(CSSPropertyOpacity, AnimatableDouble
::create(10.0).get()); | 242 keyframeBadMultipleID->setPropertyValue(CSSPropertyOpacity, AnimatableDouble
::create(10.0).get()); |
243 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeBadMu
ltipleID.get())); | 243 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(keyframeBadMu
ltipleID.get())); |
244 } | 244 } |
245 | 245 |
246 TEST_F(AnimationCompositorAnimationsTest, isNotCandidateForCompositorAnimationTr
ansformDependsOnBoxSize) | 246 TEST_F(AnimationCompositorAnimationsTest, isNotCandidateForCompositorAnimationTr
ansformDependsOnBoxSize) |
247 { | 247 { |
248 TransformOperations ops; | 248 TransformOperations ops; |
249 ops.operations().append(TranslateTransformOperation::create(Length(2, blink:
:Fixed), Length(2, blink::Fixed), TransformOperation::TranslateX)); | 249 ops.operations().append(TranslateTransformOperation::create(Length(2, Fixed)
, Length(2, Fixed), TransformOperation::TranslateX)); |
250 RefPtrWillBeRawPtr<AnimatableValueKeyframe> goodKeyframe = createReplaceOpKe
yframe(CSSPropertyTransform, AnimatableTransform::create(ops).get()); | 250 RefPtrWillBeRawPtr<AnimatableValueKeyframe> goodKeyframe = createReplaceOpKe
yframe(CSSPropertyTransform, AnimatableTransform::create(ops).get()); |
251 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(goodKeyframe.g
et())); | 251 EXPECT_TRUE(duplicateSingleKeyframeAndTestIsCandidateOnResult(goodKeyframe.g
et())); |
252 | 252 |
253 ops.operations().append(TranslateTransformOperation::create(Length(50, blink
::Percent), Length(2, blink::Fixed), TransformOperation::TranslateX)); | 253 ops.operations().append(TranslateTransformOperation::create(Length(50, Perce
nt), Length(2, Fixed), TransformOperation::TranslateX)); |
254 RefPtrWillBeRawPtr<AnimatableValueKeyframe> badKeyframe = createReplaceOpKey
frame(CSSPropertyTransform, AnimatableTransform::create(ops).get()); | 254 RefPtrWillBeRawPtr<AnimatableValueKeyframe> badKeyframe = createReplaceOpKey
frame(CSSPropertyTransform, AnimatableTransform::create(ops).get()); |
255 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe.g
et())); | 255 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe.g
et())); |
256 | 256 |
257 TransformOperations ops2; | 257 TransformOperations ops2; |
258 Length calcLength = Length(100, blink::Percent).blend(Length(100, blink::Fix
ed), 0.5, blink::ValueRangeAll); | 258 Length calcLength = Length(100, Percent).blend(Length(100, Fixed), 0.5, Valu
eRangeAll); |
259 ops2.operations().append(TranslateTransformOperation::create(calcLength, Len
gth(0, blink::Fixed), TransformOperation::TranslateX)); | 259 ops2.operations().append(TranslateTransformOperation::create(calcLength, Len
gth(0, Fixed), TransformOperation::TranslateX)); |
260 RefPtrWillBeRawPtr<AnimatableValueKeyframe> badKeyframe2 = createReplaceOpKe
yframe(CSSPropertyTransform, AnimatableTransform::create(ops2).get()); | 260 RefPtrWillBeRawPtr<AnimatableValueKeyframe> badKeyframe2 = createReplaceOpKe
yframe(CSSPropertyTransform, AnimatableTransform::create(ops2).get()); |
261 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe2.
get())); | 261 EXPECT_FALSE(duplicateSingleKeyframeAndTestIsCandidateOnResult(badKeyframe2.
get())); |
262 } | 262 } |
263 | 263 |
264 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModelMultipleFramesOkay) | 264 TEST_F(AnimationCompositorAnimationsTest, isCandidateForAnimationOnCompositorKey
frameEffectModelMultipleFramesOkay) |
265 { | 265 { |
266 AnimatableValueKeyframeVector framesSame; | 266 AnimatableValueKeyframeVector framesSame; |
267 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 0.0).get()); | 267 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 0.0).get()); |
268 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 1.0).get()); | 268 framesSame.append(createDefaultKeyframe(CSSPropertyOpacity, AnimationEffect:
:CompositeReplace, 1.0).get()); |
269 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueKe
yframeEffectModel::create(framesSame).get())); | 269 EXPECT_TRUE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueKe
yframeEffectModel::create(framesSame).get())); |
(...skipping 14 matching lines...) Expand all Loading... |
284 AnimatableValueKeyframeVector framesMixedProperties; | 284 AnimatableValueKeyframeVector framesMixedProperties; |
285 framesMixedProperties.append(createDefaultKeyframe(CSSPropertyOpacity, Anima
tionEffect::CompositeReplace, 0.0).get()); | 285 framesMixedProperties.append(createDefaultKeyframe(CSSPropertyOpacity, Anima
tionEffect::CompositeReplace, 0.0).get()); |
286 framesMixedProperties.append(createDefaultKeyframe(CSSPropertyColor, Animati
onEffect::CompositeReplace, 1.0).get()); | 286 framesMixedProperties.append(createDefaultKeyframe(CSSPropertyColor, Animati
onEffect::CompositeReplace, 1.0).get()); |
287 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesMixedProperties).get())); | 287 EXPECT_FALSE(isCandidateForAnimationOnCompositor(m_timing, *AnimatableValueK
eyframeEffectModel::create(framesMixedProperties).get())); |
288 } | 288 } |
289 | 289 |
290 TEST_F(AnimationCompositorAnimationsTest, AnimatedBoundingBox) | 290 TEST_F(AnimationCompositorAnimationsTest, AnimatedBoundingBox) |
291 { | 291 { |
292 Vector<TransformOperations> transformVector; | 292 Vector<TransformOperations> transformVector; |
293 transformVector.append(TransformOperations()); | 293 transformVector.append(TransformOperations()); |
294 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(0, blink::Fixed), Length(0, blink::Fixed), 0.0, TransformOperation::Tr
anslate3D)); | 294 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(0, Fixed), Length(0, Fixed), 0.0, TransformOperation::Translate3D)); |
295 transformVector.append(TransformOperations()); | 295 transformVector.append(TransformOperations()); |
296 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(200, blink::Fixed), Length(200, blink::Fixed), 0.0, TransformOperation
::Translate3D)); | 296 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(200, Fixed), Length(200, Fixed), 0.0, TransformOperation::Translate3D)
); |
297 OwnPtrWillBePersistent<AnimatableValueKeyframeVector> frames = createComposi
tableTransformKeyframeVector(transformVector); | 297 OwnPtrWillBePersistent<AnimatableValueKeyframeVector> frames = createComposi
tableTransformKeyframeVector(transformVector); |
298 FloatBox bounds; | 298 FloatBox bounds; |
299 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames).get(), 0, 1)); | 299 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames).get(), 0, 1)); |
300 EXPECT_EQ(FloatBox(0.0f, 0.f, 0.0f, 200.0f, 200.0f, 0.0f), bounds); | 300 EXPECT_EQ(FloatBox(0.0f, 0.f, 0.0f, 200.0f, 200.0f, 0.0f), bounds); |
301 bounds = FloatBox(); | 301 bounds = FloatBox(); |
302 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames).get(), -1, 1)); | 302 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames).get(), -1, 1)); |
303 EXPECT_EQ(FloatBox(-200.0f, -200.0, 0.0, 400.0f, 400.0f, 0.0f), bounds); | 303 EXPECT_EQ(FloatBox(-200.0f, -200.0, 0.0, 400.0f, 400.0f, 0.0f), bounds); |
304 transformVector.append(TransformOperations()); | 304 transformVector.append(TransformOperations()); |
305 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(-300, blink::Fixed), Length(-400, blink::Fixed), 1.0f, TransformOperat
ion::Translate3D)); | 305 transformVector.last().operations().append(TranslateTransformOperation::crea
te(Length(-300, Fixed), Length(-400, Fixed), 1.0f, TransformOperation::Translate
3D)); |
306 bounds = FloatBox(); | 306 bounds = FloatBox(); |
307 frames = createCompositableTransformKeyframeVector(transformVector); | 307 frames = createCompositableTransformKeyframeVector(transformVector); |
308 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames).get(), 0, 1)); | 308 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames).get(), 0, 1)); |
309 EXPECT_EQ(FloatBox(-300.0f, -400.f, 0.0f, 500.0f, 600.0f, 1.0f), bounds); | 309 EXPECT_EQ(FloatBox(-300.0f, -400.f, 0.0f, 500.0f, 600.0f, 1.0f), bounds); |
310 bounds = FloatBox(); | 310 bounds = FloatBox(); |
311 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames).get(), -1, 2)); | 311 EXPECT_TRUE(getAnimationBounds(bounds, *AnimatableValueKeyframeEffectModel::
create(*frames).get(), -1, 2)); |
312 EXPECT_EQ(FloatBox(-1300.0f, -1600.f, 0.0f, 1500.0f, 1800.0f, 3.0f), bounds)
; | 312 EXPECT_EQ(FloatBox(-1300.0f, -1600.f, 0.0f, 1500.0f, 1800.0f, 3.0f), bounds)
; |
313 } | 313 } |
314 | 314 |
315 TEST_F(AnimationCompositorAnimationsTest, ConvertTimingForCompositorStartDelay) | 315 TEST_F(AnimationCompositorAnimationsTest, ConvertTimingForCompositorStartDelay) |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 { | 577 { |
578 // Animation to convert | 578 // Animation to convert |
579 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 579 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
580 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 580 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
581 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 581 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
582 // -- | 582 // -- |
583 | 583 |
584 WebCompositorSupportMock mockCompositor; | 584 WebCompositorSupportMock mockCompositor; |
585 | 585 |
586 // Curve is created | 586 // Curve is created |
587 blink::WebFloatAnimationCurveMock* mockCurvePtr = new blink::WebFloatAnimati
onCurveMock; | 587 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
588 ExpectationSet usesMockCurve; | 588 ExpectationSet usesMockCurve; |
589 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 589 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
590 .WillOnce(Return(mockCurvePtr)); | 590 .WillOnce(Return(mockCurvePtr)); |
591 | 591 |
592 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(0.0,
2.0), blink::WebAnimationCurve::TimingFunctionTypeLinear)); | 592 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
593 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(1.0,
5.0))); | 593 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)))
; |
594 | 594 |
595 // Create animation | 595 // Create animation |
596 blink::WebAnimationMock* mockAnimationPtr = new blink::WebAnimationMock(blin
k::WebAnimation::TargetPropertyOpacity); | 596 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); |
597 ExpectationSet usesMockAnimation; | 597 ExpectationSet usesMockAnimation; |
598 | 598 |
599 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), blink::WebAnimation::TargetPropertyOpacity, _)) | 599 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), WebCompositorAnimation::TargetPropertyOpacity, _)) |
600 .WillOnce(Return(mockAnimationPtr)); | 600 .WillOnce(Return(mockAnimationPtr)); |
601 | 601 |
602 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | 602 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
603 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 603 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
604 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(f
alse)); | 604 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(f
alse)); |
605 | 605 |
606 EXPECT_CALL(*mockAnimationPtr, delete_()) | 606 EXPECT_CALL(*mockAnimationPtr, delete_()) |
607 .Times(1) | 607 .Times(1) |
608 .After(usesMockAnimation); | 608 .After(usesMockAnimation); |
609 EXPECT_CALL(*mockCurvePtr, delete_()) | 609 EXPECT_CALL(*mockCurvePtr, delete_()) |
610 .Times(1) | 610 .Times(1) |
611 .After(usesMockCurve); | 611 .After(usesMockCurve); |
612 | 612 |
613 // Go! | 613 // Go! |
614 setCompositorForTesting(mockCompositor); | 614 setCompositorForTesting(mockCompositor); |
615 Vector<OwnPtr<blink::WebAnimation> > result; | 615 Vector<OwnPtr<WebCompositorAnimation> > result; |
616 getAnimationOnCompositor(m_timing, *effect.get(), result); | 616 getAnimationOnCompositor(m_timing, *effect.get(), result); |
617 EXPECT_EQ(1U, result.size()); | 617 EXPECT_EQ(1U, result.size()); |
618 result[0].clear(); | 618 result[0].clear(); |
619 } | 619 } |
620 | 620 |
621 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) | 621 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationDuration) |
622 { | 622 { |
623 // Animation to convert | 623 // Animation to convert |
624 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 624 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
625 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 625 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
626 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 626 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
627 | 627 |
628 m_timing.iterationDuration = 10.0; | 628 m_timing.iterationDuration = 10.0; |
629 // -- | 629 // -- |
630 | 630 |
631 WebCompositorSupportMock mockCompositor; | 631 WebCompositorSupportMock mockCompositor; |
632 | 632 |
633 // Curve is created | 633 // Curve is created |
634 blink::WebFloatAnimationCurveMock* mockCurvePtr = new blink::WebFloatAnimati
onCurveMock; | 634 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
635 ExpectationSet usesMockCurve; | 635 ExpectationSet usesMockCurve; |
636 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 636 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
637 .WillOnce(Return(mockCurvePtr)); | 637 .WillOnce(Return(mockCurvePtr)); |
638 | 638 |
639 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(0.0,
2.0), blink::WebAnimationCurve::TimingFunctionTypeLinear)); | 639 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
640 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(10.0
, 5.0))); | 640 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(10.0, 5.0))
); |
641 | 641 |
642 // Create animation | 642 // Create animation |
643 blink::WebAnimationMock* mockAnimationPtr = new blink::WebAnimationMock(blin
k::WebAnimation::TargetPropertyOpacity); | 643 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); |
644 ExpectationSet usesMockAnimation; | 644 ExpectationSet usesMockAnimation; |
645 | 645 |
646 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), blink::WebAnimation::TargetPropertyOpacity, _)) | 646 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), WebCompositorAnimation::TargetPropertyOpacity, _)) |
647 .WillOnce(Return(mockAnimationPtr)); | 647 .WillOnce(Return(mockAnimationPtr)); |
648 | 648 |
649 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); | 649 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(1)); |
650 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 650 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
651 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(f
alse)); | 651 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(f
alse)); |
652 | 652 |
653 EXPECT_CALL(*mockAnimationPtr, delete_()) | 653 EXPECT_CALL(*mockAnimationPtr, delete_()) |
654 .Times(1) | 654 .Times(1) |
655 .After(usesMockAnimation); | 655 .After(usesMockAnimation); |
656 EXPECT_CALL(*mockCurvePtr, delete_()) | 656 EXPECT_CALL(*mockCurvePtr, delete_()) |
657 .Times(1) | 657 .Times(1) |
658 .After(usesMockCurve); | 658 .After(usesMockCurve); |
659 | 659 |
660 // Go! | 660 // Go! |
661 setCompositorForTesting(mockCompositor); | 661 setCompositorForTesting(mockCompositor); |
662 Vector<OwnPtr<blink::WebAnimation> > result; | 662 Vector<OwnPtr<WebCompositorAnimation> > result; |
663 getAnimationOnCompositor(m_timing, *effect.get(), result); | 663 getAnimationOnCompositor(m_timing, *effect.get(), result); |
664 EXPECT_EQ(1U, result.size()); | 664 EXPECT_EQ(1U, result.size()); |
665 result[0].clear(); | 665 result[0].clear(); |
666 } | 666 } |
667 | 667 |
668 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Linear) | 668 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Linear) |
669 { | 669 { |
670 // Animation to convert | 670 // Animation to convert |
671 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 671 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
672 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 672 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
673 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1.
0).get(), 0.25), | 673 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(-1.
0).get(), 0.25), |
674 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(20.
0).get(), 0.5), | 674 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(20.
0).get(), 0.5), |
675 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 675 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
676 | 676 |
677 m_timing.iterationCount = 5; | 677 m_timing.iterationCount = 5; |
678 m_timing.direction = Timing::PlaybackDirectionAlternate; | 678 m_timing.direction = Timing::PlaybackDirectionAlternate; |
679 // -- | 679 // -- |
680 | 680 |
681 WebCompositorSupportMock mockCompositor; | 681 WebCompositorSupportMock mockCompositor; |
682 | 682 |
683 // Curve is created | 683 // Curve is created |
684 blink::WebFloatAnimationCurveMock* mockCurvePtr = new blink::WebFloatAnimati
onCurveMock(); | 684 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); |
685 ExpectationSet usesMockCurve; | 685 ExpectationSet usesMockCurve; |
686 | 686 |
687 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 687 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
688 .WillOnce(Return(mockCurvePtr)); | 688 .WillOnce(Return(mockCurvePtr)); |
689 | 689 |
690 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(0.0,
2.0), blink::WebAnimationCurve::TimingFunctionTypeLinear)); | 690 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
691 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(0.25
, -1.0), blink::WebAnimationCurve::TimingFunctionTypeLinear)); | 691 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.25, -1.0)
, WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
692 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(0.5,
20.0), blink::WebAnimationCurve::TimingFunctionTypeLinear)); | 692 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.5, 20.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
693 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(1.0,
5.0))); | 693 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 5.0)))
; |
694 | 694 |
695 // Animation is created | 695 // Animation is created |
696 blink::WebAnimationMock* mockAnimationPtr = new blink::WebAnimationMock(blin
k::WebAnimation::TargetPropertyOpacity); | 696 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); |
697 ExpectationSet usesMockAnimation; | 697 ExpectationSet usesMockAnimation; |
698 | 698 |
699 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), blink::WebAnimation::TargetPropertyOpacity, _)) | 699 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), WebCompositorAnimation::TargetPropertyOpacity, _)) |
700 .WillOnce(Return(mockAnimationPtr)); | 700 .WillOnce(Return(mockAnimationPtr)); |
701 | 701 |
702 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); | 702 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); |
703 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 703 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
704 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(t
rue)); | 704 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(t
rue)); |
705 | 705 |
706 EXPECT_CALL(*mockAnimationPtr, delete_()) | 706 EXPECT_CALL(*mockAnimationPtr, delete_()) |
707 .Times(1) | 707 .Times(1) |
708 .After(usesMockAnimation); | 708 .After(usesMockAnimation); |
709 EXPECT_CALL(*mockCurvePtr, delete_()) | 709 EXPECT_CALL(*mockCurvePtr, delete_()) |
710 .Times(1) | 710 .Times(1) |
711 .After(usesMockCurve); | 711 .After(usesMockCurve); |
712 | 712 |
713 // Go! | 713 // Go! |
714 setCompositorForTesting(mockCompositor); | 714 setCompositorForTesting(mockCompositor); |
715 Vector<OwnPtr<blink::WebAnimation> > result; | 715 Vector<OwnPtr<WebCompositorAnimation> > result; |
716 getAnimationOnCompositor(m_timing, *effect.get(), result); | 716 getAnimationOnCompositor(m_timing, *effect.get(), result); |
717 EXPECT_EQ(1U, result.size()); | 717 EXPECT_EQ(1U, result.size()); |
718 result[0].clear(); | 718 result[0].clear(); |
719 } | 719 } |
720 | 720 |
721 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay
) | 721 TEST_F(AnimationCompositorAnimationsTest, createSimpleOpacityAnimationStartDelay
) |
722 { | 722 { |
723 // Animation to convert | 723 // Animation to convert |
724 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 724 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
725 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 725 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
726 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 726 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
727 | 727 |
728 m_timing.iterationCount = 5.0; | 728 m_timing.iterationCount = 5.0; |
729 m_timing.iterationDuration = 1.75; | 729 m_timing.iterationDuration = 1.75; |
730 m_timing.startDelay = 3.25; | 730 m_timing.startDelay = 3.25; |
731 // -- | 731 // -- |
732 | 732 |
733 WebCompositorSupportMock mockCompositor; | 733 WebCompositorSupportMock mockCompositor; |
734 | 734 |
735 // Curve is created | 735 // Curve is created |
736 blink::WebFloatAnimationCurveMock* mockCurvePtr = new blink::WebFloatAnimati
onCurveMock; | 736 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
737 ExpectationSet usesMockCurve; | 737 ExpectationSet usesMockCurve; |
738 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 738 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
739 .WillOnce(Return(mockCurvePtr)); | 739 .WillOnce(Return(mockCurvePtr)); |
740 | 740 |
741 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(0.0,
2.0), blink::WebAnimationCurve::TimingFunctionTypeLinear)); | 741 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
742 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(1.75
, 5.0))); | 742 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.75, 5.0))
); |
743 | 743 |
744 // Create animation | 744 // Create animation |
745 blink::WebAnimationMock* mockAnimationPtr = new blink::WebAnimationMock(blin
k::WebAnimation::TargetPropertyOpacity); | 745 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); |
746 ExpectationSet usesMockAnimation; | 746 ExpectationSet usesMockAnimation; |
747 | 747 |
748 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), blink::WebAnimation::TargetPropertyOpacity, _)) | 748 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), WebCompositorAnimation::TargetPropertyOpacity, _)) |
749 .WillOnce(Return(mockAnimationPtr)); | 749 .WillOnce(Return(mockAnimationPtr)); |
750 | 750 |
751 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); | 751 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); |
752 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(-3.25)); | 752 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(-3.25)); |
753 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(f
alse)); | 753 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(f
alse)); |
754 | 754 |
755 EXPECT_CALL(*mockAnimationPtr, delete_()) | 755 EXPECT_CALL(*mockAnimationPtr, delete_()) |
756 .Times(1) | 756 .Times(1) |
757 .After(usesMockAnimation); | 757 .After(usesMockAnimation); |
758 EXPECT_CALL(*mockCurvePtr, delete_()) | 758 EXPECT_CALL(*mockCurvePtr, delete_()) |
759 .Times(1) | 759 .Times(1) |
760 .After(usesMockCurve); | 760 .After(usesMockCurve); |
761 | 761 |
762 // Go! | 762 // Go! |
763 setCompositorForTesting(mockCompositor); | 763 setCompositorForTesting(mockCompositor); |
764 Vector<OwnPtr<blink::WebAnimation> > result; | 764 Vector<OwnPtr<WebCompositorAnimation> > result; |
765 getAnimationOnCompositor(m_timing, *effect.get(), result); | 765 getAnimationOnCompositor(m_timing, *effect.get(), result); |
766 EXPECT_EQ(1U, result.size()); | 766 EXPECT_EQ(1U, result.size()); |
767 result[0].clear(); | 767 result[0].clear(); |
768 } | 768 } |
769 | 769 |
770 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Chained) | 770 TEST_F(AnimationCompositorAnimationsTest, createMultipleKeyframeOpacityAnimation
Chained) |
771 { | 771 { |
772 // Animation to convert | 772 // Animation to convert |
773 AnimatableValueKeyframeVector frames; | 773 AnimatableValueKeyframeVector frames; |
774 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); | 774 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); |
775 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); | 775 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); |
776 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); | 776 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); |
777 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); | 777 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); |
778 frames[0]->setEasing(m_cubicEaseTimingFunction.get()); | 778 frames[0]->setEasing(m_cubicEaseTimingFunction.get()); |
779 frames[1]->setEasing(m_linearTimingFunction.get()); | 779 frames[1]->setEasing(m_linearTimingFunction.get()); |
780 frames[2]->setEasing(m_cubicCustomTimingFunction.get()); | 780 frames[2]->setEasing(m_cubicCustomTimingFunction.get()); |
781 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa
lueKeyframeEffectModel::create(frames); | 781 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa
lueKeyframeEffectModel::create(frames); |
782 | 782 |
783 m_timing.timingFunction = m_linearTimingFunction.get(); | 783 m_timing.timingFunction = m_linearTimingFunction.get(); |
784 m_timing.iterationDuration = 2.0; | 784 m_timing.iterationDuration = 2.0; |
785 m_timing.iterationCount = 10; | 785 m_timing.iterationCount = 10; |
786 m_timing.direction = Timing::PlaybackDirectionAlternate; | 786 m_timing.direction = Timing::PlaybackDirectionAlternate; |
787 // -- | 787 // -- |
788 | 788 |
789 WebCompositorSupportMock mockCompositor; | 789 WebCompositorSupportMock mockCompositor; |
790 | 790 |
791 // Curve is created | 791 // Curve is created |
792 blink::WebFloatAnimationCurveMock* mockCurvePtr = new blink::WebFloatAnimati
onCurveMock(); | 792 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); |
793 ExpectationSet usesMockCurve; | 793 ExpectationSet usesMockCurve; |
794 | 794 |
795 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 795 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
796 .WillOnce(Return(mockCurvePtr)); | 796 .WillOnce(Return(mockCurvePtr)); |
797 | 797 |
798 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(0.0,
2.0), blink::WebAnimationCurve::TimingFunctionTypeEase)); | 798 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 2.0),
WebCompositorAnimationCurve::TimingFunctionTypeEase)); |
799 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(0.5,
-1.0), blink::WebAnimationCurve::TimingFunctionTypeLinear)); | 799 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.5, -1.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
800 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(1.0,
20.0), 1.0, 2.0, 3.0, 4.0)); | 800 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 20.0),
1.0, 2.0, 3.0, 4.0)); |
801 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(2.0,
5.0))); | 801 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(2.0, 5.0)))
; |
802 | 802 |
803 // Animation is created | 803 // Animation is created |
804 blink::WebAnimationMock* mockAnimationPtr = new blink::WebAnimationMock(blin
k::WebAnimation::TargetPropertyOpacity); | 804 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); |
805 ExpectationSet usesMockAnimation; | 805 ExpectationSet usesMockAnimation; |
806 | 806 |
807 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), blink::WebAnimation::TargetPropertyOpacity, _)) | 807 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), WebCompositorAnimation::TargetPropertyOpacity, _)) |
808 .WillOnce(Return(mockAnimationPtr)); | 808 .WillOnce(Return(mockAnimationPtr)); |
809 | 809 |
810 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); | 810 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); |
811 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 811 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
812 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(t
rue)); | 812 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(t
rue)); |
813 | 813 |
814 EXPECT_CALL(*mockAnimationPtr, delete_()) | 814 EXPECT_CALL(*mockAnimationPtr, delete_()) |
815 .Times(1) | 815 .Times(1) |
816 .After(usesMockAnimation); | 816 .After(usesMockAnimation); |
817 EXPECT_CALL(*mockCurvePtr, delete_()) | 817 EXPECT_CALL(*mockCurvePtr, delete_()) |
818 .Times(1) | 818 .Times(1) |
819 .After(usesMockCurve); | 819 .After(usesMockCurve); |
820 | 820 |
821 // Go! | 821 // Go! |
822 setCompositorForTesting(mockCompositor); | 822 setCompositorForTesting(mockCompositor); |
823 Vector<OwnPtr<blink::WebAnimation> > result; | 823 Vector<OwnPtr<WebCompositorAnimation> > result; |
824 getAnimationOnCompositor(m_timing, *effect.get(), result); | 824 getAnimationOnCompositor(m_timing, *effect.get(), result); |
825 EXPECT_EQ(1U, result.size()); | 825 EXPECT_EQ(1U, result.size()); |
826 result[0].clear(); | 826 result[0].clear(); |
827 } | 827 } |
828 | 828 |
829 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) | 829 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimation) |
830 { | 830 { |
831 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = CubicBezierTimingFuncti
on::create(0.0, 0.0, 0.0, 1.0); | 831 RefPtr<TimingFunction> cubicEasyFlipTimingFunction = CubicBezierTimingFuncti
on::create(0.0, 0.0, 0.0, 1.0); |
832 | 832 |
833 // Animation to convert | 833 // Animation to convert |
834 AnimatableValueKeyframeVector frames; | 834 AnimatableValueKeyframeVector frames; |
835 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); | 835 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(2.0).get(), 0)); |
836 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); | 836 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(-1.0).get(), 0.25)); |
837 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); | 837 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(20.0).get(), 0.5)); |
838 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); | 838 frames.append(createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::
create(5.0).get(), 1.0)); |
839 frames[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingFunc
tion::EaseIn)); | 839 frames[0]->setEasing(CubicBezierTimingFunction::preset(CubicBezierTimingFunc
tion::EaseIn)); |
840 frames[1]->setEasing(m_linearTimingFunction.get()); | 840 frames[1]->setEasing(m_linearTimingFunction.get()); |
841 frames[2]->setEasing(cubicEasyFlipTimingFunction.get()); | 841 frames[2]->setEasing(cubicEasyFlipTimingFunction.get()); |
842 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa
lueKeyframeEffectModel::create(frames); | 842 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = AnimatableVa
lueKeyframeEffectModel::create(frames); |
843 | 843 |
844 m_timing.timingFunction = m_linearTimingFunction.get(); | 844 m_timing.timingFunction = m_linearTimingFunction.get(); |
845 m_timing.iterationCount = 10; | 845 m_timing.iterationCount = 10; |
846 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; | 846 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; |
847 // -- | 847 // -- |
848 | 848 |
849 WebCompositorSupportMock mockCompositor; | 849 WebCompositorSupportMock mockCompositor; |
850 | 850 |
851 // Curve is created | 851 // Curve is created |
852 blink::WebFloatAnimationCurveMock* mockCurvePtr = new blink::WebFloatAnimati
onCurveMock(); | 852 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock(); |
853 ExpectationSet usesMockCurve; | 853 ExpectationSet usesMockCurve; |
854 | 854 |
855 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 855 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
856 .WillOnce(Return(mockCurvePtr)); | 856 .WillOnce(Return(mockCurvePtr)); |
857 | 857 |
858 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(0.0,
5.0), 1.0, 0.0, 1.0, 1.0)); | 858 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 5.0),
1.0, 0.0, 1.0, 1.0)); |
859 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(0.5,
20.0), blink::WebAnimationCurve::TimingFunctionTypeLinear)); | 859 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.5, 20.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
860 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(0.75
, -1.0), blink::WebAnimationCurve::TimingFunctionTypeEaseOut)); | 860 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.75, -1.0)
, WebCompositorAnimationCurve::TimingFunctionTypeEaseOut)); |
861 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(1.0,
2.0))); | 861 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.0, 2.0)))
; |
862 | 862 |
863 // Create the animation | 863 // Create the animation |
864 blink::WebAnimationMock* mockAnimationPtr = new blink::WebAnimationMock(blin
k::WebAnimation::TargetPropertyOpacity); | 864 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); |
865 ExpectationSet usesMockAnimation; | 865 ExpectationSet usesMockAnimation; |
866 | 866 |
867 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), blink::WebAnimation::TargetPropertyOpacity, _)) | 867 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), WebCompositorAnimation::TargetPropertyOpacity, _)) |
868 .WillOnce(Return(mockAnimationPtr)); | 868 .WillOnce(Return(mockAnimationPtr)); |
869 | 869 |
870 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); | 870 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(10)); |
871 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); | 871 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(0.0)); |
872 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(t
rue)); | 872 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(t
rue)); |
873 | 873 |
874 EXPECT_CALL(*mockAnimationPtr, delete_()) | 874 EXPECT_CALL(*mockAnimationPtr, delete_()) |
875 .Times(1) | 875 .Times(1) |
876 .After(usesMockAnimation); | 876 .After(usesMockAnimation); |
877 EXPECT_CALL(*mockCurvePtr, delete_()) | 877 EXPECT_CALL(*mockCurvePtr, delete_()) |
878 .Times(1) | 878 .Times(1) |
879 .After(usesMockCurve); | 879 .After(usesMockCurve); |
880 | 880 |
881 // Go! | 881 // Go! |
882 setCompositorForTesting(mockCompositor); | 882 setCompositorForTesting(mockCompositor); |
883 Vector<OwnPtr<blink::WebAnimation> > result; | 883 Vector<OwnPtr<WebCompositorAnimation> > result; |
884 getAnimationOnCompositor(m_timing, *effect.get(), result); | 884 getAnimationOnCompositor(m_timing, *effect.get(), result); |
885 EXPECT_EQ(1U, result.size()); | 885 EXPECT_EQ(1U, result.size()); |
886 result[0].clear(); | 886 result[0].clear(); |
887 } | 887 } |
888 | 888 |
889 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative
StartDelay) | 889 TEST_F(AnimationCompositorAnimationsTest, createReversedOpacityAnimationNegative
StartDelay) |
890 { | 890 { |
891 // Animation to convert | 891 // Animation to convert |
892 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( | 892 RefPtrWillBeRawPtr<AnimatableValueKeyframeEffectModel> effect = createKeyfra
meEffectModel( |
893 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), | 893 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(2.0
).get(), 0), |
894 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); | 894 createReplaceOpKeyframe(CSSPropertyOpacity, AnimatableDouble::create(5.0
).get(), 1.0)); |
895 | 895 |
896 m_timing.iterationCount = 5.0; | 896 m_timing.iterationCount = 5.0; |
897 m_timing.iterationDuration = 1.5; | 897 m_timing.iterationDuration = 1.5; |
898 m_timing.startDelay = -3; | 898 m_timing.startDelay = -3; |
899 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; | 899 m_timing.direction = Timing::PlaybackDirectionAlternateReverse; |
900 // -- | 900 // -- |
901 | 901 |
902 WebCompositorSupportMock mockCompositor; | 902 WebCompositorSupportMock mockCompositor; |
903 | 903 |
904 // Curve is created | 904 // Curve is created |
905 blink::WebFloatAnimationCurveMock* mockCurvePtr = new blink::WebFloatAnimati
onCurveMock; | 905 WebFloatAnimationCurveMock* mockCurvePtr = new WebFloatAnimationCurveMock; |
906 ExpectationSet usesMockCurve; | 906 ExpectationSet usesMockCurve; |
907 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) | 907 EXPECT_CALL(mockCompositor, createFloatAnimationCurve()) |
908 .WillOnce(Return(mockCurvePtr)); | 908 .WillOnce(Return(mockCurvePtr)); |
909 | 909 |
910 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(0.0,
5.0), blink::WebAnimationCurve::TimingFunctionTypeLinear)); | 910 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(0.0, 5.0),
WebCompositorAnimationCurve::TimingFunctionTypeLinear)); |
911 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(blink::WebFloatKeyframe(1.5,
2.0))); | 911 usesMockCurve += EXPECT_CALL(*mockCurvePtr, add(WebFloatKeyframe(1.5, 2.0)))
; |
912 | 912 |
913 // Create animation | 913 // Create animation |
914 blink::WebAnimationMock* mockAnimationPtr = new blink::WebAnimationMock(blin
k::WebAnimation::TargetPropertyOpacity); | 914 WebCompositorAnimationMock* mockAnimationPtr = new WebCompositorAnimationMoc
k(WebCompositorAnimation::TargetPropertyOpacity); |
915 ExpectationSet usesMockAnimation; | 915 ExpectationSet usesMockAnimation; |
916 | 916 |
917 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), blink::WebAnimation::TargetPropertyOpacity, _)) | 917 usesMockCurve += EXPECT_CALL(mockCompositor, createAnimation(Ref(*mockCurveP
tr), WebCompositorAnimation::TargetPropertyOpacity, _)) |
918 .WillOnce(Return(mockAnimationPtr)); | 918 .WillOnce(Return(mockAnimationPtr)); |
919 | 919 |
920 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); | 920 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setIterations(5)); |
921 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(3.0)); | 921 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setTimeOffset(3.0)); |
922 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(t
rue)); | 922 usesMockAnimation += EXPECT_CALL(*mockAnimationPtr, setAlternatesDirection(t
rue)); |
923 | 923 |
924 EXPECT_CALL(*mockAnimationPtr, delete_()) | 924 EXPECT_CALL(*mockAnimationPtr, delete_()) |
925 .Times(1) | 925 .Times(1) |
926 .After(usesMockAnimation); | 926 .After(usesMockAnimation); |
927 EXPECT_CALL(*mockCurvePtr, delete_()) | 927 EXPECT_CALL(*mockCurvePtr, delete_()) |
928 .Times(1) | 928 .Times(1) |
929 .After(usesMockCurve); | 929 .After(usesMockCurve); |
930 | 930 |
931 // Go! | 931 // Go! |
932 setCompositorForTesting(mockCompositor); | 932 setCompositorForTesting(mockCompositor); |
933 Vector<OwnPtr<blink::WebAnimation> > result; | 933 Vector<OwnPtr<WebCompositorAnimation> > result; |
934 getAnimationOnCompositor(m_timing, *effect.get(), result); | 934 getAnimationOnCompositor(m_timing, *effect.get(), result); |
935 EXPECT_EQ(1U, result.size()); | 935 EXPECT_EQ(1U, result.size()); |
936 result[0].clear(); | 936 result[0].clear(); |
937 } | 937 } |
938 | 938 |
939 | 939 |
940 } // namespace blink | 940 } // namespace blink |
OLD | NEW |